db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: behavior of Statement.getGeneratedKeys()
Date Mon, 10 Jul 2006 23:27:04 GMT
Daniel John Debrunner wrote:

>Rick Hillegas wrote:
>
>  
>
>>Kathey Marsden wrote:
>>
>>    
>>
>>>Rick Hillegas wrote:
>>>
>>>      
>>>
>>>>Before filing a bug on this, I'd like the community's advice:
>>>>
>>>>1) Is this a bug? Should Statement.getGeneratedKeys() return a
>>>>ResultSet whose column has the same type as the underyling
>>>>autogenerated column?
>>>>
>>>>2) If this is a bug, is it permitted to change this behavior in a
>>>>minor release?
>>>>
>>>>        
>>>>
>>>I can't say if it is a bug or not, but with regard to 2, I wonder:
>>>What  usage cases would benefit from changing it?
>>>      
>>>
>>This would help customers who want to get the type of a table's
>>generated key from getGeneratedKeys() itself and not have to extract
>>this information from a more complicated series of metadata calls.
>>    
>>
>
>I'm lost here, what's complicated about DatabaseMetaData.getColumns()?
>  
>
You're right. It's not that complicated. If the driver returns the JDBC4 
contents of DatabaseMetaData.getColumns(), you can loop through the 
results until you get to the row whose IS_AUTOINCREMENT column is set to 
YES. If the driver returns JDBC3 results, it looks a little busier to me:

o Prepare a SELECT on the base table.
o Get the corresponding ResultSetMetaData
o Loop till you find the column index with 
ResultSetMetaData.isAutoIncrement() == true

But JDBC is big so there could be a simpler scheme.

>Dan.
>
>
>
>  
>


Mime
View raw message