KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > torque > adapter > DBInformix


1 package org.apache.torque.adapter;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements. See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership. The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with 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,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied. See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */

21
22 import java.sql.Connection JavaDoc;
23 import java.sql.SQLException JavaDoc;
24 import java.sql.Statement JavaDoc;
25
26 /**
27  * This code should be used for an Informix database pool.
28  *
29  * @author <a HREF="mailto:jon@latchkey.com">Jon S. Stevens</a>
30  * @author <a HREF="mailto:bpm@ec-group.com">Brian P Millett</a>
31  * @version $Id: DBInformix.java 473821 2006-11-11 22:37:25Z tv $
32  */

33 public class DBInformix extends AbstractDBAdapter
34 {
35     /**
36      * Serial version
37      */

38     private static final long serialVersionUID = 2599963509284952957L;
39
40     /**
41      * Empty constructor.
42      */

43     protected DBInformix()
44     {
45     }
46
47     /**
48      * This method is used to ignore case. Problem is that Informix
49      * does not have an UPPER function. So the best would be to do
50      * nothing.
51      *
52      * @param in The string to transform to upper case.
53      * @return The upper case string.
54      */

55     public String JavaDoc toUpperCase(String JavaDoc in)
56     {
57         return in;
58     }
59
60     /**
61      * This method is used to ignore case. Problem is that Informix
62      * does not have an UPPER function. So the best would be to do
63      * nothing.
64      *
65      * @param in The string whose case to ignore.
66      * @return The string in a case that can be ignored.
67      */

68     public String JavaDoc ignoreCase(String JavaDoc in)
69     {
70         return in;
71     }
72
73     /**
74      * @see org.apache.torque.adapter.DB#getIDMethodType()
75      */

76     public String JavaDoc getIDMethodType()
77     {
78         return NO_ID_METHOD;
79     }
80
81     /**
82      * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
83      */

84     public String JavaDoc getIDMethodSQL(Object JavaDoc obj)
85     {
86         return null;
87     }
88
89     /**
90      * The method is used to lock a table.
91      *
92      * @param con The JDBC connection to use.
93      * @param table The name of the table to lock.
94      * @exception SQLException No Statement could be created or executed.
95      */

96     public void lockTable(Connection JavaDoc con, String JavaDoc table) throws SQLException JavaDoc
97     {
98         Statement JavaDoc statement = con.createStatement();
99
100         StringBuffer JavaDoc stmt = new StringBuffer JavaDoc();
101         stmt.append("LOCK TABLE ")
102         .append(table)
103         .append(" IN EXCLUSIVE MODE");
104
105         statement.executeQuery(stmt.toString());
106     }
107
108     /**
109      * The method is used to unlock a table.
110      *
111      * @param con The JDBC connection to use.
112      * @param table The name of the table to unlock.
113      * @exception SQLException No Statement could be created or executed.
114      */

115     public void unlockTable(Connection JavaDoc con, String JavaDoc table) throws SQLException JavaDoc
116     {
117         // Tables in Informix are unlocked when a commit is issued.
118
// The user may have issued a commit but do it here to be
119
// sure.
120
con.commit();
121     }
122 }
123
Popular Tags