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.util.StringTokenizer;
22
23 /***
24 * This is used to connect to Cloudscape SQL databases.
25 *
26 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
27 * @version $Id: DBCloudscape.java 239630 2005-08-24 12:25:32Z henning $
28 */
29 public class DBCloudscape extends DB
30 {
31 /*** qualifier */
32 private static final String QUALIFIER = ".";
33
34 /***
35 * Constructor.
36 */
37 protected DBCloudscape()
38 {
39 }
40 /***
41 * This method is used to ignore case.
42 *
43 * @param in The string to transform to upper case.
44 * @return The upper case string.
45 */
46 public String toUpperCase(String in)
47 {
48 return in;
49 }
50
51 /***
52 * This method is used to ignore case.
53 *
54 * @param in The string whose case to ignore.
55 * @return The string in a case that can be ignored.
56 */
57 public String ignoreCase(String in)
58 {
59 return in;
60 }
61
62 /***
63 * @see org.apache.torque.adapter.DB#getIDMethodType()
64 */
65 public String getIDMethodType()
66 {
67 return AUTO_INCREMENT;
68 }
69
70 /***
71 * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object obj)
72 */
73 public String getIDMethodSQL(Object obj)
74 {
75 StringBuffer sql = new StringBuffer(132);
76 sql.append("select distinct ConnectionInfo.lastAutoincrementValue(");
77
78 String qualifiedIdentifier = (String) obj;
79
80 StringTokenizer tokenizer = new StringTokenizer(qualifiedIdentifier,
81 QUALIFIER);
82 int count = tokenizer.countTokens();
83
84 String schema, table, column;
85
86 System.out.println("qi = " + qualifiedIdentifier);
87
88 switch (count)
89 {
90 case 0:
91 return "";
92 case 1:
93 return "";
94
95 case 2:
96 table = tokenizer.nextToken();
97 column = tokenizer.nextToken();
98 sql.append("'APP', '");
99 sql.append(table);
100 break;
101
102 case 3:
103 schema = tokenizer.nextToken();
104 table = tokenizer.nextToken();
105 column = tokenizer.nextToken();
106 sql.append("'");
107 sql.append(schema);
108 sql.append("', '");
109 sql.append(table);
110 break;
111
112 default:
113 return "";
114 }
115
116 sql.append("', '");
117 sql.append(column);
118 sql.append("') FROM ");
119 sql.append(table);
120
121 System.out.println(sql.toString());
122 return sql.toString();
123 }
124
125 /***
126 * Locks the specified table.
127 *
128 * @param con The JDBC connection to use.
129 * @param table The name of the table to lock.
130 * @exception SQLException No Statement could be created or executed.
131 */
132 public void lockTable(Connection con, String table) throws SQLException
133 {
134 }
135
136 /***
137 * Unlocks the specified table.
138 *
139 * @param con The JDBC connection to use.
140 * @param table The name of the table to unlock.
141 * @exception SQLException No Statement could be created or executed.
142 */
143 public void unlockTable(Connection con, String table) throws SQLException
144 {
145 }
146 }