1. Connexion JDBC à DB2
Copiez le code comme suit :
Class.forName("Com.ibm.db2.jdbc.net.DB2Driver");
Chaîne url="jdbc:db2://dburl:port/DBname"
cn = DriverManager.getConnection( url, sUsr, sPwd );
Class.forName("Com.ibm.db2.jdbc.net.DB2Driver");
Chaîne url="jdbc:db2://dburl:port/DBname"
cn = DriverManager.getConnection( url, sUsr, sPwd );
2. Connexion JDBC à Microsoft SQLServer (microsoft)
Copiez le code comme suit :
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 );
3. Connexion JDBC à Sybase (jconn2.jar)
Copiez le code comme suit :
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 );
4. Connexion JDBC à MySQL (mm.mysql-3.0.2-bin.jar)
Copiez le code comme suit :
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 );
5. Connexion JDBC à PostgreSQL (pgjdbc2.jar)
Copiez le code comme suit :
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 );
6. Connexion JDBC à Oracle (classes12.jar)
Copiez le code comme suit :
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 );
7. JDBC se connecte à ODBC
Copiez le code comme suit :
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connexion cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );