java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 参数不足,期待是 1。

飞歌 2010-09-18 02:38:57
java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 参数不足,期待是 1。
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)
at org.apache.jsp.checkReg_jsp._jspService(checkReg_jsp.java:102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
...全文
444 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞歌 2010-10-13
  • 打赏
  • 举报
回复
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'checkReg.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>

<%


String name = request.getParameter("uname"); //用来保存姓名的变量
String password = request.getParameter("upwd"); //密码
String repassword = request.getParameter("reupwd"); //密码
String sex = request.getParameter("sex"); //性别
String dat = request.getParameter("udate"); //注册日期
String email = request.getParameter("uemail"); //邮箱地址
String level = request.getParameter("ulevel"); //用户级别
String logourl = request.getParameter("ulogo"); //LOGO路径

Connection con = null; //声明连接对象
Statement stmt = null; //声明语句对象
ResultSet rs = null; //声明结果集对象
try{
String url; //连接字符串
url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="
+ application.getRealPath("/") + "db\\bbs.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //加载驱动程序
con = DriverManager.getConnection(url); //获取连接
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); //创建语句对象
String sql = "select * from users where uname ='" + name + "'"; //构建sql语句
String sql2 = "insert into users(uname, upwd, reupwd,usex,udate,uemail,ulevel,ulogo) values('"+name+"','"+password+"','"+repassword+"','"+sex+"','"+email+"',default,'"+level+"','"+logourl+"')";
rs = stmt.executeQuery(sql); //执行查询语句,查询结果存入对象rs中
if(rs!=null){
if(rs.next())
{
%>
<script language="JavaScript">
alert("该用户已经被使用,请重新输入!");
window.location.href="register.jsp";
</script>
<%
}
else{

int ps = stmt.executeUpdate(sql2);
if(ps>0){
out.println("添加信息成功!");
}else{
out.println("添加信息失败!");
}
}
}
}catch(Exception e){
e.printStackTrace(System.err);
}finally{
try{
if(rs!=null)
rs.close();
}catch(Exception e){}
try{
if(stmt!=null)
rs.close();
}catch(Exception e){}
try{
if(con!=null)
rs.close();
}catch(Exception e){}
}

%>
</body>
</html>
feixianxxx 2010-09-18
  • 打赏
  • 举报
回复
看看链接字符串的参数齐了么
ACMAIN_CHM 2010-09-18
  • 打赏
  • 举报
回复
你的程序代码是什么?

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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