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 ...
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. ...
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
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, ...
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 ...