<%@ page language="java" import="java.sql.*" contentType="text/html ; chartset=GB2312"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>starting page</title></head><body> 從數(shù)據(jù)庫(kù)中讀取的數(shù)據(jù): <hr> <table border="1"> <tr> <th>用戶登錄號(hào)</th> <th>姓名</th> <th>性別</th> <th>出生日期</th> <th>興趣愛(ài)好</th> </tr> <% String driverName = "com.mysql.jdbc.Driver"; String userName = "root"; String userPasswd = "some_pass"; String dbName = "test"; String tableName = "userinfo"; String url = "jdbc:mysql://localhost:3306/" + dbName; Connection con=null; Statement s; ResultSet rs; Class.forName(driverName); con = DriverManager.getConnection(url,userName,userPasswd); s = con.createStatement(); String sql = "SELECT * From" + tableName; ? ?rs = s.executeQuery(sql); while (rs.next()) { out.print("<tr>"); out.print("<td>" + rs.getString("UserId") + "</td>"); out.print("<td>" + rs.getString("Name") + "</td>"); out.print("<td>" + rs.getString("Sex") + "</td>"); out.print("<td>" + rs.getString("BirthDate") + "</td>"); out.print("<td>" + rs.getString("Interest") + "</td>"); out.print("</tr>"); } rs.close(); s.close(); con.close(); %> </table></body></html>以下是網(wǎng)頁(yè)顯示的錯(cuò)誤類型異常報(bào)告消息?發(fā)生處理JSP頁(yè)面/A1-1.jsp例外在33行說(shuō)明?服務(wù)器遇到阻止其完成此請(qǐng)求內(nèi)部錯(cuò)誤。例外org.apache.jasper.JasperException:發(fā)生處理JSP頁(yè)面/A1-1.jsp例外在33行
30:CON?=的DriverManager.getConnection(URL,用戶名userPasswd);
31:S?=?con.createStatement();
32:字符串SQL?=“SELECT?*?FROM”+?tableName值;
33:RS?=?s.executeQuery(SQL);
34:而(rs.next()){
35:的out.print(“<TR>”);
36:的out.print(“<TD>”+?rs.getString(“用戶ID”)+“</?TD>”);
堆棧跟蹤:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:579)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)根本原因javax.servlet.ServletException:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:你在你的SQL語(yǔ)法錯(cuò)誤;?檢查對(duì)應(yīng)于你的MySQL服務(wù)器版本在1號(hào)線附近使用“Fromuserinfo'正確的語(yǔ)法手冊(cè)
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838)
org.apache.jsp.A1_002d1_jsp._jspService(A1_002d1_jsp.java:172)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)根本原因com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:你在你的SQL語(yǔ)法錯(cuò)誤;?檢查對(duì)應(yīng)于你的MySQL服務(wù)器版本在1號(hào)線附近使用“Fromuserinfo'正確的語(yǔ)法手冊(cè)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(本機(jī)方法)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:526)
com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
com.mysql.jdbc.Util.getInstance(Util.java:408)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3970)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3906)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2677)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2503)
com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1369)
org.apache.jsp.A1_002d1_jsp._jspService(A1_002d1_jsp.java:143)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
用myeclipes+mysql+Tomcat進(jìn)行配置,執(zhí)行程序時(shí)顯示錯(cuò)誤,求大神幫忙
風(fēng)騷小王子
2016-11-25 10:28:12