Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in Bulk Copy #2469

Closed
typhoon2k opened this issue Jul 5, 2024 · 1 comment
Closed

NullPointerException in Bulk Copy #2469

typhoon2k opened this issue Jul 5, 2024 · 1 comment

Comments

@typhoon2k
Copy link

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 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

@typhoon2k
Copy link
Author

It seems this is duplicate of #2442.

@typhoon2k typhoon2k closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant