This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL Exception on refeshing the servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Exception on refeshing the servlet." Watch "SQL Exception on refeshing the servlet." New topic
Author

SQL Exception on refeshing the servlet.

Kavita Ghia
Ranch Hand

Joined: Oct 10, 2000
Posts: 91
Hello friends,
I have a servlet written which is making connection to my database(Ms Access)if it helps and then performing search query.
The connection is done in the init() method of the servlet and the query is executed in the doGet() method.If the search query contains the data then it displays the result else the message record not found.Now my problem is this-
the whole procedure is happening only once when my servlet is called for the first time.i.e. when my init method is invoked.Subsequently whenever I try to refresh the servlet for other search result I get an SQLException stating the "General Error".Basically it is not creating or executing the following:
Statement st=con.createStatement();.
Can anyone explain me the reason for such a weird behavior.
Thanking in advance,
Regards,
Kavita.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
What part is weird? You are creating the connection in the init() but what if the connection drops? Then since the init() is only run the first time the servlet is loaded into memory, the createStatement() won't have a valid connection to use to create a statement. And when do you close the connection?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Exception on refeshing the servlet.
 
Similar Threads
HTML FORM processing problem
Connection Pool Design Issue
JDBC in JSP/Servlet question
SQL Exception on refeshing the servlet.
Abstract servlet