Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/apache/derby/impl/sql/conn/CachedStatement.java


1   /*
2   
3      Derby - Class org.apache.derby.impl.sql.conn.CachedStatement
4   
5      Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
6   
7      Licensed under the Apache License, Version 2.0 (the "License");
8      you may not use this file except in compliance with the License.
9      You may obtain a copy of the License at
10  
11        http://www.apache.org/licenses/LICENSE-2.0
12  
13     Unless required by applicable law or agreed to in writing, software
14     distributed under the License is distributed on an "AS IS" BASIS,
15     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16     See the License for the specific language governing permissions and
17     limitations under the License.
18  
19   */
20  
21  package org.apache.derby.impl.sql.conn;
22  
23  import org.apache.derby.iapi.services.context.ContextManager;
24  
25  import org.apache.derby.iapi.error.StandardException;
26  import org.apache.derby.impl.sql.GenericPreparedStatement;
27  import org.apache.derby.impl.sql.GenericStatement;
28  
29  import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
30  
31  import org.apache.derby.iapi.sql.PreparedStatement;
32  
33  import org.apache.derby.iapi.services.cache.Cacheable;
34  
35  import org.apache.derby.iapi.services.sanity.SanityManager;
36  
37  import org.apache.derby.iapi.services.monitor.Monitor;
38  
39  /**
40    @author ames
41  */
42  public class CachedStatement implements Cacheable {
43  
44    private GenericPreparedStatement ps;
45    private Object identity;
46  
47    public CachedStatement() {
48    }
49  
50    /**
51     * Get the PreparedStatement that is associated with this Cacheable
52     */
53    public GenericPreparedStatement getPreparedStatement() {
54      return ps;
55    }
56  
57    /* Cacheable interface */
58  
59    /**
60  
61        @see Cacheable#clean
62    */
63    public void clean(boolean forRemove) {
64    }
65  
66    /**
67    */
68    public Cacheable setIdentity(Object key) {
69  
70      identity = key;
71      ps = new GenericPreparedStatement((GenericStatement) key);
72      ps.setCacheHolder(this);
73  
74      return this;
75    }
76  
77    /** @see Cacheable#createIdentity */
78    public Cacheable createIdentity(Object key, Object createParameter) {
79      if (SanityManager.DEBUG)
80        SanityManager.THROWASSERT("Not expecting any create() calls");
81  
82      return null;
83  
84    }
85  
86    /** @see Cacheable#clearIdentity */
87    public void clearIdentity() {
88  
89      if (SanityManager.DEBUG)
90        SanityManager.DEBUG("StatementCacheInfo","CLEARING IDENTITY: "+ps.getSource());
91      ps.setCacheHolder(null);
92  
93      identity = null;
94      ps = null;
95    }
96  
97    /** @see Cacheable#getIdentity */
98    public Object getIdentity() {
99      return identity;
100   }
101 
102   /** @see Cacheable#isDirty */
103   public boolean isDirty() {
104     return false;
105   }
106 
107   /* Cacheable interface */
108 }