java中连接各种数据的方法
1.oracle
thin驱动连接字符串:jdbc:oracle:thin:用户名/密码@localhost:1521:cake
驱动类:oracle.jdbc.driver.OracleDriver
2.mysql
连接字符串:jdbc:mysql://localhost:3306/数据库名?useUnicode=true&characterEncoding=utf-8
驱动类:com.mysql.jdbc.Driver
3.SQl Server
连接字符串:jdbc:microsoft:sqlserver://localhost:1433;user=sa;password=sa;DatabaseName=数据库名
驱动类:com.microsoft.jdbc.sqlserver.SQLServerDriver
//MicroSoft SQL Server 2005
String classStr="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String conStr="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=mydatabase";//注意端口号
//MicroSoft SQL Server 2000
String classStr="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String conStr="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs","sa","password"
//mysql
"com.mysql.jdbc.Driver"
"jdbc:mysql://localhost:3306/Login?useUnicode=true&characterEncoding=utf-8","root","7415"
//oracle
"oracle.jdbc.driver.OracleDriver"
"jdbc:oracle:thin:@10.0.0.248:1521:ora9","username","password"
//ODBC桥连接
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:jsp");