Z
zlmark
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个连接数据库和执行sql语句的bean如下:
import java.sql.*;
public class sqltest{
public String url="jdbcdbca";
public Connection con=null;
public Statement st=null;
public ResultSet rs=null;
private String uid="sa";
private String psword="nmc";
public sqltest(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
public void sqlclose(){
try{
st.close();
con.close();
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
public ResultSet execQuery(String ssql){
rs=null;
try{
con=DriverManager.getConnection(url);
st=con.createStatement();
rs=st.executeQuery(ssql);
}
catch(SQLException e){
System.err.println("error");
}
return rs;
}
}
,但在jsp页面中调用后返回的ResultSet为null,这是怎么回事?我用的AppServer为JRun
import java.sql.*;
public class sqltest{
public String url="jdbcdbca";
public Connection con=null;
public Statement st=null;
public ResultSet rs=null;
private String uid="sa";
private String psword="nmc";
public sqltest(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
public void sqlclose(){
try{
st.close();
con.close();
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
public ResultSet execQuery(String ssql){
rs=null;
try{
con=DriverManager.getConnection(url);
st=con.createStatement();
rs=st.executeQuery(ssql);
}
catch(SQLException e){
System.err.println("error");
}
return rs;
}
}
,但在jsp页面中调用后返回的ResultSet为null,这是怎么回事?我用的AppServer为JRun