Database connection method highlights

xiaoxiao2021-03-06  41

Java Connects Example 1 of Various Databases (Thin Mode) Class.Forname ("Oracle.jdbc.driver.Oracledriver). NewInstance (); String Url = JDBC: Oracle: Thin:

@localhost

: 1521: ORCL "; // ORCL is the sidstring user =" test "for 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 for your database name String user =" admin "; string Password = ""; connection conn = drivermanager.getConnection (URL, User, Password); 3, SQL Server 7.0 / 2000 database class.forname ("com.microsoft.jdbc.sqlser.sqlserverdriver). NewInstance (); string URL = "JDBC: Microsoft: SQLSERVER: // localhost: 1433; // mydb is 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.jd Bc.iFxDriver "). Newinstance (); String 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); 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);

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

New Post(0)