db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Yuill" <pyu...@objectix.com.au>
Subject Re: Get auto increment value
Date Tue, 12 Feb 2008 21:52:28 GMT
The standard way to do it is to use the alternate execute eg
statement.executeUpdate("some query", true);
and then
statement.getGeneratedKeys()

Cheers,
Peter
----- Original message -----
From: "larsk" <larsk8@yahoo.se>
To: derby-user@db.apache.org
Date: Tue, 12 Feb 2008 13:41:47 -0800 (PST)
Subject: Get auto increment value


I am making a java-application that uses an apache derby database. One
of the
fields in one of the tables has auto increment applied (GENERATED BY
DEFAULT
AS IDENTITY). Is it possible to get the value that this field is going
to
get or what value it got when making an insert? Or do I have to make a
select to the database to know this?
I use the following code to insert data to the database:

--------------------

Connection con = DriverManager.getConnection(connectionString);

Statement state = con.createStatement();

try
{
	state.executeUpdate(queryString);
}

catch (Exception ex)
{
	throw(ex);
}

con.close();

--------------------

If anyone has any idea on how to make this know I would appreciate any
help.
-- 
View this message in context:
http://www.nabble.com/Get-auto-increment-value-tp15443701p15443701.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message