使用jconnect插入远程表时出错

时间:2013-03-22 16:45:09

标签: java jdbc sybase jconnect

当我使用jconnect在远程tabke中插入时,它给出了以下错误:

Unexpected exception : java.sql.SQLException: This transaction has been rolled back, rather than only the current statement.
, sqlstate = ZZZZZjava.sql.SQLException: This transaction has been rolled back, rather than only the current statement.

    at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(SybConnection.java:2780)
    at com.sybase.jdbc4.jdbc.SybStatement.handleSQLE(SybStatement.java:2665)
    at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:295)
    at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:272)
    at com.sybase.jdbc4.jdbc.SybStatement.updateLoop(SybStatement.java:2515)
    at com.sybase.jdbc4.jdbc.SybStatement.executeUpdate(SybStatement.java:2499)
    at com.sybase.jdbc4.jdbc.SybStatement.executeUpdate(SybStatement.java:577)
    at connectSybase.main(connectSybase.java:48)

你知道它可能是什么吗?

这是我的完整代码:

import java.io.*;
import java.sql.*;

public class connectSybase {

    public static void main(String args[])
    {
        try
        {
            // jconn3 <-- do pessoal do OMS
            //Class.forName("com.sybase.jdbc3.jdbc.SybDriver");

            // jconn4 <-- do servidor de OMS1_PAR_DEV_SQL
            Class.forName("com.sybase.jdbc4.jdbc.SybDriver");

        }
        catch (ClassNotFoundException cnfe)
        {
            System.out.println("BUM!");
        }
        try
        {
            System.out.println("Any of the following may throw an SQLException.");

            System.out.println("Opening a connection.");

            Connection con = java.sql.DriverManager.getConnection
                    ("----------------------------");
            // more code to use connection ...


            System.out.println("Creating a statement object.");

            Statement stmt = con.createStatement();

            System.out.println("Executing the query.");

            ResultSet rs = stmt.executeQuery("Select top 10 * from OMS_DEV..SCRIBE_AR");

            System.out.println("Process the result set.");

            while (rs.next())
            {
                System.out.println("Fetched value " + rs.getString(1));
            }

            System.out.println("Executing the query.");
            int result = stmt.executeUpdate("---------------");


            System.out.println("Process the result set: " + result );

        }

        catch (SQLException sqe)
        {
            sqe.printStackTrace();


            System.out.println("Unexpected exception : " +
                    sqe.toString() + ", sqlstate = " +
                    sqe.getSQLState());
            System.exit(1);
        }
        System.exit(0);
    }
}

我省略了插入和连接,但两者都有效,因为我得到第一个select的结果(只有插入失败),插入也正确,因为它使用isql或dbartisan。

1 个答案:

答案 0 :(得分:0)

Sybase错误消息不是特定的,但问题与数据包大小有关。 在ASE中它是8192,在IQ中只有2048。

当数据包超过2k时产生错误。