KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > AbstractDatabaseMetaData


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

6 package org.logicalcobwebs.proxool;
7
8 import org.logicalcobwebs.logging.Log;
9 import org.logicalcobwebs.logging.LogFactory;
10
11 import java.sql.Connection JavaDoc;
12 import java.sql.DatabaseMetaData JavaDoc;
13 import java.sql.SQLException JavaDoc;
14
15 /**
16  * Contains most of the functionality that we require to manipilate the
17  * connection. The subclass of this defines how we delegate to the
18  * real connection.
19  *
20  * @version $Revision: 1.4 $, $Date: 2003/03/03 11:11:56 $
21  * @author bill
22  * @author $Author: billhorsman $ (current maintainer)
23  * @since Proxool 0.7
24  */

25 public abstract class AbstractDatabaseMetaData {
26
27     private static final Log LOG = LogFactory.getLog(AbstractDatabaseMetaData.class);
28
29     private DatabaseMetaData JavaDoc databaseMetaData;
30
31     private ProxyConnectionIF proxyConnection;
32
33     /**
34      * Whether we have invoked a method that requires us to reset
35      */

36     private boolean needToReset = false;
37
38     protected AbstractDatabaseMetaData(Connection JavaDoc connection, ProxyConnectionIF proxyConnection) throws SQLException JavaDoc {
39         databaseMetaData = connection.getMetaData();
40         this.proxyConnection = proxyConnection;
41     }
42
43     /**
44      * Whether the underlying databaseMetaData are equal
45      * @param obj the object (probably another databaseMetaData) that we
46      * are being compared to
47      * @return whether they are the same
48      */

49     public boolean equals(Object JavaDoc obj) {
50         return databaseMetaData.hashCode() == obj.hashCode();
51     }
52
53     /**
54      * We don't want to ask the DatabaseMetaData object for the
55      * connection or we will get the delegate instead of the Proxool
56      * one.
57      * @see DatabaseMetaData#getConnection
58      */

59     public Connection JavaDoc getConnection() {
60         return ProxyFactory.getConnection(proxyConnection);
61     }
62
63     /**
64      * Get the DatabaseMetaData from the connection
65      * @return databaseMetaData
66      */

67     protected DatabaseMetaData JavaDoc getDatabaseMetaData() {
68         return databaseMetaData;
69     }
70
71     /**
72      * @see Object#toString
73      */

74     public String JavaDoc toString() {
75         return databaseMetaData.toString();
76     }
77
78 }
79
80
81 /*
82  Revision history:
83  $Log: AbstractDatabaseMetaData.java,v $
84  Revision 1.4 2003/03/03 11:11:56 billhorsman
85  fixed licence
86
87  Revision 1.3 2003/02/06 17:41:03 billhorsman
88  now uses imported logging
89
90  Revision 1.2 2003/01/31 16:53:13 billhorsman
91  checkstyle
92
93  Revision 1.1 2003/01/31 14:33:11 billhorsman
94  fix for DatabaseMetaData
95
96  Revision 1.3 2003/01/31 11:38:57 billhorsman
97  birthDate now stored as Date not long
98
99  Revision 1.2 2003/01/28 11:50:35 billhorsman
100  more verbose debug
101
102  Revision 1.1 2003/01/27 18:26:33 billhorsman
103  refactoring of ProxyConnection and ProxyStatement to
104  make it easier to write JDK 1.2 patch
105
106  */
Popular Tags