KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > db > ConnectionInfo


1 /*
2
3    Derby - Class org.apache.derby.iapi.db.ConnectionInfo
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.db;
23
24 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
25 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
26 import org.apache.derby.iapi.error.StandardException;
27 import org.apache.derby.iapi.error.PublicAPI;
28 import java.sql.SQLException JavaDoc;
29
30 /**
31  *
32  * ConnectionInfo class provides static methods for getting information
33  * related to a JDBC connection.
34  *
35  * When called from within the query language,
36  * each method returns information about the connection from which it was called.
37  * <p>
38  * Use the methods of this class only within an SQL-J statement; do not call
39  * them directly.
40  */

41  
42 public abstract class ConnectionInfo
43 {
44
45     /** no requirement for a constructor */
46     private ConnectionInfo() {}
47
48     /**
49      * Get the last autoincrement value inserted into the column by
50      * a statement in this connection.
51
52      <BR><B> In JDBC 3.0 an application should use the standard methods provided by
53      JDBC 3.0 to obtain generated key values. See java.sql.Statement.getGeneratedKeys().</B>
54      *
55      * @param schemaName Name of the schema.
56      * @param tableName Name of the table.
57      * @param columnName Name of the column.
58      *
59      * @return the last value to be inserted into the named autoincrement
60      * column by this connection. Returns null if this connection has never
61      * inserted into this column.
62      *
63      * @exception SQLException if the current connection could not be
64      * established properly.
65      */

66     public static Long JavaDoc lastAutoincrementValue(String JavaDoc schemaName,
67                                               String JavaDoc tableName,
68                                               String JavaDoc columnName)
69             throws SQLException JavaDoc
70     {
71         // a static method can manipulate lcc?
72
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
73         return lcc.lastAutoincrementValue(schemaName, tableName, columnName);
74     }
75     
76     /**
77      * <B>INTERNAL USE ONLY</B>
78      * (<B>THIS METHOD MAY BE REMOVED IN A FUTURE RELEASE</B>.)
79      * @throws SQLException on error
80      **/

81     public static long nextAutoincrementValue(String JavaDoc schemaName,
82                                               String JavaDoc tableName,
83                                               String JavaDoc columnName
84                                               )
85          throws SQLException JavaDoc
86     {
87         LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
88         try
89         {
90             return
91                 lcc.nextAutoincrementValue(schemaName, tableName, columnName);
92         }
93         catch (StandardException se)
94         {
95             throw PublicAPI.wrapStandardException(se);
96         }
97     }
98 }
99
100
Popular Tags