Snowflake JDBC 无法检索第一个箭头块的行数:sun.misc.Unsafe 或 java.nio.DirectByteBuffer.<init>(long, int) 不可用
Snowflake JDBC Fail to retrieve row count for first arrow chunk: sun.misc.Unsafe or java.nio.DirectByteBuffer.<init>(long, int) not available
虽然我的问题听起来与这个问题相同Snowflake JDBC driver internal error: Fail to retrieve row count for first arrow chunk: null -- only occurs on SELECT statements,但实际上并非如此。
我可以从 java:
连接到 Snowflake 数据仓库
public static Connection getConnection()
throws SQLException
{
String user = Optional.ofNullable(System.getenv("USER"))
.or(() -> Optional.ofNullable(System.getenv("USERNAME")))
.orElseThrow();
try
{
Class.forName("net.snowflake.client.jdbc.SnowflakeDriver");
}
catch (ClassNotFoundException ex)
{
System.err.println("Driver not found");
}
// build connection properties
Properties properties = new Properties();
properties.put("authenticator", "xxx");
properties.put("user", user);
String connStr = Optional.ofNullable(System.getenv("SF_JDBC_CONNECT_STRING")).orElse("jdbc:snowflake://xxx.xxx.com");
return DriverManager.getConnection(connStr, properties);
}
但是当我尝试 运行 来自下面代码的一个非常简单的 select 语句时:
try {
Connection conn = Helper.getConnection();
Statement sqlStm = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
ResultSet sqlOutput = sqlStm.executeQuery("select getdate();");
while (sqlOutput.next()) {
System.out.println(sqlOutput.getInt(1));
}
}
catch (SQLException e){
e.printStackTrace();
}
我遇到以下错误:
net.snowflake.client.jdbc.SnowflakeSQLLoggedException: JDBC driver internal error: Fail to retrieve row count for first arrow chunk: sun.misc.Unsafe or java.nio.DirectByteBuffer.<init>(long, int) not available.
at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.setFirstChunkRowCountForArrow(SnowflakeResultSetSerializableV1.java:1066)
at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:550)
at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:467)
at net.snowflake.client.core.SFResultSetFactory.getResultSet(SFResultSetFactory.java:29)
at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:220)
at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:135)
at net.snowflake.client.core.SFStatement.execute(SFStatement.java:781)
at net.snowflake.client.core.SFStatement.execute(SFStatement.java:677)
at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:238)
at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQuery(SnowflakeStatementV1.java:133)
at com.marqeta.Main.main(Main.java:42)
我在 github 上发现人们在这个线程上有同样的问题:https://github.com/snowflakedb/snowflake-jdbc/issues/484。我已经按照下面设置了 VM 选项,但仍然有同样的错误,我是否错误地设置了 VM 选项或者可能是什么问题。
我添加了 --add-opens java.base/java.nio=ALL-UNNAMED
作为测试的 VM 参数,它们正在通过。
请参阅 this comment. Also, there is a good explanation 了解发生这种情况的原因。传递 VM 参数应该被视为一个临时解决方案。
虽然我的问题听起来与这个问题相同Snowflake JDBC driver internal error: Fail to retrieve row count for first arrow chunk: null -- only occurs on SELECT statements,但实际上并非如此。
我可以从 java:
连接到 Snowflake 数据仓库public static Connection getConnection()
throws SQLException
{
String user = Optional.ofNullable(System.getenv("USER"))
.or(() -> Optional.ofNullable(System.getenv("USERNAME")))
.orElseThrow();
try
{
Class.forName("net.snowflake.client.jdbc.SnowflakeDriver");
}
catch (ClassNotFoundException ex)
{
System.err.println("Driver not found");
}
// build connection properties
Properties properties = new Properties();
properties.put("authenticator", "xxx");
properties.put("user", user);
String connStr = Optional.ofNullable(System.getenv("SF_JDBC_CONNECT_STRING")).orElse("jdbc:snowflake://xxx.xxx.com");
return DriverManager.getConnection(connStr, properties);
}
但是当我尝试 运行 来自下面代码的一个非常简单的 select 语句时:
try {
Connection conn = Helper.getConnection();
Statement sqlStm = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
ResultSet sqlOutput = sqlStm.executeQuery("select getdate();");
while (sqlOutput.next()) {
System.out.println(sqlOutput.getInt(1));
}
}
catch (SQLException e){
e.printStackTrace();
}
我遇到以下错误:
net.snowflake.client.jdbc.SnowflakeSQLLoggedException: JDBC driver internal error: Fail to retrieve row count for first arrow chunk: sun.misc.Unsafe or java.nio.DirectByteBuffer.<init>(long, int) not available.
at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.setFirstChunkRowCountForArrow(SnowflakeResultSetSerializableV1.java:1066)
at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:550)
at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:467)
at net.snowflake.client.core.SFResultSetFactory.getResultSet(SFResultSetFactory.java:29)
at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:220)
at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:135)
at net.snowflake.client.core.SFStatement.execute(SFStatement.java:781)
at net.snowflake.client.core.SFStatement.execute(SFStatement.java:677)
at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:238)
at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQuery(SnowflakeStatementV1.java:133)
at com.marqeta.Main.main(Main.java:42)
我在 github 上发现人们在这个线程上有同样的问题:https://github.com/snowflakedb/snowflake-jdbc/issues/484。我已经按照下面设置了 VM 选项,但仍然有同样的错误,我是否错误地设置了 VM 选项或者可能是什么问题。
我添加了 --add-opens java.base/java.nio=ALL-UNNAMED
作为测试的 VM 参数,它们正在通过。
请参阅 this comment. Also, there is a good explanation 了解发生这种情况的原因。传递 VM 参数应该被视为一个临时解决方案。