001: /* Copyright (c) 2001-2005, The HSQL Development Group
002: * All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * Redistributions of source code must retain the above copyright notice, this
008: * list of conditions and the following disclaimer.
009: *
010: * Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * Neither the name of the HSQL Development Group nor the names of its
015: * contributors may be used to endorse or promote products derived from this
016: * software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
022: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
026: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030:
031: package org.hsqldb.util;
032:
033: import java.sql.ResultSet;
034: import java.sql.ResultSetMetaData;
035: import java.sql.SQLException;
036: import java.sql.Types;
037:
038: // sqlbob@users 20020325 - patch 1.7.0 - reengineering
039:
040: /**
041: * Conversions to / from Hsqldb
042: *
043: * @author sqlbob@users
044: * @version 1.7.0
045: */
046: class HsqldbTransferHelper extends TransferHelper {
047:
048: public HsqldbTransferHelper() {
049: super ();
050: }
051:
052: public HsqldbTransferHelper(TransferDb database, Traceable t,
053: String q) {
054: super (database, t, q);
055: }
056:
057: int convertFromType(int type) {
058:
059: if (type == 100) {
060: type = Types.VARCHAR;
061:
062: tracer
063: .trace("Converted HSQLDB VARCHAR_IGNORECASE to VARCHAR");
064: }
065:
066: return (type);
067: }
068:
069: String fixupColumnDefRead(TransferTable t, ResultSetMetaData meta,
070: String columnType, ResultSet columnDesc, int columnIndex)
071: throws SQLException {
072:
073: String CompareString = "INTEGER IDENTITY";
074:
075: if (columnType.indexOf(CompareString) >= 0) {
076:
077: // We just found a increment
078: columnType = "SERIAL";
079: }
080:
081: return (columnType);
082: }
083:
084: String fixupColumnDefWrite(TransferTable t, ResultSetMetaData meta,
085: String columnType, ResultSet columnDesc, int columnIndex)
086: throws SQLException {
087:
088: if (columnType.indexOf("SERIAL") >= 0) {
089: columnType = " INTEGER IDENTITY ";
090: }
091:
092: return (columnType);
093: }
094:
095: String fixupColumnDefRead(String aTableName,
096: ResultSetMetaData meta, String columnType,
097: ResultSet columnDesc, int columnIndex) throws SQLException {
098: return fixupColumnDefRead((TransferTable) null, meta,
099: columnType, columnDesc, columnIndex);
100: }
101:
102: String fixupColumnDefWrite(String aTableName,
103: ResultSetMetaData meta, String columnType,
104: ResultSet columnDesc, int columnIndex) throws SQLException {
105: return fixupColumnDefWrite((TransferTable) null, meta,
106: columnType, columnDesc, columnIndex);
107: }
108:
109: String formatName(String t) {
110: return formatIdentifier(t);
111: }
112: }
|