The following is a list of the ways in which databases use JDBC connections, which can be used as a manual.
1. oracle8/8i/9i/10g/11g database (thin mode)
Class.forName ("Oracle.jdbc.driver.OracleDriver"). newinstance ();
String url= "Jdbc:oracle:thin: @localhost: 1521:ORCL"; ORCL the SID for the database
String user= "Test";
String password= "Test";
Connection conn= drivermanager.getconnection (Url,user,password);
2. DB2 Database
Class.forName ("Com.ibm.db2.jdbc.app.DB2Driver"). newinstance ();
String url= "Jdbc:db2://localhost:5000/sample"; Sample is your database name
String user= "admin";
String password= "";
Connection conn= drivermanager.getconnection (Url,user,password);
3. SQL server7.0/2000 Database
Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver"). newinstance ();
String url= "Jdbc:microsoft:sqlserver://localhost:1433;databasename=mydb";
MyDB for the database
String user= "SA";
String password= "";
Connection conn= drivermanager.getconnection (Url,user,password);
4. SQL Server 2005/2008 Database
Class.forName ("Com.microsoft.sqlserver.jdbc.SQLServerDriver"). newinstance ();
String url= "Jdbc:sqlserver://localhost:1433;databasename=mydb";
MyDB for the database
String user= "SA";
String password= "";
Connection conn= drivermanager.getconnection (Url,user,password);
5. Sybase database
Class.forName ("Com.sybase.jdbc.SybDriver"). newinstance ();
String url = "Jdbc:sybase:tds:localhost:5007/mydb";//mydb is your database name
Properties sysprops = System.getproperties ();
Sysprops.put ("User", "userid");
Sysprops.put ("Password", "User_password");
Connection conn= drivermanager.getconnection (URL, sysprops);
6. Informix Database
Class.forName ("Com.informix.jdbc.IfxDriver"). newinstance ();
String url = "Jdbc:informix-sqli://123.45.67.89:1533/mydb:informixserver=myserver;
User=testuser;password=testpassword "; MyDB for Database name
Connection conn= drivermanager.getconnection (URL);
7. mysql Database
Class.forName ("Org.gjt.mm.mysql.Driver"). newinstance ();
String url = "jdbc:mysql://localhost/mydb?user=soft&password=soft1234&useunicode=true& Characterencoding=8859_1 "
MyDB for Database name
Connection conn= drivermanager.getconnection (URL);
8. PostgreSQL Database
Class.forName ("Org.postgresql.Driver"). newinstance ();
String url = "Jdbc:postgresql://localhost/mydb"//mydb for database name
String user= "MyUser";
String password= "MyPassword";
Connection conn= drivermanager.getconnection (Url,user,password);
9, Access database directly with ODBC
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
String url= "Jdbc:odbc:driver={microsoft Access Driver (*.mdb)};D bq=" +application.getrealpath ("/data/reportdemo.mdb ");
Connection conn = drivermanager.getconnection (URL, "", "");
Statement stmtnew=conn.createstatement ();
How the database uses JDBC connections