I am resending this question, because it didn't seem to make it teh first
time around.
First of all, I didn't choose the database software. That said, I have a
question about JOnAS and MS SQL.
When you insert a row into MS SQL, you can SELECT @@IDENTITY as the next
operation on a connection and get the primary key created for the previous
insert.
In my case, I am running the sql:
INSERT INTO V_TIMEZONE(code, description, tz_offset)
VALUES('pst', 'pacific standard time', '0')
which creates:
seq=100
code=pst
description=pacific standard time
tz_offset=0
If I then execute:
SELECT @@IDENTITY
it returns 100.
This is all from the MS SQL Client.
When I run the equivalent code in an EJB, It always returns 0.
The code I am working with looks like:
Statement pStmt = con.createStatement();
pStmt.execute(sql);
ResultSet resultSet = pStmt.executeQuery(" select @@identity");
//ResultSet resultSet = stmt.getResultSet();
if (resultSet == null) {
System.out.println("ResultSet is null");
} else {
resultSet.next();
System.out.println("PPKK: " + resultSet.getInt(1));
}
I see the line PPKK: 0
It never reports that the ResultSet is null. If I change getInt(1) to
getObject(1) it will report a null object though.
Utilmately, I would like to execute an insert via a prepared statement, and
get the auto-generated primary key. Does anyone have any ideas?
Thanks,
Lucas McGregor([EMAIL PROTECTED])
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".