001: package org.apache.torque.adapter;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import java.sql.Connection;
023: import java.sql.SQLException;
024: import java.sql.Statement;
025:
026: /**
027: * This code should be used for an Informix database pool.
028: *
029: * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
030: * @author <a href="mailto:bpm@ec-group.com">Brian P Millett</a>
031: * @version $Id: DBInformix.java 473821 2006-11-11 22:37:25Z tv $
032: */
033: public class DBInformix extends AbstractDBAdapter {
034: /**
035: * Serial version
036: */
037: private static final long serialVersionUID = 2599963509284952957L;
038:
039: /**
040: * Empty constructor.
041: */
042: protected DBInformix() {
043: }
044:
045: /**
046: * This method is used to ignore case. Problem is that Informix
047: * does not have an UPPER function. So the best would be to do
048: * nothing.
049: *
050: * @param in The string to transform to upper case.
051: * @return The upper case string.
052: */
053: public String toUpperCase(String in) {
054: return in;
055: }
056:
057: /**
058: * This method is used to ignore case. Problem is that Informix
059: * does not have an UPPER function. So the best would be to do
060: * nothing.
061: *
062: * @param in The string whose case to ignore.
063: * @return The string in a case that can be ignored.
064: */
065: public String ignoreCase(String in) {
066: return in;
067: }
068:
069: /**
070: * @see org.apache.torque.adapter.DB#getIDMethodType()
071: */
072: public String getIDMethodType() {
073: return NO_ID_METHOD;
074: }
075:
076: /**
077: * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
078: */
079: public String getIDMethodSQL(Object obj) {
080: return null;
081: }
082:
083: /**
084: * The method is used to lock a table.
085: *
086: * @param con The JDBC connection to use.
087: * @param table The name of the table to lock.
088: * @exception SQLException No Statement could be created or executed.
089: */
090: public void lockTable(Connection con, String table)
091: throws SQLException {
092: Statement statement = con.createStatement();
093:
094: StringBuffer stmt = new StringBuffer();
095: stmt.append("LOCK TABLE ").append(table).append(
096: " IN EXCLUSIVE MODE");
097:
098: statement.executeQuery(stmt.toString());
099: }
100:
101: /**
102: * The method is used to unlock a table.
103: *
104: * @param con The JDBC connection to use.
105: * @param table The name of the table to unlock.
106: * @exception SQLException No Statement could be created or executed.
107: */
108: public void unlockTable(Connection con, String table)
109: throws SQLException {
110: // Tables in Informix are unlocked when a commit is issued.
111: // The user may have issued a commit but do it here to be
112: // sure.
113: con.commit();
114: }
115: }
|