Looking back at the database access in Java, there are still some ridiculous questions about randomness.

Source: Internet
Author: User

I haven't written Java for nine years. Recently, I suddenly used Java to write a prototype demonstration system and used database access. So I relived the old dream of a few years ago, but I still dreamed of a demon.

When talking about Java database access, you will immediately think of several methods:

I. Local API semi-Java DRIVER:

These designs were useless at the beginning, that is, they wrote a set of libraries in Java and directly called the binary driver API of the database installed on the local machine for the most direct access to the database, the implementations of various databases are different. The second is to break Java's cross-platform nature? However, if you want to write middleware for specific databases, the access speed is very efficient.

Second, JDBC-ODBC Bridge:

It is a set of interfaces that perform JNI access to ODBC. This means that many database access operations are not recommended, but the portability is very high. There are many old ODBC database sources.

3. pure Java driver for local protocols

Each vendor is connected to a Java-only implementation library based on a uniform interface, which can directly access the database through the database network protocol. The system can facilitate the release design and have a unified interface. It is also pure Java code and is also concise, also known as the thin client access method. I don't know if it's wrong. After all, I haven't played Java for nine years. Don't be honest with the visitor.


4. JDBC-net method:

The JDBC used by the client is converted to a network protocol unrelated to the database protocol, received by the middleware on the network, and then converted to a database call. Convenience for distributed systems, of course, will increase the complexity of the system. The configuration in the middle was really tough when I was playing the movie ELE. net.


After recalling the memories, let's start working. First, we decided to adopt the thin client method. Advantages: moderate speed, easy code migration, and low requirements on the database environment. MySQL is not a complex application for database types. Now MySQL is generally enough.

1. Download The mysqlconnectorxxxxx516.jar package from the MySQL official website, which is only a few MB long,

2. Load it to references of eclipse-related projects.

3. Use class. forname () and drivermanager to call the code,

Result: it is a failure. Check all the correlations. No problem, but the call fails. It took one night to solve the problem. It turned out that the JDBC package mysqlxxx516 had a problem. It cannot be used together with jre1.6. I changed to mysqlxxx508. In what time, there was still such a problem. This was also one of the reasons why I didn't like to engage in Java any more. In that time, there were unknown reasons for not configuring partitions, it is much better now, but compared with the development environment like Symbian, there are more excellent. After several years, you will find the advantages of other development environments. Hey, write it first.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.