Topic: jsp连接mysql出错,紧急求助高手!

  Print this page

1.jsp连接mysql出错,紧急求助高手! Copy to clipboard
Posted by: borisflag
Posted on: 2006-04-13 21:45

问题1:
我在jsp文件的属性中选择了以后全用 记事本 打开,文件就全变为记事本的样子了,怎么可以把它还原为jsp文件呢?
问题2:
我的jsp总是不能连接到数据库mysql,界面显示为:
type status report
message /myapp/first.jsp
description The requested resource (/myapp/first.jsp) is not available.
具体配置:
jdk: jdk-1_5_0_06-windows-i586-p.exe
Apache Tomcat 5.5
mysql: mysql-4.1.13-win32.zip
jdbc: mysql-connector-java-3.1.10.zip

已经在C:\Program Files\Java目录下建立了mysqlforjdbc子目录,进入该目录将mysql-connector-java-3.1.10-bin.jar拷贝到了该目录下
也已经进入C:\Program Files\Java\jdk1.5.0_06\lib目录将mysql-connector-java-3.1.10-bin-g.jar拷贝到该目录下

jdk,tomcat,mysql已经配置成功,各自运行正常,数据库内已经新建了一个数据库first,库内已经加入一张表about,表内数据已经设好,只是jsp文件连接不到mysql,我该怎么做啊?

我使用的jsp测试文件是:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//first为你的数据库名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from first";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

我的环境变量设置:
classpath=.\;C:\Program Files\Java\jdk1.5.0_06\lib\tools.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;C:\Program Files\Java\jdk1.5.0_06\lib\mysql-connector-java-3.1.10-bin-g.jar;C:\Program Files\Java\mysqlforjdbc\mysql-connector-java-3.1.10-bin.jar;

path=C:\Program Files\Java\jdk1.5.0_06\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;

急盼回复!

2.Re:jsp连接mysql出错,紧急求助高手! [Re: borisflag] Copy to clipboard
Posted by: yclc
Posted on: 2006-07-08 15:21

汗,首先,你的web应用似乎没有部署成功.......

3.Re:jsp连接mysql出错,紧急求助高手! [Re: borisflag] Copy to clipboard
Posted by: aroky1983
Posted on: 2006-07-12 16:30

你的错误实在不知道从何说起!
看来你得段时间自己摸索下才行~

4.Re:jsp连接mysql出错,紧急求助高手! [Re: borisflag] Copy to clipboard
Posted by: haiming
Posted on: 2006-09-14 11:45

你要把mysql-connector-java-3.1.10-bin-g.jar拷到tomcat下的share\lib和common\lib下


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923