Unlike ASP,
Java code is expected to be able to "run anywhere", which often means not supporting features that are unique to a given vendor's DBMS, such as auto-incrementing keys (I know it's a common feature, but it's not in the SQL standard). So from a purely portable perspective, there's nothing you could latch on to. For a particular vendor's DBMS, however, you may find an extra driver function or the like - check their
jdbc docs. Or, if you're using SQL Server, someone else's jdbc docs, since Microsoft doesn't provide a Java driver.
This problem gets even worse when working with Enterprise JavaBeans, where the key is expected to be known BEFORE the record is added - so much so, that I expect Sun will eventually have to provide a rathole for it.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.