1 package org.apache.torque.adapter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 Interbase database pool.
25 *
26 * @author <a href="mailto:frank@opticode.co.za">Frank Conradie</a>
27 * @version $Id: DBInterbase.java 239630 2005-08-24 12:25:32Z henning $
28 */
29 public class DBInterbase extends DB
30 {
31 /***
32 * This method is used to ignore case.
33 *
34 * @param in The string to transform to upper case.
35 * @return The upper case string.
36 */
37 public String toUpperCase(String in)
38 {
39 return new StringBuffer("UPPER(").append(in).append(")").toString();
40 }
41
42 /***
43 * This method is used to ignore case.
44 *
45 * @param in The string whose case to ignore.
46 * @return The string in a case that can be ignored.
47 */
48 public String ignoreCase(String in)
49 {
50 return new StringBuffer("UPPER(").append(in).append(")").toString();
51 }
52
53 /***
54 * This method is used to ignore case in an ORDER BY clause.
55 * Usually it is the same as ignoreCase, but some databases
56 * (Interbase for example) does not use the same SQL in ORDER BY
57 * and other clauses.
58 *
59 * @param in The string whose case to ignore.
60 * @return The string in a case that can be ignored.
61 */
62 public String ignoreCaseInOrderBy(String in)
63 {
64 return in;
65 }
66
67 /***
68 * Gets the string delimiter (usually '\'').
69 *
70 * @return The delimiter.
71 */
72 public char getStringDelimiter()
73 {
74 return '\'';
75 }
76
77 /***
78 * @see org.apache.torque.adapter.DB#getIDMethodType()
79 */
80 public String getIDMethodType()
81 {
82 return NO_ID_METHOD;
83 }
84
85 /***
86 * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
87 */
88 public String getIDMethodSQL(Object obj)
89 {
90 return null;
91 }
92
93 /***
94 * Locks the specified table.
95 *
96 * @param con The JDBC connection to use.
97 * @param table The name of the table to lock.
98 * @exception SQLException No Statement could be created or executed.
99 */
100 public void lockTable(Connection con, String table) throws SQLException
101 {
102 Statement statement = con.createStatement();
103
104 StringBuffer stmt = new StringBuffer();
105 stmt.append("SET TRANSACTION ")
106 .append("ISOLATION LEVEL READ COMMITTED ")
107 .append("NO RECORD_VERSION WAIT ")
108 .append("RESERVING ")
109 .append(table)
110 .append(" FOR PROTECTED WRITE");
111
112 statement.executeQuery(stmt.toString());
113 }
114
115 /***
116 * Unlocks the specified table.
117 *
118 * @param con The JDBC connection to use.
119 * @param table The name of the table to unlock.
120 * @exception SQLException No Statement could be created or executed.
121 */
122 public void unlockTable(Connection con, String table) throws SQLException
123 {
124
125
126
127 con.commit();
128 }
129 }