1 package org.apache.torque.adapter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.sql.Connection;
23 import java.sql.SQLException;
24 import java.sql.Statement;
25
26 /***
27 * This is used to connect to SapDB databases.
28 *
29 * <a href="http://www.sapdb.org">http://www.sapdb.org</a>
30 *
31 * @author <a href="mailto:dave.polito@planetcad.com">Dave Polito</a>
32 * @version $Id: DBSapDB.java 473821 2006-11-11 22:37:25Z tv $
33 */
34 public class DBSapDB extends AbstractDBAdapter
35 {
36 /***
37 * Serial version
38 */
39 private static final long serialVersionUID = 8277068258155186370L;
40
41 /***
42 * Empty constructor.
43 */
44 protected DBSapDB()
45 {
46 }
47
48 /***
49 * This method is used to ignore case.
50 *
51 * @param in The string to transform to upper case.
52 * @return The upper case string.
53 */
54 public String toUpperCase(String in)
55 {
56 return new StringBuffer("UPPER(").append(in).append(")").toString();
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 new StringBuffer("UPPER(").append(in).append(")").toString();
68 }
69
70 /***
71 * @see org.apache.torque.adapter.DB#getIDMethodType()
72 */
73 public String getIDMethodType()
74 {
75 return SEQUENCE;
76 }
77
78 /***
79 * Returns the next key from a sequence. Uses the following
80 * implementation:
81 *
82 * <blockquote><code><pre>
83 * select sequenceName.nextval from dual
84 * </pre></code></blockquote>
85 *
86 * @param sequenceName The name of the sequence (should be of type
87 * <code>String</code>).
88 * @return SQL to retreive the next database key.
89 * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object)
90 */
91 public String getIDMethodSQL(Object sequenceName)
92 {
93 return ("select " + sequenceName + ".nextval from dual");
94 }
95
96 /***
97 * Locks the specified table.
98 *
99 * @param con The JDBC connection to use.
100 * @param table The name of the table to lock.
101 * @exception SQLException No Statement could be created or executed.
102 */
103 public void lockTable(Connection con, String table) throws SQLException
104 {
105 Statement statement = con.createStatement();
106
107 StringBuffer stmt = new StringBuffer();
108 stmt.append("SELECT next_id FROM ")
109 .append(table)
110 .append(" FOR UPDATE");
111
112 statement.executeQuery(stmt.toString());
113 }
114
115 /***
116 * This method is for the SqlExpression.quoteAndEscape rules. The rule is,
117 * any string in a SqlExpression with a BACKSLASH will either be changed to
118 * "//" or left as "\". SapDB does not need the escape character.
119 *
120 * @return false.
121 */
122
123 public boolean escapeText()
124 {
125 return false;
126 }
127
128 /***
129 * Unlocks the specified table.
130 *
131 * @param con The JDBC connection to use.
132 * @param table The name of the table to unlock.
133 * @exception SQLException No Statement could be created or
134 * executed.
135 */
136 public void unlockTable(Connection con, String table) throws SQLException
137 {
138
139
140 con.commit();
141 }
142 }