日期:2014-05-20  浏览次数:20652 次

为什么插入数据时抛出sqlerror异常
我要向数据库中添加新的数据,可是每次执行的时候总会抛出SQLerror的错误,这是什么原因呢
我调试了下   在执行PreparedStatement   pst=con.prepareStatement(str)这条语句时中断的,不过不知道应该怎么改。
<!--buy.jsp-->
<%@   page   contentType= "text/html;charset=gb2312 "%>
<%@   page   import= "java.sql.* "%>

<html>
<head>
<title> 添加新书 </title>
</head>
<body   bgcolor= "#C0C0C0 ">
<center>
<%
if(session.isNew())
{
%>
<center>
<h1> 添加新书信息 </h1> <br>
<form   method= "post "   action= "buy.jsp "   name= "form ">
ID <input   type= "text "   size= "20 "   maxlength= "20 "   name= "name ">
<br>

书名 <input   type= "text "   size= "20 "   maxlength= "20 "   name= "name ">
<br>
作者 <input   type= "password "   size= "20 "   maxlength= "20 "   name= "author ">
<br>
价格 <input   type= "text "   size= "20 "   maxlength= "20 "   name= "price ">
<br>
数量 <input   type= "text "   size= "20 "   maxlength= "20 "   name= "amount ">
<br>
出版社 <input   type= "text "   size= "20 "   maxlength= "20 "   name= "product ">
<br>
类别 <input   type= "text "   size= "20 "   maxlength= "20 "   name= "type ">
<br>
<input   type= "submit "   value= "提交 "   name= "submit ">
<input   type= "reset "   value= "重置 "   name= "reset ">
</center>
<%
}
else  
{
try{
String   id=request.getParameter( "id ");
if(id==null)
id= " ";
String   author=request.getParameter( "author ");
if(author==null)
author= " ";
String   type=request.getParameter( "type ");
if(type==null)
type= " ";
String   name=request.getParameter( "name ");
if(name==null)
name= " ";
String   price=request.getParameter( "price ");
if(price==null)
price= " ";
String   amount=request.getParameter( "amount ");
if(amount==null)
amount= " ";
String   product=request.getParameter( "product ");
if(product==null)
product= " ";
//Class.forName( "DriverManager.JdbcOdbcDriver ");
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
//////////////////////////////////////////////////
String   strDirPath=getServletContext().getRealPath( "/ ");    
out.println(strDirPath);
//获得所在站点的绝对路径:E:\javatest\
    //out.print(strDirPath+ " <br> ");
    strDirPath=strDirPath.replace( '\\ ', '/ ');    
    out.print(strDirPath);
    //将“\”替换为“/”             E:/javatest/
    //out.print(strDirPath+ " <br> ");
    String   url   =   "jdbc:odbc:driver={Microsoft   Access   Driver   (*.mdb)};DBQ= "+strDirPath+ "Library/library.mdb ";