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 9071861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:01:29+00:00 2026-06-16T18:01:29+00:00

I am currently trying to debug my Java servlet which is having problems interfacing

  • 0

I am currently trying to debug my Java servlet which is having problems interfacing with a JDBC connection pool.

Note: my servlet was working fine three days ago but now its stopped working so I am assuming its my Sun One webserver or Database problem but with no error message I have no idea what is happening.

My servlet normally returns an XML response through the browser but with this error that is happening I am getting nothing returned just a black file.

After painstakingly putting breakpoints in my code I have isolated where the error occurs but I have no information being returned on this error.

It occurs at this line in my getData() method.

Statement stmt = conn.createStatement();

Here is the full database class

DatabaseLogic Class

    public class DatabaseLogic
{
    private static Connection conn;

    public static void openDatabase() throws IOException, SQLException,
            NamingException
    {


        Context initialContext = new InitialContext();
        Context envContext = (Context) initialContext.lookup("java:comp/env");
        // servlet looks up for a connection pool called "jdbc/POOL"
        DataSource ds = (DataSource) envContext.lookup("jdbc/POOL");
        // connection is then made/requests to connection pool

        try
        {
            conn = ds.getConnection();
        }
        catch (SQLException e)
        {
            String message = "Unable to connect to archive database : " + e;
            XMLBuilder.dbError(message);            
        }
    }


    public static String getData(String queryId, int requestNumber)
            throws SQLException
    {
        String result = "";
        if (queryId != null)
        { 

            try
            {

                // prepare a statement for use in query;
                try
                {
                    result = "This is where it breaks";
                    Statement stmt = conn.createStatement();
                    result = "This message does not get returned";

                    // query parameratised with queryId
                    String qry = "SELECT RECORD_ID, USER_ID, OPERATION_CD, BUSCOMP_NAME, OPERATION_DT, FIELD_NAME, OLD_VAL, NEW_VAL, AUDIT_LOG, ROW_ID, BC_BASE_TBL FROM S_AUDIT_ITEM WHERE RECORD_ID='"
                            + queryId + "'";

                    try
                    {
                        ResultSet results = stmt.executeQuery(qry);

                        result = XMLBuilder.xmlBuilder(results, queryId,
                            requestNumber);

                        // close the connection
                        stmt.close();
                        results.close();
                    }
                    catch (SQLException e)
                    {
                        String message = "A database error occurred : " + e;
                        XMLBuilder.dbError(message);
                    }



                }
                catch (SQLException e)
                {
                    String message = "A database error occurred : " + e;
                    XMLBuilder.dbError(message);
                }

            }
            catch (Exception e)
            {
                // log.error("Cannot connect to database :" + e);

                String message = "Unable to query the archive database : " + e;
                XMLBuilder.dbError(message);            
            }
        }
        else
        {
            // not sure if ever reached
            result = "The query parameter  is a null value";
        }
        return result;
    }

All information being returned is sent to XMLBuilder to be packaged into an XML however nothing is being returned. Meaning the function in my class is not being called when dealing with exceptions.

XMLBuilder.dbError()

public static String dbError(String message)
{
    //added uniquestring generator for id 
            String uniqueId = UUID.randomUUID().toString();

    String result = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?> "
            + "<SMessage MessageId=\"" + uniqueId + "\" MessageType=\"Integration Object\" IntObjectName=\"Test\" IntObjectFormat=\"Siebel Hierarchical\""
            + " ReturnCode=\"1\" ErrorMessage=\"Database error" + message + ".\">" +
    "</SMessage>";
    return result;
}

How can I get an error message returned so I can figure out whether this is a server error or it is my servlet

Thankyou

Merry Christmas and Happy Holidays!

  • 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-16T18:01:31+00:00Added an answer on June 16, 2026 at 6:01 pm

    You’re calling this method:

    XMLBuilder.dbError(message);
    

    but not using its result. So the result variable remain blank, and that’s what you return to the client.

    I would rather throw all execptions (that you can’t recover from) out to the top level request handler method (otherwise you’ll duplicate all your XML marshalling invocations). Only then should you:

    1. log that exception in your server logs
    2. present an error to the client (via XML)

    That would give you a more consistent (less repeated) means of handling errors, and you’re not having to present an XML-wrapped error from the depths of your code.

    As an aside, your code isn’t thread-safe. You’re calling ‘static’ methods on the class to set up connections etc. You’ll be better off getting the connection, statement etc. all within one service method.

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

Sidebar

Related Questions

I am currently trying to debug a program, which is rather determined to not
How to disable qt creator from auto building when trying to debug? Currently when
I am trying to debug web service call which uses JMS in the background.I
I'm trying to secure a connection from a Java Client/Server application that communicates over
I'm currently trying to debug my application, however, I'm running into some difficulties with
Everyone, I am trying to code an applet in Java which will access a
I'm currently trying to configure log4j to use 2 appenders. Debug info should be
I am currently trying to read in an XML node from a filepath which
I'm currently trying to debug a piece of simple code and wish to see
I'm currently trying to debug a customer's issue with an FTP upload feature in

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.