检查一下你的连接sql中是否有错
//连接数据库
public static synchronized Connection getConnection() throws Exception{
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydata";
String user = "sa";
String password = "";
return conn=DriverManager.getConnection(url, user, password);
}
catch(Exception e){
System.out.println("数据库连接错误!");
throw e;
}
}
//连接数据库
public static synchronized Connection getConnection() throws Exception{
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydata";
String user = "sa";
String password = "";
return conn=DriverManager.getConnection(url, user, password);
}
catch(Exception e){
System.out.println("数据库连接错误!");
throw e;
}
}
在jsp对sqlserver数据库进行数据读取的时候,
必须按照表中列名的顺序读取,否则会出现错误