Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * See the COPYRIGHT.txt file distributed with this work for information
   * regarding copyright ownership.  Some portions may be licensed
   * to Red Hat, Inc. under one or more contributor license agreements.
   * 
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  * 
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  * 
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA.
  */
 
 package org.teiid.dialect;
 
 import java.sql.Types;
 
 
 public class TeiidDialect extends Dialect {
 	private static DoubleType DOUBLE = .;
 	private static StringType STRING = .;
 	private static FloatType FLOAT = .;
 	private static IntegerType INTEGER = .;
 	private static LongType LONG = .;
 	private static CharacterType CHARACTER = .
 	private static DateType DATE = .;
 	private static TimeType TIME = .;
 	private static BlobType BLOB = .;
 	private static ClobType CLOB = .;
 	private static ObjectType OBJECT = .;
 	
     public TeiidDialect() {
         // Register types
         registerColumnType(."char"); //$NON-NLS-1$
         registerColumnType(."string"); //$NON-NLS-1$
 
         registerColumnType(."boolean"); //$NON-NLS-1$
         registerColumnType(."byte"); //$NON-NLS-1$
         registerColumnType(."short"); //$NON-NLS-1$
         registerColumnType(."integer"); //$NON-NLS-1$
         registerColumnType(."long"); //$NON-NLS-1$
 
         registerColumnType(."float"); //$NON-NLS-1$
         registerColumnType(."float"); //$NON-NLS-1$
         registerColumnType(."double"); //$NON-NLS-1$
         registerColumnType(."bigdecimal"); //$NON-NLS-1$
 
         registerColumnType(."date"); //$NON-NLS-1$
         registerColumnType(."time"); //$NON-NLS-1$
         registerColumnType(."timestamp"); //$NON-NLS-1$
 
         registerColumnType(."blob"); //$NON-NLS-1$
         registerColumnType(."blob"); //$NON-NLS-1$
         registerColumnType(."clob"); //$NON-NLS-1$
         registerColumnType(."object"); //$NON-NLS-1$
         
         registerFunction("acos"new StandardSQLFunction("acos")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("asin"new StandardSQLFunction("asin")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("atan"new StandardSQLFunction("atan")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("atan2"new StandardSQLFunction("atan2")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("ceil"new StandardSQLFunction("ceiling")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("cos"new StandardSQLFunction("cos")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("cot"new StandardSQLFunction("cot")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("degrees"new StandardSQLFunction("degrees")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("exp"new StandardSQLFunction("exp")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("floor"new StandardSQLFunction("floor")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("formatbigdecimal"new StandardSQLFunction("formatbigdecimal")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("formatbiginteger"new StandardSQLFunction("formatbiginteger")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("formatdouble"new StandardSQLFunction("formatdouble")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("formatfloat"new StandardSQLFunction("formatfloat")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("formatinteger"new StandardSQLFunction("formatinteger")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("formatlong"new StandardSQLFunction("formatlong")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("log"new StandardSQLFunction("log")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("mod"new StandardSQLFunction("mod")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("parsebigdecimal"new StandardSQLFunction("parsebigdecimal")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("parsebiginteger"new StandardSQLFunction("parsebiginteger")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("parsedouble"new StandardSQLFunction("parsedouble")); //$NON-NLS-1$ //$NON-NLS-2$
         registerFunction("parsefloat"new StandardSQLFunction("parsefloat")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("parseinteger"new StandardSQLFunction("parseinteger")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("parselong"new StandardSQLFunction("parselong")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("pi"new StandardSQLFunction("pi")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("power"new StandardSQLFunction("power")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("radians"new StandardSQLFunction("radians")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("round"new StandardSQLFunction("round")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("sign"new StandardSQLFunction("sign")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("sin"new StandardSQLFunction("sin")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("tan"new StandardSQLFunction("tan")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("ascii"new StandardSQLFunction("ascii")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("chr"new StandardSQLFunction("chr")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("char"new StandardSQLFunction("char")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("concat"new VarArgsSQLFunction("""||""")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        registerFunction("initcap"new StandardSQLFunction("initcap")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("insert"new StandardSQLFunction("insert")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("lcase"new StandardSQLFunction("lcase")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("left"new StandardSQLFunction("left")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("locate"new StandardSQLFunction("locate")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("lpad"new StandardSQLFunction("lpad")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("ltrim"new StandardSQLFunction("ltrim")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("repeat"new StandardSQLFunction("repeat")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("replace"new StandardSQLFunction("replace")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("right"new StandardSQLFunction("right")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("rpad"new StandardSQLFunction("rpad")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("rtrim"new StandardSQLFunction("rtrim")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("substring"new StandardSQLFunction("substring")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("translate"new StandardSQLFunction("translate")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("ucase"new StandardSQLFunction("ucase")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("curdate"new NoArgSQLFunction("curdate")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("curtime"new NoArgSQLFunction("curtime")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("now"new NoArgSQLFunction("now")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("dayname"new StandardSQLFunction("dayname")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("dayofmonth"new StandardSQLFunction("dayofmonth")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("dayofweek"new StandardSQLFunction("dayofweek")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("dayofyear"new StandardSQLFunction("dayofyear")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("formatdate"new StandardSQLFunction("formatdate")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("formattime"new StandardSQLFunction("formattime")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("formattimestamp"new StandardSQLFunction("formattimestamp")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("hour"new StandardSQLFunction("hour")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("minute"new StandardSQLFunction("minute")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("monthname"new StandardSQLFunction("monthname")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("parsedate"new StandardSQLFunction("parsedate")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("parsetime"new StandardSQLFunction("parsetime")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("parsetimestamp"new StandardSQLFunction("parsetimestamp")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("second"new StandardSQLFunction("second")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("timestampcreate"new StandardSQLFunction("timestampcreate")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("timestampAdd"new StandardSQLFunction("timestampAdd")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("timestampDiff"new StandardSQLFunction("timestampDiff")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("week"new StandardSQLFunction("week")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("year"new StandardSQLFunction("year")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("modifytimezone"new StandardSQLFunction("modifytimezone")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("convert"new StandardSQLFunction("convert")); //$NON-NLS-1$ //$NON-NLS-2$
        
        registerFunction("to_bytes"new StandardSQLFunction("to_bytes")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("to_chars"new StandardSQLFunction("to_chars")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("from_unittime"new StandardSQLFunction("from_unittime")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("session_id"new StandardSQLFunction("session_id")); //$NON-NLS-1$ //$NON-NLS-2$
        
        registerFunction("uuid"new StandardSQLFunction("uuid")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("unescape"new StandardSQLFunction("unescape")); //$NON-NLS-1$ //$NON-NLS-2$
        
        registerFunction("array_get"new StandardSQLFunction("array_get")); //$NON-NLS-1$ //$NON-NLS-2$
        registerFunction("array_length"new StandardSQLFunction("array_length")); //$NON-NLS-1$ //$NON-NLS-2$
    }
    public boolean dropConstraints() {
        return false;
    }
    public boolean hasAlterTable() {
        return false;
    }
    public boolean supportsColumnCheck() {
        return false;
    }
    public boolean supportsCascadeDelete() {
        return false;
    }
        return "now"//$NON-NLS-1$
    }
    public boolean isCurrentTimestampSelectStringCallable() {
        return false;
    }
    public boolean supportsCurrentTimestampSelection() {
        return true;
    }
    public boolean supportsLimit() {
        return true;
    }
    public boolean supportsOuterJoinForUpdate() {
        return false;
    }
    public boolean supportsTableCheck() {
        return false;
    }
    public boolean supportsUnionAll() {
        return true;
    }
    public boolean supportsUnique() {
        return false;
    }
    public String toBooleanValueString(boolean arg0) {
        if (arg0) {
            return "{b'true'}"//$NON-NLS-1$
        }
        return "{b'false'}"//$NON-NLS-1$
    }

    
    public String getLimitString(String querySelect,
                                 boolean hasOffset) {
        return new StringBuffer(querySelect.length() + 20).append(querySelect).append(hasOffset ? " limit ?, ?" : " limit ?"//$NON-NLS-1$ //$NON-NLS-2$
                                                          .toString();
    }

    
    public ResultSet getResultSet(CallableStatement psthrows SQLException {
        boolean isResultSet = ps.execute();
        while (!isResultSet && ps.getUpdateCount() != -1) {
            isResultSet = ps.getMoreResults();
        }
        ResultSet rs = ps.getResultSet();
        return rs;
    }
    
    
    public int registerResultSetOutParameter(CallableStatement statement,
                                             int colthrows SQLException {
        return col;
    }
		return ""//$NON-NLS-1$
	}
		return "";		 //$NON-NLS-1$
	}
		return ""//$NON-NLS-1$
	}
	public String getForUpdateString(LockMode lockMode) {
		return ""//$NON-NLS-1$
	}
	public String getForUpdateString(String aliases) {
		return ""//$NON-NLS-1$
	}
		return "select uuid()"//$NON-NLS-1$
	}
	public boolean supportsTemporaryTables() {
		return true;
	}
		return "drop table"//$NON-NLS-1$
	}
		return "create local temporary table"//$NON-NLS-1$
	}
		return ""//$NON-NLS-1$
	}
   
New to GrepCode? Check out our FAQ X