KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > conn > CachedStatement


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.conn.CachedStatement
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.conn;
23
24 import org.apache.derby.iapi.services.context.ContextManager;
25
26 import org.apache.derby.iapi.error.StandardException;
27 import org.apache.derby.impl.sql.GenericPreparedStatement;
28 import org.apache.derby.impl.sql.GenericStatement;
29
30 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
31
32 import org.apache.derby.iapi.sql.PreparedStatement;
33
34 import org.apache.derby.iapi.services.cache.Cacheable;
35
36 import org.apache.derby.iapi.services.sanity.SanityManager;
37
38 import org.apache.derby.iapi.services.monitor.Monitor;
39
40 /**
41     @author ames
42 */

43 public class CachedStatement implements Cacheable {
44
45     private GenericPreparedStatement ps;
46     private Object JavaDoc identity;
47
48     public CachedStatement() {
49     }
50
51     /**
52      * Get the PreparedStatement that is associated with this Cacheable
53      */

54     public GenericPreparedStatement getPreparedStatement() {
55         return ps;
56     }
57
58     /* Cacheable interface */
59
60     /**
61
62         @see Cacheable#clean
63     */

64     public void clean(boolean forRemove) {
65     }
66
67     /**
68     */

69     public Cacheable setIdentity(Object JavaDoc key) {
70
71         identity = key;
72         ps = new GenericPreparedStatement((GenericStatement) key);
73         ps.setCacheHolder(this);
74
75         return this;
76     }
77
78     /** @see Cacheable#createIdentity */
79     public Cacheable createIdentity(Object JavaDoc key, Object JavaDoc createParameter) {
80         if (SanityManager.DEBUG)
81             SanityManager.THROWASSERT("Not expecting any create() calls");
82
83         return null;
84
85     }
86
87     /** @see Cacheable#clearIdentity */
88     public void clearIdentity() {
89
90         if (SanityManager.DEBUG)
91             SanityManager.DEBUG("StatementCacheInfo","CLEARING IDENTITY: "+ps.getSource());
92         ps.setCacheHolder(null);
93
94         identity = null;
95         ps = null;
96     }
97
98     /** @see Cacheable#getIdentity */
99     public Object JavaDoc getIdentity() {
100         return identity;
101     }
102
103     /** @see Cacheable#isDirty */
104     public boolean isDirty() {
105         return false;
106     }
107
108     /* Cacheable interface */
109 }
110
Popular Tags