Search in sources :

Example 6 with JDBCMetadataProcessor

use of org.teiid.translator.jdbc.JDBCMetadataProcessor in project teiid by teiid.

the class DB2ExecutionFactory method getMetadataProcessor.

@Override
public MetadataProcessor<Connection> getMetadataProcessor() {
    return new JDBCMetadataProcessor() {

        @Override
        protected ResultSet executeSequenceQuery(Connection conn) throws SQLException {
            String query = // $NON-NLS-1$
            "select null as sequence_catalog, seqschema as sequence_schema, seqname as sequence_name from sysibm.syssequences " + // $NON-NLS-1$
            "where seqschema like ? and seqname like ?";
            PreparedStatement ps = conn.prepareStatement(query);
            // $NON-NLS-1$
            ps.setString(1, getSchemaPattern() == null ? "%" : getSchemaPattern());
            // $NON-NLS-1$
            ps.setString(2, getSequenceNamePattern() == null ? "%" : getSequenceNamePattern());
            return ps.executeQuery();
        }
    };
}
Also used : JDBCMetadataProcessor(org.teiid.translator.jdbc.JDBCMetadataProcessor) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 7 with JDBCMetadataProcessor

use of org.teiid.translator.jdbc.JDBCMetadataProcessor in project teiid by teiid.

the class H2ExecutionFactory method getMetadataProcessor.

@Override
public MetadataProcessor<Connection> getMetadataProcessor() {
    return new JDBCMetadataProcessor() {

        @Override
        protected ResultSet executeSequenceQuery(Connection conn) throws SQLException {
            // matches the catalog search behavior of the h2 driver, as a pattern
            String query = // $NON-NLS-1$
            "select SEQUENCE_CATALOG, SEQUENCE_SCHEMA, SEQUENCE_NAME from information_schema.sequences " + // $NON-NLS-1$
            "where SEQUENCE_CATALOG like ? escape '' and SEQUENCE_SCHEMA like ? escape '' and sequence_name like ? escape ''";
            PreparedStatement ps = conn.prepareStatement(query);
            // $NON-NLS-1$
            ps.setString(1, getCatalog() == null ? "%" : getCatalog());
            // $NON-NLS-1$
            ps.setString(2, getSchemaPattern() == null ? "%" : getSchemaPattern());
            // $NON-NLS-1$
            ps.setString(3, getSequenceNamePattern() == null ? "%" : getSequenceNamePattern());
            return ps.executeQuery();
        }
    };
}
Also used : JDBCMetadataProcessor(org.teiid.translator.jdbc.JDBCMetadataProcessor) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Aggregations

JDBCMetadataProcessor (org.teiid.translator.jdbc.JDBCMetadataProcessor)7 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)3 Column (org.teiid.metadata.Column)3 MetadataFactory (org.teiid.metadata.MetadataFactory)2 Table (org.teiid.metadata.Table)2 SQLException (java.sql.SQLException)1