JSP SQL数据链接类调用问题
我写了个数据库的链接类
package db;
import java.sql.*;
public class ConnDB
{
public Connection conn=null;
public Statement st=null;
public String bd_Drive= "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
public Connection mygetConn() throws Exception{
Class.forName(bd_Drive);
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db ";
String user= "sa ";
String pwd= " ";
conn=DriverManager.getConnection(url,user,pwd);
st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return conn;
}
public void getConn()throws Exception
{
Class.forName(bd_Drive);
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db ";
String user= "sa ";
String pwd= " ";
conn=DriverManager.getConnection(url,user,pwd);
}
public ResultSet getRs(String sql)throws Exception
{
st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=st.executeQuery(sql);
return rs;
}
public void getUpdate(String sql)throws Exception
{
st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
st.executeUpdate(sql);
}
public void closeConn() throws Exception
{
if(st!=null)
st.close();
st=null;
if(conn!=null)
conn.close();
conn=null;
}
}
文件调用:
package com;
import java.sql.*;
import db.*;
import db.ConnDB;
public class newManage
{
ConnDB con= new ConnDB();
private String userid,password,qy,username,bm,job,type;
public void setUserid(String u){userid=u;}
public String getUserid(){return userid;}
public void setPassword(String p){password=p;}
public String getPassword(){return password;}
public void setQy(String q){qy=q;}
public String getQy(){return qy;}
public void setUsername(String n){username=n;}
public String getUsername(){return username;}
public void setBm(String b){bm=b;}
public String getBm(){return bm;}
public void setJob(String j){job=j;}
public String getJob(){return job;}
public void setType(String t){typ