1.MySQL数据库
MySQL Connector/J Driver
驱动程序包名:mysql-connector-java-x.x.xx-bin.jar
驱动程序类名: com.mysql.JDBC jdbc:mysql://:/<database_name>
默认端口3306,如果服务器使用默认端口则port可以省略
MySQL Connector/J Driver 允许在jdbc:mysql://:/<database_name>?property1=value1&property2=value2
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//myDB为数据库名
Connection conn= DriverManager.getConnection(url);
2.PostgreSQL数据库
PostgreSQL
PostgreSQL Native 驱动程序包名:驱动程序类名: org.postgresql.Driver
URL: database_name>
默认端口5432
Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/myDB"
//myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
3.Oracle
Oracle Thin 驱动程序包名:ojdbc14.jar
驱动程序类名: oracle.JDBC URL:
jdbc:oracle:thin:@//:/ServiceName
或
jdbc:oracle:thin:@::
Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/myDB"
//myDB为数据库名
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);