Search in sources :

Example 36 with JDBCPreparedStatement

use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.

the class DB2NicknameCache method prepareLookupStatement.

@NotNull
@Override
public JDBCStatement prepareLookupStatement(@NotNull JDBCSession session, @NotNull DB2Schema db2Schema, DB2Nickname db2Nickname, String db2NicknameName) throws SQLException {
    if (db2Nickname != null || db2NicknameName != null) {
        final JDBCPreparedStatement dbStat = session.prepareStatement(SQL_NICK);
        dbStat.setString(1, db2Schema.getName());
        dbStat.setString(2, db2Nickname != null ? db2Nickname.getName() : db2NicknameName);
        return dbStat;
    } else {
        final JDBCPreparedStatement dbStat = session.prepareStatement(SQL_NICK_ALL);
        dbStat.setString(1, db2Schema.getName());
        return dbStat;
    }
}
Also used : JDBCPreparedStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement) NotNull(org.jkiss.code.NotNull)

Example 37 with JDBCPreparedStatement

use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.

the class DB2RoutineCache method prepareObjectsStatement.

@Override
protected JDBCStatement prepareObjectsStatement(@NotNull JDBCSession session, @NotNull DB2Schema db2Schema) throws SQLException {
    String sql;
    if (db2Schema.getDataSource().isAtLeastV9_7()) {
        sql = SQL_ALL;
    } else {
        sql = SQL_V95;
    }
    JDBCPreparedStatement dbStat = session.prepareStatement(sql);
    dbStat.setString(1, db2Schema.getName());
    return dbStat;
}
Also used : JDBCPreparedStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement)

Example 38 with JDBCPreparedStatement

use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.

the class DB2RoutineParmsCache method prepareObjectsStatement.

@Override
protected JDBCStatement prepareObjectsStatement(@NotNull JDBCSession session, @NotNull DB2Routine db2Routine) throws SQLException {
    JDBCPreparedStatement dbStat = session.prepareStatement(SQL);
    dbStat.setString(1, db2Routine.getSchema().getName());
    dbStat.setString(2, db2Routine.getUniqueName());
    return dbStat;
}
Also used : JDBCPreparedStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement)

Example 39 with JDBCPreparedStatement

use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.

the class DB2TableCache method prepareLookupStatement.

@NotNull
@Override
public JDBCStatement prepareLookupStatement(@NotNull JDBCSession session, @NotNull DB2Schema db2Schema, @Nullable DB2Table db2Table, @Nullable String db2TableName) throws SQLException {
    if (db2Table != null || db2TableName != null) {
        final JDBCPreparedStatement dbStat = session.prepareStatement(SQL_TAB);
        dbStat.setString(1, db2Schema.getName());
        dbStat.setString(2, db2Table != null ? db2Table.getName() : db2TableName);
        return dbStat;
    } else {
        final JDBCPreparedStatement dbStat = session.prepareStatement(SQL_TAB_ALL);
        dbStat.setString(1, db2Schema.getName());
        return dbStat;
    }
}
Also used : JDBCPreparedStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement) NotNull(org.jkiss.code.NotNull)

Example 40 with JDBCPreparedStatement

use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.

the class DB2TableCache method prepareChildrenStatement.

@Override
protected JDBCStatement prepareChildrenStatement(@NotNull JDBCSession session, @NotNull DB2Schema db2Schema, @Nullable DB2Table forTable) throws SQLException {
    String sql;
    if (forTable != null) {
        sql = SQL_COLS_TAB;
    } else {
        sql = SQL_COLS_ALL;
    }
    JDBCPreparedStatement dbStat = session.prepareStatement(sql);
    dbStat.setString(1, db2Schema.getName());
    if (forTable != null) {
        dbStat.setString(2, forTable.getName());
    }
    return dbStat;
}
Also used : JDBCPreparedStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement)

Aggregations

JDBCPreparedStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement)100 JDBCResultSet (org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet)66 SQLException (java.sql.SQLException)49 JDBCSession (org.jkiss.dbeaver.model.exec.jdbc.JDBCSession)46 DBException (org.jkiss.dbeaver.DBException)45 ArrayList (java.util.ArrayList)18 DBCException (org.jkiss.dbeaver.model.exec.DBCException)15 NotNull (org.jkiss.code.NotNull)12 AbstractObjectReference (org.jkiss.dbeaver.model.impl.struct.AbstractObjectReference)10 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)10 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)8 DB2DataSource (org.jkiss.dbeaver.ext.db2.model.DB2DataSource)4 DB2XMLString (org.jkiss.dbeaver.ext.db2.info.DB2XMLString)3 GenericDataSource (org.jkiss.dbeaver.ext.generic.model.GenericDataSource)3 ResultSet (java.sql.ResultSet)2 DB2Parameter (org.jkiss.dbeaver.ext.db2.info.DB2Parameter)2 DB2Schema (org.jkiss.dbeaver.ext.db2.model.DB2Schema)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Clob (java.sql.Clob)1 SQLXML (java.sql.SQLXML)1