[ 轉載]常用資料庫JDBC連線寫法
1. MySQL()mm.mysql-2.0.2-bin.jar
Class.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName", sUsr, sPwd );
2. PostgreSQL()pgjdbc2.jar
Class.forName( "org.postgresql.Driver" );
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
3. Oracle()classes12.zip
Class.forName( "oracle.jdbc.driver.OracleDriver" );
cn = DriverManager.getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd );
4. Sybase()jconn2.jar
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
//(Default-Username/Password: "dba"/"sql")
5. Microsoft SQLServer()
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );
6. Microsoft SQLServer()
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:1433; databaseName=master", sUsr, sPwd );
7. ODBC
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );
8.DB2(新新增)
Class.forName("com.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://192.9.200.108:6789/SAMPLE"
cn = DriverManager.getConnection( url, sUsr, sPwd );
9.Microsoft SQL Server series (6.5, 7.x and 2000) and Sybase 10
JDBC Name: jTDS
URL: /
Version: 0.5.1
Download URL:
語法:
Class.forName("net.sourceforge.jtds.jdbc.Driver ");
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://host:port/database","user","password");
or
Connection con = DriverManager.getConnection("jdbc:jtds:sybase://host:port/database","user","password");
10.Postgresql
JDBC Name: PostgreSQL JDBC
URL:
Version: 7.3.3 build 110
Download URL: download.html
語法:
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");
11.IBM AS400主機在用的JDBC語法
有裝V4R4以上版本的Client Access Express
可以在C:Program FilesIBMClient Accessjt400lib
找到 driver 檔案 jt400.zip,並更改副檔名成為 jt400.jar
語法:
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");
12.informix
Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser; password=testpassword";
Lib:jdbcdrv.zip〈br〉〈br〉Class.forName( "com.sybase.jdbc.SybDriver" )
url="jdbc:sybase:Tds:127.0.0.1:2638/asademo";
SybConnection connection= (SybConnection)DriverManager.getConnection(url,"dba","sql");
13.SAP DB
Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
java.sql.Connection connection = java.sql.DriverManager.getConnection ( "jdbc:sapdb://" + host + "/" + database_name,user_name, password)
14.InterBase
String url = "jdbc:interbase://localhost/e:/testbed/database/employee.gdb";
Class.forName("interbase.interclient.Driver");
//Driver d = new interbase.interclient.Driver (); /* this will also work if you do not want the line above */
Connection conn = DriverManager.getConnection( url, "sysdba", "masterkey" );
15.HSqlDB
url:
driver: org.hsqldb.jdbcDriver
連線方式有4種,分別為:
con-str(記憶體): jdbc:hsqldb.
con-str(本地): jdbc:hsqldb:/path/to/the/db/dir
con-str(http): jdbc:hsqldb:
con-str(hsql): jdbc:hsqldb:hsql://dbsrv[@more@]
Class.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName", sUsr, sPwd );
2. PostgreSQL()pgjdbc2.jar
Class.forName( "org.postgresql.Driver" );
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
3. Oracle()classes12.zip
Class.forName( "oracle.jdbc.driver.OracleDriver" );
cn = DriverManager.getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd );
4. Sybase()jconn2.jar
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
//(Default-Username/Password: "dba"/"sql")
5. Microsoft SQLServer()
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );
6. Microsoft SQLServer()
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:1433; databaseName=master", sUsr, sPwd );
7. ODBC
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );
8.DB2(新新增)
Class.forName("com.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://192.9.200.108:6789/SAMPLE"
cn = DriverManager.getConnection( url, sUsr, sPwd );
9.Microsoft SQL Server series (6.5, 7.x and 2000) and Sybase 10
JDBC Name: jTDS
URL: /
Version: 0.5.1
Download URL:
語法:
Class.forName("net.sourceforge.jtds.jdbc.Driver ");
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://host:port/database","user","password");
or
Connection con = DriverManager.getConnection("jdbc:jtds:sybase://host:port/database","user","password");
10.Postgresql
JDBC Name: PostgreSQL JDBC
URL:
Version: 7.3.3 build 110
Download URL: download.html
語法:
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");
11.IBM AS400主機在用的JDBC語法
有裝V4R4以上版本的Client Access Express
可以在C:Program FilesIBMClient Accessjt400lib
找到 driver 檔案 jt400.zip,並更改副檔名成為 jt400.jar
語法:
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");
12.informix
Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser; password=testpassword";
Lib:jdbcdrv.zip〈br〉〈br〉Class.forName( "com.sybase.jdbc.SybDriver" )
url="jdbc:sybase:Tds:127.0.0.1:2638/asademo";
SybConnection connection= (SybConnection)DriverManager.getConnection(url,"dba","sql");
13.SAP DB
Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
java.sql.Connection connection = java.sql.DriverManager.getConnection ( "jdbc:sapdb://" + host + "/" + database_name,user_name, password)
14.InterBase
String url = "jdbc:interbase://localhost/e:/testbed/database/employee.gdb";
Class.forName("interbase.interclient.Driver");
//Driver d = new interbase.interclient.Driver (); /* this will also work if you do not want the line above */
Connection conn = DriverManager.getConnection( url, "sysdba", "masterkey" );
15.HSqlDB
url:
driver: org.hsqldb.jdbcDriver
連線方式有4種,分別為:
con-str(記憶體): jdbc:hsqldb.
con-str(本地): jdbc:hsqldb:/path/to/the/db/dir
con-str(http): jdbc:hsqldb:
con-str(hsql): jdbc:hsqldb:hsql://dbsrv[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/443058/viewspace-974277/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 常用資料庫JDBC連線寫法 (轉)資料庫JDBC
- 常用資料庫JDBC連線寫法資料庫JDBC
- jdbc連線oracle rac資料庫的寫法JDBCOracle資料庫
- 【轉載】JDBC連線各種資料庫的字串JDBC資料庫字串
- 各種資料庫的JDBC驅動下載及連線字串URL寫法資料庫JDBC字串
- jdbc-odbc連線資料庫 (轉)JDBC資料庫
- JDBC中連線資料庫的常用jar包JDBC資料庫JAR
- JDBC連線資料庫JDBC資料庫
- java應用通過jdbc連線資料庫jdbc的串的3種寫法:JavaJDBC資料庫
- java jdbc連線資料庫JavaJDBC資料庫
- [轉載] 1.1Java使用JDBC原生方式連線MySql資料庫JavaJDBCMySql資料庫
- JDBC、JDBC框架、資料庫事務、資料庫連線池JDBC框架資料庫
- 【JavaWeb】JDBC連線MySQL資料庫JavaWebJDBCMySql資料庫
- JDBC之連線sqlserver資料庫JDBCSQLServer資料庫
- JDBC連線資料庫步驟JDBC資料庫
- JDBC連線資料庫經驗JDBC資料庫
- JDBC 連線資料庫的類JDBC資料庫
- JDBC連線各資料庫大全JDBC資料庫
- jdbc獲取資料庫連線JDBC資料庫
- 欄位連線的各種資料庫的寫法 (轉)資料庫
- MySQL下載安裝配置及JDBC連線資料庫MySqlJDBC資料庫
- java Jdbc連線oracle資料庫連線測試JavaJDBCOracle資料庫
- 轉載pythonmysql資料庫連線PythonMySql資料庫
- JDBC資料庫連線池實現JDBC資料庫
- JDBC---jsp資料庫連線JDBCJS資料庫
- JDBC連線三種資料庫例子JDBC資料庫
- JAVA基礎:JDBC最佳化資料庫連線(轉)JavaJDBC資料庫
- JDBC連線批量處理資料入庫JDBC
- 淺談JDBC和資料庫連線池JDBC資料庫
- JDBC連線各種資料庫的字串JDBC資料庫字串
- jdbc獲取各種資料庫連線JDBC資料庫
- 【LISTENER】資料庫連線串的幾種寫法資料庫
- 各種資料庫的jdbc驅動下載及連線方式資料庫JDBC
- 資料庫連線分析(1)-從JDBC到MyBatis資料庫JDBCMyBatis
- JDBC【資料庫連線池、DbUtils框架、分頁】JDBC資料庫框架
- JDBC連線MySQL資料庫及演示樣例JDBCMySql資料庫
- 各種資料庫的resin 連線池的寫法資料庫
- 《四 資料庫連線池原始碼》手寫資料庫連線池資料庫原始碼