I am using SQL Server. My table has a column with the data type datetime2
.
I am accessing the table data using ResultSet
. I need to get the data type of a column. The method rs.getColumnTypeName()
returns nvarchar
for database data type datetime2
.
Is there any way to get datetime2
or Timestamp
for the same?
If you are doing it in Java, there is a class ResultSetMetaData
.
You can use ResultSetMetaData.getColumnClassName()
to get the fully qualified name of the class.
For example, if the datatype in database is VARCHAR
, the value returned is java.lang.String
.
Also try using ResultSetMetaData.getColumnLabel()
- see whether its applicable in your case.
Java Documentation for ResultSetMetaData
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With