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