View Javadoc

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;
23  import java.sql.SQLException;
24  
25  /***
26   * This is used to connect to Hypersonic SQL databases.
27   *
28   * <a href="http://hsqldb.org/">http://hsqldb.org/</a>
29   *
30   * @author <a href="mailto:celkins@scardini.com">Christopher Elkins</a>
31   * @version $Id: DBHypersonicSQL.java 476550 2006-11-18 16:08:37Z tfischer $
32   */
33  public class DBHypersonicSQL extends AbstractDBAdapter
34  {
35      /***
36       * Serial version
37       */
38      private static final long serialVersionUID = 8392727399615702372L;
39  
40      /***
41       * Constructor.
42       */
43      protected DBHypersonicSQL()
44      {
45      }
46  
47      /***
48       * This method is used to ignore case.
49       *
50       * @param in The string to transform to upper case.
51       * @return The upper case string.
52       */
53      public String toUpperCase(String in)
54      {
55          String s = new StringBuffer("UPPER(").append(in).append(")").toString();
56          return s;
57      }
58  
59      /***
60       * This method is used to ignore case.
61       *
62       * @param in The string whose case to ignore.
63       * @return The string in a case that can be ignored.
64       */
65      public String ignoreCase(String in)
66      {
67          return toUpperCase(in);
68      }
69  
70      /***
71       * @see org.apache.torque.adapter.DB#getIDMethodType()
72       */
73      public String getIDMethodType()
74      {
75          return AUTO_INCREMENT;
76      }
77  
78      /***
79       * @see org.apache.torque.adapter.DB#ignoreCaseInOrderBy(String)
80       */
81      public String ignoreCaseInOrderBy(String in)
82      {
83          return "CAST(" + in + " AS VARCHAR_IGNORECASE)";
84      }
85  
86      /***
87       * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
88       */
89      public String getIDMethodSQL(Object obj)
90      {
91          StringBuffer command = new StringBuffer("select IDENTITY() from ");
92          String qualifiedIdentifier = (String) obj;
93          command.append(qualifiedIdentifier);
94          return command.toString();
95      }
96  
97      /***
98       * Locks the specified table.
99       *
100      * @param con The JDBC connection to use.
101      * @param table The name of the table to lock.
102      * @exception SQLException No Statement could be created or executed.
103      */
104     public void lockTable(Connection con, String table) throws SQLException
105     {
106     }
107 
108     /***
109      * Unlocks the specified 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 con, String table) throws SQLException
116     {
117     }
118 
119     /***
120      * This method is for the SqlExpression.quoteAndEscape rules.  The rule is,
121      * any string in a SqlExpression with a BACKSLASH will either be changed to
122      * "//" or left as "\".
123      *
124      * @return false.
125      */
126     public boolean escapeText()
127     {
128         return false;
129     }
130 
131     /***
132      * Whether an escape clause in like should be used.
133      * Example : select * from AUTHOR where AUTHOR.NAME like '\_%' ESCAPE '\';
134      *
135      * HSQLDB needs this, so this implementation always returns
136      * <code>true</code>.
137      *
138      * @return whether the escape clause should be appended or not.
139      */
140     public boolean useEscapeClauseForLike()
141     {
142         return true;
143     }
144 }