主题:一个连接sqlserver数据库的问题!
我的配置环境是tomcat+mssqlserver2000,可是执行到rs=stmt.exectueQuery(sql)时返回给rs的却是null,用输出语句的方法判断过,程序在前几句都正常,可是到了这句就异常了,数据源测试的时候是正常的,在sqlserver里用企业管理器也可以执行查询语句
select* from user,
另:sqlserver里建立数据库test,里面有一张表user,两个字段,分别是username,和password
<%
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String msg="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:test");
stmt=con.createStatemen(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select* from user";
rs=stmt.executeQuery(sql);
}
catch(Exception e){
System.out.println(e.toString());}
}
%>[em6]
select* from user,
另:sqlserver里建立数据库test,里面有一张表user,两个字段,分别是username,和password
<%
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String msg="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:test");
stmt=con.createStatemen(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select* from user";
rs=stmt.executeQuery(sql);
}
catch(Exception e){
System.out.println(e.toString());}
}
%>[em6]