1. Koneksi JDBC ke DB2
Copy kode kodenya sebagai berikut:
Class.forName("Com.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://dburl:port/Nama DB"
cn = DriverManager.getConnection( url, sUsr, sPwd );
Class.forName("Com.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://dburl:port/Nama DB"
cn = DriverManager.getConnection( url, sUsr, sPwd );
2. Koneksi JDBC ke Microsoft SQLServer (microsoft)
Copy kode kodenya sebagai berikut:
Kelas.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://DBServerIP:1433;databaseName=master", sUsr, sPwd );
Kelas.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://DBServerIP:1433;databaseName=master", sUsr, sPwd );
3. Koneksi JDBC ke Sybase (jconn2.jar)
Copy kode kodenya sebagai berikut:
Kelas.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
cn = DriverManager.getConnection( "jdbc:sybase:Tds:DBServerIP:2638", sUsr, sPwd );
Kelas.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
cn = DriverManager.getConnection( "jdbc:sybase:Tds:DBServerIP:2638", sUsr, sPwd );
4. Koneksi JDBC ke MySQL (mm.mysql-3.0.2-bin.jar)
Copy kode kodenya sebagai berikut:
Kelas.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection( "jdbc:mysql://DBServerIP:3306/myDatabaseName", sUsr, sPwd );
Kelas.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection( "jdbc:mysql://DBServerIP:3306/myDatabaseName", sUsr, sPwd );
5. Koneksi JDBC ke PostgreSQL (pgjdbc2.jar)
Copy kode kodenya sebagai berikut:
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. Koneksi JDBC ke Oracle (classes12.jar)
Copy kode kodenya sebagai berikut:
Kelas.forName( "Oracle.jdbc.driver.OracleDriver" );
cn = DriverManager.getConnection( "jdbc:Oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd );
Kelas.forName( "Oracle.jdbc.driver.OracleDriver" );
cn = DriverManager.getConnection( "jdbc:Oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd );
7. JDBC terhubung ke ODBC
Copy kode kodenya sebagai berikut:
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Koneksi cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );