import java.sql.*;
class Connect
{
public static void main(String[] asds)
{
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(ClassNotFoundException s){System.out.print("s");}
try{
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ycl";
Connection con=DriverManager.getConnection(url,"sa","");
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select * from ycl");
while(rs.next())
{
System.out.print(rs.getString("a"));
System.out.print(rs.getString("s"));
System.out.println(rs.getString("d"));
}
con.close();
}catch(SQLException s){System.out.print("Ece");}
}
}
第一个ycl为数据库名,另一个为表名