import java.sql.*;
public class Test{
public Test(){}
public static void main(String args[]){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=null;DatabaseName=maxwell");
Statement stmt=conn.createStatement();
String sql="select * from employee";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
System.out.println("TestName:"+rs.getString("name"));
}
rs.close();
stmt.close();
conn.close();
} catch(Exception ex) { System.err.println(ex.getMessage()); }
}}
原代码
public class Test{
public Test(){}
public static void main(String args[]){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=null;DatabaseName=maxwell");
Statement stmt=conn.createStatement();
String sql="select * from employee";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
System.out.println("TestName:"+rs.getString("name"));
}
rs.close();
stmt.close();
conn.close();
} catch(Exception ex) { System.err.println(ex.getMessage()); }
}}
原代码
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货