Linked Questions

102 votes
2 answers
185k views

Possible Duplicate: How to get the insert ID in JDBC? Hi, I'm using JDBC to connect on database through out Java. Now, I do some insert query, and I need to get the id of last inserted value (so,...
markzzz's user avatar
  • 48.3k
62 votes
14 answers
116k views

Is there some way to get a value from the last inserted row? I am inserting a row where the PK will automatically increase, and I would like to get this PK. Only the PK is guaranteed to be unique in ...
eflles's user avatar
  • 6,896
39 votes
3 answers
59k views

This answer to this question done this way seems to be very difficult to find on the internet. Basically I am inserting values into a MySQL database using PreparedStatement. I use the ...
Devin Dixon's user avatar
  • 12.5k
13 votes
2 answers
18k views

My current method is this: SELECT TOP 1 ID FROM DATAENTRY ORDER BY ID DESC This assumes the latest inserted item always has the highest unique ID (primary key, autoincrementing). Something smells ...
Daddy Warbox's user avatar
  • 4,618
9 votes
8 answers
11k views

Is there any way of insert a row in a table and get the new generated ID, in only one statement? I want to use JDBC, and the ID will be generated by a sequence or will be an autoincrement field. ...
user avatar
5 votes
1 answer
8k views

I have a primary key auto increment attribute in my table. I want to know the value assigned to it for a row that is inserted using statement.executeUpdate(). How to achieve this in the best possible ...
Rohit Banga's user avatar
5 votes
1 answer
13k views

I'm programming with plain JDBC a DAO layer because I only have 61.38 MB on Java Memory in my Tomcat (service hosting). I have a table with an AUTO_INCREMENT column in MySQL. The current ...
Paul Vargas's user avatar
  • 42.2k
1 vote
3 answers
3k views

I have a database table A which stores records, A has a primary key (recordid) with auto_increment, each time i insert a record in to A, i get the inserted recordid and store it in another ...
Sudheer's user avatar
  • 329
0 votes
1 answer
4k views

I want to get the last inserted ID as long. Because the primary key of my table is of long data type. Here's my code: Connection connection = null; Statement statement = null; ...
Anonymous One's user avatar
0 votes
4 answers
409 views

Ok so my code looks like this String sqlString = "INSERT into auditlog(report_name, username, start_datetime, resource_uri, resource_id) VALUES (?,?,?,?,?)"; preparedStatement = ...
Andre's user avatar
  • 661
0 votes
2 answers
2k views

Possible Duplicate: How to get the insert ID in JDBC? I have the following tables: customer(cid, ...) book(cid, rid) reservation(rid, ...) I want to add a reservation in its table then I want ...
malhobayyeb's user avatar
  • 2,881
0 votes
3 answers
2k views

In MySql, I want to use equivalent of SQL @@IDENTITY and I found this LAST_INSERT_ID(). I found in search that it work fines even if there are different sessions exist. I want to find last ID,in ...
Hammad Hassan's user avatar
0 votes
2 answers
2k views

How to fetch id from db using JSP servlet. This is my JSP servlet code and I need code for display id through alert message box and in my db I will gave id as auto-increment in data base. I ...
user3563088's user avatar
0 votes
1 answer
2k views

Possible Duplicate: How to get the insert ID in JDBC? In the following statement, how can I fetch the last inserted C12 identity value? This is from the JavaDB manual, but they have not mentioned ...
Sam's user avatar
  • 2,812
1 vote
1 answer
1k views

I'm using H2DB for a litthe cuesheet-database. I'm inserting several records to a table with anj auto-increment field for the primary key ID. For each record I want to know the value of the ID-field ...
user avatar

15 30 50 per page
1
2 3 4 5
7