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: 6 in the jsp file: /testdb3.jsp Syntax error on token "import", assert expected 3: <html> 4: <body> 5: <% 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; An error occurred at line: 6 in the jsp file: /testdb3.jsp java.sql.Connection cannot be resolved 3: <html> 4: <body> 5: <% 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; An error occurred at line: 7 in the jsp file: /testdb3.jsp Syntax error on token "import", assert expected 4: <body> 5: <% 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; An error occurred at line: 7 in the jsp file: /testdb3.jsp java.sql.DriverManager cannot be resolved 4: <body> 5: <% 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; An error occurred at line: 8 in the jsp file: /testdb3.jsp Syntax error on token "import", assert expected 5: <% 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: An error occurred at line: 8 in the jsp file: /testdb3.jsp java.sql.PreparedStatement cannot be resolved 5: <% 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: An error occurred at line: 9 in the jsp file: /testdb3.jsp Syntax error on token "import", assert expected 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: 12: public class DBConnection { An error occurred at line: 9 in the jsp file: /testdb3.jsp java.sql.ResultSet cannot be resolved 6: import java.sql.Connection; 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: 12: public class DBConnection { An error occurred at line: 10 in the jsp file: /testdb3.jsp Syntax error on token "import", assert expected 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: 12: public class DBConnection { 13: private static Connection conn = null; An error occurred at line: 10 in the jsp file: /testdb3.jsp java.sql.SQLException cannot be resolved 7: import java.sql.DriverManager; 8: import java.sql.PreparedStatement; 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: 12: public class DBConnection { 13: private static Connection conn = null; An error occurred at line: 12 in the jsp file: /testdb3.jsp Illegal modifier for the local class DBConnection; only abstract or final is permitted 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: 12: public class DBConnection { 13: private static Connection conn = null; 14: 15: static An error occurred at line: 12 in the jsp file: /testdb3.jsp Cannot define static initializer in inner type DBConnection 9: import java.sql.ResultSet; 10: import java.sql.SQLException; 11: 12: public class DBConnection { 13: private static Connection conn = null; 14: 15: static An error occurred at line: 25 in the jsp file: /testdb3.jsp The method getConnection cannot be declared static; static methods can only be declared in a static or top level type 22: } 23: } 24: 25: public static Connection getConnection() 26: { 27: String url = "jdbc:mysql://localhost:8080/first"; 28: String user="root"; An error occurred at line: 40 in the jsp file: /testdb3.jsp The method close cannot be declared static; static methods can only be declared in a static or top level type 37: } 38: 39: 40: public static void close() 41: { 42: if(conn!=null) 43: { An error occurred at line: 73 in the jsp file: /testdb3.jsp The method main cannot be declared static; static methods can only be declared in a static or top level type 70: close(); 71: } 72: } 73: public static void main(String[] args) { 74: new DBConnection().printResult("about"); 75: //你将这段代码运行看看,是不是有数据输出. 76: //表名,数据库用户以及密码我都按照你的写的,你用改了直接运行看看 Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415) org.apache.jasper.compiler.Compiler.compile(Compiler.java:308) org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) org.apache.jasper.compiler.Compiler.compile(Compiler.java:273) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
----------------解决方案--------------------------------------------------------
一个是数据库mysql的端口号
一个是tomcat的端口号
不一样的,你不用改了
唉!!哈哈.....
----------------解决方案--------------------------------------------------------
还是不行。我要哭了!
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DBConnection.<clinit>(DBConnection.java:14)
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DBConnection.getConnection(DBConnection.java:27)
at DBConnection.printResult(DBConnection.java:54)
at DBConnection.main(DBConnection.java:69)
Exception in thread "main" java.lang.NullPointerException
at DBConnection.printResult(DBConnection.java:54)
at DBConnection.main(DBConnection.java:69)
----------------解决方案--------------------------------------------------------
类找不到,驱动包放什么地方了你
找到你的工程文件,在文件的WEB-INF/lib中放一个驱动包
在不行的话放一个在你的jdk的jre\lib\ext目录中放一个驱动包
在不行的话在你的Tomcat的common\lib目录中放一个驱动包
在不行的话,我也快不行了!!哈哈
----------------解决方案--------------------------------------------------------
呵,人太笨了,没办法!
----------------解决方案--------------------------------------------------------
发现一个问题,美女在这里提问,解答的人一大堆!呵呵
----------------解决方案--------------------------------------------------------
打你,乱说话!
----------------解决方案--------------------------------------------------------
回复:(luoxian_2003)发现一个问题,美女在这里提问...
是美女呀? 哥们你要是不说还真不知道呢! 呵呵! ----------------解决方案--------------------------------------------------------
问题还没有解决,请大家多多指教啊!
----------------解决方案--------------------------------------------------------
大家来顶啊!
----------------解决方案--------------------------------------------------------