连接数据库的问题,急,SOS!

net_spirit 2001-11-22 10:17:46
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
<%@page language="java" %>
<%@page import="java.sql.*" %>
<jsp:useBean id="db" scope="page" class="editeq.Connect" />
<%@page contentType="text/html;charset=gb2312" %>

test.jsp测试文件
<%@ include file="connect.jsp" %>
<%
ResultSet rs;
String Sql="SELECT landname,password FROM suppliers";
if(db.Init_Connect()) {
out.println("test ok!");
rs=db.executeQuery(Sql);
while(rs.next())
{
String landname1=rs.getString("landname");
out.println("用户名是:"+landname1);
String password1=rs.getString("password");
out.println("密码是:"+password1);
out.println("<br>");
}
}
else{
out.println("error!");
}
%>


报错信息!
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080\_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:67: ???? editeq.Connect?
editeq.Connect db = null;
^
C:\tomcat\work\localhost_8080\_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:70: ???? editeq.Connect?
db= (editeq.Connect)
^
C:\tomcat\work\localhost_8080\_0002fEdit_0002ftest_0002ejsptest_jsp_0.java:75: ???? editeq.Connect?
db = (editeq.Connect) Beans.instantiate(this.getClass().getClassLoader(), "editeq.Connect");
^
3 ???

求求各位大哥,我怎么解决呀?
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
net_spirit 2001-11-22
  • 打赏
  • 举报
回复
不是路径的关系!
我如果不用javaBean的话!
仅仅用jsp程序!
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Editeq?user=root;password=");
Statement stmt = conn.createStatement();
%>
可以连接数据库!
longaway 2001-11-22
  • 打赏
  • 举报
回复
是不是路径的关系?
看一下 Apache Tomcat 4.0\common\lib
jdbc 的 *.jar 得放在那里。
tc 3.2 得设置 classpath 。

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧