日期:2014-05-18  浏览次数:20763 次

JSP向数据库中插入 数据出现错误,请大虾帮忙
我向数据库中插入数据
出现一下错误:
ava.sql.SQLException:   [Microsoft][SQLServer   2000   Driver   for   JDBC][SQLServer]将截断字符串或二进制数据。
at   com.microsoft.jdbc.base.BaseExceptions.createException(Unknown   Source)
at   com.microsoft.jdbc.base.BaseExceptions.getException(Unknown   Source)
at   com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown   Source)
at   com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown   Source)
at   com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown   Source)
at   com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown   Source)
at   com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown   Source)
at   com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown   Source)失败

at   com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown   Source)
at   com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown   Source)
at   com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown   Source)
at   com.microsoft.jdbc.base.BaseStatement.executeUpdate(Unknown   Source)
at   connDB.connectDB.executeUpdata(connectDB.java:78)
at   connDB.connectDB.main(connectDB.java:173)

我在网上也查了查,说是字段长度不同,我的没右这个问题。
还有说是jdbc的三个包的问题,我也试了,把这三个包添入classpath中,但是也不行啊,还是这个问题。
我把我的java类传上来大家帮忙看看,我用的数据库是sqlserver2000
package   connDB;

import   java.sql.Connection;
import   java.sql.ResultSet;
import   java.sql.SQLException;
import   java.sql.Statement;
import   java.util.Date;
public   class   connectDB{
          private   java.sql.Connection     con   =   null;
          private   final   String   url   =   "jdbc:microsoft:sqlserver:// ";
          private   final   String   serverName=   "localhost ";
          private   final   String   portNumber   =   "1433 ";
          private   final   String   databaseName=   "ZYXW ";
          private   final   String   userName   =   "sa ";
          private   final   String   password   =   " ";
          //   Informs   the   driver   to   use   server   a   side-cursor,  
          //   which   permits   more   than   one   active   statement  
          //   on   a   connection.
          private   final   String   selectMethod   =   "cursor ";  
         
          //   Constructor
          public   connectDB(){}
         
          private   String   getConnectionUrl(){