连接数据库的问题,急,SOS!
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 ???
求求各位大哥,我怎么解决呀?
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 ???
求求各位大哥,我怎么解决呀?
...全文
相关推荐
汉语词典快速查找算法研究.pdf
汉语词典快速查找算法研究.pdf
利用SOS扩展库进入高阶.NET6程序的调试
????欢迎点赞 :???? 收藏 ⭐留言 ???? 如有错误敬请指正,赐人玫瑰,手留余香! ????本文作者:由webmote 原创,首发于 【掘金】 ????作者格言: 生活在于折腾,当你不折腾生活时,生活就开始折腾你,让我们一起加油!???????????? 有时候我们可能想深入到程序的运行核心,去观察下内存分配情况以及堆栈内保存的东东,那么作为编程新贵的底层框架.NET6,又为我们提供了什么可用的观测工具呢? 1.SOS 扩展是什么? SOS扩展库是Windows 附带的调试扩展库,它允许开
TXT格式《现代汉语词典》
这是个TXT格式的《现代汉语词典》,推荐收藏!
汉语词典 mdb版数据库
蓝本为台湾教育部编《国语辞典》,现转为简体mdb版,版权归台湾教育部所有,只限学习,谢勿商用.
\汉语词典快速查询算法研究.doc
汉语词典快速查询算法研究.doc


Web 开发
