%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.torque.adapter.DBCloudscape |
|
|
1 | package org.apache.torque.adapter; |
|
2 | ||
3 | /* |
|
4 | * Licensed to the Apache Software Foundation (ASF) under one |
|
5 | * or more contributor license agreements. See the NOTICE file |
|
6 | * distributed with this work for additional information |
|
7 | * regarding copyright ownership. The ASF licenses this file |
|
8 | * to you under the Apache License, Version 2.0 (the |
|
9 | * "License"); you may not use this file except in compliance |
|
10 | * with the License. You may obtain a copy of the License at |
|
11 | * |
|
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
13 | * |
|
14 | * Unless required by applicable law or agreed to in writing, |
|
15 | * software distributed under the License is distributed on an |
|
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
17 | * KIND, either express or implied. See the License for the |
|
18 | * specific language governing permissions and limitations |
|
19 | * under the License. |
|
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 | 0 | { |
47 | 0 | } |
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 | 0 | 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 | 0 | return in; |
68 | } |
|
69 | ||
70 | /** |
|
71 | * @see org.apache.torque.adapter.DB#getIDMethodType() |
|
72 | */ |
|
73 | public String getIDMethodType() |
|
74 | { |
|
75 | 0 | 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 | 0 | StringBuffer sql = new StringBuffer(132); |
84 | 0 | sql.append("select distinct ConnectionInfo.lastAutoincrementValue("); |
85 | ||
86 | 0 | String qualifiedIdentifier = (String) obj; |
87 | ||
88 | 0 | StringTokenizer tokenizer = new StringTokenizer(qualifiedIdentifier, |
89 | QUALIFIER); |
|
90 | 0 | int count = tokenizer.countTokens(); |
91 | ||
92 | String schema, table, column; |
|
93 | ||
94 | 0 | System.out.println("qi = " + qualifiedIdentifier); |
95 | // no qualifiers, its simply a column name |
|
96 | 0 | switch (count) |
97 | { |
|
98 | case 0: |
|
99 | /* return ""; */ // not valid -- we need the column name and table name |
|
100 | case 1: |
|
101 | 0 | return ""; // not valid -- we need the table name to select from |
102 | ||
103 | case 2: |
|
104 | 0 | table = tokenizer.nextToken(); |
105 | 0 | column = tokenizer.nextToken(); |
106 | 0 | sql.append("'APP', '"); |
107 | 0 | sql.append(table); |
108 | 0 | break; |
109 | ||
110 | case 3: |
|
111 | 0 | schema = tokenizer.nextToken(); |
112 | 0 | table = tokenizer.nextToken(); |
113 | 0 | column = tokenizer.nextToken(); |
114 | 0 | sql.append("'"); |
115 | 0 | sql.append(schema); |
116 | 0 | sql.append("', '"); |
117 | 0 | sql.append(table); |
118 | 0 | break; |
119 | ||
120 | default: |
|
121 | 0 | return ""; // not valid |
122 | } |
|
123 | ||
124 | 0 | sql.append("', '"); |
125 | 0 | sql.append(column); |
126 | 0 | sql.append("') FROM "); |
127 | 0 | sql.append(table); |
128 | ||
129 | 0 | System.out.println(sql.toString()); |
130 | 0 | 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 | 0 | } |
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 | 0 | } |
154 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |