标签:result query ext .exe try lis rest 连接数 red
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=Temp";
String user = "wzf";
String password = "123456";
Connection conn = DriverManager.getConnection(url,user,password);
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
userList = new ArrayList<Users>();
while(rs.next()){
Users users = new Users();
String userName = rs.getString("USERNAME");
String passwords = rs.getString("PASSWORD");
users.setUserName(userName);
users.setPassword(passwords);
userList.add(users);
}
rs.close();
ps.close();
conn.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
标签:result query ext .exe try lis rest 连接数 red
原文地址:http://www.cnblogs.com/wangzhaofang/p/7965436.html