Common database JDBC connection writing method

zhaozj2021-02-16  84

1. MySQL (http://www.mysql.com) mm.mysql-2.0.2-bin.jar class.forname ("org.gjt.mm.mysql.driver); cn = drivermanager.getConnection (" JDBC : mysql: // mydbcomputernameorip: 3306 / mydatabaseName ", SUSR, SUSR, SPWD); 2. PostgreSQL (http://www.de.postgreSql.org) Pgjdbc2.jar class.Forname (" org.postgreSql.driver); CN = DriverManager.getConnection ("JDBC: PostgreSql: // mydbcomputernameorip / mydatabase", susr, spd); 3. Oracle (http://www.racle.com/ip/deploy/database/oracle9i/) Classes12.zip class. Forname ("Oracle.jdbc.driver.OracleDriver"); CN = DriverManager.getConnection ("JDBC: Oracle: Thin: @mydbcomputernameorip: 1521: Orcl", SUSR, SPWD); 4. Sybase (http://jtds.sourceforge .NET) 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 (http://jtds.sourceforge.net) class.forname ("Net.SourceForge.jtds.jdbc.driver"); cn = drivermanager.getconne Ction ("JDBC: JTDS: SQLSERVER: // MYDBComputernameorip: 1433 / Master", SUSR, SPWD); 6. Microsoft SQL Server (http://www.microsoft.com) 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 "

转载请注明原文地址:https://www.9cbs.com/read-12572.html

New Post(0)