老师,能不能稍微讲一下SQL sever的 驱动方式
SQL sever的不知道
SQL sever的不知道
2014-12-19
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://127.0.0.1:1433;" +
"databaseName=JDBC;user=sa;password=123;";
Connection con;
try {
con = DriverManager.getConnection(connectionUrl);
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("select*from imooc_goddess");
while (rs.next()) {
System.out.println(rs.getNString("user_name"));
}
rs.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
举报