001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.jdbc;
031:
032: import com.caucho.util.Log;
033:
034: import javax.sql.DataSource;
035: import java.sql.Types;
036: import java.util.logging.Logger;
037:
038: /**
039: * Abstract way of grabbing data from the JDBC connection.
040: */
041: public class OracleMetaData extends GenericMetaData {
042: private static final Logger log = Log.open(OracleMetaData.class);
043:
044: protected OracleMetaData(DataSource ds) {
045: super (ds);
046: }
047:
048: /**
049: * Returns the literal for FALSE.
050: */
051: public String getFalseLiteral() {
052: return "0";
053: }
054:
055: /**
056: * True if blobs must be truncated on delete.
057: */
058: public boolean isTruncateBlobBeforeDelete() {
059: return true;
060: }
061:
062: /**
063: * Returns the SQL for the table with the given SQL type.
064: */
065: public String getCreateColumnSQL(int sqlType, int length,
066: int precision, int scale) {
067: // the oracle metadata doesn't return a proper value for data/time
068: switch (sqlType) {
069: case Types.DATE:
070: case Types.TIME:
071: return "DATE";
072: case Types.DOUBLE:
073: return "DOUBLE PRECISION";
074: }
075:
076: return super .getCreateColumnSQL(sqlType, length, precision,
077: scale);
078: }
079:
080: /**
081: * Returns true if the POSITION function is supported.
082: */
083: public boolean supportsPositionFunction() {
084: return false;
085: }
086:
087: /**
088: * Returns true if sequences are supported.
089: */
090: public boolean supportsSequences() {
091: return true;
092: }
093:
094: /**
095: * Returns true if table alias name with UPDATE is supported.
096: */
097: public boolean supportsUpdateTableAlias() {
098: return true;
099: }
100:
101: /**
102: * Returns a sequence select expression.
103: */
104: public String createSequenceSQL(String name, int size) {
105: if (size > 1)
106: return "CREATE SEQUENCE " + name + " INCREMENT BY " + size;
107: else
108: return "CREATE SEQUENCE " + name;
109: }
110:
111: /**
112: * Returns a sequence select expression.
113: */
114: public String selectSequenceSQL(String name) {
115: return "SELECT " + name + ".nextval FROM DUAL";
116: }
117: }
|