First, JDBC Connection DB2
Copy Code code as follows:
class.forname ("Com.ibm.db2.jdbc.net.DB2Driver");
String url= "Jdbc:db2://dburl:port/dbname"
cn = drivermanager.getconnection (URL, susr, spwd);
class.forname ("Com.ibm.db2.jdbc.net.DB2Driver");
String url= "Jdbc:db2://dburl:port/dbname"
cn = drivermanager.getconnection (URL, susr, spwd);
ii. JDBC Connection Microsoft SQL Server (Microsoft)
Copy Code code as follows:
class.forname ("Com.microsoft.jdbc.sqlserver.SQLServerDriver");
cn = Drivermanager.getconnection ("Jdbc:microsoft:sqlserver://dbserverip:1433;databasename=master", SUSR, SPWD) ;
class.forname ("Com.microsoft.jdbc.sqlserver.SQLServerDriver");
cn = Drivermanager.getconnection ("Jdbc:microsoft:sqlserver://dbserverip:1433;databasename=master", SUSR, SPWD);
iii. JDBC Connection sybase (Jconn2.jar)
Copy Code code as follows:
class.forname ("Com.sybase.jdbc2.jdbc.SybDriver");
cn = Drivermanager.getconnection ("jdbc:sybase:tds:dbserverip:2638", Susr, spwd);
class.forname ("Com.sybase.jdbc2.jdbc.SybDriver");
cn = Drivermanager.getconnection ("jdbc:sybase:tds:dbserverip:2638", Susr, spwd);
Four, JDBC connection mysql (Mm.mysql-3.0.2-bin.jar)
Copy Code code as follows:
class.forname ("Org.gjt.mm.mysql.Driver");
cn = Drivermanager.getconnection ("Jdbc:mysql://dbserverip:3306/mydatabasename", Susr, SPWD);
class.forname ("Org.gjt.mm.mysql.Driver");
cn = Drivermanager.getconnection ("Jdbc:mysql://dbserverip:3306/mydatabasename", Susr, spwd);
v. JDBC Connection PostgreSQL (Pgjdbc2.jar)
Copy Code code as follows:
class.forname ("Org.postgresql.Driver");
cn = Drivermanager.getconnection ("Jdbc:postgresql://dbserverip/mydatabasename", Susr, SPWD);
class.forname ("Org.postgresql.Driver");
cn = Drivermanager.getconnection ("Jdbc:postgresql://dbserverip/mydatabasename", Susr, SPWD);
vi. JDBC Connection Oracle (Classes12.jar)
Copy Code code as follows:
class.forname ("Oracle.jdbc.driver.OracleDriver");
cn = Drivermanager.getconnection ("Jdbc:oracle:thin: @MyDbComputerNameOrIP: 1521:orcl", SUSR, spwd);
class.forname ("Oracle.jdbc.driver.OracleDriver");
cn = Drivermanager.getconnection ("Jdbc:oracle:thin: @MyDbComputerNameOrIP: 1521:orcl", SUSR, spwd);
vii. JDBC Connection ODBC
Copy Code code as follows:
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn = Drivermanager.getconnection ("JDBC:ODBC:" + sdsn, SUSR, spwd);