01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.lucene.store.jdbc.dialect;
18:
19: /**
20: * A SQLServer dialect.
21: *
22: * @author kimchy
23: */
24: public class SQLServerDialect extends SybaseDialect {
25:
26: public char closeQuote() {
27: return ']';
28: }
29:
30: public char openQuote() {
31: return '[';
32: }
33:
34: /**
35: * SQLServer supports if table exists queries.
36: */
37: public boolean supportsTableExists() {
38: return true;
39: }
40:
41: public String sqlTableExists(String catalog, String schemaName) {
42: StringBuffer sb = new StringBuffer();
43: sb
44: .append("select table_name from INFORMATION_SCHEMA.TABLES where lower(table_name) = ?");
45: if (schemaName != null) {
46: sb.append(" and lower(table_schema) = '").append(
47: schemaName.toLowerCase()).append("'");
48: }
49: if (catalog != null) {
50: sb.append(" and lower(table_catalog) = '").append(
51: catalog.toLowerCase()).append("'");
52: }
53: return sb.toString();
54: }
55: }
|