The code in this article mainly lists the key code of the connection database, other access database code omits 1, Oracle8 / 8i / 9i database (Thin mode) class.Forname ("Oracle.jdbc.driver.Oracledriver). NewInstance (); string URL = "JDBC: Oracle: Thin: @localhost: 1521: ORCL"; // ORCL is a database of SID string user = "test"; string password = "test"; connection conn = drivermanager.getConnection (URL, User, Password 2, DB2 database class.forname ("com.ibm.db2.jdbc.app.db2driver") .newinstance (); string url = "jdbc: db2: // localhost: 5000 / sample"; // Sample Your database name String user = "admin"; string password = ""
Connection conn = drivermanager.getConnection (URL, User, Password); 3, SQL Server 7.0 / 2000 database class.Forname ("com.microsoft.jdbc.sqlser.sqlserverdriver). NewinStance (); string url =" JDBC: Microsoft: SQLServer: // localhost: 1433; // mydb is the database string user = "sa"; string password = ""; connection conn = drivermanager.getConnection (URL, User, Password); 4, Sybase Database Class.Forname ("com.sybase.jdbc.sybdriver). NewInstance (); string url =" jdbc: sybase: tds: localhost: 5007 / mydb "; // mydb For your database name Properties sysprops = system. GetProperties (); sysprops.put ("user", "userid"); sysprops.put ("password", "user_password"); connection conn = drivermanager.getConnection (URL, sysprops); 5, Informix database class.Forname "com.informix.jdbc.ifxdriver"). newinstance (); string url = "jdbc: informix-sqli: //123.45.67.89: 1533 / mydb: informixserver = myserver; user = testuser; password = TestPassword"; // Mydb is the database name Connection Conn = DriverManager.getConnection (URL); 6, M ySQL database Class.forName ( "org.gjt.mm.mysql.Driver") newInstance (); String url =. "jdbc:? mysql: // localhost / myDB user = soft & password = soft1234 & useUnicode = true & characterEncoding = 8859_1" // myDB For the database name Connection Conn = DriverManager.getConnection (URL); 7, PostgreSQL Database Class.Forname ("org.postgreSQL.Driver). NewInStance (); string url =" jdbc: postgreSQL: // localhost / mydb "// MyDB is the database name string user = "myuser"; string password = "mypassword"; connection conn =