Hello everyone, I know that the db-driver (mySQLjdbc.jar e.g.) implements the connection interface. I would like to add new functions to a connection, such as retrieving unique keys. How do I do that? Thanks in advance, Rolf Mueller
Post by:Nathaniel Stoddard
, Ranch Hand
I'm not sure this sort of thing is possible. The connections are returned from the drivers provided by the database vendor. So, even though you can implement your own connection or somehow extend the connection returned by your driver's implementation, there's no way to force your driver to use the newly improved connection. You would basically have to hack all the little pieces of your driver to do the whole thing (using the connection and everything else). Of course, at that point, you wouldn't be using a JDBC-compliant driver, which would bring more misery to your life. On a plus side, JDBC3 lets you retrieve generated primary keys. In earlier versions (I'm assuming you're using mySQL), the mySql driver let you cast something so you could retrieve the generated primary key for inserts. My point: make sure you thoroughly research what you need and other ways to get what you want. Just because you can develop yourself some solution doesn't mean there aren't other, much-easier ways of doing the same thing.
Post by:Rolf Mueller
Sorry for posting this without having a morning cafe Now I found an easy solution, which seems to work. Looks like that:
I use this class in my connection-pool, and can use the added functionality in my persistence-controler. [ March 22, 2004: Message edited by: Rolf Mueller ]
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad: