0

i have created a singleton logger to use in my java application. all the statements before the connection to hsql standalone database are working fine i.e the messages are getting logged. but the logging statements after the conneciton to database are not getting logged. if i remove the connection statement or if the connection to database is failed then the statements after that connection statement are working normally.

why was this happening ??

ORLogger.getLogger().log(Level.INFO, "Trying to connect databse . . .");
        Class.forName("org.hsqldb.jdbc.JDBCDriver").newInstance();
        ORLogger.getLogger().log(Level.INFO, "HSQL driver loaded . . .");
        dbConnection = DriverManager.getConnection("jdbc:hsqldb:file:db/db", "username", "password");
        ORLogger.getLogger().log(Level.INFO, "Connected to databse.");

In log file, the log messages are up to the below statement

HSQL driver loaded . . .

But, after that, there is no log messages are added in log file. if remove the connection statement, i.e

dbConnection = DriverManager.getConnection("jdbc:hsqldb:file:db/db", "username", "password");

all messages after the above connection statement are working well.

There is no problem with the connection to database. all the database related work is fine. except this logging is not working properly.

3
  • would you show your code Commented Aug 28, 2012 at 5:32
  • why are u using dbc:hsqldb:file:db/db Commented Aug 28, 2012 at 5:45
  • Looks like you have a problem to connect with your database. Also, it is good that you have implemented your own logger, but don't reinvent the wheel, use a proven logger like log4j. Commented Aug 28, 2012 at 5:45

2 Answers 2

1

If you are using log4J or JDK logging, HSQLDB will change the setting unless you have a system property to tell it not to. See here:

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks fredt, your answer was very useful. i am just thinking about the same thing. HSql is modifying the logging sequence somehow, but i dont know exactly whats going on. System.getProperties().setProperty("hsqldb.reconfig_logging", "false"); solves the problem
@sanjeev: Don't forget to upvote answers that you feel are useful, and accept the answer that best answered your question (if such an answer exists).
0

Did you use a debugger to check that the call to DriverManager.getConnection actually returns? Sounds like it gets stuck trying to open the connection, and you won't see the next line logged, because the program is stuck waiting to get a connection open.

Check your connection string, try first with something like jdbc:hsqldb:mem:testdb, if that works, it could be that hsqldb cannot open the file you're trying to use for the database.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.