Skip to content

Driver not handling properly result set with VARCHAR or CHAR types #439

@rodionstl

Description

@rodionstl

Driver version or jar name

6.3.0.jre8-preview

SQL Server version

Microsoft SQL Server vNext (CTP2.0) - 14.0.500.272 (X64)

Client operating system

Ubuntu 16.04.2 LTS

Java/JVM version

openjdk version "1.8.0_131"

Problem description

ResultSet.next() method fails with "java.lang.IllegalArgumentException: Invalid SQL Server data type 0" if the previous row contains either VARCHAR or CHAR types.

It starts working if you comment out the following line
https://github.com/Microsoft/mssql-jdbc/blob/ca55cc340969fbf6f1787c69a0cd52d9856a74c4/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java#L4208-L4208

Repro code

Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE sql_var_tab(val sql_variant)");
PreparedStatement prepStmt = conn.prepareStatement("INSERT INTO sql_var_tab VALUES (?)");
prepStmt.setObject(1, "abc", Types.VARCHAR);
prepStmt.execute();
prepStmt.setObject(1, 42, Types.INTEGER);
prepStmt.execute();
ResultSet resultSet = stmt.executeQuery("SELECT * FROM sql_var_tab ORDER BY val");
while (resultSet.next()) {
    resultSet.getObject(1);
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions