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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:40:05+00:00 2026-06-12T12:40:05+00:00

Situation: I have a static Database class, using HSQLDB and I want to use

  • 0

Situation:
I have a static Database class, using HSQLDB and I want to use Logging also in it.

I set up the logger, set up all the statements, but after using a specific method, the logger seems not to be working anymore. No exception are thrown, just seems to be dead.

this is the Logger class:

public class GLogger {

    private static GFormatter   formatterHTML;
    private static FileHandler  fileHTML;
    private static boolean      isReady = false;

public static void setup() throws IOException {
    Logger logger = Logger.getLogger("");
    fileHTML = new FileHandler("conf/logging.html");
    formatterHTML = new GFormatter();
    fileHTML.setFormatter(formatterHTML);
    logger.addHandler(fileHTML);
    isReady = true;
}

public static boolean isReady() {
    return isReady;
}
}

This is the (part of) Database class:

public class Database {

private static final Logger LOG = Logger.getLogger(Database.class.getName());
/**
 * The database server class
 */
private static Server       hsqlServer;

/**
 * The connection class. Used to manage request to the database.
 */
private static Connection   connection;

/**
 * The name of the database
 */
private static String       dbName;

public Database(String databaseName, String fileName) {

    LOG.setLevel(Level.FINEST);

    hsqlServer = null;
    connection = null;

    dbName = databaseName;

    // ###### LOGGER ######
    LOG.finest("Creating a new database server class");
    // ####################
    hsqlServer = new Server();

    hsqlServer.setLogWriter(null);
    hsqlServer.setSilent(true);

    hsqlServer.setDatabaseName(0, dbName);
    hsqlServer.setDatabasePath(0, "file:db/" + fileName);
}

/**
 * Start the new database class.
 */
public static void start() {

    // ###### LOGGER ######
    LOG.finest("Starting a new database class");
    // ####################
    hsqlServer.start();
    connection = null;
}

/**
 * Start the new connection to the specified database, using the default username "sa" e no password
 */
public static void connect() {
    try {
        // ###### LOGGER ######
        LOG.finest("Getting a connection to the newly started database");
        // ####################
        Class.forName("org.hsqldb.jdbcDriver");
        // Default user of the HSQLDB is 'sa' with an empty password
        connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/garby", "sa", "");
    } catch (ClassNotFoundException e) {
        // ###### LOGGER ######
        LOG.severe("Impossible to connect to the database. ClassNotFound");
        // ####################
    } catch (SQLException e) {
        // ###### LOGGER ######
        LOG.finest("Impossible to connect to the database. " + e.getCause());
        // ####################
    }
}
// ... more other stuff, not important and then the main method:
public static void main(String[] args) {
    if (!GLogger.isReady()) {
        try {
            GLogger.setup();
        } catch (Exception e) {

        }
    }
    new Database("garby", "garbydb");
    Database.start();
    Database.connect();
    Database.tableStructureCreation();
    Database.populateFromFile("conf/populateServ.txt", "services");
    System.out.println(Database.listServices());
    Database.stop();
}

I deleted all methods and other action that are not related to my problem.

If I run the class, all works well (!! the database add the correct structure and data, verified with second last line “system.out”). The thing that don’t work how should is the logger.

If I open the html file (I omitted the htmlFormatter for simplicity, that’s not useful, it only format the log message), I can read ONLY two lines, the one in the constructor and the one in start() method.

After few tries, I understood that the problem is in the line

hsqlServer.start();

in public static void start(); method.

In fact, if in the main I move the Database.connect() BEFORE the Database.start(), I can read 4 messages (1 from the constructor, 2 from the connect [getting a conn…. impossible to conn…] and 1 from the start) and then nothing.

If I comment that line [hsqlServer.start()] I can read ALL log messages (obviously until somewhere is thrown a NullPointerException due to the missing statement).

I really can’t figure out why and how to solve this problem. This thing is blocking me all my program Log messages, because obviously the “Database” class is started almost before any other and blocks all Log message.

Any ideas? Thank you in advance

[again, sorry for my bad english, I hope I can be understandable]
EDIT: I removed also Javadoc comment – not useful.

  • 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-12T12:40:06+00:00Added an answer on June 12, 2026 at 12:40 pm

    HSQLDB will use java.util.logging or Log4J if either is present. It reconfigures the logging setup for logging to work properly. If you are configuring logging yourself, you must include the system property setting hsqldb.reconfig_logging=false. You then need to configure the level at which you want HSQLDB log message to be included. See the Guide:

    http://hsqldb.org/doc/2.0/guide/management-chapt.html#mtc_jdc_logging

    One way of setting the system property before you start the Server is this:

     System.setProperty("hsqldb.reconfig_logging", "false");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Situation: I have this log4j logger: private static final Logger logger = Logger.getLogger(ThisClassName.class); And
I have following situation - Have a MongoService class, which reads host, port, database
I have a situation where a helper class with a static DBContext member is
Pseudo-situation: have a class (let's say BackgroundMagic ), and it has Start() and Stop()
i have situation like this: class IData { virtual void get() = 0; virtual
This is a rather a problem from a convoluted situation. I have a static
I have situation where I have to call method of interface using reflection, like
I have a web application built using jsp/servlets.The web application session is set to
I have situation to extend the Enumerable class in c# to add the new
first of all here is my situation. I am programming an intranet application using

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.