Hi,

create an updateable Statement, this is the create statement method
with the two parameters.
Then you can:
1. Try a "Select * from <your_table> where <xyz> = <your_form_id>"
2. Try if(rs.next())
2.1 TRUE: entity exists already, with updateable select you can
immediately change the entities values within the current resultset row
(use the set Methods)
2.2 FALSE: entity does NOT exist: Use the ResultSet 'navigation'
methods to navigate it to the 'insert row' (ResultSet.moveToInsertRow
()). set your values with the set methods. Finally call
ResultSet.insertRow().

ATTENTION: I think this is a very special feature, so it may work in
theory but not with your jdbc-driver. Better create a prototype first
to figure out your drivers capabilities.

Another way would be to have a primary key constraint on your table for
the very id (or unique key if you have another primary).
Then you may use a try-and-see approach which always uses "INSERT"
statements. If you try to insert entity with id which is already in db
you going to get a exception. Act upon that exception by propagating it
or use a "UPDATE" now.

Peter


----- Original Message -----
From: mike dizon <[EMAIL PROTECTED]>
Date: Wednesday, November 21, 2001 4:42 am
Subject: verifying database entries

> Hi All,
>
> I'm trying to make sure that an entry in a database doesn't exist
> before I enter data into the database -- based on information
> entered in on a form.
>
> How do I go about doing that? Any help would be appreciated.
>
> Thanks
> MD
>
>
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to