Driver version or jar name
mssql-jdbc-6.5.0.jre8.jar (preview)
SQL Server version
SQL Server 2012 and SQL Server 2014
Client operating system
Win 10 x64
Java/JVM version
java version "1.8.0_144"
Table schema
CREATE TABLE [jpoetest] ([_creation_instance] varchar(200), [GEOM] geometry)
Problem description
Working with SQL Server 2012 and 2014, when trying to insert to a geometry column, parameter type for geometry columns are returned as -157. (geography columns are -158)
Connection connection = getConnection();
PreparedStatement statement = connection.prepareStatement("INSERT INTO [jpoetest] ([_creation_instance], [GEOM]) VALUES (?, ?)");
ParameterMetaData paramMetaData = statement.getParameterMetaData();
int sqlType = paramMetaData.getParameterType(2);
When talking to SQL Server 2008, paramMetaData.getParameterType() would return java.sql.Types.VARBINARY
I haven't tried SQL Server 2016 and 2017.
I've searched for which sql.Types would -157 map to, but it doesn't seem to be a valid sql.Types value.
Interestingly, SQL Server 2008, 2012, and 2014 all return paramMetaData.getParameterTypeName() correctly. ie. "geometry" or "geography"
Expected behavior and actual behavior
expected: Geometry and Geography parameters should be reported as sql.Types.VARBINARY, consistent with ResultSetMetadata.getColumnType() for these columns.
actual: Geometry parameters are being returned as type -157, and Geography as type -158
Repro code
Connection connection = getConnection();
PreparedStatement statement = connection.prepareStatement("INSERT INTO [jpoetest] ([_creation_instance], [GEOM]) VALUES (?, ?)");
ParameterMetaData paramMetaData = statement.getParameterMetaData();
int sqlType = paramMetaData.getParameterType(2);
Driver version or jar name
mssql-jdbc-6.5.0.jre8.jar (preview)
SQL Server version
SQL Server 2012 and SQL Server 2014
Client operating system
Win 10 x64
Java/JVM version
java version "1.8.0_144"
Table schema
CREATE TABLE [jpoetest] ([_creation_instance] varchar(200), [GEOM] geometry)
Problem description
Working with SQL Server 2012 and 2014, when trying to insert to a geometry column, parameter type for geometry columns are returned as
-157. (geography columns are-158)When talking to SQL Server 2008,
paramMetaData.getParameterType()would returnjava.sql.Types.VARBINARYI haven't tried SQL Server 2016 and 2017.
I've searched for which
sql.Typeswould-157map to, but it doesn't seem to be a validsql.Typesvalue.Interestingly, SQL Server 2008, 2012, and 2014 all return
paramMetaData.getParameterTypeName()correctly. ie. "geometry" or "geography"Expected behavior and actual behavior
expected: Geometry and Geography parameters should be reported as
sql.Types.VARBINARY, consistent withResultSetMetadata.getColumnType()for these columns.actual: Geometry parameters are being returned as type
-157, and Geography as type-158Repro code