You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* Retrieves the designated column's SQL type.
...
* @return SQL type from java.sql.Types
...
*/
int getColumnType(int column) throws SQLException;
For columns of type charchar(max) I would then expect this to return -1 (java.sql.Types.LONGVARCHAR), but it returns 12 (java.sql.Types.VARCHAR). I debugged a little bit, and found that this is caused by this switch-case:
tormodatt
changed the title
[QUESTION] How differantiate max and non-max types in ResultSet
[QUESTION] How differentiate max and non-max types in ResultSet
Jan 7, 2021
I believe the longvarchar datatype no longer exists in "newer" versions of SQL Server, it's been replaced with varchar(max).
From the documentation: "The SQL Server text and ntext types map to the JDBC LONGVARCHAR and LONGNVARCHAR type, respectively. These are deprecated types beginning in SQL Server 2005 (9.x), so you should use large value types, varchar(max) or nvarchar(max), instead."
Question
From JDBC-spec:
For columns of type charchar(max) I would then expect this to return -1 (java.sql.Types.LONGVARCHAR), but it returns 12 (java.sql.Types.VARCHAR). I debugged a little bit, and found that this is caused by this switch-case:
https://github.com/microsoft/mssql-jdbc/blob/master/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java#L138
r = -1 before that switch-case (which is what I would want).
The comment here gives a pointer to why this is done:
https://github.com/microsoft/mssql-jdbc/blob/master/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java#L112
I guess DBMD is DatabaseMetaData, but still don't understand why this is done this way.
I can't find any other way to derminine whether a column in a resultset is varchar or longvarchar.
Same goes for the other max-types I guess.
I reason I ask this question is that I'm trying to do .getClob when the coloumn is varchar(max), and .getString if it's a normal varchar.
Relevant Issues and Pull Requests
I couldn't find any issues related to this.
The text was updated successfully, but these errors were encountered: