JAVA-JDBC Configuring drivers

Source: Internet
Author: User

For example, we use 3 kinds of databases.

MySQL Database

Driver Package Name: Mysql-connector-java-3.1.11-bin.jar

Name of the driver class: Com.mysql.jdbc.Driver

JDBC Url:jdbc:mysql://dbip:port/databasename

Description: The driver package name may change

The black font portion of the JDBC URL must remain intact, in the URL format recognized by the driver. The Red font section needs to be filled in according to the database installation situation. The meanings of each part are as follows:

dbip– is the IP address of the database server, if local writable: localhost or 127.0.0.1.

port– is the listening port for the database and needs to look at the configuration at the time of installation, default is 3306.

The name of the databasename– database.

For example, if you want to access the local database allandb, port 1433, then the URL is spelled as follows:

Jdbc:mysql://localhost:3306/allandb

: http://dev.mysql.com/downloads/connector/j/

SQL Server Database

Driver package Name: Msbase.jar Mssqlserver.jar Msutil.jar

Name of the driver class: Com.microsoft.jdbc.sqlserver.SQLServerDriver

JDBC Url:jdbc:microsoft:sqlserver://dbip:port;databasename=databasename

Description: The driver package name may change

The black font portion of the JDBC URL must remain intact, in the URL format recognized by the driver. The Red font section needs to be filled in according to the database installation situation. The meanings of each part are as follows:

dbip– is the IP address of the database server, if local writable: localhost or 127.0.0.1.

port– is the listening port for the database and needs to look at the configuration at the time of installation, default is 1433.

The name of the databasename– database.

For example, if you want to access the local database allandb, port 1433, then the URL is spelled as follows:

Jdbc:microsoft:sqlserver: @localhost: 1433; DatabaseName =allandb

: http://www.microsoft.com/downloads/details.aspx

Oracle Database:

Driver Package Name: Ojdbc14.jar

Name of the driver class: Oracle.jdbc.driver.OracleDriver

JDBC URL:jdbc:oracle:thin: @dbip:p ort:databasename

Description: The driver package name may change

The black font portion of the JDBC URL must remain intact, in the URL format recognized by the driver. The Red font section needs to be filled in according to the database installation. The meanings of each part are as follows:

dbip– is the IP address of the database server, if local writable: localhost or 127.0.0.1.

port– is the listening port for the database and needs to look at the configuration at the time of installation, default is 1521.

databasename– is the SID of the database, usually the name of the global database.

For example, if you want to access the local database allandb, Port 1521, then the URL is spelled as follows:

Jdbc:oracle:thin: @localhost: 1521:allandb as follows:

Http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html

After we have downloaded the jar package, it is best to place the jar in the workspace directory of the corresponding project. Prevent future copying of items with fewer jar files

Next we start importing the driver package

Right-Select the build path in the project name location-Configure the build path.

Then open the configuration build path and go to the configuration interface. Select the above library, click Add external jar, import the jar file you need, save it.

Here, the driver file is configured, how to link the server, see the next article

JAVA-JDBC Configuring drivers

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.