This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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?