log4j not closing database connections

D

Dave V

Hi,

I'm using log4j with a configuration file. I use it to log to a
database table. The logging works great. The only problem is that I
end up with a bunch of connections left open all the time. How can I
get these connections to close?

My code looks like something this:

///////////////////////////////////////
public class myClass{
private static Logger coSuccessLog = null ;
private static Logger coErrorLog = null;

public void logTest() throws Exception {

try {
InputStream boInputStream =
this.getClass().getResourceAsStream("/log4j_lai.properties");
Properties boLog4jProps = new Properties();
boLog4jProps.load(boInputStream);
PropertyConfigurator.configure(boLog4jProps);
coErrorLog =
Logger.getLogger("error."+this.getClass().getName());
coSuccessLog =
Logger.getLogger("success."+this.getClass().getName());
Class.forName("oracle.jdbc.OracleDriver");
} catch (ClassNotFoundException ex) {
throw ex;
} catch (IOException ex) {
throw ex;
}

coSuccessLog.info(new java.util.Date() + "made it into
logTest.");
}
}

/////////////////////////////////////// The config file looks like
this:///////////////////////////////////
log4j.category.error=info, R
log4j.appender.R=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.R.URL=jdbc:eek:racle:thin:mad:qeweb.lordabbett.com:1521:qeweb
log4j.appender.R.user=mi
log4j.appender.R.password=mi
log4j.appender.R.sql=INSERT INTO LAI_ERROR_LOG (ERROR_LOG_ID,
APPLICATION, MSG, RECORD_TYPE, CREATED_DATE) VALUES
(LAI_ERROR_ID_SEQ.Nextval, 'LAISearch', '%m', 'E', SYSDATE)
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.category.success=info, S
log4j.appender.S=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.S.URL=jdbc:eek:racle:thin:mad:qeweb.lordabbett.com:1521:qeweb
log4j.appender.S.user=mi
log4j.appender.S.password=mi
log4j.appender.S.sql=INSERT INTO LAI_ERROR_LOG (ERROR_LOG_ID,
APPLICATION, MSG, RECORD_TYPE, CREATED_DATE) VALUES
(LAI_ERROR_ID_SEQ.Nextval, 'LAISearch', '%m', 'I', SYSDATE)
log4j.appender.S.layout=org.apache.log4j.PatternLayout
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Anyone have a clue? Obviously I don't!

Thanks,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top