当我使用 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);
}
}
我省略了插入和连接,但两者都有效,因为我得到了第一次选择的结果(只有插入失败),并且插入也是正确的,因为它使用 isql 或 dbartisan 工作。