标题:[求助]jsp连接mysql老是出问题啊
只看楼主
GKKP
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-11-27
 问题点数:0 回复次数:1 
[求助]jsp连接mysql老是出问题啊

我完全默认安装的mysql里面的访问权限是最大的了,所有用户都没有密码 jsp内容是: <html> <head> <title>MY First MySQL Test</title></head> <body> <%@ page language="java" import="java.sql.*" contentType="text/html;charset=gb2312" %> <% String driver="org.gjt.mm.mysql.Driver"; String url="jdbc:mysql://222.18.15.131:3306/test"; String user="root"; String password="225and223"; try {Class.forName(driver);} catch(Exception e) {out.println("无法加载驱动程序!!"+driver); e.printStackTrace();} try { Connection con=DriverManager.getConnection(url,user,password); if(!con.isClosed( )){%> <p align=center><b>数据库连接成功!</b></p> <hr> <%} Statement sqlStmt=con.createStatement (java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY); String sqlQuery="select version(), now(), database(), user()"; ResultSet sqlRst=sqlStmt.executeQuery (sqlQuery); while (sqlRst.next()) { out.println(sqlRst.getString(1)); out.println(sqlRst.getString(2)); out.println(sqlRst.getString(3)); out.println(sqlRst.getString(4)); out.println("<hr><br>"); } con.close( );} catch(SQLException ee) {out.println("数据库连接失败!"); out.println(ee); return; }%> <%="数据库连接成功"%> </body> </html>

结果出错为: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.lang.NumberFormatException)

搜索更多相关主题的帖子: jsp mysql 
2004-11-29 21:58
GKKP
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-11-27
得分:0 

谢谢,不用了,我已经解决了哈,原来是jdbc-mysql和mysql不兼容

2004-11-30 08:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-8583-1-1.html




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

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