| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1163 人关注过本帖
标题:JAVA 连接MySql出错
取消只看楼主 加入收藏
zacom
Rank: 2
等 级:论坛游民
威 望:2
帖 子:381
专家分:15
注 册:2007-9-15
结帖率:88.89%
收藏
已结贴  问题点数:20 回复次数:1 
JAVA 连接MySql出错
<%@ page contentType="text/html;l anguage=gb2312"  language="java" import="java.sql.*"%>
<html>
<body>
以下是从MYSQL数据库读取的数据:<br>
<table border=1>
<tr><td>id</td><td>书名</td></tr>
<%
     Class.forName("org.gjt.mm.mysql.Driver").newInstance();
     Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1/jspdev","root","root");
     Statement stmt=con.createStatement();
     ResultSet rst=stmt.executeQuery("select * from book");
     while(rst.next())
    {
    out.println("<tr>");
    out.println("<td>“+rst.getString(1)+"</td>");
    out.println("<td>"+rst.getString(2)+"</td>");
    out.println("</tr>")
    }
    rst.close();
    stmt.close();
   con.close();
%>
</table>
</body>
</html>


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

An error occurred at line: 7 in the jsp file: /testMysql.jsp
Syntax error on token "/", delete this token
4: 以下是从MYSQL数据库读取的数据:<br>
5: <table border=1>
6: <tr><td>id</td><td>书名</td></tr>
7: <%
8:      Class.forName("org.gjt.mm.mysql.Driver").newInstance();
9:      Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1/jspdev","root","root");
10:      Statement stmt=con.createStatement();


An error occurred at line: 7 in the jsp file: /testMysql.jsp
String literal is not properly closed by a double-quote
4: 以下是从MYSQL数据库读取的数据:<br>
5: <table border=1>
6: <tr><td>id</td><td>书名</td></tr>
7: <%
8:      Class.forName("org.gjt.mm.mysql.Driver").newInstance();
9:      Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1/jspdev","root","root");
10:      Statement stmt=con.createStatement();


An error occurred at line: 7 in the jsp file: /testMysql.jsp
Syntax error, insert ")" to complete Expression
4: 以下是从MYSQL数据库读取的数据:<br>
5: <table border=1>
6: <tr><td>id</td><td>书名</td></tr>
7: <%
8:      Class.forName("org.gjt.mm.mysql.Driver").newInstance();
9:      Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1/jspdev","root","root");
10:      Statement stmt=con.createStatement();


An error occurred at line: 16 in the jsp file: /testMysql.jsp
Syntax error, insert ";" to complete Statement
13:     {
14:     out.println("<tr>");
15:     out.println("<td>“+rst.getString(1)+"</td>");
16:     out.println("<td>"+rst.getString(2)+"</td>");
17:     out.println("</tr>")
18:     }
19:     rst.close();
搜索更多相关主题的帖子: JAVA MySql 
2009-09-29 18:47
zacom
Rank: 2
等 级:论坛游民
威 望:2
帖 子:381
专家分:15
注 册:2007-9-15
收藏
得分:0 
现在是连接不上的问题。不要说方法好不

没有最好只有更好
2009-09-30 12:04
快速回复:JAVA 连接MySql出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.047612 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved