Connect the database

xiaoxiao2021-03-06  143

I. Oracle8 / 8i / 9i database (THIN mode) TestoCle.jsp is as follows: Class.Forname ("Oracle.jdbc.driver.Oracledriver). NewInstance (); string url =" JDBC: Oracle: Thin: @localhost: 1521: ORCL "; // ORCL for your database SID string user =" scott "; string password =" tiger "; connection conn = drivermanager.getConnection (URL, User, Password);

Note: The driving of 8 and 9 is different! Second, SQL Server 7.0 / 2000 Database Class.Forname ("com.microsoft.jdbc.sqlser.sqlserverdriver). NewInstance (); string url =" JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = PUBS " // Pubs for your database String User = "SA"; string password = "; connection conn = drivermanager.getconnection (URL, User, Password);

Third, DB2 database class.Forname ("com.ibm.db2.jdbc.app.db2driver") .newinstance (); string url = "jdbc: db2: // localhost: 5000 / sample"; // Sample for you Database name string user = "admin"; string password = "; connection conn = drivermanager.getConnection (URL, User, Password);

Fourth, Informix Database Class.Forname ("com.informix.jdbc.ifxdriver). Newinstance (); string url =" jdbc: informix-sqli: //123.45.67.89: 1533 / testdb: informixserver = myserver; user = testuser Password = testpassword "; // testdb for your database name Connection Conn = DriverManager.getConnection (URL);

V. Connect the Sybase database class.Forname ("com.sybase.jdbc.sybdriver). NewInstance (); string url =" JDBC: Sybase: TDS: localhost: 5007 / tsdata "; // tsdata For your database name Properties Sysprops = system.getProperties (); sysprops.put ("user", "userid"); sysprops.put ("password", "user_password"); six, mysql database class.forname ("Org.gjt.mm.mysql .Driver ".) newInstance (); String url =" jdbc:? mysql: // localhost / softforum user = soft & password = soft1234 & useUnicode = true & characterEncoding = 8859_1 "// testDB for your database name Connection conn = DriverManager.getConnection (url) ; // org.git.mm.mysql.driver is 2.x driver

// com.mysql.jdbc.driver is above 3.x or more

7. Connect the PostgreSQL database class.Forname ("org.postgreSql.driver). NewInstance (); string url =" jdbc: postgreSQL: // localhost / Soft "// Soft for your database name string user =" myuser " String password = "mypassword"; connection conn = drivermanager.getConnection (URL, User, Password);

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

New Post(0)