KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jdbc > standard > PreparedStatementCache


1 /*
2  * XAPool: Open Source XA JDBC Pool
3  * Copyright (C) 2003 Objectweb.org
4  * Initial Developer: Lutris Technologies Inc.
5  * Contact: xapool-public@lists.debian-sf.objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA
21  */

22  package org.enhydra.jdbc.standard;
23
24 import org.enhydra.jdbc.util.LRUCache;
25
26 import java.sql.PreparedStatement JavaDoc;
27 import java.sql.SQLException JavaDoc;
28
29 /**
30  * Implementation of LRUCache to handle prepared statements
31  * TODO: Override put to check type
32  */

33 public class PreparedStatementCache extends LRUCache {
34
35     /**
36      * Constructor
37      */

38     public PreparedStatementCache(int maxSize) {
39         super(maxSize);
40     }
41
42     /**
43      * Overriden to close the statement
44      */

45     protected void cleanupObject(Object JavaDoc obj) {
46         if (obj != null) {
47         log.debug(
48             "PreparedStatementCache:cleanupObject class='"
49                 + obj.getClass()
50                 + "'");
51         log.debug(
52             "PreparedStatementCache:cleanupObject close a PreparedStatement o="
53                 + "'"
54                 + obj.toString()
55                 + "'");
56         }
57         try {
58             ((PreparedStatement JavaDoc) obj).close();
59             //obj = null;
60
} catch (SQLException JavaDoc e) {
61             log.error(
62                 "PreparedStatementCache:cleanupObject problem to close"
63                     + "a PreparedStatement: "
64                     + e);
65         }
66     }
67
68 }
69
Popular Tags