Small series in this article will mainly introduce Java and Oracle, DB2, SQL Server, Sybase, MySQL, PostgreSQL and other database connection methods.
1. Oracle Database
Class.forName ("Oracle.jdbc.driver.OracleDriver"). newinstance ();
String url= "Jdbc:oracle:thin: @localhost: 1521:ORCL";
ORCL the SID
String user= "test" for the database
; 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 for your database name
String user= "admin";
String password= "";
3. SQL Server Database
Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver"). newinstance ();
String url= "Jdbc:microsoft:sqlserver://localhost:1433;databasename=mydb";
MyDB is a database
String user= "sa";
String password= "";
4. Sybase database
Class.forName ("Com.sybase.jdbc.SybDriver"). newinstance ();
String url = "Jdbc:sybase:tds:localhost:5007/mydb";
MyDB for your database name
Properties sysprops = system.getproperties ();
Sysprops.put ("User", "userid");
Sysprops.put ("Password", "User_password");
5. 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
6. PostgreSQL database
Class.forName ("Org.postgresql.Driver"). newinstance ();
String url = "Jdbc:postgresql://localhost/mydb"
//mydb the database name
string user= "MyUser";
String password= "MyPassword";
The above is the Java connection of various types of database skills, I believe it will be able to realize the Java Connection database Help.