課程
/后端開發(fā)
/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();
舉報(bào)
一起領(lǐng)略JDBC的奧秘,為進(jìn)一步學(xué)習(xí)集成框架打下良好的基礎(chǔ)
2 回答老師這驅(qū)動在哪下載的
1 回答為什么我的sql包不能自動導(dǎo)入,
1 回答有哪位能告訴我怎么用SQL server進(jìn)行連接嗎?我一直在連接不上,驅(qū)動鏈接了
1 回答驅(qū)動的問題
2 回答麻煩老師回答一下加載驅(qū)動后class創(chuàng)建問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
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();
}
}