1. oracle8/8i/9i Database (thin mode) class. forname ("oracle. JDBC. driver. oracledriver "). newinstance (); string url = "JDBC: oracle: thin: @ localhost: 1521: orcl"; // orcl indicates the SID string user = "test" of the database "; 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 Server7.0/2000 database class. forname ("com. microsoft. JDBC. sqlserver. sqlserverdriver "). newinstance (); string url = "JDBC: Microsoft: sqlserver: // localhost: 1433; databasename = mydb"; // 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 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 indicates 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 indicates the database name connection conn = drivermanager. getconnection (URL );
7. PostgreSQL database class. forname ("org. postgreSQL. driver "). newinstance (); string url = "JDBC: PostgreSQL: // localhost/mydb" // mydb indicates the database name string user = "myuser"; string Password = "mypassword "; connection conn = drivermanager. getconnection (URL, user, password );