From 3e1a874653a3f20ce55c245ac835019b98df5acf Mon Sep 17 00:00:00 2001 From: travismccauley Date: Tue, 23 Dec 2003 20:40:07 +0000 Subject: [PATCH] Added a lazy initialization to cover connections that are closed by the container --- src/java/org/thdl/lex/LexRepository.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/java/org/thdl/lex/LexRepository.java b/src/java/org/thdl/lex/LexRepository.java index 39a922f..499f471 100644 --- a/src/java/org/thdl/lex/LexRepository.java +++ b/src/java/org/thdl/lex/LexRepository.java @@ -85,6 +85,12 @@ public class LexRepository */ private Connection getConnection() { + if ( null == connection || connection.isClosed() ) + { + Context context = new InitialContext(); + DataSource source = (DataSource) context.lookup( LexConstants.DATASOURCE_NAME ); + setConnection( source.getConnection() ); + } return connection; } @@ -97,6 +103,12 @@ public class LexRepository */ public Statement getQueryStatement() { + if ( getConnection().isClosed() ) + { + Context context = new InitialContext(); + DataSource source = (DataSource) context.lookup( LexConstants.DATASOURCE_NAME ); + setConnection( source.getConnection() ); + } return queryStatement; }