大家请帮帮忙看一下,我是新学这个的,请大家帮我看一下,如果我的jsp调用这个类,我在jsp中最后还用调用db.close()这个方法吗???;
package airinb2b;
import java.sql.*;
import java.io.*;
import java.util.*;
public class conn //定义类名
{
java.sql.Connection con;
Statement st;
ResultSet rs;
public conn()
{
try{ //容错
Class.forName( "net.sourceforge.jtds.jdbc.Driver ");
DriverManager.registerDriver(new net.sourceforge.jtds.jdbc.Driver());
con = java.sql.DriverManager.getConnection( "jdbc:jtds:sqlserver://127.0.0.1:1433/airin_b2b;user=sa;password=tytymnty110110 ");
st = con.createStatement();
}
catch(Exception e){}
}
/**查询记录的方法*/
public ResultSet Query(String biao,String table,String tiaojian)
{
try{//必要的容错
String select = "select "+biao+ " from "+table+ " where 1=1 "+tiaojian;
rs = st.executeQuery(select);//查询结果的显示
}
catch(Exception e)
{
System.out.print(e.toString());//容错语句
}
return rs;
}
public int count(String table)
{
int n=0;
try{
String select = "select * from "+table;
rs = st.executeQuery(select);//查询结果的显示
while(rs.next()){ n = rs.getRow();}
}
catch(Exception e)
{
System.out.print(e.toString());//容错语句
}
return n;
}
/**删除记录的方法*/
public void del(String table,String tiaojian)//定义无返回类型的删除方法里面有两个变量