File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Re: Checking for duplicate rows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Re: Checking for duplicate rows" Watch "Re: Checking for duplicate rows" New topic

Re: Checking for duplicate rows

Ashwin Tadepalli

Joined: Feb 01, 2001
Posts: 27
What is the easiest way to check for the insertion of duplicate rows in a database table from a client program.I have tried used using try catch block statements and then raising an exception,but it does not solve my problem.All of my JDBC processing is done through a servlet,so if I try to run the client program and try to insert some duplicate entries it stops my servlet engine.I can see that it has raised that SQL exception on the console of my Visual Age tool,but I want some other method which will not let my servlet engine to stop but tell in advance to the client program(on the command prompt) that you are trying to insert some duplicate entries.Any suggestions on this topic are welcome.
Thanking You
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
Use the kiss() method...
exec a select using the table's primary key...
if you get a row count GT 0..
then you have a duplicate...

Multi-Platform Database Developer

Multi Platform Database Developer & DBA on E.S.T.
I agree. Here's the link:
subject: Re: Checking for duplicate rows
It's not a secret anymore!