7 messages in com.mysql.lists.javaRe: PreparedStatement and getGenerate...
FromSent OnAttachments
Pierre03 Dec 2003 02:04 
Christopher Taylor03 Dec 2003 02:11 
Pierre03 Dec 2003 02:18 
Pierre03 Dec 2003 03:01 
Mark Matthews03 Dec 2003 06:04 
Pierre03 Dec 2003 06:34 
Mark Matthews03 Dec 2003 06:51 
Subject:Re: PreparedStatement and getGeneratedKeys()
From:Pierre (pie@jovialyteam.com)
Date:12/03/2003 06:34:05 AM
List:com.mysql.lists.java

Mark Matthews a écrit :

Pierre said:

Well... I tried (not a lost, I mus confess) to deal with this, and I didn't see the way to do so. May someone help me ? What I need to do is to prepare a statement db_stmt=db_conn.prepareStatement("INSERT INTO foo SET (?,?)"); where foo is a table with one generated field. Then it would use the getGeneratedKeys() method from the super class (thus using executeUpdate() with the Statement.RETURN_GENERATED_KEYS parameter). Is there anyway to do so, without rewriting the prepareStatement class (which I prefer not ot do).

It's a little confusing, you actually need to go check your javadocs for the _connection_ interface to see how it all works :). There's a prepareStatement() method that takes the Statement.RETURN_GENERATED_KEYS flag, and then you just use the normal PreparedStatement.executeUpdate() method, followed by a Statement.getGeneratedKeys().

Regards,

-Mark

Thank you for your answer, but I have some probleme with javadoc... http://java.sun.com/j2ee/apidocs-1_5-fr/javax/resource/cci/Connection.html does not mention any statement... I guess I found the bad connection interface ? :-) So I tried to find some good JDBC Javadoc online, but I am unable to... Just some .pdf text about the specification, or some rowset specification... Is there any link for me to get some real API specification javadoc about JDBC 3 ?