• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

handling multiple queries with the same connection

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello someone,
I am trying to use java servlets and jdbc for a project i am working on. I have a register servlet that does the registration part. When i submit this servlet,it should first check the database table if the username already exists ,if it exists then it do nothing. in case if the submitted username doesnt exist then the submitted information should be inserted into the database table. I tried doing this but i get erorrs. could someone throw light on this topic as to how to handle both the select query and insert query one after the other.
Any help, ideas, suggested readings are appreciated.
thanks,
shailu.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
algorithm:
connect
query the table for the username
if username does not exist
write to the database

I didn't compile the above code, but it should give you a start. As you can see, I prefer PreparedStatements over Statements in any situation that I can!
Jamie
 
satya sxy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks jamie,
i will try this one.
I appreciate your help. thanks a lot.
shailu
 
reply
    Bookmark Topic Watch Topic
  • New Topic