1, Oracle8 / 8i / 9i database (Thin mode)
Class.Forname ("Oracle.jdbc.driver.OracleDriver"). NewInstance ();
String Url = "JDBC: Oracle: Thin: @localhost: 1521: Orcl";
// ORCL is the SID of the database
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 is your database name
String user = "admin";
String password = ""
Connection conn = drivermanager.getConnection (URL, User, Password);
3, SQL Server7.0 / 2000 database
Class.Forname ("com.microsoft.jdbc.sqlserver.sqlserverdriver). NewInstance ();
String Url = "JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = MYDB";
// mydb is a 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 is 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, 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);
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 = drivermanager.getConnection (URL, User, Password);
8, ODBC bridge
Class.Forname ("sun.jdbc.odbc.jdbcodbcdriver"); // Load JDBC-ODBC driver
StrCon = "JDBC: ODBC: Test_db"; // Setting the database connection string, test_db