请教各位JSP高手,大虾(急)
我写了一个小网站,我把连接数据库封装到两个类中,方法也封进去了,放在WEB-INF/classes下
具体是这么写的DBConnectionManager.java
package bookshop;
import java.sql.*;
public class DBConnectionManager{
private String DriverName =
"org.gjt.mm.mysql.Driver";
private String url =
"jdbc:mysql://localhost/jspshop?useUnicode=true&characterEncoding=GB2312";
private String user="root";
private String password="1983113";
public void setDrverName(String newDriverName){
this.DriverName = newDriverName;
}
public String getDriverName(){
return DriverName;
}
public void setUrl(String newUrl){
this.url=newUrl;
}
public String getUrl(){
return url;
}
public void setUser(String newUser){
this.user = newUser;
}
public String getUser(){
return user;
}
public void setPassword(String newPassword){
this.password=newPassword;
}
public String getPassword(){
return password;
}
public Connection getConnection(){
try
{
Class.forName(DriverName).newInstance();
return DriverManager.getConnection(url,user,password);
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
DBSQLManager.java
package bookshop;
import java.sql.*;
import bookshop.*;
public class DBSQLManager{
protected Connection conn=null;
protected Statement stmt=null;
protected ResultSet rs=null;
protected String sqlStr;
public DBSQLManager(){
try
{
sqlStr="";
DBConnectionManager dcm=new DBConnectionManager();
conn=dcm.getConnection();
stmt=conn.createStatement();
}
catch(Exception e){
System.out.println(e);
isConnect=false;
}
}
public Statement getStmt(){
return stmt;
}
public Connection getConn(){
return conn;
}
public ResultSet getRs(){
return rs;
}
public void setSqlStr(String newSqlstr){
this.sqlStr=newSqlStr;
}
public String getSqlStr(){
return sqlStr;
}
public void executeQuery() throws Exception {
rs=stmt.executeQuery(sqlStr);
}
public void executeUpdate() throws Exception {
stmt.executeUpdate(sqlStr);
}
public void close() throws SQLException {
if(stmt !=null){
stmt.close();
stmt=null;
}
conn.close();
conn=null;
}
}
在JSP页面中我将DBSQLManager实例化(DBSQLManager dbsm=new DBSQLManager();
然后用实例对象调用方法对数据库进行插入,查询等操作,但是每次要么是页面完全通过,但是数据并没有插入进去,要么就是显示找不到类.各位大哥请指教~~~