KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > sql > informix > InformixLogicalDatabase


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: InformixLogicalDatabase.java,v 1.1 2004/09/03 13:42:52 sinisa Exp $
22  */

23 package com.lutris.appserver.server.sql.informix;
24
25 import java.sql.SQLException JavaDoc;
26 import com.lutris.appserver.server.sql.ConnectionAllocator;
27 import com.lutris.appserver.server.sql.ObjectIdAllocator;
28 import com.lutris.appserver.server.sql.standard.StandardLogicalDatabase;
29 import com.lutris.appserver.server.sql.DatabaseManagerConfiguration;
30 import com.lutris.util.Config;
31 import com.lutris.util.ConfigException;
32
33
34 /**
35  * Represents a logical database with Informix capabilities.
36  *
37  * @author Kyle Clark
38  * @since LBS1.8
39  * @version $Revision: 1.1 $
40  */

41 public class InformixLogicalDatabase extends StandardLogicalDatabase {
42
43     /**
44      * The amount of time (in seconds) that
45      * a query will block before throwing an exception. If <= 0 then the
46      * query will not block. Optional, if not specified, then the value
47      * defaults to 0.
48      */

49     protected int defaultQueryTimeout = 0;
50
51     /**
52      * The amount of time (in seconds)
53      * that a transaction will block before throwing an exception. If
54      * <= 0 then the transaction will not block. Optional, if not specified,
55      * then the value defaults to 0.
56      */

57     protected int defaultTransactionTimeout = 0;
58
59     /**
60      * Default constructor to configure a single logical database.
61      * Note that the <CODE>init()</CODE> method must be called to
62      * configure the database.
63      */

64     public InformixLogicalDatabase() {
65         super();
66     }
67
68     /**
69      * Creates and configures a single logical database.
70      *
71      * @param dbName
72      * The logical name of the database. Used to
73      * @param dbConfig
74      * The configuration object for this logical Informix database.
75      * <p>
76      * The configuration data is specified in the section:
77      * <CODE>DatabaseManager.DB.<I>dbName</I></CODE>
78      * <p>
79      * The Informix specific configuration parameters are:
80      * <UL>
81      * <LI> <CODE>QueryTimeout</CODE> - The amount of time (in seconds) that
82      * a query will block before throwing an exception. If < 0 then the
83      * query will block indefinitly. Optional, if not specified, then the value
84      * defaults to 0.
85      * <LI> <CODE>TransactionTimeout</CODE> - The amount of time (in seconds)
86      * that a transaction will block before throwing an exception. If
87      * &lt; 0 then the transaction will block indefinitly. Optional, if not specified,
88      * then the value defaults to 0.
89      * </UL>
90      * @exception ConfigException
91      * If there is an error in the configuration file.
92      * @exception SQLException
93      * If a SQL error occurs.
94      */

95     public InformixLogicalDatabase(String JavaDoc dbName, Config dbConfig)
96         throws ConfigException, SQLException JavaDoc {
97         super(dbName, dbConfig);
98         this.defaultQueryTimeout = dbConfig.getInt("QueryTimeout", 0);
99         this.defaultTransactionTimeout = dbConfig.getInt("TransactionTimeout", 0);
100     }
101     
102     
103     /**
104      * Creates and configures a single logical database.
105      *
106      * @param dbName
107      * The logical name of the database. Used to
108      * @param dbConfig
109      * The configuration object for this logical Informix database.
110      * @param DbManagerConf
111      * The configuration object of DatabaseManager.
112      *
113      * <p>
114      * The configuration data is specified in the section:
115      * <CODE>DatabaseManager.DB.<I>dbName</I></CODE>
116      * <p>
117      * The Informix specific configuration parameters are:
118      * <UL>
119      * <LI> <CODE>QueryTimeout</CODE> - The amount of time (in seconds) that
120      * a query will block before throwing an exception. If < 0 then the
121      * query will block indefinitly. Optional, if not specified, then the value
122      * defaults to 0.
123      * <LI> <CODE>TransactionTimeout</CODE> - The amount of time (in seconds)
124      * that a transaction will block before throwing an exception. If
125      * &lt; 0 then the transaction will block indefinitly. Optional, if not specified,
126      * then the value defaults to 0.
127      * </UL>
128      * @exception ConfigException
129      * If there is an error in the configuration file.
130      * @exception SQLException
131      * If a SQL error occurs.
132      */

133     public InformixLogicalDatabase(String JavaDoc dbName, Config dbConfig, DatabaseManagerConfiguration DbManagerConf)
134         throws ConfigException, SQLException JavaDoc {
135         super(dbName, dbConfig, DbManagerConf);
136         this.defaultQueryTimeout = dbConfig.getInt("QueryTimeout", 0);
137         this.defaultTransactionTimeout = dbConfig.getInt("TransactionTimeout", 0);
138     }
139     
140     /**
141      * Return the connection allocator.
142      *
143      * @param connectionConfig
144      * The configuration object for the connection allocator.
145      * @exception ConfigException
146      * If there is an error in the configuration file.
147      * @return
148      * The connection allocator.
149      */

150     public ConnectionAllocator loadConnectionAllocator(Config connectionConfig)
151         throws ConfigException {
152         return new InformixConnectionAllocator(this, connectionConfig);
153     }
154
155     /**
156      * Return the object id allocator.
157      *
158      * @param objIdConfig
159      * The configuration object for the object id allocator.
160      * @exception ConfigException
161      * If there is an error in the configuration file.
162      * @return
163      * The object id allocator.
164      */

165     public ObjectIdAllocator loadObjectIdAllocator(Config objIdConfig)
166         throws ConfigException {
167         return new InformixObjectIdAllocator(this, objIdConfig);
168     }
169
170     /**
171      * Return a description of the logical database type.
172      *
173      * @return The type.
174      */

175     public String JavaDoc getType() {
176         return "Informix";
177     }
178
179     /**
180      * Returns the configured default amount of time (in seconds) that
181      * a query should block before throwing an exception. If < 0 then the
182      * query should block indefinitly.
183      *
184      * @return the default query timeout.
185      */

186     protected int getDefaultQueryTimeout() {
187         return defaultQueryTimeout;
188     }
189
190     /**
191      * Returns the configured default amount of time (in seconds)
192      * that a transaction should block before throwing an exception. If
193      * less than zero then the transaction should block indefinitly.
194      *
195      * @return the default transaction timeout.
196      */

197     protected int getDefaultTransactionTimeout() {
198         return defaultTransactionTimeout;
199     }
200 }
201
Popular Tags