Common database JDBC connection writing method

zhaozj2021-02-17  59

1. MySQL (http://www.mysql.com) mm.mysql-2.0.2-bin.jarclass.Forname ("org.gjt.mm.mysql.driver); cn = drivermanager.getConnection (" JDBC: Mysql: // mydbcomputernameorip: 3306 / mydatabaseename ", SUSR, SPWD);

2. PostgreSQL (http://www.de.postgresql.org) pgjdbc2.jarClass.forName ( "org.postgresql.Driver"); cn = DriverManager.getConnection ( "jdbc: postgresql: // MyDbComputerNameOrIP / myDatabaseName", sUsr SPWD);

3. Oracle (http://www.racle/oracle9i/) class 12.zipClass.Forname ("Oracle.jdbc.driver.Oracledriver); CN = DriverManager.getConnection (" JDBC: Oracle : Thin: @mydbcomputernameorip: 1521: Orcl ", SUSR, SPWD);

4. Sybase (http://jtds.s.sourceforge.net) jconn2.jarclass.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.getConnection ( "jdbc: jtds: sqlserver: // MyDbComputerNameOrIP: 1433 / Master ", SUSR, SPWD);

6. Microsoft SQLServer (http://www.microsoft.com) Class.forName ( "com.microsoft.jdbc.sqlserver.SQLServerDriver"); cn = DriverManager.getConnection ( "jdbc: microsoft: sqlserver: // MyDbComputerNameOrIP: 1433 DatabaseName = Master ", SUSR, SPWD);

7. odbcclass.Forname ("Sun.jdbc.odbc.jdbcodbcdriver"); Connection CN = DriverManager.getConnection ("JDBC: ODBC:" SDSN, SUSR, SPWD);

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

New Post(0)