Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong data type returned for date in jtds.jar

I have a table on MS SQL Server with a column having data type as date. I am using jtds.jar for JDBC connection with DB. I am taking DatabaseMetaData from Connection. While checking columns from DatabaseMetaData, I observed that

int iType = rsMeta.getInt("DATA_TYPE");

returns Column type as java.sql.Types.VARCHAR which is a string and not date. but it also returns

String tmp = rsMeta.getString("TYPE_NAME");

type name as date.

But for Oracle, It returns the date datatype as java.sql.Types.DATE.

Why is such a difference?

like image 356
FlyingDutchman Avatar asked Jan 20 '12 06:01

FlyingDutchman


1 Answers

This is a known JTDS bug, see http://sourceforge.net/p/jtds/bugs/679/.

The returned datatype for a SQLServer Date type is returned as a varchar with a length of 10. This is wrong, it should return as Sql.Date. int iType = rsMeta.getInt("DATA_TYPE"); String tmp = rsMeta.getString("TYPE_NAME");

like image 184
flup Avatar answered Sep 29 '22 07:09

flup