com.mysql.jdbc.Driver

com.microsoft.sqlserver.jdbc.SQLServerDerver

1.加载驱动程序 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDerver");

2.建立连接

Mysql:    jdbc:mysql://localhost/abc

SQLServer:  String uri = "jdbc:sqlserver"//localhost:1433;databaseName = abc";

DriverManager.getConnection(url,"sa","123");

 

接口:

Statement        执行一般的SQL语句

PrepardStaterment    执行预编译的SQL语句

一般的:

"select * from test where id = " + id     俩种接口皆可

"select * from test where id = ? "      第二种