一个数据库插入的错误
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
这个问题是怎么回事啊。搞了半天都搞不好。也不知道错在哪里
代码如下:
<%@page contentType= "text/html; charset=GBK " import= "java.sql.* "%>
<html>
<jsp:useBean id= "student " scope= "page " class= "untitled1.ISOtoGb2312 "> </jsp:useBean>
<head>
<title> add_2 </title>
</head>
<body bgcolor= "#ffffff ">
<%
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
String url = "jdbc:odbc:studentdata ";
String uid = " ";
String pwd = " ";
Connection con = DriverManager.getConnection(url, uid, pwd);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
String id = request.getParameter( "id ");
String name = student.convert(request.getParameter( "name "));
String sex = student.convert(request.getParameter( "sex "));
String age = request.getParameter( "age ");
String weight = request.getParameter( "weight ");
System.out.println( "设置语句 ");
//String sql = "insert into stu_info(id,name,sex,age,weigth) values( "+id+ ", "+name+ ", "+sex+ ", "+age+ ", "+weight+ ") ";
System.out.println( "开始执行 ");
//●●●●●●●运行到这里就出错●●●●●●●●
stmt.executeUpdate( "insert into stu_info(id,name,sex,age,weigth) values( " + id + ", " + name + ", " + sex + ", " + age + ", " + weight + ") ");
//●●●●●●●●●●●●●●●
System.out.println( "插入完毕 ");
}
catch (Exception ex) {
System.out.print(ex.getMessage().toString());
}
%>
<center>
<h2> 数据库已经添加到数据库 </h2>
<form action= "index.jsp " name= "form1 " method= "POST ">
<input type= "submit " id= "back " name= "back " value= "返回 "/>
</form>
</center>
</body>
</html>
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
------解决方案--------------------应该是stmt.executeUpdate( "insert into stu_info(id