在 jre-1.8_66 上运行时,我们在 JTDS 中遇到了奇怪的 ArrayIndexOutOfBoundsException,并且在网络上找不到任何其他提及此问题的信息。
当使用服务器 jvmdll 运行 32 位版本的 jre-1.8_66 时,我已经能够使用 jtds 1.2.5 和 1.2.8 复制此错误。当使用 64 位 JRE 或 32 位客户端 jvm.dll 时,我无法复制该错误。
在 Eclipse 中运行或尝试从 Eclipse 远程调试时,我也根本无法复制该错误,因此无法缩小问题的具体原因。
完整的堆栈跟踪如下。
java.lang.ArrayIndexOutOfBoundsException: 14
at net.sourceforge.jtds.jdbc.TdsData.readData(TdsData.java:800)
at net.sourceforge.jtds.jdbc.TdsCore.tdsRowToken(TdsCore.java:3081)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2346)
at net.sourceforge.jtds.jdbc.TdsCore.getNextRow(TdsCore.java:777)
at net.sourceforge.jtds.jdbc.JtdsResultSet.next(JtdsResultSet.java:596)
at test.jtdstest.JtdsText.main(JtdsText.java:51)
我有异常发生处的 jtds 代码,我看不出它有什么问题,但我很容易出错。
我编写的用于复制错误的测试程序如下。
package test.jtdstest;
import java.io.File;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
public class JtdsText
{
private static PrintWriter pw;
static
{
try
{
pw = new PrintWriter(new File("c:\\temp\\jtds_trace.txt"));
DriverManager.setLogWriter(pw);
Class.forName("net.sourceforge.jtds.jdbc.Driver");
}
catch (Exception localException)
{
}
}
public static void main(String[] args)
throws Exception
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet res = null;
try
{
String sql =
"SELECT "
+ "text1, "
+ "int1, "
+ "int2, "
+ "text2 "
+ "FROM "
+ "text_test";
conn = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/test;user=user1;password=aa");
stmt = conn.prepareStatement(sql);
res = stmt.executeQuery();
while (res.next())
{
int int1 = res.getInt(2);
System.out.println("int1 = " + Integer.toString(int1));
}
}
catch (Exception ex)
{
System.out.println("Error processing result set:");
ex.printStackTrace();
System.out.println();
}
finally
{
try
{
if(res != null)
{
res.close();
}
if(stmt != null)
{
stmt.close();
}
if(conn != null)
{
conn.close();
}
}
catch (Exception ex)
{
System.out.println("Error cleaning up Statement:");
ex.printStackTrace();
System.out.println();
}
}
}
}
如果需要,我也可以提供用于复制错误的数据。
我强烈怀疑这是 JRE 中的错误,因为这是唯一可以更改以复制该错误的变量。
有人遇到过这种情况吗?除了更改JVM之外还有其他方法可以解决该错误吗?我应该向 JVM 报告此错误吗?
最佳答案
事实证明这是 JIT 编译器中的一个错误。使用 -Xint 选项关闭 JIT 编译器可以解决该问题。我们正在向 Oracle 记录此问题以解决问题。
关于java - Jre 1.8.66 上的 jtds ArrayIndexOutOfBoundsException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36598783/