1) Connect Oracle 8/8i/9i/10g/11g (thin mode)
Class.forName ("Oracle. JDBC.driver.OracleDriver "). newinstance ();
String url= "JDBC:oracle:thin: @localhost: 1521:orcl"//ORCL the SID for the Oracle database
String user= "Test";
String password= "Test";
Connection con=drivermanager.getconnection (Url,user,password);
2) Connect DB2 database
Class.forName ("Com.ibm.db2.jcc.DB2Driver");
String url= "Jdbc:db2://localhost:5000/testdb";
String user= "Test"; String password= "Test";
Connection con=drivermanager.getconnection (Url,user,password);
3) connect to MySQL Database
Class.forName ("Com.mysql.jdbc.Driver");
String url= "Jdbc:mysql://localhost:8080/testdb";
String user= "Test"; String password= "Test";
Connection con=drivermanager.getconnection (Url,user,password);
4) Connect the SQL Server2000 database
Class.forName ("Com.microsoft.JDBC.sqlserver.SQLServerDriver");
String url= "Jdbc:microsoft:sqlserver://localhost:1433;databasename=testdb";
String user= "Test"; String password= "Test";
Connection con=drivermanager.getconnection (Url,user,password);
5) Connect the PostgreSQL database
Class.forName ("Org.postgresql.Driver");
String url= "Jdbc:postgresql://localhost/testdb";
String user= "Test"; String password= "Test";
Connection con=drivermanager.getconnection (Url,user,password);
6) Connect to an Access database
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
String url= "Jdbc:odbc:driver={microsoft Access Driver (*.mdb)};D bq=" +application.getrealpath ("/data/testdb/mdb");
Connection conn=drivermanager.getconnection (URL, "", "");
7 Connecting the Sybase database
Class.forName ("Com.sybase.JDBC.SybDriver");
String url= "Jdbc:sybase:tds:localhost:5007/testdb";
Properties pro=system.getproperties ();
Pro.put ("User", "userId");
Pro.put ("Password", "User_password");
Connection con=drivermanager.getconnection (Url,pro);
8 Connecting to the Informix database
Class.forName ("Com.informix.JDBC.ifxDriver");
String url= "Jdbc:informix-sqli:localhost:1533/testdb:informixserver=myserver" user=testuser;password= Testpassword "; Connection con=drivermanager.getconnection (URL);
JDBC Various database connection methods