标签:
Class.forName("oracle.jdbc.driver.OracleDriver");
装载MySQL驱动:
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://host:port/datebase","user","password");
Connection conn = DriverManager.getConnection("jdbc:mysql://host:port/datebase","user","password");
import java.sql.*; public class TestJDBC { public static void main(String[] args) throws Exception { //Class.forName("com.mysql.jdbc.Driver"); long start = System.currentTimeMillis(); new com.mysql.jdbc.Driver(); //Connection conn = DriverManager.getConnection("jdbc:mysql://host:port/datebase","user","password"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/martin","root","admin"); //Connection conn = DriverManager.getConnection("jdbc:oracle:thin@host:port:datebase","user","password"); //System.out.println(conn); System.out.println(conn); long end = System.currentTimeMillis(); System.out.println("建立连接耗时: "+(end - start)); } }
标签:
原文地址:http://www.cnblogs.com/MrYuan/p/5039624.html