課程
/后端開發
/Java
/JDBC之 “ 對岸的女孩看過來”
SQL sever的不知道
2014-12-19
源自:JDBC之 “ 對岸的女孩看過來” 2-2
正在回答
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();
舉報
一起領略JDBC的奧秘,為進一步學習集成框架打下良好的基礎
2 回答老師這驅動在哪下載的
1 回答為什么我的sql包不能自動導入,
1 回答有哪位能告訴我怎么用SQL server進行連接嗎?我一直在連接不上,驅動鏈接了
1 回答驅動的問題
2 回答麻煩老師回答一下加載驅動后class創建問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-12-20
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();
}
}