View Javadoc

1   package org.apache.torque.adapter;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.sql.Connection;
20  import java.sql.SQLException;
21  import java.sql.Statement;
22  
23  /***
24   * This code should be used for an Informix database pool.
25   *
26   * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
27   * @author <a href="mailto:bpm@ec-group.com">Brian P Millett</a>
28   * @version $Id: DBInformix.java 239630 2005-08-24 12:25:32Z henning $
29   */
30  public class DBInformix extends DB
31  {
32      /***
33       * Empty constructor.
34       */
35      protected DBInformix()
36      {
37      }
38  
39      /***
40       * This method is used to ignore case.  Problem is that Informix
41       * does not have an UPPER function.  So the best would be to do
42       * nothing.
43       *
44       * @param in The string to transform to upper case.
45       * @return The upper case string.
46       */
47      public String toUpperCase(String in)
48      {
49          return in;
50      }
51  
52      /***
53       * This method is used to ignore case.  Problem is that Informix
54       * does not have an UPPER function.  So the best would be to do
55       * nothing.
56       *
57       * @param in The string whose case to ignore.
58       * @return The string in a case that can be ignored.
59       */
60      public String ignoreCase(String in)
61      {
62          return in;
63      }
64  
65      /***
66       * @see org.apache.torque.adapter.DB#getIDMethodType()
67       */
68      public String getIDMethodType()
69      {
70          return NO_ID_METHOD;
71      }
72  
73      /***
74       * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
75       */
76      public String getIDMethodSQL(Object obj)
77      {
78          return null;
79      }
80  
81      /***
82       * The method is used to lock a table.
83       *
84       * @param con The JDBC connection to use.
85       * @param table The name of the table to lock.
86       * @exception SQLException No Statement could be created or executed.
87       */
88      public void lockTable(Connection con, String table) throws SQLException
89      {
90          Statement statement = con.createStatement();
91  
92          StringBuffer stmt = new StringBuffer();
93          stmt.append("LOCK TABLE ")
94          .append(table)
95          .append(" IN EXCLUSIVE MODE");
96  
97          statement.executeQuery(stmt.toString());
98      }
99  
100     /***
101      * The method is used to unlock a table.
102      *
103      * @param con The JDBC connection to use.
104      * @param table The name of the table to unlock.
105      * @exception SQLException No Statement could be created or executed.
106      */
107     public void unlockTable(Connection con, String table) throws SQLException
108     {
109         // Tables in Informix are unlocked when a commit is issued.
110         // The user may have issued a commit but do it here to be
111         // sure.
112         con.commit();
113     }
114 }