急,在线等!jsp+mysql连接报错!

xwqlitchi 2007-09-28 03:08:19
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 134 in the jsp file: /OrganizeProduct.jsp
Generated servlet error:
D:\jakarta-tomcat-5.0.28\work\Catalina\localhost\anine\org\apache\jsp\OrganizeProduct_jsp.java:197: ';' expected
^
1 error



org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

代码如下
<%
String na=request.getParameter("bh");
if(na==null)
{na=""; }
String driverName="com.mysql.jdbc.Driver";
String userName="root"; //数据库用户名
String userPasswd="19851017";//密码
String dbName="anine";//数据库名
String tableName="organize";//表名
String url="jdbc:mysql://localhost/"+anine+"?user="+root+"&password="+19851017; //联结字符串
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();



try {
ResultSet rs=statement.executeQuery("SELECT * FROM organize WHERE Item_no = '"+na+"'")

while(rs.next())
{
String Item_no1=rs.getString(1);
String Type=rs.getString(2);
String Available_color=rs.getString(3);
String Product_info1=rs.getString(4);
ResultSetMetaData rmeta = rs.getMetaData();//获得数据结果集合
int numColumns=rmeta.getColumnCount();
%>
。。。。。。。。
<%
}
rs.close();
statement.close();connection.close();

}
catch(SQLException event)
{ }
%>
...全文
204 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
aphroditewshq 2007-09-30
  • 打赏
  • 举报
回复
慢慢来,急是解决不了问题的.静下心来调试.
chengwenying 2007-09-30
  • 打赏
  • 举报
回复
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd; //联结字符串 这个引号放错了,放后一格;
xwqlitchi 2007-09-29
  • 打赏
  • 举报
回复
有人知道不?急啊,从上午急到凌晨了
a68020405ybcoomy 2007-09-29
  • 打赏
  • 举报
回复
你的URL里的localhost后面应该是“:”而不应该是“/”吧
yifuzhiming 2007-09-28
  • 打赏
  • 举报
回复
xwqlitchi 2007-09-28
  • 打赏
  • 举报
回复
好,我试试,bh应该过来了啊,
大家看看
这是上个页面的代码
<a href="OrganizeProduct.jsp?bh=RPT60855"><img src="image312/organize/RPT60855.jpg" width="100" height="100" border="0"></a>
这是下个页面的代码

<%
String na=request.getParameter("bh");
if(na==null)
{na=""; }
String driverName="com.mysql.jdbc.Driver";
String userName="root"; //数据库用户名
String userPasswd="19851017";//密码
String dbName="anine";//数据库名
String tableName="organize";//表名
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd; //联结字符串
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
try {
ResultSet rs=statement.executeQuery("SELECT * FROM organize WHERE Item_no = '"+na+"'");

while(rs.next())
{
String Item_no1=rs.getString(1);
String Type=rs.getString(2);
String Available_color=rs.getString(3);
String Product_info1=rs.getString(4);
String Service=rs.getString(5);
String Size=rs.getString(6);
String Sheet=rs.getString(7);
String Package=rs.getString(8);
String Cover_material=rs.getString(9);
String Cnt_size=rs.getString(10);
String Gw=rs.getString(11);
String Small_picture=rs.getString(12);
String Middle_picture=rs.getString(13);
String Larger_picture=rs.getString(14);
String Corner_picture=rs.getString(15);
String Edge_picture=rs.getString(16);
ResultSetMetaData rmeta = rs.getMetaData();//获得数据结果集合
int numColumns=rmeta.getColumnCount();
%>
。。。。。。。。。。。。。。
<%
}
rs.close();
statement.close();connection.close();

}
catch(SQLException event)
{ }
%>
jiqimiao 2007-09-28
  • 打赏
  • 举报
回复
还有看看你那个bh有没有传过来
jiqimiao 2007-09-28
  • 打赏
  • 举报
回复
你在sql的地方设断点调试一下,把sql语句直接到库中执行一下看看能不能查到内容
xwqlitchi 2007-09-28
  • 打赏
  • 举报
回复
晕,这回改完了,是不报错了,但是没有从数据库里读出任何东西,页面上什么都没有。
图片在我的相册里http://photo.163.com/photos/xwqlitchi/137293931/
yuer1985 2007-09-28
  • 打赏
  • 举报
回复
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd"";
正解
jiqimiao 2007-09-28
  • 打赏
  • 举报
回复
你出错的原因就是这个,你原先写的
String url="jdbc:mysql://localhost/"+anine+"?user="+root+"&password="+19851017;
anine和root都没有声明啊
xwqlitchi 2007-09-28
  • 打赏
  • 举报
回复
说下,我原来是用sql的,mysql是昨天现学的。不好意思。老板要在月底之前交工,麻烦大家耐心指点
jiqimiao 2007-09-28
  • 打赏
  • 举报
回复
你上面不是定义了
String userName="root"; //数据库用户名
String userPasswd="19851017";//密码
String dbName="anine";//数据库名
String tableName="organize";//表名
url中应该使用变量了啊,改为
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
xiciliu 2007-09-28
  • 打赏
  • 举报
回复
建议好好打打基础。
提示 symbol : variable anine 等
你的anine是变量吗?不是变量怎么能这样用?这个只是你想付的值而已。
诸如root,19851017等也是一样的。


需要提高空间,店铺等访问量的请看-- http://www.TheseTags.com
yuer1985 2007-09-28
  • 打赏
  • 举报
回复
String url="jdbc:mysql://localhost/"+anine+"?user="+root+"&password="+19851017;
掉了双引号
String url="jdbc:mysql://localhost/"+anine+"?user="+root+"&password=19851017";
freedom2001 2007-09-28
  • 打赏
  • 举报
回复
String url="jdbc:mysql://localhost/"+anine+"?user="+root+"&password="+19851017;
你看看觉得这样对吗最后那个数那么写能对吗?
xwqlitchi 2007-09-28
  • 打赏
  • 举报
回复
我加上;了,又出来错误了
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 134 in the jsp file: /OrganizeProduct.jsp
Generated servlet error:
D:\jakarta-tomcat-5.0.28\work\Catalina\localhost\anine\org\apache\jsp\OrganizeProduct_jsp.java:188: cannot resolve symbol
symbol : variable anine
location: class org.apache.jsp.OrganizeProduct_jsp


An error occurred at line: 134 in the jsp file: /OrganizeProduct.jsp
Generated servlet error:
String url="jdbc:mysql://localhost/"+anine+"?user="+root+"&password="+19851017; //脕陋陆谩脳脰路没麓庐
^


An error occurred at line: 134 in the jsp file: /OrganizeProduct.jsp
Generated servlet error:
D:\jakarta-tomcat-5.0.28\work\Catalina\localhost\anine\org\apache\jsp\OrganizeProduct_jsp.java:188: cannot resolve symbol
symbol : variable root
location: class org.apache.jsp.OrganizeProduct_jsp


An error occurred at line: 134 in the jsp file: /OrganizeProduct.jsp
Generated servlet error:
String url="jdbc:mysql://localhost/"+anine+"?user="+root+"&password="+19851017; //脕陋陆谩脳脰路没麓庐
^
2 errors



org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

xiciliu 2007-09-28
  • 打赏
  • 举报
回复
try{ 后面一行没有分号啊。 出错提示里面很清楚的指出来了。


需要提高空间,店铺等访问量的请看-- http://www.TheseTags.com

81,090

社区成员

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

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