File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes handling multiple queries with the same connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "handling multiple queries with the same connection" Watch "handling multiple queries with the same connection" New topic
Author

handling multiple queries with the same connection

satya sxy
Greenhorn

Joined: Mar 23, 2001
Posts: 13
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.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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

Joined: Mar 23, 2001
Posts: 13
Thanks jamie,
i will try this one.
I appreciate your help. thanks a lot.
shailu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: handling multiple queries with the same connection
 
Similar Threads
sql
MySQL - add and remove username from table
AbstractTableModel
Validating Username and Password in JSP
Resetting Values