You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bulk Copy is performed using prepared statement and useBulkCopyForBatchInsert=true in connection string.
Getting null pointer exception, if destination table has SQLVariant column.
It seems that SQLServerBulkCopy.writeSqlVariant expects sourceResultSet to be set, but when void writeToServer(ISQLServerBulkData sourceData) is called this variable is explicitly set to null.
I guess it never worked with SQLVariant columns in target table.
Expected behavior
Bulk copy operation should be successful.
Actual behavior
NullPointerException is thrown.
Error message/stack trace
java.lang.NullPointerException: null
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeSqlVariant(SQLServerBulkCopy.java:2632)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeColumnToTdsWriter(SQLServerBulkCopy.java:2598)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeColumn(SQLServerBulkCopy.java:3112)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeBatchData(SQLServerBulkCopy.java:3682)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.doInsertBulk(SQLServerBulkCopy.java:1582)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy$1InsertBulk.doExecute(SQLServerBulkCopy.java:673)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7748)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4410)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.sendBulkLoadBCP(SQLServerBulkCopy.java:707)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:1670)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:630)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:2361)
Any other details that can be helpful
I guess it should rely on column meta data stored in passed ISQLServerBulkData in this scenario.
JDBC trace logs
N/A
The text was updated successfully, but these errors were encountered:
Driver version
12.6.3/12.7.0
SQL Server version
SQL Server 2019
Client Operating System
Any
JAVA/JVM version
11.0.23
Table schema
Any table schema with SQLVariant column.
Problem description
Bulk Copy is performed using prepared statement and
useBulkCopyForBatchInsert=true
in connection string.Getting null pointer exception, if destination table has SQLVariant column.
It seems that
SQLServerBulkCopy.writeSqlVariant
expectssourceResultSet
to be set, but whenvoid writeToServer(ISQLServerBulkData sourceData)
is called this variable is explicitly set tonull
.I guess it never worked with SQLVariant columns in target table.
Expected behavior
Bulk copy operation should be successful.
Actual behavior
NullPointerException is thrown.
Error message/stack trace
Any other details that can be helpful
I guess it should rely on column meta data stored in passed
ISQLServerBulkData
in this scenario.JDBC trace logs
N/A
The text was updated successfully, but these errors were encountered: