JSP连接MySQL问题

andy8lin 2006-09-04 10:59:22
今天刚刚装了MySQL,尝试用JSP连接但是出现下面这样的错误,请大侠指点指点
exception

javax.servlet.ServletException: The connection property 'useUnicode' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'true;characterEncoding' is not in this set.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.test2_jsp._jspService(test2_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.sql.SQLException: The connection property 'useUnicode' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'true;characterEncoding' is not in this set.
com.mysql.jdbc.ConnectionProperties$ConnectionProperty.validateStringValues(ConnectionProperties.java:2258)
com.mysql.jdbc.ConnectionProperties$BooleanConnectionProperty.initializeFrom(ConnectionProperties.java:2342)
com.mysql.jdbc.ConnectionProperties$ConnectionProperty.initializeFrom(ConnectionProperties.java:2158)
com.mysql.jdbc.ConnectionProperties.initializeProperties(ConnectionProperties.java:1953)
com.mysql.jdbc.Connection.initializeDriverProperties(Connection.java:3087)
com.mysql.jdbc.Connection.<init>(Connection.java:405)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:270)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp.test2_jsp._jspService(test2_jsp.java:50)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

小弟不胜感激
...全文
114 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
nemo0228 2006-09-21
  • 打赏
  • 举报
回复
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//myDB为数据库名
Connection conn= DriverManager.getConnection(url);
连接mysql的方法
andy8lin 2006-09-04
  • 打赏
  • 举报
回复
就是简单的数据库连接查询

<%@ 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:3306/student?user=root&password=076808&useUnicode=true;characterEncoding=8859_1";
Connection con = DriverManager.getConnection(url);
Statement stmt = con.createStatement();
String sql = "select * from jobs";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{%>
第一个字段内容:<%=rs.getString(1)%>
第二个字段内容:<%=rs.getString(2)%>
<%}%>
<%out.print("操作成功");%>
<%
rs.close();
stmt.close();
con.close();
%>
</body>
</html>
边城狂人 2006-09-04
  • 打赏
  • 举报
回复
url 有问题。

它把
useUnicode=true;characterEncoding=xxxx
认成了
useUnicode=true;characterEncoding

你是不是后面忘了写 =xxxxxx
user27 2006-09-04
  • 打赏
  • 举报
回复
你的jsp 文件贴出来看看,

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧