Finally, give the key code for Java to connect other databases:
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 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 for your database name String user =" admin "; string password ="; connection CONN = DriverManager.getConnection (URL, User, Password); 3, Sybase Database Class.Forname ("com.sybase.jdbc.sybdriver). NewInstance (); string url =" JDBC: Sybase: TDS: Localhost: 5007 / Mydb "; // mydb for your database name" sysprops = system.getproperties (); sysprops.put ("user", "userid"); sysprops.put ("password", "user_password"); connection conn = drivermanager .getConnection (URL, SysProps); 4, Informix Database Class.Forname ("com.informix.jdbc.ifxdriver). NewInstance (); Strin g url = "JDBC: Informix-Sqli: //123.45.67.89: 1533 / mydb: inform:erver = myserver; user = testuser; password = TestPassword"; // mydb is the database name Connection conn = drivermanager.getConnection (URL); 5 , MySQL 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 is the database name Connection Conn = DriverManager.getConnection (URL);
6, 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 = drivermanager.getConnection (URL, User, Password);