Example for Java connection database

xiaoxiao2021-03-06  83

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 Server7.0 / 2000 database class.Forname (" com.microsoft.jdbc) . SQLServer.sqlserdriver "). 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 proteprops = 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"

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

New Post(0)