Skip to content

MSSQL Geometry/Geography types with JDBC fails with class [B? #1701

Open
@sproket

Description

@sproket

Driver version

9.4.0.jre16

SQL Server version

Microsoft SQL Server 2019 (RTM-GDR) (KB4583458) - 15.0.2080.9 (X64) Nov 6 2020 16:50:01 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit)

Client Operating System

Windows 10 Pro 10.0 (Build 19041: )

JAVA/JVM version

openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-39)
OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)

Table schema

Cities table from WideWorldImporters sample database

Problem description

See:
https://stackoverflow.com/questions/70213493/mssql-geometry-geography-types-with-jdbc-fails-with-class-b

  1. Expected behaviour:

I expect resultSet.getObject and statement.setObject to work with geometry types.

  1. Actual behaviour:

class [B cannot be cast to class com.microsoft.sqlserver.jdbc.Geometry ([B is in module java.base of loader 'bootstrap'; com.microsoft.sqlserver.jdbc.Geometry is in unnamed module of loader 'app')

  1. Error message/stack trace:

see 2.

  1. Any other details that can be helpful:

I used the sample from here:

https://docs.microsoft.com/en-us/sql/connect/jdbc/spatial-data-types-sample?view=sql-server-ver15

And modified it slightly to use Statement and ResultSet instead of SQLServerPreparedStatement and SQLServerResultSet
and used setObject and getObject instead of setGeometry and getGeometry.

JDBC trace logs

N/A

Reproduction code

See the sample link

Metadata

Metadata

Assignees

No one assigned

    Labels

    BacklogThe topic in question has been recognized and added to development backlogEnhancementAn enhancement to the driver. Lower priority than bugs.

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions