Preparedstatement Conn Sql Statement.return_generated_keys
Jan 03, 2005 pstmt = conn.prepareStatement(psqlstmt,Statement.RETURNGENERATEDKEYS); // populate the '?' Parameters in PreparedStatement pstmt. How do I use both preparedstatement and CONCURUPDATEABLE? Java.sql.Connection only supports 2 prepareStatement API for using getGeneratedKeys and it does not provide a way to specify the ResultSet type. Is there a way to retrieve the auto generated key from a DB query when using a java query with prepared statements. For example, I know AutoGeneratedKeys can work as follows. Mar 04, 2004 Re: preparedStatement and Date probs! 796254 Mar 4, 2004 1:20 PM ( in response to 807595 ) You don't have to set the autoincrement column at all. Retrieving auto-generated keys for an INSERT statement With the IBM® Data Server Driver for JDBC and SQLJ, you can use JDBC 3.0 methods to retrieve the keys that are automatically generated when you execute an INSERT statement. Connection.prepareStatement(sql-statement, Statement.RETURNGENERATEDKEYS);The following forms are valid only if the data source supports SELECT FROM INSERT statements. Sql-statement can be a single-row INSERT statement or a multiple-row INSERT statement. With the first form, you specify the names of the columns for which you want automatically generated keys. Connection.prepareStatement(sql-statement, Statement.RETURNGENERATEDKEYS);If the data server is Db2 for z/OS, the following forms are valid only if the data server supports SELECT FROM INSERT statements.With the first form, you specify the names of the columns for.
Summary: in this tutorial, you will learn how to insert data into a table in the PostgreSQL database using JDBC API. We will use the actor table in the sample database for the demonstration. Inserting one row into a table. To insert a row into a table, you follow these steps: Establish a database connection to get a Connection object.
Date: November 04, 2004 04:07PM
thanks
- alex
-------------------------------------------------------------------
pstmt = conn.prepareStatement(psqlstmt,Statement.RETURN_GENERATED_KEYS);
// populate the '?' parameters in PreparedStatement [pstmt].
for (int i=0; i < data.length; i++)
{
System.out.println('pstmt.setObject('+(i+1)+','+ data + ')');
pstmt.setObject(i+1, data);
}
pstmt.execute();
resultSet = pstmt.getGeneratedKeys();
if (resultSet != null && resultSet.next())
{
newid = resultSet.getInt(1);
resultSet.updateInt(1, newid+1);
System.out.println('newid = ' + newid);
}
else
{
System.out.println('resultset is NULL.');
}
-------------------------------------------------------------------
com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for
more details.
How do I use both preparedstatement and CONCUR_UPDATEABLE? java.sql.Connection only supports 2 prepareStatement() API for using getGeneratedKeys() and it does not provide a way to specify the ResultSet type like createStatement() call.
-alex


Preparedstatement Conn Sql Statement.return_generated_keys Pdf
Preparedstatement Sql Injection
Smart office license key generator. Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.