当前位置: 技术问答>java相关
连接数据库的问题,急,SOS!
来源: 互联网 发布时间:2015-02-22
本文导语: JavaBean代码: package editeq; import java.sql.*; import java.util.*; public class Connect { protected String DBDriver="org.gjt.mm.mysql.Driver"; protected String DBUrl="jdbc:mysql://loccalhost:3306/Editeq? user=root&password="; protected Connection Conn=null;...
JavaBean代码:
package editeq;
import java.sql.*;
import java.util.*;
public class Connect
{
protected String DBDriver="org.gjt.mm.mysql.Driver";
protected String DBUrl="jdbc:mysql://loccalhost:3306/Editeq? user=root&password=";
protected Connection Conn=null;
protected ResultSet rs=null;
protected Statement Stmt=null;
public boolean Init_Connect(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
Conn=DriverManager.getConnection(DBUrl);
Stmt=Conn.createStatement();
}
catch (Exception e){
System.err.println("exception is connection:"+e.getMessage());
return false;
}
return true;
}
public ResultSet executeQuery(String sql){
rs=null;
try {
rs = Stmt.executeQuery(sql);
}
catch (Exception e){
System.err.println("aq.executeQuery:"+e.getMessage());
}
return rs;
}
public void executeUpdate(String sql){
try {
Stmt.executeUpdate(sql);
}
catch (Exception e){
System.err.println("exception is:"+e.getMessage());
}
}
public void Close_Connect(){
try{
if(this.rs!=null){
this.rs.close();
}
if(Stmt!=null){
this.Stmt.close();
}
if(Conn!=null){
this.Conn.close();
}
}
catch (Exception e){
System.err.println("exception is:"+e.getMessage());
}
}
}
Jsp连接程序!
connect.jsp
test.jsp测试文件
报错信息!
org.apache.jasper.JasperException: Unable to compile class for JSPC:tomcatworklocalhost_8080_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:67: ???? editeq.Connect?
editeq.Connect db = null;
^
C:tomcatworklocalhost_8080_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:70: ???? editeq.Connect?
db= (editeq.Connect)
^
C:tomcatworklocalhost_8080_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:75: ???? editeq.Connect?
db = (editeq.Connect) Beans.instantiate(this.getClass().getClassLoader(), "editeq.Connect");
^
3 ???
求求各位大哥,我怎么解决呀?
package editeq;
import java.sql.*;
import java.util.*;
public class Connect
{
protected String DBDriver="org.gjt.mm.mysql.Driver";
protected String DBUrl="jdbc:mysql://loccalhost:3306/Editeq? user=root&password=";
protected Connection Conn=null;
protected ResultSet rs=null;
protected Statement Stmt=null;
public boolean Init_Connect(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
Conn=DriverManager.getConnection(DBUrl);
Stmt=Conn.createStatement();
}
catch (Exception e){
System.err.println("exception is connection:"+e.getMessage());
return false;
}
return true;
}
public ResultSet executeQuery(String sql){
rs=null;
try {
rs = Stmt.executeQuery(sql);
}
catch (Exception e){
System.err.println("aq.executeQuery:"+e.getMessage());
}
return rs;
}
public void executeUpdate(String sql){
try {
Stmt.executeUpdate(sql);
}
catch (Exception e){
System.err.println("exception is:"+e.getMessage());
}
}
public void Close_Connect(){
try{
if(this.rs!=null){
this.rs.close();
}
if(Stmt!=null){
this.Stmt.close();
}
if(Conn!=null){
this.Conn.close();
}
}
catch (Exception e){
System.err.println("exception is:"+e.getMessage());
}
}
}
Jsp连接程序!
connect.jsp
test.jsp测试文件
报错信息!
org.apache.jasper.JasperException: Unable to compile class for JSPC:tomcatworklocalhost_8080_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:67: ???? editeq.Connect?
editeq.Connect db = null;
^
C:tomcatworklocalhost_8080_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:70: ???? editeq.Connect?
db= (editeq.Connect)
^
C:tomcatworklocalhost_8080_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:75: ???? editeq.Connect?
db = (editeq.Connect) Beans.instantiate(this.getClass().getClassLoader(), "editeq.Connect");
^
3 ???
求求各位大哥,我怎么解决呀?
|
是不是路径的关系?
看一下 Apache Tomcat 4.0commonlib
jdbc 的 *.jar 得放在那里。
tc 3.2 得设置 classpath 。
看一下 Apache Tomcat 4.0commonlib
jdbc 的 *.jar 得放在那里。
tc 3.2 得设置 classpath 。