What you really mean by ID ?  Is it going to be a primarykey like key in the
DB, or you are extracting the value out for a Read ?

If as PK, then I guess, sequence is a better choice, but otherwise (for a
read or further processing), this works fine.

Soundar
www.eoriginal.com




-----Original Message-----
From: Dan Hinojosa [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 11, 2000 10:45 AM
To: [EMAIL PROTECTED]
Subject: Concurrency.


Well lets say I have a customers table.  In a session bean I have this
function that creates an ID for me.  Do I have concurrency problems with
this?

private int getID() throws SQLException, NamingException {
    Connection conn = getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT MAX(ID+1) FROM CUSTOMERS");

    rs.next();
    int i = rs.getInt(1);
    stmt.close();
    return i;
}

It works like a champ.  Granted I need better handling of the
Exceptions.  But the question is concurrency will this pose a problem?

P.S. If anyone is a manager of this newsgroup I always get a legg@...
someone or rather is not a valid email box.  Can someone drop this
person?

--

Dan Hinojosa
Java & Lotus Notes Consultant
Java Certified Programmer

P.O. Box 4675
Albuquerque, NM 87196-4675
Telephone: (505) 262-0911
Email: [EMAIL PROTECTED]
WWW: http://www.digitalpriest.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to