Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checking existence query?

 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All I want to know is if Name is not null. I have a unique constraint on my name so I need to ensure none exists which is the same as the one I plan to use.

I am using


and rs.next() to tell me if such a name exists or not. Is there a better query for this since I am not even looking at the returned name, only if it exists or not.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This version is slightly more efficient because the database doesn't have to return as much data.


Did you want a unique name in general or per component id? The unique index would do it for name only.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic