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.util.StringTokenizer;
25
26 /***
27 * This is used to connect to Cloudscape SQL databases.
28 *
29 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
30 * @version $Id: DBCloudscape.java 473821 2006-11-11 22:37:25Z tv $
31 */
32 public class DBCloudscape extends AbstractDBAdapter
33 {
34 /***
35 * Serial version
36 */
37 private static final long serialVersionUID = -7475830417640153351L;
38
39 /*** qualifier */
40 private static final String QUALIFIER = ".";
41
42 /***
43 * Constructor.
44 */
45 protected DBCloudscape()
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 in;
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 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#getIDMethodSQL(Object obj)
80 */
81 public String getIDMethodSQL(Object obj)
82 {
83 StringBuffer sql = new StringBuffer(132);
84 sql.append("select distinct ConnectionInfo.lastAutoincrementValue(");
85
86 String qualifiedIdentifier = (String) obj;
87
88 StringTokenizer tokenizer = new StringTokenizer(qualifiedIdentifier,
89 QUALIFIER);
90 int count = tokenizer.countTokens();
91
92 String schema, table, column;
93
94 System.out.println("qi = " + qualifiedIdentifier);
95
96 switch (count)
97 {
98 case 0:
99
100 case 1:
101 return "";
102
103 case 2:
104 table = tokenizer.nextToken();
105 column = tokenizer.nextToken();
106 sql.append("'APP', '");
107 sql.append(table);
108 break;
109
110 case 3:
111 schema = tokenizer.nextToken();
112 table = tokenizer.nextToken();
113 column = tokenizer.nextToken();
114 sql.append("'");
115 sql.append(schema);
116 sql.append("', '");
117 sql.append(table);
118 break;
119
120 default:
121 return "";
122 }
123
124 sql.append("', '");
125 sql.append(column);
126 sql.append("') FROM ");
127 sql.append(table);
128
129 System.out.println(sql.toString());
130 return sql.toString();
131 }
132
133 /***
134 * Locks the specified table.
135 *
136 * @param con The JDBC connection to use.
137 * @param table The name of the table to lock.
138 * @exception SQLException No Statement could be created or executed.
139 */
140 public void lockTable(Connection con, String table) throws SQLException
141 {
142 }
143
144 /***
145 * Unlocks the specified table.
146 *
147 * @param con The JDBC connection to use.
148 * @param table The name of the table to unlock.
149 * @exception SQLException No Statement could be created or executed.
150 */
151 public void unlockTable(Connection con, String table) throws SQLException
152 {
153 }
154 }