主题:[讨论]请问怎么弄JAVA与microsoft sql server的连接和驱动
请问那个JAVA怎么和SQL SERVER 2000怎么连接啊``
我编了个
import java.sql.*;
public class shujuku{
public static void main(String[] a){
Connection con;
Statement sql;
ResultSet rs;
try{Class.forName("sun.microsoft.jdbc.sqlserver.SQLServerDriver");}
catch(ClassNotFoundException e){System.out.println(""+e);}
try{con=DriverManager.getConnection
("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student","sa","");
sql=con.createStatement();
rs=sql.executeQuery("select * from chengjibiao");
while(rs.next())
{String number=rs.getString(1);
String name=rs.getString(2);
String date=rs.getString(3);
int math=rs.getInt("math");
int english=rs.getInt("english");
System.out.print("学号"+number);
System.out.print("姓名"+name);
System.out.print("出生"+date);
System.out.print("数学"+math);
System.out.print("英语"+english);}
con.close();
}
catch(SQLException e){System.out.println(e);}
}
}
异常在上面的压缩包里``
是怎么回事啊 要设置什么参数还是什么的 请说下哦```
谢谢哦```
我编了个
import java.sql.*;
public class shujuku{
public static void main(String[] a){
Connection con;
Statement sql;
ResultSet rs;
try{Class.forName("sun.microsoft.jdbc.sqlserver.SQLServerDriver");}
catch(ClassNotFoundException e){System.out.println(""+e);}
try{con=DriverManager.getConnection
("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student","sa","");
sql=con.createStatement();
rs=sql.executeQuery("select * from chengjibiao");
while(rs.next())
{String number=rs.getString(1);
String name=rs.getString(2);
String date=rs.getString(3);
int math=rs.getInt("math");
int english=rs.getInt("english");
System.out.print("学号"+number);
System.out.print("姓名"+name);
System.out.print("出生"+date);
System.out.print("数学"+math);
System.out.print("英语"+english);}
con.close();
}
catch(SQLException e){System.out.println(e);}
}
}
异常在上面的压缩包里``
是怎么回事啊 要设置什么参数还是什么的 请说下哦```
谢谢哦```