在下试了n次了
都无法连接
代码如下
import java.sql.*;
public class jdbc2005 {
private Connection con;
private Statement stmt;
private ResultSet rs;
public jdbc2005() throws SQLException {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url =
"jdbc:sqlserver://localhost:1433;database=master;user=sa;password=1234";
con = DriverManager.getConnection(url);
stmt = con.createStatement(ResultSet.
TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String str = "select * from emp";
rs = stmt.executeQuery(str);
while (rs.next()) {
System.out.println(rs.getInt("e_id"));
System.out.println(rs.getString("e_name"));
}
} catch (Exception e) {}
;
con.close();
stmt.close();
rs.close();
}
public static void main(String[] args) throws SQLException {
jdbc2005 jb = new jdbc2005();
}
}
请高人指点