我有WEB-INF\lib\mysql-connector-java-3.1.14-bin.jar文件代码如下:
<%@ page contentType="text/html; charset=gb2312" %><%@ page language="java" %><%@ page import="com.mysql.jdbc.Driver" %><%@ page import="java.sql.*" %><%//驱动程序名String driverName="com.mysql.jdbc.Driver";//数据库用户名String userName="root";//密码String userPasswd="123456";//数据库名String dbName="test";//表名String tableName="login";//联结字符串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();String sql="SELECT * FROM "+tableName;ResultSet rs = statement.executeQuery(sql); //获得数据结果集合ResultSetMetaData rmeta = rs.getMetaData();//确定数据集的列数,亦字段数int numColumns=rmeta.getColumnCount();// 输出每一个数据值out.print("id"); out.print("|");out.print("num");out.print("<br>");while(rs.next()) {out.print(rs.getString(1)+" "); out.print("|");out.print(rs.getString(2));out.print("<br>"); } out.print("<br>");out.print("数据库操作成功,恭喜你"); rs.close(); statement.close(); connection.close(); %>
出错提示
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /jsp-mysql.jsp
Generated servlet error:
String literal is not properly closed by a double-quote
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /jsp-mysql.jsp
Generated servlet error:
String literal is not properly closed by a double-quote
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.请各位大吓指点,谢谢
<%@ page contentType="text/html; charset=gb2312" %><%@ page language="java" %><%@ page import="com.mysql.jdbc.Driver" %><%@ page import="java.sql.*" %><%//驱动程序名String driverName="com.mysql.jdbc.Driver";//数据库用户名String userName="root";//密码String userPasswd="123456";//数据库名String dbName="test";//表名String tableName="login";//联结字符串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();String sql="SELECT * FROM "+tableName;ResultSet rs = statement.executeQuery(sql); //获得数据结果集合ResultSetMetaData rmeta = rs.getMetaData();//确定数据集的列数,亦字段数int numColumns=rmeta.getColumnCount();// 输出每一个数据值out.print("id"); out.print("|");out.print("num");out.print("<br>");while(rs.next()) {out.print(rs.getString(1)+" "); out.print("|");out.print(rs.getString(2));out.print("<br>"); } out.print("<br>");out.print("数据库操作成功,恭喜你"); rs.close(); statement.close(); connection.close(); %>
出错提示
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /jsp-mysql.jsp
Generated servlet error:
String literal is not properly closed by a double-quote
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /jsp-mysql.jsp
Generated servlet error:
String literal is not properly closed by a double-quote
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.请各位大吓指点,谢谢
解决方案 »
- s2sh使用泛型后不能在dao里获取到泛型的类型
- 高手进来赐教(关开jsp自动跳转)
- 为什么int 、float的都是四个字节,取值范围相差那么多
- 请教一下java web开发源码里面的目录结构,都是做什么用的,之间关系如何,比如mvnforum
- JAVA技术交流群10606795,欢迎大家加入
- 火,火,火……开发jsp+mysql 页面里加入了中文处理但eclipse+myeclipse保存后变成了乱码
- 一个访问本地txt文档的applet能运行,客户端为何看不到?(好久没人回)
- 裸体跪求JSP从JRUN移植到WEBLOGIC的详细方法!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 高分索求个人主页源代码!!!!
- 初学入门,紧急求助,等待高手,为我解惑!
- 出现HTTP Status 500 - 错误是怎么回事
- 为什么eclipse,自己没有设置断电,自己也会有断电,怎么取消
classpath
;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%TOMCAT_HOME%\common\lib;%TOMCAT_HOME%\common\lib\servlet-api.jar;%JAVA_HOME%\lib;%JAVA_HOME%\mysql-connector-java-3.1.14-bin.jar