| Bug #12141 | JDBC and Default-Values | ||
|---|---|---|---|
| Submitted: | 24 Jul 2005 18:16 | Modified: | 24 Jul 2005 20:12 |
| Reporter: | Tom Schindl | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S4 (Feature request) |
| Version: | 3.1.10 | OS: | |
| Assigned to: | CPU Architecture: | Any | |
[24 Jul 2005 20:12]
Mark Matthews
What you ask for is _not_ JDBC-compliant, see http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getColumns(java.lan...) Quoting... " COLUMN_DEF String => default value (may be null) " If the JDBC specification itself says that a column is of type "String", a driver can only return java.lang.String for ResultSet.getObject().
[24 Jul 2005 20:17]
Tom Schindl
What can one then do to get the "real" default-value like when calling moveToInsertRow()?

Description: It would be nice if the JDBC-Driver could return the appropiate Data-Types for default values retrieved. At the moment when calling getObject() one always gets a java.lang.String as return value. This should be able because when using ResultSet.moveToInsertRow() and then calling getObject() returns the appropriate data-type. How to repeat: DatabaseMetaData meta = getConnection().getMetaData(); ResultSet set= meta.getColumns(null,"%","testTable","%"); HashMap<String,Object> map = new HashMap<String,Object>(); while( set.next() ) { map.put( set.getString("COLUMN_NAME"), set.getObject("COLUMN_DEF") ); if( set.getObject("COLUMN_DEF") != null ) { System.out.println( set.getObject("COLUMN_DEF").getClass() ); } }