%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.torque.adapter.DBCloudscape |
|
|
1 | package org.apache.torque.adapter; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
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 | 0 | { |
39 | 0 | } |
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 | 0 | 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 | 0 | return in; |
60 | } |
|
61 | ||
62 | /** |
|
63 | * @see org.apache.torque.adapter.DB#getIDMethodType() |
|
64 | */ |
|
65 | public String getIDMethodType() |
|
66 | { |
|
67 | 0 | 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 | 0 | StringBuffer sql = new StringBuffer(132); |
76 | 0 | sql.append("select distinct ConnectionInfo.lastAutoincrementValue("); |
77 | ||
78 | 0 | String qualifiedIdentifier = (String) obj; |
79 | ||
80 | 0 | StringTokenizer tokenizer = new StringTokenizer(qualifiedIdentifier, |
81 | QUALIFIER); |
|
82 | 0 | int count = tokenizer.countTokens(); |
83 | ||
84 | String schema, table, column; |
|
85 | ||
86 | 0 | System.out.println("qi = " + qualifiedIdentifier); |
87 | // no qualifiers, its simply a column name |
|
88 | 0 | switch (count) |
89 | { |
|
90 | case 0: |
|
91 | 0 | return ""; // not valid -- we need the column name and table name |
92 | case 1: |
|
93 | 0 | return ""; // not valid -- we need the table name to select from |
94 | ||
95 | case 2: |
|
96 | 0 | table = tokenizer.nextToken(); |
97 | 0 | column = tokenizer.nextToken(); |
98 | 0 | sql.append("'APP', '"); |
99 | 0 | sql.append(table); |
100 | 0 | break; |
101 | ||
102 | case 3: |
|
103 | 0 | schema = tokenizer.nextToken(); |
104 | 0 | table = tokenizer.nextToken(); |
105 | 0 | column = tokenizer.nextToken(); |
106 | 0 | sql.append("'"); |
107 | 0 | sql.append(schema); |
108 | 0 | sql.append("', '"); |
109 | 0 | sql.append(table); |
110 | 0 | break; |
111 | ||
112 | default: |
|
113 | 0 | return ""; // not valid |
114 | } |
|
115 | ||
116 | 0 | sql.append("', '"); |
117 | 0 | sql.append(column); |
118 | 0 | sql.append("') FROM "); |
119 | 0 | sql.append(table); |
120 | ||
121 | 0 | System.out.println(sql.toString()); |
122 | 0 | 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 | 0 | } |
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 | 0 | } |
146 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |