ID « Operation « Java Database Q&A





1. How to get the insert ID in JDBC?    stackoverflow.com

I want to INSERT a record in a database (which is Microsoft SQL Server in my case) using JDBC in Java. At the same time, I want to obtain the insert ...

2. Java JDBC Retrieve ID After Insert    stackoverflow.com

I use triggers to set PK column values of all tables so i do not do any operation about IDs in java but i need the ID after insert. How can ...

3. pass the value in the id="Rate<%=Cnt%>" into showEdit(typ) function to enable it updated in db    stackoverflow.com

<table width=100%>
      <tr>
            <td id="show1" class="centerNoBorder">&nbsp;<input type="button" name="upd_rate" value="Update Rate" onclick="showEdit(1)"></td>
    </tr>
 ...

4. getting ID after Insert.    coderanch.com

Hi all. Does somebody know, how to solve this problem: In my code I insert a new record into the table. ... String sqlStmt = "INSERT INTO Texts (text) VALUES (?)"; PreparedStatement stmt = getConnection().prepareStatement(sqlStmt); stmt.setString(1,newtext); //newtext is String. stmt.executeUpdate(); ... And right after(immediatly) I need to get text_ID (that is given by DB Server) number of this new created Text-record. ...

5. last_insert_id()    coderanch.com

Hi all! If I add a record that has a id field with auto_increment, how do I get the id created for this record? I'm using mySQL and there is this method latest_insert_id() but I dont get how I could invoke it using java.sql library. Has someone got a clue? // Andreas

6. Getting unique ID for INSERT    coderanch.com

Hi, I have a small problem I have come accross, which I can't see an obious way round. I have a RegistrationServlet (for creating a new user) which inserts the details of the new user into two seperate tables in a MS SQL database. The first insert puts the users personal data into a table called tblUsers (name, dob, tel no, ...

8. LAST_INSERT_ID() with threads    coderanch.com

I need to get the id from a previous insert to use as a foreign ke in another table I am using the connection pool below in a web application. Can i use LAST_INSERT_ID() in this configuration whithout the risk of getting the wrong value? If not what is another way of doing this? import java.sql.*; import javax.sql.DataSource; import javax.naming.InitialContext; public ...