JDBC (Java Data Base connectivity, Java database connection) is a Java API used to execute SQL statements. It can provide unified access to multiple relational databases, it consists of a group of classes and interfaces written in Java. JDBC provides a benchmark to build more advanced tools and interfaces.
Database developers can write database applications, and JDBC is also a trademark name.
In order to make it easy for you to learn, here are some major database JDBC drivers and corresponding operation methods, hoping to help you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
DB name: Microsoft SQL Server (2008)
JDBC name: JDBC Driver 3.0
Home page:
Http://www.microsoft.com/zh/cn/default.aspx
JDBC Ver: 3.0
Download:
Http://www.microsoft.com/downloads/details.aspx? Displaylang = ZH-CN & familyid = a737000d-68d0-4531-b65d-da0f2a735707 # filelist
Conn code:
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;integratedSecurity=true;";Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");Connection con = DriverManager.getConnection(connectionUrl);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
DB name: Oracle
JDBC name: Connector/J
Home page: http://www.oracle.com/technology/global/cn/software/tech/java/sqlj_jdbc/index.html
JDBC Ver: (based on Oracle)
Download:
Http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
Conn code:
Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@host:port:databse","user","password");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
DB name: MySQL
JDBC name: Connector/J
Home page: http://dev.mysql.com/
JDBC Ver: 5.1.13
Download: http://dev.mysql.com/downloads/
Conn code:
Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://host:port/database","user","password");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
DB name: Sybase
JDBC name: jconnect
Home page:
Http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/jconnect
JDBC Ver: 5.5/6.05
Download: http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/jconnect
Conn code:
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance(); DriverManager.getConnection("jdbc:sybase:Tds:IP:2638?ServiceName="+database,"user","password");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
DB name: PostgreSQL
JDBC name: PostgreSQL JDBC
Home page: http://jdbc.postgresql.org/
JDBC Ver: 8.4-701
Download: http://jdbc.postgresql.org/download.html
Conn code:
Class.forName("org.postgresql.Driver"); Connection con = DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
DB name: IBM Informix
JDBC name: Informix JDBC Driver (IBM Informix JDBC v3.50)
Home page: http://www-01.ibm.com/software/data/informix/
JDBC Ver: 3.50.jc6w1
Download:
Http://www14.software.ibm.com/webapp/download/search.jsp? Go = Y & rs = ifxjdbc
Conn code:
Class.forName("com.informix.jdbc.IfxDriver").newInstance(); Connection conn= DriverManager.getConnection("jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;user=testuser;password=testpassword";);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
DB name: IBM DB2
JDBC name: DB2 JDBC universal driver
Home page: http://www-01.ibm.com/software/data/db2/
JDBC Ver:
Download:
Http://www-128.ibm.com/developerworks/db2/downloads/jcc/
Conn code:
Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance(); Connection conn= DriverManager.getConnection("jdbc:db2://localhost:5000/sample",user,password);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
JDBC syntax used by the IBM as400 host
Clients with v4r4 or later versions
Access Express
You can go to c: \ Program Files \ IBM \ Client Access \ jt400 \ Lib
Find the driver File
Jt400.zip and change the extension to jt400.jar.
Conn code:
java.sql.DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ()); Class.forName("com.ibm.as400.access.AS400JDBCConnection"); con = DriverManager.getConnection("jdbc:as400://IP","user","password");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
DB name: MS access or MS FoxPro
Conn code:
Step 1: Configure ODBC (for example, mydb)
Step 2:
String dbURL = "jdbc:odbc:myDb"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection(dbURL);
Or
String dbURL = "jdbc:odbc:driver={MicrosoftAccessDriver(*.mdb)};DBQ=dabaseName.mdb"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection(dbURL);
Note: This article Reprinted from: http://hi.baidu.com/leespring/blog/item/0baf30a3c8fe2fb9cbefd05d.html