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

Geometry and Geography typenames are not supported #533

Closed
jeffersonatsafe opened this issue Oct 24, 2017 · 3 comments
Closed

Geometry and Geography typenames are not supported #533

jeffersonatsafe opened this issue Oct 24, 2017 · 3 comments
Assignees
Projects

Comments

@jeffersonatsafe
Copy link

@jeffersonatsafe jeffersonatsafe commented Oct 24, 2017

Driver version or jar name

mssql-jdbc-66.2.2.jre8

SQL Server version

tested with SQL Server 2014

Client operating system

Windows 10 x64

Java/JVM version

java version "1.8.0_144"

Table schema

CREATE TABLE [dbo].[my_table]([GEOM] [geography] NULL)

Problem description

SQLServerPreparedStatement.getParameterMetaData() will fail if SQLServerPreparedStatement was prepared using a query that contains geometry or geography column types.
Seems that the source of the issue is, our resultSet from "exec sp_describe_uneclared_parameters ?") returns a typename of "geometry" or "geography".
DataTypes.SSType does not have these value, and therefore an exception is thrown.

Expected behavior and actual behavior

expected -- the method returns a SQLServerParameterMetadata successfully (for reference, the JDBCType for geography was VARBINARY in sqljdbc41.jar)
actual -- the following exception was thrown:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: A metadata error for the parameter {0} occurred.
at com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.parseQueryMeta(SQLServerParameterMetaData.java:289)
at com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.(SQLServerParameterMetaData.java:573)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getParameterMetaData(SQLServerPreparedStatement.java:2799)
at COM.safe.fme.JdbcBackendHelper.bindValues(JdbcBackendHelper.java:1204)
... 3 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid SQL Server data type geography.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:227)
at com.microsoft.sqlserver.jdbc.SSType.of(DataTypes.java:185)
at com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.parseQueryMeta(SQLServerParameterMetaData.java:242)
... 6 more

Repro code

for example, using the above table schema, create a prepared statement with a query of INSERT INTO [my_table] ([GEOM]) VALUES (?)

sqlServerConnection = getSQLServerConnection(); // set up SQLServerConnection
PreparedStatement statement = sqlServerConnection.prepareStatement("INSERT INTO [my_table] ([GEOM]) VALUES (?)");
statement.setQueryTimeout(5000);
ParameterMetaData metaData = statement.getParameterMetaData(); // ---> this throws an exception
@peterbae

This comment has been minimized.

Copy link
Member

@peterbae peterbae commented Oct 24, 2017

Hi @jpoernomoatsafe, thanks for creating this issue. We are currently working on adding support for Geometry/Geography datatypes, and will let you know once they are under review / merged into preview.

@peterbae peterbae self-assigned this Oct 24, 2017
@peterbae

This comment has been minimized.

Copy link
Member

@peterbae peterbae commented Nov 21, 2017

Hi @jpoernomoatsafe, I've merged in the initial implementation for supporting Geometry/Geography datatypes into Spatial_Datatypes branch. This branch will not be merged into preview for now - but please feel free to use/test it.

@cheenamalhotra cheenamalhotra added this to In progress in MSSQL JDBC Feb 9, 2018
@peterbae

This comment has been minimized.

Copy link
Member

@peterbae peterbae commented Mar 23, 2018

Geometry/Geography types are supported starting from preview release v6.5.0. Closing this issue.

@peterbae peterbae closed this Mar 23, 2018
MSSQL JDBC automation moved this from In progress to Closed Issues Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
MSSQL JDBC
  
Closed Issues
2 participants
You can’t perform that action at this time.