JDBC connects to the database using myeclipse to obtain the driver name and connection string

Source: Internet
Author: User

When using JDBC to connect to the database (although there are not many large projects, but small projects do not use Hibernate and other frameworks, JDBC still needs to be used ), the following two basic fixed connection statements are required:

① First load the driver. Take MYSQL as an example: class. forname ("com. MySQL. JDBC. Driver ");

②. Then, get the connection drivermanager. getconnection (URL, user, password );

The driver name com. MySQL. JDBC. driver and the connection URL can be obtained using the following method:

Change the view of myeclipse to myeclipse Database Explorer, right-click the database blank space on the left-> New-> databasedriver dialog box, and select the database you are using in drivertemplate, at this time, you can see the connection URL in the connection URL and modify the URL as needed. For example, if MySQL is selected, the URL is JDBC: mysql: //

Click Add jars on the Right of driver jars to add the JAR file of the database to be connected. After the connection, you can obtain the driver name, that is, Com. mySQL. JDBC. driver. The retrieval is complete. The connection is successful.

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.