Common database JDBC connection writing method

zhaozj2021-02-16  72

1.Mysql (http://www.mysql.com) mysql-connector-java-2.0.14-bin.jar class.forname ("org.gjt.mm.mysql.driver"); cn = drivermanager.getConnection "JDBC: mysql: // mydbcomputernameorip: 3306 / mydatabaseename", SUSR, SPWD); 2. PostgreSQL (http://www.de.postgreSql.org) pgjdbc2.jar class.Forname ("org.postgreSql.driver) CN = DriverManager.getConnection ("JDBCOSTGRESQL: // mydbcomputernameorip / myDatabaseName", SUSR, SUSR, SPWD); 3. Oracle (http://www.oracle.com/ip/deploy/database/oracle9i/) Classes12.zip class. Forname ("Oracle.jdbc.driver.OracleDriver"); CN = DriverManager.getConnection ("JDBCracle: Thin: @mydbcomputernameorip: 1521: Orcl", SUSR, SPWD); 4. Sybase (http://jtds.sourceforge.net JCONN2.JAR Class.Forname ("com.sybase.jdb2.jdbc.sybdriver"); CN = DriverManager.getConnection ("JDBC: Sybase: TDS: MyDBComputernameorip: 2638", SUSR, SPWD); // (Default-Username / Password: "DBA" / "SQL") 5. Microsoft SQL Server (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. ODBC Class.forName (" sun.jdbc.odbc.JdbcOdbcDriver " Connection CN = DriverManager.getConnection ("JDBCDBC:" SDSN, SUSR, SPWD); 8.DB2 Class.Forname ("com.ibm.db2.jdbc.net.db2driver"); string url = "

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

New Post(0)