往数据库插入记录时出问题,请各位帮忙看看这是什么错误!

时间:2021-04-16 21:43:54
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot cre
ate a row of size 8073 which is greater than the allowable maximum of 8060.
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(Unknown Source)

        at yuxun.sm.smSendContr.smSendInsert(smSendContr.java:37)
        at org.apache.jsp.reg.send_005fmelody_jsp._jspService(org.apache.jsp.reg
.send_005fmelody_jsp:97)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:322)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
91)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
        at java.lang.Thread.run(Unknown Source)

12 个解决方案

#1


根据报错,应该是你插入数据超过限制而引起的..
把yuxun.sm.smSendContr.smSendInsert(smSendContr.java:37) 附近的代码贴出来看看先!

#2


public int smSendInsert(smSendObj sso,Connection conn){
        String insertStr = "insert into Sm_Send (smstype,mmid,command,mmtype,feenumber) values(?,?,?,?,?)";
        PreparedStatement pstmt = null;
        int temp = 0;
        try{
            pstmt = conn.prepareStatement(insertStr);
            pstmt.setString(1,sso.getSmstype());
            pstmt.setString(2,sso.getMmid());
            pstmt.setString(3,sso.getCommand());
            pstmt.setString(4,sso.getMmtype());
            pstmt.setString(5,sso.getFeenumber());
            pstmt.setString(6,sso.getUsernumber());
            pstmt.setInt(7,Integer.parseInt(sso.getUid()));
            System.out.println("Smstype:"+sso.getSmstype()+";Mmid:"+sso.getMmid()+";Command:"+sso.getCommand()+";Mmtype:"+sso.getMmtype()+";Feenumber:"+sso.getFeenumber()+";Usernumber:"+sso.getUsernumber()+";Uid:"+sso.getUid());
            temp = pstmt.executeUpdate();
            System.out.println("555555555555555555");
            String sqlStr;
            if(sso.getMmtype().equals("pic")){
                sqlStr = "update picture set PDcounter=PDcounter+1 where PID=?";
            }
            else{
                sqlStr = "update melody set MDcounter=MDcounter+1 where MID=?";
            }
            if(temp > 0){
                pstmt = conn.prepareStatement(sqlStr);
                pstmt.setString(1,sso.getMmid());
                pstmt.executeUpdate();
            }   
        }
        catch(SQLException e){
            e.printStackTrace();
        }
        finally{
            DBConnection.releasePstmt(pstmt);
        }
        return temp;
    }

#3


上面是往数据库插入数据的方法的代码

#4


限象是一行中的最大字符个数是有限制的。有一个最大值8000。

#5


上面的方法贴错了,重新贴出来:
    public int smSendInsert(smSendObj sso,Connection conn){
        String insertStr = "insert into Sm_Send (smstype,mmid,command,mmtype,feenumber,usernumber,uid) values(?,?,?,?,?,?,?)";
        PreparedStatement pstmt = null;
        int temp = 0;
        try{
            pstmt = conn.prepareStatement(insertStr);
            pstmt.setString(1,sso.getSmstype());
            pstmt.setString(2,sso.getMmid());
            pstmt.setString(3,sso.getCommand());
            pstmt.setString(4,sso.getMmtype());
            pstmt.setString(5,sso.getFeenumber());
            pstmt.setString(6,sso.getUsernumber());
            pstmt.setInt(7,Integer.parseInt(sso.getUid()));
            temp = pstmt.executeUpdate();
            System.out.println("555555555555555555");
            String sqlStr;
            if(sso.getMmtype().equals("pic")){
                sqlStr = "update picture set PDcounter=PDcounter+1 where PID=?";
            }
            else{
                sqlStr = "update melody set MDcounter=MDcounter+1 where MID=?";
            }
            if(temp > 0){
                pstmt = conn.prepareStatement(sqlStr);
                pstmt.setString(1,sso.getMmid());
                pstmt.executeUpdate();
            }
        }
        catch(SQLException e){
            e.printStackTrace();
        }
        finally{
            DBConnection.releasePstmt(pstmt);
        }
        return temp;
    }

#6


String insertStr = "insert into Sm_Send (smstype,mmid,command,mmtype,feenumber) values(?,?,?,?,?)";
        PreparedStatement pstmt = null;
        int temp = 0;
        try{
            pstmt = conn.prepareStatement(insertStr);
            pstmt.setString(1,sso.getSmstype());
            pstmt.setString(2,sso.getMmid());
            pstmt.setString(3,sso.getCommand());
            pstmt.setString(4,sso.getMmtype());
            pstmt.setString(5,sso.getFeenumber());
            pstmt.setString(6,sso.getUsernumber());
            pstmt.setInt(7,Integer.parseInt(sso.getUid()));
你要传的参数 个数不一样...
自己好好检查一下....5个文号...可是你传了7个值

#7


快来人帮忙呀,自己顶一下

#8


我试过如果把与往数据库里插入记录的后三个字段的代码注释掉就可以正常运行,只要一把后面三个自动加入就会出问题。到底是什么问题啊,各位赶紧帮帮忙吧,多谢啦!

#9


第二次帖的东西,报错是报什么错啊?

#10


第二次贴的还是那个错误!!!!!!!急,急,急,急,急,急!!!!

#11


sql server字符串最大8000个字符,超出了就挂了

#12


根本没有超出8000个字符啊,郁闷死了

#1


根据报错,应该是你插入数据超过限制而引起的..
把yuxun.sm.smSendContr.smSendInsert(smSendContr.java:37) 附近的代码贴出来看看先!

#2


public int smSendInsert(smSendObj sso,Connection conn){
        String insertStr = "insert into Sm_Send (smstype,mmid,command,mmtype,feenumber) values(?,?,?,?,?)";
        PreparedStatement pstmt = null;
        int temp = 0;
        try{
            pstmt = conn.prepareStatement(insertStr);
            pstmt.setString(1,sso.getSmstype());
            pstmt.setString(2,sso.getMmid());
            pstmt.setString(3,sso.getCommand());
            pstmt.setString(4,sso.getMmtype());
            pstmt.setString(5,sso.getFeenumber());
            pstmt.setString(6,sso.getUsernumber());
            pstmt.setInt(7,Integer.parseInt(sso.getUid()));
            System.out.println("Smstype:"+sso.getSmstype()+";Mmid:"+sso.getMmid()+";Command:"+sso.getCommand()+";Mmtype:"+sso.getMmtype()+";Feenumber:"+sso.getFeenumber()+";Usernumber:"+sso.getUsernumber()+";Uid:"+sso.getUid());
            temp = pstmt.executeUpdate();
            System.out.println("555555555555555555");
            String sqlStr;
            if(sso.getMmtype().equals("pic")){
                sqlStr = "update picture set PDcounter=PDcounter+1 where PID=?";
            }
            else{
                sqlStr = "update melody set MDcounter=MDcounter+1 where MID=?";
            }
            if(temp > 0){
                pstmt = conn.prepareStatement(sqlStr);
                pstmt.setString(1,sso.getMmid());
                pstmt.executeUpdate();
            }   
        }
        catch(SQLException e){
            e.printStackTrace();
        }
        finally{
            DBConnection.releasePstmt(pstmt);
        }
        return temp;
    }

#3


上面是往数据库插入数据的方法的代码

#4


限象是一行中的最大字符个数是有限制的。有一个最大值8000。

#5


上面的方法贴错了,重新贴出来:
    public int smSendInsert(smSendObj sso,Connection conn){
        String insertStr = "insert into Sm_Send (smstype,mmid,command,mmtype,feenumber,usernumber,uid) values(?,?,?,?,?,?,?)";
        PreparedStatement pstmt = null;
        int temp = 0;
        try{
            pstmt = conn.prepareStatement(insertStr);
            pstmt.setString(1,sso.getSmstype());
            pstmt.setString(2,sso.getMmid());
            pstmt.setString(3,sso.getCommand());
            pstmt.setString(4,sso.getMmtype());
            pstmt.setString(5,sso.getFeenumber());
            pstmt.setString(6,sso.getUsernumber());
            pstmt.setInt(7,Integer.parseInt(sso.getUid()));
            temp = pstmt.executeUpdate();
            System.out.println("555555555555555555");
            String sqlStr;
            if(sso.getMmtype().equals("pic")){
                sqlStr = "update picture set PDcounter=PDcounter+1 where PID=?";
            }
            else{
                sqlStr = "update melody set MDcounter=MDcounter+1 where MID=?";
            }
            if(temp > 0){
                pstmt = conn.prepareStatement(sqlStr);
                pstmt.setString(1,sso.getMmid());
                pstmt.executeUpdate();
            }
        }
        catch(SQLException e){
            e.printStackTrace();
        }
        finally{
            DBConnection.releasePstmt(pstmt);
        }
        return temp;
    }

#6


String insertStr = "insert into Sm_Send (smstype,mmid,command,mmtype,feenumber) values(?,?,?,?,?)";
        PreparedStatement pstmt = null;
        int temp = 0;
        try{
            pstmt = conn.prepareStatement(insertStr);
            pstmt.setString(1,sso.getSmstype());
            pstmt.setString(2,sso.getMmid());
            pstmt.setString(3,sso.getCommand());
            pstmt.setString(4,sso.getMmtype());
            pstmt.setString(5,sso.getFeenumber());
            pstmt.setString(6,sso.getUsernumber());
            pstmt.setInt(7,Integer.parseInt(sso.getUid()));
你要传的参数 个数不一样...
自己好好检查一下....5个文号...可是你传了7个值

#7


快来人帮忙呀,自己顶一下

#8


我试过如果把与往数据库里插入记录的后三个字段的代码注释掉就可以正常运行,只要一把后面三个自动加入就会出问题。到底是什么问题啊,各位赶紧帮帮忙吧,多谢啦!

#9


第二次帖的东西,报错是报什么错啊?

#10


第二次贴的还是那个错误!!!!!!!急,急,急,急,急,急!!!!

#11


sql server字符串最大8000个字符,超出了就挂了

#12


根本没有超出8000个字符啊,郁闷死了