Search in sources :

Example 1 with LeftOrRightFunctionModifier

use of org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier in project teiid by teiid.

the class DerbyExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    // additional derby functions
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
    // overrides of db2 functions
    registerFunctionModifier(SourceSystemFunctions.CONCAT, new EscapeSyntaxModifier());
}
Also used : EscapeSyntaxModifier(org.teiid.translator.jdbc.EscapeSyntaxModifier) LeftOrRightFunctionModifier(org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier)

Example 2 with LeftOrRightFunctionModifier

use of org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier in project teiid by teiid.

the class PostgreSQLExecutionFactory method initCapabilities.

@Override
public void initCapabilities(Connection connection) throws TranslatorException {
    super.initCapabilities(connection);
    if (getVersion().compareTo(NINE_0) <= 0) {
        registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
    }
    if (this.postGisVersion.compareTo(Version.DEFAULT_VERSION) != 0 || connection == null) {
        return;
    }
    Statement s = null;
    ResultSet rs = null;
    Savepoint savepoint = null;
    try {
        if (!connection.getAutoCommit()) {
            // we need to use a savepoint as an exception will invalidate the connection
            savepoint = connection.setSavepoint();
        }
        s = connection.createStatement();
        // $NON-NLS-1$
        rs = s.executeQuery("SELECT PostGIS_Full_Version()");
        rs.next();
        String versionInfo = rs.getString(1);
        if (versionInfo != null) {
            if (versionInfo.contains("PROJ=")) {
                // $NON-NLS-1$
                projSupported = true;
            }
            // $NON-NLS-1$
            int index = versionInfo.indexOf("POSTGIS=");
            if (index > -1) {
                String version = versionInfo.substring(index + 9, versionInfo.indexOf('"', index + 9));
                this.setPostGisVersion(version);
            }
        }
    } catch (SQLException e) {
        // $NON-NLS-1$
        LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "Could not determine PostGIS version");
    } finally {
        if (savepoint != null) {
            try {
                connection.rollback(savepoint);
            } catch (SQLException e) {
            }
        }
        try {
            if (rs != null) {
                rs.close();
            }
        } catch (SQLException e) {
        }
        try {
            if (s != null) {
                s.close();
            }
        } catch (SQLException e) {
        }
    }
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) Savepoint(java.sql.Savepoint) LeftOrRightFunctionModifier(org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier) Savepoint(java.sql.Savepoint)

Aggregations

LeftOrRightFunctionModifier (org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Savepoint (java.sql.Savepoint)1 Statement (java.sql.Statement)1 EscapeSyntaxModifier (org.teiid.translator.jdbc.EscapeSyntaxModifier)1