驱动类:com.microsoft.sqlserver.jdbc.SQLServerDriver
链接方法:jdbc:sqlserver://IP:端口;DatabaseName=数据库
public class DB {
Statement stmt;
String mc;
Connection conn = null;
CachedRowSetImpl crs;
public static String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test";
public static String user = "sa";
public static String password = "123";
public DB() {}
public CachedRowSetImpl dbquery(String sqlstr){//查询时调用该方法
System.out.println("-*-*-*-*-*-*-*-chaxun-*-*-*-*-*-*-*" + sqlstr);
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
conn= DriverManager.getConnection(url,user,password);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);</