Skip to content

java.lang.NullPointerException: Cannot read field "columnName" because the return value of "java.util.Map.get(Object)" is null #2606

@atul-delphix

Description

@atul-delphix

Driver version

12.6.4.jre11

SQL Server version

Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64)
Sep 24 2019 13:48:23
Copyright (C) 2019 Microsoft Corporation
Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)

Client Operating System

x86_64 GNU/Linux

JAVA/JVM version

openjdk version "17.0.14" 2025-01-21
OpenJDK Runtime Environment (build 17.0.14+7-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.14+7-Ubuntu-120.04, mixed mode, sharing)

Table schema

CREATE TABLE [dbo].[Test](
[NAME] varchar NOT NULL,
[AGE] [int] NULL,
[CAL_COL] [numeric](17, 2) NULL,
[ORIGINAL] varchar NOT NULL,
[COMPUTED_COL] AS (right([NAME],(8))) PERSISTED,
[LAST_COL] varchar NULL
) ON [PRIMARY]

Problem description

On BULK INSERT through CSV file, it got failed while validation.

java.lang.NullPointerException: Cannot read field "columnName" because the return value of "java.util.Map.get(Object)" is null
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.validateColumnMappings(SQLServerBulkCopy.java:1907)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:1668)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:630)

Expected behavior

NPE, should not be there, and insertion must be successful.

Actual behavior

It failed with below error:

java.lang.NullPointerException: Cannot read field "columnName" because the return value of "java.util.Map.get(Object)" is null
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.validateColumnMappings(SQLServerBulkCopy.java:1907)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:1668)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:630)

Error message/stack trace

java.lang.NullPointerException: Cannot read field "columnName" because the return value of "java.util.Map.get(Object)" is null
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.validateColumnMappings(SQLServerBulkCopy.java:1907)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:1668)
at com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:630)

Any other details that can be helpful

Add any other context about the problem here.

JDBC trace logs

Provide the JDBC driver trace logs. Instructions can be found here: https://docs.microsoft.com/sql/connect/jdbc/tracing-driver-operation

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Closed Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions