| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5030 人关注过本帖
标题:jsp与mysql数据库链接问题!
只看楼主 加入收藏
wenbin171
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2007-11-6
收藏
得分:0 
和以前一样,你们说是什么问题!


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.


-------哼!谁说不可以-------
2007-11-08 16:10
hardes
Rank: 1
等 级:新手上路
帖 子:322
专家分:0
注 册:2006-6-3
收藏
得分:0 
一个是数据库mysql的端口号
一个是tomcat的端口号
不一样的,你不用改了
唉!!哈哈.....

当神已无能为力,就让爷来普度众生吧!
2007-11-08 16:22
wenbin171
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2007-11-6
收藏
得分:0 
还是不行。我要哭了!
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)

-------哼!谁说不可以-------
2007-11-08 16:32
hardes
Rank: 1
等 级:新手上路
帖 子:322
专家分:0
注 册:2006-6-3
收藏
得分:0 
类找不到,驱动包放什么地方了你
找到你的工程文件,在文件的WEB-INF/lib中放一个驱动包
在不行的话放一个在你的jdk的jre\lib\ext目录中放一个驱动包
在不行的话在你的Tomcat的common\lib目录中放一个驱动包
在不行的话,我也快不行了!!哈哈

当神已无能为力,就让爷来普度众生吧!
2007-11-08 16:37
wenbin171
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2007-11-6
收藏
得分:0 

呵,人太笨了,没办法!

-------哼!谁说不可以-------
2007-11-08 16:50
luoxian_2003
Rank: 1
等 级:新手上路
威 望:2
帖 子:163
专家分:0
注 册:2006-2-22
收藏
得分:0 
发现一个问题,美女在这里提问,解答的人一大堆!呵呵

天地有正气,凛烈万古存。
2007-11-08 17:38
wenbin171
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2007-11-6
收藏
得分:0 
打你,乱说话!

-------哼!谁说不可以-------
2007-11-08 18:04
hjlwlyhjl
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2006-12-6
收藏
得分:0 
回复:(luoxian_2003)发现一个问题,美女在这里提问...
是美女呀? 哥们你要是不说还真不知道呢! 呵呵!

2007-11-08 20:09
wenbin171
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2007-11-6
收藏
得分:0 

问题还没有解决,请大家多多指教啊!


-------哼!谁说不可以-------
2007-11-09 09:40
wenbin171
Rank: 1
等 级:新手上路
帖 子:119
专家分:0
注 册:2007-11-6
收藏
得分:0 

大家来顶啊!


-------哼!谁说不可以-------
2007-11-09 09:49
快速回复:jsp与mysql数据库链接问题!
数据加载中...
 
   



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

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