Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8262421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:45:01+00:00 2026-06-08T03:45:01+00:00

I have created a servlet to access a database and giving response to a

  • 0

I have created a servlet to access a database and giving response to a BB application…it was running fine during development…but after loading it on a tomcat server 6.0 after goining live the servlet has to be reloaded every morning on the tomcat server….after that it works fine during the whole day..but the next morning when i request something it gives a blank page as response and my server admin tells the servlet has to be reloaded …
other application hosted on the server are working fine and do not need a restart…

what might be the problem….

adding the code ..if it helps

    package com.ams.servlets;
    import java.io.*;
    import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;

import com.cms.dbaccess.DataAccess;
import com.cms.utils.ApplicationConstants;
import com.cms.utils.ApplicationHelper;

import java.sql.ResultSet;
public class BBRequestProcessorServlet extends HttpServlet {
/**
 * 
 */String userString;
 private static final long serialVersionUID = 1L;
 String jsonString = "";
 ResultSet rs = null;
 Connection connection = null;
 Statement statement=null;

 public enum db_name
 { 
     //Test
     resource_management_db,osms_inventory_db; 

 }
 public void init(ServletConfig config)throws ServletException
 {
     super.init(config);

     System.out.println("Inside init");




 }

 public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException 
 {
     try{
         connection = DataAccess.connectToDatabase("xxx", connection);
         statement = DataAccess.createStatement(connection); 

         statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

         rs = statement.executeQuery("query is here");
     }
     catch(SQLException e)
     {
         e.printStackTrace();
     }
     String db =request.getParameter("db");
     System.out.println("DATABASE NAME :"+ db);
     if(db.equalsIgnoreCase("xxx")){ 
         //Call to populate JSONArray with the fetch ResultSet data
         jsonString = ApplicationHelper.populateJSONArray(rs);
     }
     response.setContentType(ApplicationConstants.JSON_CONTENT_TYPE);
     PrintWriter out = response.getWriter();
     out.print(jsonString);      
     out.flush();
     out.close();
     System.out.println("json object sent");
     try {
        rs.close();

    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

 }   
 }

the only errors i could find was
Jul 20, 2012 9:57:24 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/usr/local/tomcat/apache-tomcat-6.0.20/webapps/MobileServlet /WEB-INF/lib/servlet-api.jar) – jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:45:03+00:00Added an answer on June 8, 2026 at 3:45 am

    The culprit is most likely the way how you handle external DB resources like the Connection. This problem can happen when you keep a DB Connection open all the time without closing it. When a DB Connection is been opened for a too long time, then the DB will timeout and reclaim it. This is most likely what was happening overnight.

    You should redesign your DataAccess and BBRequestProcessorServlet that way so that you are nowhere keeping hold of Connection, Statement and ResultSet as an instance variable, or worse, a static variable of the class. The Connection should be created in the very same scope as where you’re executing the SQL query/queries and it should be closed in the finally block of the very same try block as where you’ve created it.

    By the way your jsonString should absolutely also not be declared as an instance variable of the servlet, it’s not threadsafe this way.

    See also:

    • Is it safe to use a static java.sql.Connection instance in a multithreaded system?
    • How do servlets work? Instantiation, sessions, shared variables and multithreading

    As to the error which you’re seeing in the log, you should definitely remove the offending JAR. See also How do I import the javax.servlet API in my Eclipse project?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a JSP / servlets application running in Tomcat 7. It runs
I have created a login application in jsp/servlet in my web project and I
I have to write VXML application which will be able to access to database.
For my web application, i have created login page. To block the access to
I have created a servlet that passes a string variable strname to a JSP
I have created an android application that calls (using kSOAP library) a SOAP based
I have an existing database (PostgreSQL in my case), and would like to access
I have created an application suite of three programs. The first program is a
I have created a servlet that accepts an image from my android app.I am
I have created a basic servlet to handle logins on my web app. currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.