Common database JDBC connection writing!

xiaoxiao2021-04-05  276

1. MySQL (http://www.mysql.com) mm.mysql-2.0.2-bin.jarclass.Forname ("org.gjt.mm.mysql.driver); cn = drivermanager.getConnection (" JDBC: Mysql: // mydbcomputernameorip: 3306 / mydatabaseename ", SUSR, SPWD);

2. PostgreSQL (http://www.de.postgresql.org) pgjdbc2.jarClass.forName ( "org.postgresql.Driver"); cn = DriverManager.getConnection ( "jdbc: postgresql: // MyDbComputerNameOrIP / myDatabaseName", sUsr SPWD);

3. Oracle (http://www.racle/oracle9i/) class 12.zipClass.Forname ("Oracle.jdbc.driver.Oracledriver); CN = DriverManager.getConnection (" JDBC: Oracle : Thin: @mydbcomputernameorip: 1521: Orcl ", SUSR, SPWD);

4. Sybase (http://jtds.s.sourceforge.net) jconn2.jarclass.Forname ("com.sybase.jdbc2.jdbc.sybdriver"); cn = drivermanager.getConnection ("JDBC: Sybase: TDS: mydbcomputernameorip: 2638" , SUSR, SPWD); // (Default-username / password: "dba" / "sql")

5. Microsoft SQLServer (http://jtds.sourceforge.net) Class.forName ( "net.sourceforge.jtds.jdbc.Driver"); cn = DriverManager.getConnection ( "jdbc: jtds: sqlserver: // MyDbComputerNameOrIP: 1433 / Master ", SUSR, SPWD);

6. Microsoft SQLServer (http://www.microsoft.com) Class.forName ( "com.microsoft.jdbc.sqlserver.SQLServerDriver"); cn = DriverManager.getConnection ( "jdbc: microsoft: sqlserver: // MyDbComputerNameOrIP: 1433 DatabaseName = Master ", SUSR, SPWD);

7. odbcclass.Forname ("Sun.jdbc.odbc.jdbcodbcdriver"); Connection CN = DriverManager.getConnection ("JDBC: ODBC:" SDSN, SUSR, SPWD);

8.DB2 (new addition) class.Forname ("com.ibm.db2.jdbc.net.db2driver"); string url = "JDBC: DB2: //192.9.200.108: 6789 / sample" CN = DriverManager.getConnection URL, SUSR, SPWD; Supplement Microsoft SQL Server Series (6.5, 7.x and 2000) and Sybase 10

JDBC Name: htdsurl: http://jtds.sourceforge.net/Version: 0.5.1download URL: http://sourceforge.net/project/showfiles.php?group_id=33291

grammar:

Class.Forname ("Net.SourceForge.jtds.jdbc.driver"); connection con = drivermanager.getConnection ("JDBC: JTDS: SQLServer: // Host: Port / Database", "User", "Password"); Orconnection Con = DriverManager.getConnection ("JDBC: JTDS: Sybase: // Host: Port / Database", "User", "Password"); PostgreSQL

JDBC name: postgreSQL JDBCURL: http://jdbc.postgreSQL.ORG/Version: 7.3.3 Build 110download URL: http://jdbc.postgreSQL.org/download.html

grammar:

Class.Forname ("Org.PostgreSql.driver); Connection Con = DriverManager.getConnection (" JDBC: PostgreSQL: // Host: Port / Database "," User "," Password ");

JDBC syntax for IBM AS400 host

Client Access Express, which is available, V4R4, can find Driver file JT400.zip in C: / Program Files / IBM / Client Access / JT400 / Lib, and change the extension to become JT400.jar

grammar

Java.sql.drivermanager.registerdriver (new com.ibm.as400.access.as400jdbcdriver ()); class.forname ("com.ibm.as400.access.as400jdbcconnection"); con = DriverManager.getConnection ("JDBC: AS400: // ip "," user "," password ");

Informix

Class.Forname ("com.informix.jdbc.ifxdriver). NewInstance ();

String URL =

"JDBC: Informix-SQLI: //123.45.67.89: 1533 / TESTDB: InformixServer = MyServer;

User = testuser; password = TestPassword ";

Lib: jdbcdrv.zip

Class.forName ( "com.sybase.jdbc.SybDriver")
url = "jdbc: sybase: Tds: 127.0.0.1: 2638 / asademo";
SybConnection Connection = (SybConnection) DriverManager.getConnection (URL, "DBA", "SQL");
Supplement Two SAP DBClass.Forname ("com.sap.dbtech.jdbc.driversapdb"); java.sql.connection connectivity = java.sql.driverManager.getConnection ("JDBC: SAPDB: //" Host "/" Database_name, user_name, password)

InterbaseString URL = "JDBC: Interbase: // LocalHost / E: / Testbed/database/employee.gdb"; class.forname ("interbase.interclient.driver); // driver d = new interbase.interclient.driver () ; / * This Will Also Work if you do not want the line Above * / connection conn = drivermanager.getConnection (URL, "Sysdba", "MasterKey");

I also come to make up one: hsqldb

URL: http://hsqldb.sourceforge.net/driver: org.hsqldb.jdbcdriver

There are 4 types of connection, respectively: con-str (memory): JDBC: hsqldb.con-str (local): JDBC: HSQLDB: / path / to / the / db / dircon-str (http): JDBC: HSQLDB : http: // dbsrvcon-str (HSQL): JDBC: HSQLDB: HSQL: // DBSRV

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

New Post(0)