Jdbc Google BigQuery,为准备语句中的null值引发异常

Jdbc Google BigQuery,为准备语句中的null值引发异常,jdbc,google-bigquery,prepared-statement,Jdbc,Google Bigquery,Prepared Statement,我们正在尝试使用Jdbc(Simba驱动程序)将数据加载到GoogleBigQuery。当试图在准备好的语句中插入空值时,我们得到了一个异常。当它不是一个预先准备好的语句时,这是有效的。例如,代码(隐藏连接Url): 生成以下输出: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementat

我们正在尝试使用Jdbc(Simba驱动程序)将数据加载到GoogleBigQuery。当试图在准备好的语句中插入空值时,我们得到了一个异常。当它不是一个预先准备好的语句时,这是有效的。例如,代码(隐藏连接Url):

生成以下输出:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Create table.

Table created.

Executing statement...

 done.

Executing prepared statement...

java.sql.SQLException: [Simba][BigQueryJDBCDriver](100032) Error executing query job. Message: Unparseable query parameter `` in type `TYPE_INT64`, Bad int64 value: null value: 'null'
        at com.simba.googlebigquery.googlebigquery.client.BQClient.insertJob(Unknown Source)
        at com.simba.googlebigquery.googlebigquery.client.BQClient.executeQuery(Unknown Source)
        at com.simba.googlebigquery.googlebigquery.dataengine.BQAbstractExecutor.execute(Unknown Source)
        at com.simba.googlebigquery.googlebigquery.dataengine.BQSQLExecutor.execute(Unknown Source)
        at com.simba.googlebigquery.jdbc.common.SPreparedStatement.executeWithParams(Unknown Source)
        at com.simba.googlebigquery.jdbc.common.SPreparedStatement.executeAnyUpdate(Unknown Source)
        at com.simba.googlebigquery.jdbc.common.SPreparedStatement.executeUpdate(Unknown Source)
        at Program.doPreparedStatement(Program.java:35)
Caused by: com.simba.googlebigquery.support.exceptions.GeneralException: [Simba][BigQueryJDBCDriver](100032) Error executing query job. Message: Unparseable query parameter `` in type `TYPE_INT64`, Bad int64 value: null value: 'null'
        ... 8 more

我发现在为(例如)数字类型添加BigQuery支持时,这一点很有效:

statement.setBigDecimal(6,null);
BigDecimal
类型是唯一一种非原语的数字JDBC类型。对于其他数据类型,如果支持,则使用其各自的setter;如果Simba仍然不喜欢各自类型的
null
值,则使用其各自的setter,例如:

  • Boolean
  • 日期
  • 时间
如果对任何转换问题有疑问(例如,因为Simba似乎将
BigDecimal
绑定为
STRING
,目前至少在版本1.2.13.1016中),请确保强制转换绑定变量,例如:

CAST(?AS INT64)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Create table.

Table created.

Executing statement...

 done.

Executing prepared statement...

java.sql.SQLException: [Simba][BigQueryJDBCDriver](100032) Error executing query job. Message: Unparseable query parameter `` in type `TYPE_INT64`, Bad int64 value: null value: 'null'
        at com.simba.googlebigquery.googlebigquery.client.BQClient.insertJob(Unknown Source)
        at com.simba.googlebigquery.googlebigquery.client.BQClient.executeQuery(Unknown Source)
        at com.simba.googlebigquery.googlebigquery.dataengine.BQAbstractExecutor.execute(Unknown Source)
        at com.simba.googlebigquery.googlebigquery.dataengine.BQSQLExecutor.execute(Unknown Source)
        at com.simba.googlebigquery.jdbc.common.SPreparedStatement.executeWithParams(Unknown Source)
        at com.simba.googlebigquery.jdbc.common.SPreparedStatement.executeAnyUpdate(Unknown Source)
        at com.simba.googlebigquery.jdbc.common.SPreparedStatement.executeUpdate(Unknown Source)
        at Program.doPreparedStatement(Program.java:35)
Caused by: com.simba.googlebigquery.support.exceptions.GeneralException: [Simba][BigQueryJDBCDriver](100032) Error executing query job. Message: Unparseable query parameter `` in type `TYPE_INT64`, Bad int64 value: null value: 'null'
        ... 8 more