KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > sql > conn > LanguageConnectionContext


1 /*
2
3    Derby - Class org.apache.derby.iapi.sql.conn.LanguageConnectionContext
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.iapi.sql.conn;
23
24 import org.apache.derby.iapi.services.context.Context;
25 import org.apache.derby.iapi.services.context.ContextManager;
26 import org.apache.derby.iapi.db.Database;
27 import org.apache.derby.iapi.error.StandardException;
28 import org.apache.derby.iapi.sql.compile.CompilerContext;
29 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
30 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
31 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
32 import org.apache.derby.iapi.sql.compile.OptimizerFactory;
33 import org.apache.derby.iapi.types.DataValueFactory;
34
35 import org.apache.derby.iapi.sql.depend.Provider;
36 import org.apache.derby.iapi.sql.execute.ConstantAction;
37 import org.apache.derby.iapi.sql.execute.CursorActivation;
38 import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
39 import org.apache.derby.iapi.sql.execute.ExecutionContext;
40 import org.apache.derby.iapi.sql.execute.ExecutionStmtValidator;
41 import org.apache.derby.iapi.sql.Activation;
42 import org.apache.derby.iapi.sql.LanguageFactory;
43 import org.apache.derby.iapi.sql.PreparedStatement;
44 import org.apache.derby.iapi.sql.ResultSet;
45 import org.apache.derby.iapi.sql.ParameterValueSet;
46
47 import org.apache.derby.iapi.store.access.TransactionController;
48 import org.apache.derby.iapi.store.access.AccessFactory;
49 import org.apache.derby.iapi.db.TriggerExecutionContext;
50 import org.apache.derby.iapi.services.i18n.LocaleFinder;
51 import org.apache.derby.iapi.sql.execute.RunTimeStatistics;
52 import org.apache.derby.catalog.UUID;
53
54 import java.util.Locale JavaDoc;
55 import java.util.Hashtable JavaDoc;
56 import java.util.Vector JavaDoc;
57
58 /**
59  * LanguageConnectionContext keeps the result sets,
60  * and activations in use by the current connection.
61  * <p>
62  * More stable items, like other factories, are accessible through
63  * the LanguageConnectionFactory or the LanguageFactory.
64  *
65  * @see LanguageConnectionFactory
66  * @see org.apache.derby.iapi.sql.LanguageFactory
67  */

68 public interface LanguageConnectionContext extends Context {
69
70     /**
71      * this is the ID we expect these contexts
72      * to be stored into a context manager under.
73      */

74     public static final String JavaDoc CONTEXT_ID = org.apache.derby.iapi.reference.ContextId.LANG_CONNECTION;
75
76     public static final int OUTERMOST_STATEMENT = 1;
77
78     // Constants describing how this connection handles schemas
79
public static final int SQL92_SCHEMAS = 0;
80     public static final int USER_NAME_SCHEMA = 1; // User names are schema names.
81
public static final int NO_SCHEMAS = 2; // Schemas not implemented.
82

83     /* String for logStatementText output */
84     public static final String JavaDoc xidStr = "(XID = ";
85     public static final String JavaDoc lccStr = "(SESSIONID = ";
86     public static final String JavaDoc dbnameStr = "(DATABASE = ";
87     public static final String JavaDoc drdaStr = "(DRDAID = ";
88
89     // Lock Management
90

91     public static final int SINGLE_TRANSACTION_LOCK = 1;
92     public static final int MULTI_TRANSACTION_LOCK = 2;
93
94     // controls casing of NON-delimited identifiers. ANSI casing forces all
95
// non-delimited identifiers to be lower case.
96

97     public static final int UNKNOWN_CASING = -1;
98     public static final int ANSI_CASING = 0;
99     public static final int ANTI_ANSI_CASING = 1;
100
101     /**
102      * Initialize. For use after pushing the contexts that initialization needs.
103      *
104      * @param sqlConnection Whether or not this is called from a sql connection.
105      *
106      * @exception StandardException thrown if something goes wrong
107      */

108     void initialize(boolean sqlConnection) throws StandardException;
109
110     /**
111      * Get value of logStatementText.
112      * (Whether or not to write info on currently
113      * executing statement to error log.)
114      *
115      * @return value of logStatementText
116      */

117     public boolean getLogStatementText();
118
119     /**
120      * Set value of logStatementText
121      * (Whether or not to write info on currently
122      * executing statement to error log.)
123      *
124      * @param logStatementText Whether or not logStatementText property is set.
125      */

126     public void setLogStatementText(boolean logStatementText);
127
128     /**
129      * Get value of logQueryPlan.
130      * (Whether or not to write query plan info on currently
131      * executing statement to error log.)
132      *
133      * @return value of logQueryPlan
134      */

135     public boolean getLogQueryPlan();
136
137     /**
138      * get the lock escalation threshold to use with this connection.
139      */

140     int getLockEscalationThreshold();
141
142     /**
143      * Add the activation to those known about by this connection.
144      *
145      */

146     void addActivation(Activation a)
147         throws StandardException;
148
149     /**
150      * Make a note that some activations are marked unused
151      */

152     void notifyUnusedActivation();
153
154     /**
155      * Remove the activation from those known about by this connection.
156      *
157      * @exception StandardException thrown if something goes wrong
158      */

159     void removeActivation(Activation a)
160         throws StandardException;
161
162     /**
163      * Return the number of activation known for this connection.
164      *
165      */

166     int getActivationCount();
167
168     /**
169      * See if a given cursor is available for use. This is used
170      * to locate the cursor during its execution.
171      *
172      * @return the activation for the given cursor, null if none exists.
173      */

174     CursorActivation lookupCursorActivation(String JavaDoc cursorName);
175
176     /**
177      * Return the last activation added
178      * This is used to find the drop activation in dropViewCascade
179      * so we can add warning messages to the activation
180      *
181      */

182     public Activation getLastActivation();
183
184     /**
185         Get a connection unique system generated name for a cursor.
186     */

187     public String JavaDoc getUniqueCursorName();
188
189     /**
190         Get a connection unique system generated name for an unnamed savepoint.
191     */

192     public String JavaDoc getUniqueSavepointName();
193
194     /**
195         Get a connection unique system generated id for an unnamed savepoint.
196     */

197     public int getUniqueSavepointID();
198
199     /**
200      * Check if there are any global temporary tables declared for this connection.
201      * @return true if there are declared temp tables for this connectoin else false
202      *
203      */

204     public boolean checkIfAnyDeclaredGlobalTempTablesForThisConnection();
205
206     /**
207      * Mark the passed temporary table as modified in the current unit of work. That information will be used at rollback time
208      * The compile phase will generate code to call this method if the DML is on a temporary table
209      *
210      * @param tableName Mark the passed temporary table name as modified
211      */

212     public void markTempTableAsModifiedInUnitOfWork(String JavaDoc tableName);
213   
214     /**
215      * Add the declared global temporary table to the list of temporary tables known by this connection.
216      * @param td Corresponding to the temporary table
217      *
218      */

219     public void addDeclaredGlobalTempTable(TableDescriptor td) throws StandardException;
220
221     /**
222      * Drop (mark the declared global temporary table for dropping) from the list of temporary tables known by this connection.
223      * @param tableName look for this table name in the saved list and drop it if found
224      * @return true if dropped the temporary table. False if no such temporary table exists.
225      *
226      * @see org.apache.derby.impl.sql.conn.TempTableInfo
227      */

228     public boolean dropDeclaredGlobalTempTable(String JavaDoc tableName);
229
230     /**
231      * Get table descriptor for the declared global temporary table from the list of temporary
232      * tables known by this connection.
233      * @param tableName Get table descriptor for the passed table name
234      * @return TableDescriptor if found the temporary table. Else return null
235      *
236      */

237     public TableDescriptor getTableDescriptorForDeclaredGlobalTempTable(String JavaDoc tableName);
238
239     /**
240         Reset the connection before it is returned (indirectly) by
241         a PooledConnection object. See EmbeddedConnection.
242      */

243     public void resetFromPool()
244          throws StandardException;
245
246     /**
247         Do a commit, as internally needed by Cloudscape. E.g.
248         a commit for sync, or a commit for autocommit. Skips
249         checks that a user isn't doing something bad like issuing
250         a commit in a nested xact.
251
252         @param commitStore true if we should commit the Store transaction
253
254         @exception StandardException thrown if something goes wrong
255      */

256     void internalCommit( boolean commitStore )
257          throws StandardException;
258
259     /**
260         Similar to internalCommit() but has logic for an unsynchronized commit
261
262         @param commitflag the flags to pass to commitNoSync in the store's
263                             TransactionController
264
265         @exception StandardException thrown if something goes wrong
266      */

267     void internalCommitNoSync(int commitflag) throws StandardException;
268
269     /**
270         Do a commit, as issued directly by a user (e.g. via Connection.commit()
271         or the JSQL 'COMMIT' statement.
272
273         @exception StandardException thrown if something goes wrong
274      */

275     void userCommit() throws StandardException;
276
277     /**
278         Commit a distrubuted transaction.
279
280         @param onePhase if true, allow it to commit without first going thru a
281         prepared state.
282
283         @exception StandardException thrown if something goes wrong
284      */

285     void xaCommit(boolean onePhase) throws StandardException;
286
287
288     /**
289         Do a rollback, as internally needed by Cloudscape. E.g.
290         a rollback for sync, or a rollback for an internal error. Skips
291         checks that a user isn't doing something bad like issuing
292         a rollback in a nested xact.
293
294         @exception StandardException thrown if something goes wrong
295      */

296     void internalRollback() throws StandardException;
297
298     /**
299         Do a rollback, as issued directly by a user (e.g. via Connection.rollback()
300         or the JSQL 'ROLLBACK' statement.
301
302         @exception StandardException thrown if something goes wrong
303      */

304     void userRollback() throws StandardException;
305
306     /**
307      * Let the context deal with a rollback to savepoint
308      *
309      * @param savepointName Name of the savepoint that needs to be rolled back
310      * @param refreshStyle boolean indicating whether or not the controller should close
311      * open conglomerates and scans. Also used to determine if language should close
312      * open activations.
313      * @param kindOfSavepoint A NULL value means it is an internal savepoint (ie not a user defined savepoint)
314      * Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint
315      * A String value for kindOfSavepoint would mean it is SQL savepoint
316      * A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
317      *
318      * @exception StandardException thrown if something goes wrong
319      */

320     void internalRollbackToSavepoint
321     ( String JavaDoc savepointName, boolean refreshStyle, Object JavaDoc kindOfSavepoint ) throws StandardException;
322
323     /**
324      * Let the context deal with a release of a savepoint
325      *
326      * @param savepointName Name of the savepoint that needs to be released
327      * @param kindOfSavepoint A NULL value means it is an internal savepoint (ie not a user defined savepoint)
328      * Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint
329      * A String value for kindOfSavepoint would mean it is SQL savepoint
330      * A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
331      *
332      * @exception StandardException thrown if something goes wrong
333      */

334     void releaseSavePoint ( String JavaDoc savepointName, Object JavaDoc kindOfSavepoint ) throws StandardException;
335
336
337     /**
338         Roll back a distrubuted transaction.
339
340         @exception StandardException thrown if something goes wrong
341      */

342     void xaRollback() throws StandardException;
343
344     /**
345       Sets a savepoint. Causes the Store to set a savepoint.
346
347       @param savepointName name of savepoint
348       @param kindOfSavepoint A NULL value means it is an internal savepoint (ie not a user defined savepoint)
349       Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint
350       A String value for kindOfSavepoint would mean it is SQL savepoint
351       A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
352
353         @exception StandardException thrown if something goes wrong
354       */

355     void languageSetSavePoint( String JavaDoc savepointName, Object JavaDoc kindOfSavepoint ) throws StandardException;
356
357     /**
358         Returns true if any transaction is blocked (even if not by this one)
359
360      */

361     boolean anyoneBlocked();
362
363     /**
364         Sets the transaction controller to use with this language connection
365         context.
366
367         @param tran the transaction to use with this language connection context
368      */

369     void setTransaction( TransactionController tran );
370
371     /**
372      * Begin a nested transaction.
373      *
374      * @param readOnly The nested transaction would be read only if param value true
375      *
376      * @exception StandardException on error.
377      * @see TransactionController#startNestedUserTransaction
378      */

379
380     void beginNestedTransaction(boolean readOnly) throws StandardException;
381
382     /**
383      * commit a nested transaction.
384      * We do not provide a abortNestedTransaction.
385      * If a nested xaction is aborted, then this results in the parent xaction
386      * also being aborted. This is not what we need for releasing
387      * compile time locks or autoincrement-- hence we do not provide
388      * abortNestedTransaction.
389      *
390      * @exception StandardException thrown on erro
391      *
392      * @see TransactionController#startNestedUserTransaction
393      */

394     void commitNestedTransaction() throws StandardException;
395
396     /**
397         Get the transaction controller to use with this language connection
398         context at compile time.
399      */

400     TransactionController getTransactionCompile();
401
402     /**
403         Get the transaction controller to use with this language connection
404         context during execute time.
405      */

406
407     TransactionController getTransactionExecute();
408
409     /**
410      * Get the system schema name.
411      *
412      * @return a String containing the system schema name.
413      */

414     public String JavaDoc getSystemSchemaName() throws StandardException;
415     
416     /**
417      * Get the SYSIBM schema name.
418      *
419      * @return a String containing the SYSIBM schema name.
420      */

421     public String JavaDoc getSysIBMSchemaName() throws StandardException;
422
423     /**
424      * Get the SYSCS_DIAG schema name.
425      *
426      * @return a String containing the SYSIBM schema name.
427      */

428     public String JavaDoc getSystemDiagSchemaName() throws StandardException;
429
430     /**
431      * Get the SYSCS_UTIL schema name.
432      *
433      * @return a String containing the SYSIBM schema name.
434      */

435     public String JavaDoc getSystemUtilSchemaName() throws StandardException;
436     
437     /**
438         Get the data dictionary
439
440         @return the data dictionary
441
442      */

443     public DataDictionary getDataDictionary();
444
445     /**
446         Get the data value factory to use with this language connection
447         context.
448      */

449     DataValueFactory getDataValueFactory();
450
451     /**
452         Get the language factory to use with this language connection
453         context.
454      */

455     LanguageFactory getLanguageFactory();
456
457     /**
458      * get the optimizer factory to use with this language connection context.
459      */

460     OptimizerFactory getOptimizerFactory();
461     
462     /**
463         Get the language connection factory to use with this language connection
464         context.
465      */

466     LanguageConnectionFactory getLanguageConnectionFactory();
467
468     /**
469      * Get the Authorization Id
470      *
471      * @return String the authorization id
472      */

473     public String JavaDoc getAuthorizationId();
474
475     /**
476      * Get the declared global temporary tables schema name.
477      *
478      * @return a String containing the declared global temporary tables schema name.
479      */

480     public String JavaDoc getDeclaredGlobalTemporaryTablesSchemaName() throws StandardException;
481   
482     /**
483      * Get the current default schema
484      *
485      * @return SchemaDescriptor the current schema
486      */

487     public SchemaDescriptor getDefaultSchema();
488
489     /**
490      * Set the current default schema
491      *
492      * @param sd the new default schema
493      *
494      * @exception StandardException thrown on failure
495      */

496     public void setDefaultSchema(SchemaDescriptor sd)
497         throws StandardException;
498
499     /**
500      * Get the current schema name
501      *
502      * @return SchemaDescriptor the current schema
503      */

504     public String JavaDoc getCurrentSchemaName();
505
506     /**
507      * Get the identity column value most recently generated.
508      *
509      * @return the generated identity column value
510      */

511     public Long JavaDoc getIdentityValue();
512
513     /**
514      * Set the field of most recently generated identity column value.
515      *
516      * @param val the generated identity column value
517      */

518     public void setIdentityValue(long val);
519
520     /**
521      * Verify that there are no activations with open result sets
522      * on the specified prepared statement.
523      *
524      * @param pStmt The prepared Statement
525      * @param provider The object precipitating a possible invalidation
526      * @param action The action causing the possible invalidation
527      *
528      * @return Nothing.
529      *
530      * @exception StandardException thrown on failure
531      */

532     boolean verifyNoOpenResultSets(PreparedStatement pStmt, Provider provider,
533                                        int action)
534             throws StandardException;
535
536     /**
537      * Verify that there are no activations with open held result sets.
538      *
539      * @return boolean Found no open resultsets.
540      *
541      * @exception StandardException thrown on failure
542      */

543     public boolean verifyAllHeldResultSetsAreClosed()
544             throws StandardException;
545
546     /**
547      * Push a CompilerContext on the context stack with
548      * the current default schema as the default schema
549      * which we compile against.
550      *
551      * @return the compiler context
552      *
553      * @exception StandardException thrown on failure
554      */

555     public CompilerContext pushCompilerContext();
556
557     /**
558      * Push a CompilerContext on the context stack with
559      * the passed in default schema as the default schema
560      * we compile against.
561      *
562      * @param sd the default schema
563      *
564      * @return the compiler context
565      *
566      * @exception StandardException thrown on failure
567      */

568     public CompilerContext pushCompilerContext(SchemaDescriptor sd);
569
570     /**
571      * Pop a CompilerContext off the context stack.
572      *
573      * @param compilerContext The compiler context.
574      *
575      * @exception StandardException thrown on failure
576      */

577     public void popCompilerContext(CompilerContext compilerContext);
578
579     /**
580      * Push a StatementContext on the context stack.
581      *
582      * @param isAtomic whether a commit/rollback is permitted
583      * from a nested connection under this statement
584      *
585      * @param stmtText the text of the statement. Needed for any language
586      * statement (currently, for any statement that can cause a trigger
587      * to fire). Please set this unless you are some funky jdbc setXXX
588      * method or something.
589      *
590      * @param pvs parameter value set, if it has one
591      *
592      * @param rollbackParentContext True if 1) the statement context is
593      * NOT a top-level context, AND 2) in the event of a statement-level
594      * exception, the parent context needs to be rolled back, too.
595      *
596      * @param timeoutMillis Timeout value for this statement, in milliseconds.
597      * Zero means no timeout.
598      *
599      * @return StatementContext The statement context.
600      *
601      */

602     StatementContext pushStatementContext(boolean isAtomic, boolean isForReadOnly, String JavaDoc stmtText,
603         ParameterValueSet pvs, boolean rollbackParentContext, long timeoutMillis);
604
605     /**
606      * Pop a StatementContext of the context stack.
607      *
608      * @param statementContext The statement context.
609      * @param error The error, if any (Only relevant for DEBUG)
610      */

611     public void popStatementContext(StatementContext statementContext,
612                                     Throwable JavaDoc error);
613
614     /**
615      * Push a new execution statement validator. An execution statement
616      * validator is an object that validates the current statement to
617      * ensure that it is permitted given the current execution context.
618      * An example of a validator a trigger ExecutionStmtValidator that
619      * doesn't allow ddl on the trigger target table.
620      * <p>
621      * Multiple ExecutionStmtValidators may be active at any given time.
622      * This mirrors the way there can be multiple connection nestings
623      * at a single time. The validation is performed by calling each
624      * validator's validateStatement() method. This yields the union
625      * of all validations.
626      *
627      * @param validator the validator to add
628      */

629     public void pushExecutionStmtValidator(ExecutionStmtValidator validator);
630
631     /**
632      * Remove the validator. Does an object identity (validator == validator)
633      * comparison. Asserts that the validator is found.
634      *
635      * @param validator the validator to remove
636      *
637      * @exception StandardException on error
638      */

639     public void popExecutionStmtValidator(ExecutionStmtValidator validator)
640         throws StandardException;
641
642     /**
643      * Validate a statement. Does so by stepping through all the validators
644      * and executing them. If a validator throws and exception, then the
645      * checking is stopped and the exception is passed up.
646      *
647      * @param constantAction the constantAction that is about to be executed (and
648      * should be validated
649      *
650      * @exception StandardException on validation failure
651      */

652     public void validateStmtExecution(ConstantAction constantAction)
653         throws StandardException;
654     
655     /**
656      * Push a new trigger execution context.
657      * <p>
658      * Multiple TriggerExecutionContexts may be active at any given time.
659      *
660      * @param tec the trigger execution context
661      *
662      * @exception StandardException on trigger recursion error
663      */

664     public void pushTriggerExecutionContext(TriggerExecutionContext tec)
665         throws StandardException;
666
667     /**
668      * Remove the tec. Does an object identity (tec == tec)
669      * comparison. Asserts that the tec is found.
670      *
671      * @param tec the tec to remove
672      *
673      * @exception StandardException on error
674      */

675     public void popTriggerExecutionContext(TriggerExecutionContext tec)
676         throws StandardException;
677
678     /**
679      * Get the topmost tec.
680      *
681      * @return the tec
682      */

683     public TriggerExecutionContext getTriggerExecutionContext();
684
685     /**
686      * Set the trigger table descriptor. Used to compile
687      * statements that may special trigger pseudo tables.
688      *
689      * @param td the table that the trigger is
690      * defined upon
691      *
692      */

693     public void pushTriggerTable(TableDescriptor td);
694
695     /**
696      * Remove the trigger table descriptor.
697      *
698      * @param td the table to remove from the stack.
699      */

700     public void popTriggerTable(TableDescriptor td);
701
702     /**
703      * Get the topmost trigger table descriptor
704      *
705      * @return the table descriptor, or null if we
706      * aren't in the middle of compiling a create
707      * trigger.
708      */

709     public TableDescriptor getTriggerTable();
710
711     /**
712      * Increment the DataDictionary bind count. This is for keeping track
713      * of nested binding, which can happen if SQL statements are bound from
714      * within static initializers.
715      *
716      * @return The new bind count
717      */

718     int incrementBindCount();
719
720     /**
721      * Decrement the DataDictionary bind count.
722      *
723      * @return The new bind count
724      */

725     int decrementBindCount();
726
727     /**
728      * Get the DataDictionary bind count.
729      *
730      * @return The current bind count.
731      */

732     int getBindCount();
733
734     /**
735      * Remember that the DataDictionary is in write mode, so we can take
736      * it out of write mode at the end of the transaction.
737      */

738     void setDataDictionaryWriteMode();
739
740     /**
741      * Return true if the data dictionary is in write mode (that is, this
742      * context was informed that is is in write mode by the method call
743      * setDataDictionaryWriteMode().
744      */

745     boolean dataDictionaryInWriteMode();
746
747     /**
748      * Turn RUNTIMESTATISTICS on or off.
749      */

750     public void setRunTimeStatisticsMode(boolean onOrOff);
751
752     /**
753      * Get the RUNTIMESTATISTICS mode.
754      */

755     public boolean getRunTimeStatisticsMode();
756
757     /**
758      * Turn STATISTICS TIMING on or off.
759      */

760     public void setStatisticsTiming(boolean onOrOff);
761
762     /**
763      * Get the STATISTICS TIMING mode.
764      */

765     public boolean getStatisticsTiming();
766
767     /**
768      * Set the RUNTIMESTATISTICS object.
769      */

770     public void setRunTimeStatisticsObject(RunTimeStatistics runTimeStatisticsObject);
771
772     /**
773      * Get the RUNTIMESTATISTICS object.
774      */

775     public RunTimeStatistics getRunTimeStatisticsObject();
776
777
778     /**
779       * Reports how many statement levels deep we are.
780       *
781       * @return a statement level >= OUTERMOST_STATEMENT
782       */

783     public int getStatementDepth();
784
785     /**
786       Returns the Database of this connection.
787      */

788     public Database getDatabase();
789
790     /**
791      * Returns true if isolation level has been set using JDBC/SQL.
792      */

793     public boolean isIsolationLevelSetUsingSQLorJDBC();
794     /**
795      * Reset the isolation level flag used to keep correct isolation level
796      * state in BrokeredConnection. This resetting will happen at the start
797      * and end of a global transaction, after the BrokeredConection's
798      * isolation level state is brought upto date with the EmbedConnection's
799      * isolation state.
800      * The flag gets set to true when isolation level is set using JDBC/SQL.
801      */

802     public void resetIsolationLevelFlagUsedForSQLandJDBC();
803
804     /**
805      * Set current isolation level.
806      *
807      * @param isolationLevel The new isolationLevel.
808      */

809     public void setIsolationLevel(int isolationLevel) throws StandardException;
810
811     /**
812      * Get the current isolation level.
813      *
814      * @return The current isolation level.
815      */

816     public int getCurrentIsolationLevel();
817
818     /**
819      * Get the current isolation level in DB2 format.
820      *
821      * @return The current isolation level as a 2 character string.
822      */

823     public String JavaDoc getCurrentIsolationLevelStr();
824     public void setPrepareIsolationLevel(int isolationLevel) ;
825
826     /**
827      * Get the prepare isolation level.
828      * If the isolation level has been explicitly set with a SQL statement or
829      * embedded call to setTransactionIsolation, this will return
830      * ExecutionContext.UNSPECIFIED_ISOLATION_LEVEL
831      * SET ISOLATION always takes priority.
832      *
833      */

834     public int getPrepareIsolationLevel();
835
836     /**
837      * Set the readOnly status for the current connection. This can
838      * only be called when the current transaction has not done
839      * any work.
840      *
841      * @param onOrOff true sets the connection to be readOnly and
842      * false sets it to readWrite.
843      *
844      * @exception StandardException The call failed and the readOnly
845      * status has not changed.
846      */

847     public void setReadOnly(boolean onOrOff) throws StandardException;
848
849     /**
850       * Get the readOnly status for the current connection.
851       */

852     public boolean isReadOnly();
853
854     /**
855      * Get an Authorizer for this connection.
856      */

857     public Authorizer getAuthorizer();
858
859     /**
860      * Get the current ExecutionContext.
861      */

862     ExecutionContext getExecutionContext();
863
864     /**
865      * Get the current StatementContext.
866      */

867     StatementContext getStatementContext();
868
869     /** Get the AccessFactory cached in this LanguageConnectionContext */
870     AccessFactory getAccessFactory();
871
872     /**
873      * Return a PreparedStatement object for the query.
874      * This method first tries to locate the PreparedStatement object from a statement
875      * cache. If the statement is not found in the cache, the query will be compiled and
876      * put into the cache.
877      * @param compilationSchema schema
878      * @param sqlText sql query string
879      * @param isForReadOnly read only status for resultset. Set to true if the concurrency mode for the resultset
880      * is CONCUR_READ_ONLY
881      * @param allowInternalSyntax If true, then this query is allowed to use internal
882      * sql syntax. One instance where this will be true is if a
883      * metadata query is getting executed.
884      */

885          public PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema,
886                 String JavaDoc sqlText, boolean isForReadOnly, boolean allowInternalSyntax)
887         throws StandardException;
888
889         /**
890      * Return a PreparedStatement object for the query.
891      * This method first tries to locate the PreparedStatement object from a statement
892      * cache. If the statement is not found in the cache, the query will be compiled and
893      * put into the cache.
894      * The schema used when compiling the statement is the same schema as returned by
895      * getDefaultSchema(). For internal statements, the read only status is set to
896      * true.
897      * Calling this method is equivalent to calling
898      * prepareExternalStatement(lcc.getDefaultSchema(), sqlText, true);
899      *
900      * @param sqlText sql query string
901      */

902         public PreparedStatement prepareInternalStatement(String JavaDoc sqlText)
903         throws StandardException;
904
905     /**
906      * Control whether or not optimizer trace is on.
907      *
908      * @param onOrOff Whether to turn optimizer trace on (true) or off (false).
909      *
910      * @return Whether or not the call was successful. (false will be returned when optimizer tracing is not supported.)
911      */

912     public boolean setOptimizerTrace(boolean onOrOff);
913
914     /**
915      * Get whether or not optimizer trace is on.
916      *
917      * @return Whether or not optimizer trace is on.
918      */

919     public boolean getOptimizerTrace();
920
921     /**
922      * Control whether or not optimizer trace is generated in html.
923      *
924      * @param onOrOff Whether or not optimizer trace will be in html (true) or not (false).
925      *
926      * @return Whether or not the call was successful. (false will be returned when optimizer tracing is not supported.)
927      */

928     public boolean setOptimizerTraceHtml(boolean onOrOff);
929
930     /**
931      * Get whether or not optimizer trace html is on.
932      *
933      * @return Whether or not optimizer trace html is on.
934      */

935     public boolean getOptimizerTraceHtml();
936
937     /**
938      * Get the optimizer trace output for the last optimized query as a String. If optimizer trace
939      * html is on, then the String will contain the html tags.
940      *
941      * @return The optimizer trace output for the last optimized query as a String.
942      * Null will be returned if optimizer trace output is off or not supported
943      * or no trace output was found or an exception occurred.
944      */

945     public String JavaDoc getOptimizerTraceOutput();
946
947     /**
948      * Set the optimizer trace output to the specified String.
949      * (Done at the beginning of each statement.)
950      */

951     public void setOptimizerTraceOutput(String JavaDoc startingText);
952
953     /**
954      * Append the latest output to the optimizer trace output.
955      */

956     public void appendOptimizerTraceOutput(String JavaDoc output);
957
958     /**
959       * Reports whether there is any outstanding work in the transaction.
960       *
961       * @return true if there is outstanding work in the transaction
962       * false otherwise
963       */

964     public boolean isTransactionPristine();
965
966     /**
967       * Get the lock handle for the current transaction.
968       *
969       * @param lockScope SINGLE_TRANSACTION_LOCK or MULTI_TRANSACTION_LOCK
970       *
971       * @return the current lock handle
972       *
973       * @exception StandardException thrown if something goes wrong
974       */

975     public Object JavaDoc getLockObject( int lockScope ) throws StandardException;
976
977     /**
978       * Get casing for delimited identifiers. This feature is here to
979       * support the Plugin.
980       *
981       * @return ANSI_CASING or ANTI_ANSI_CASING.
982       *
983       * @exception StandardException thrown if something goes wrong
984       */

985     public int getIdentifierCasing() throws StandardException;
986
987     /**
988      * Convert an identifier to the proper case for this connection. This method
989      * is here to support the Plugin.
990      *
991      * @param id an identifier string
992      * @return the string converted to upper or lower case, as appropriate
993      *
994      * @exception StandardException thrown if something goes wrong
995      */

996     public String JavaDoc convertIdentifierCase( String JavaDoc id) throws StandardException;
997
998
999     /**
1000     * Returns the last autoincrement value inserted by this connection.
1001     * If no values have been inserted into the given column a NULL value
1002     * is returned.
1003     *
1004     * @param schemaName
1005     * @param tableName
1006     * @param columnName
1007     */

1008    public Long JavaDoc lastAutoincrementValue(String JavaDoc schemaName,
1009                                       String JavaDoc tableName,
1010                                       String JavaDoc columnName);
1011
1012    /**
1013     * Sets autoincrementUpdate-- this variable allows updates to autoincrement
1014     * columns if it is set to true. The default is ofcourse false; i.e
1015     * ai columns cannot be directly modified by the user. This is set to
1016     * true by AlterTableConstantAction, when a new ai column is being added
1017     * to an existing table.
1018     *
1019     * @param flag the value for autoincrementUpdate (TRUE or FALSE)
1020     * @see org.apache.derby.impl.sql.execute.AlterTableConstantAction#updateNewAutoincrementColumn
1021     *
1022     */

1023    public void setAutoincrementUpdate(boolean flag);
1024
1025    /**
1026     * Returns the current value of autoincrementUpdate.
1027     *
1028     * @return true if updates to autoincrement columns is permitted.
1029     */

1030    public boolean getAutoincrementUpdate();
1031
1032    /**
1033     * copy a hashtable of autoincrement key value pairs into the cache of
1034     * ai values stored in the language connection context.
1035     */

1036    public void copyHashtableToAIHT(Hashtable JavaDoc from);
1037    
1038    /**
1039     * returns the <b>next</b> value to be inserted into an autoincrement col.
1040     * This is used internally by the system to generate autoincrement values
1041     * which are going to be inserted into a autoincrement column. This is
1042     * used when as autoincrement column is added to a table by an alter
1043     * table statemenet and during bulk insert.
1044     *
1045     * @param schemaName
1046     * @param tableName
1047     * @param columnName identify the column uniquely in the system.
1048     *
1049     * @exception StandardException on error.
1050     */

1051    public long nextAutoincrementValue(String JavaDoc schemaName, String JavaDoc tableName,
1052                                       String JavaDoc columnName)
1053        throws StandardException;
1054
1055    /**
1056     * Flush the cache of autoincrement values being kept by the lcc.
1057     * This will result in the autoincrement values being written to the
1058     * SYSCOLUMNS table as well as the mapping used by lastAutoincrementValue
1059     *
1060     * @param tableUUID the table which is being flushed; we need this value to
1061     * identify the table for which the autoincrement counter is being
1062     * maintained.
1063     *
1064     * @exception StandardException thrown on error.
1065     *
1066     * @see LanguageConnectionContext#lastAutoincrementValue
1067     * @see org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext#lastAutoincrementValue
1068     * @see org.apache.derby.iapi.db.ConnectionInfo#lastAutoincrementValue
1069     */

1070    public void autoincrementFlushCache(UUID tableUUID)
1071        throws StandardException;
1072
1073    /**
1074     * Create an autoincrement counter to be used on behalf of a SQL-J
1075     * statement. The counter is identified by (schemaName, tableName,
1076     * columnName). The counter must be freed up by calling
1077     * autoincrementFlushCache at the end of the statement. It is expected
1078     * that a ai-counter with the same signaure doesn't exist when the
1079     * method is called.
1080     *
1081     * @param s SchemaName
1082     * @param t TableName
1083     * @param c ColumnName
1084     * @param initialValue initial value of the counter.
1085     * @param increment increment for the counter.
1086     * @param position column position (1-based).
1087     */

1088    public void autoincrementCreateCounter(String JavaDoc s, String JavaDoc t, String JavaDoc c,
1089                                           Long JavaDoc initialValue, long increment,
1090                                           int position);
1091    
1092    /**
1093     * Get the instance number of this LCC.
1094     *
1095     * @return instance number of this LCC.
1096     */

1097    public int getInstanceNumber();
1098
1099    /**
1100     * Get the DRDA ID of this LCC.
1101     *
1102     * @return DRDA ID this LCC.
1103     */

1104    public String JavaDoc getDrdaID();
1105
1106    /**
1107     * Set the DRDA ID of this LCC.
1108     *
1109     * @param drdaID DRDA ID.
1110     */

1111    public void setDrdaID(String JavaDoc drdaID);
1112
1113    /**
1114     * Get the database name of this LCC.
1115     *
1116     * @return database name of this LCC.
1117     */

1118    public String JavaDoc getDbname();
1119
1120    /**
1121     * Check if in SQL standard mode, with support for Grant & Revoke
1122     *
1123     * @return True if SQL standard permissions are being used
1124     */

1125    public boolean usesSqlAuthorization();
1126}
1127
Popular Tags