Search in sources :

Example 11 with JDBCPreparedStatement

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

the class DB2TriggerDepCache method prepareObjectsStatement.

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

Example 12 with JDBCPreparedStatement

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

the class DB2ViewBaseDepCache method prepareObjectsStatement.

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

Example 13 with JDBCPreparedStatement

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

the class DB2ViewCache method prepareLookupStatement.

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

Example 14 with JDBCPreparedStatement

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

the class DB2PlanAnalyser method explain.

// ----------------
// Business Methods
// ----------------
public void explain(JDBCSession session) throws DBCException {
    Integer stmtNo = STMT_NO_GEN.incrementAndGet();
    String explainStmt = String.format(PT_EXPLAIN, stmtNo, query);
    LOG.debug("Schema=" + planTableSchema + " : " + explainStmt);
    try {
        // Start by cleaning old rows for safety
        cleanExplainTables(session, stmtNo, planTableSchema);
        // Explain
        try (JDBCPreparedStatement dbStat = session.prepareStatement(String.format(PT_EXPLAIN, stmtNo, query))) {
            dbStat.execute();
        }
        // Build Node Structure
        try (JDBCPreparedStatement dbStat = session.prepareStatement(String.format(SEL_STMT, planTableSchema))) {
            dbStat.setInt(1, stmtNo);
            try (JDBCResultSet dbResult = dbStat.executeQuery()) {
                dbResult.next();
                db2PlanStatement = new DB2PlanStatement(session, dbResult, planTableSchema);
            }
        }
        listNodes = db2PlanStatement.buildNodes();
        // Clean afterward
        cleanExplainTables(session, stmtNo, planTableSchema);
    } catch (SQLException e) {
        throw new DBCException(e, session.getDataSource());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JDBCPreparedStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement) SQLException(java.sql.SQLException) JDBCResultSet(org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet) DBCException(org.jkiss.dbeaver.model.exec.DBCException)

Example 15 with JDBCPreparedStatement

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

the class DB2Utils method getListOfUsableTsForExplain.

// ------------------------
// EXPLAIN
// ------------------------
public static List<String> getListOfUsableTsForExplain(DBRProgressMonitor monitor, JDBCSession session) throws SQLException {
    LOG.debug("Get List Of Usable Tablespaces For Explain Tables");
    List<String> listTablespaces = new ArrayList<>();
    try (JDBCPreparedStatement dbStat = session.prepareStatement(SEL_LIST_TS_EXPLAIN)) {
        try (JDBCResultSet dbResult = dbStat.executeQuery()) {
            while (dbResult.next()) {
                listTablespaces.add(dbResult.getString(1));
            }
        }
    }
    return listTablespaces;
}
Also used : JDBCPreparedStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement) JDBCResultSet(org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet) ArrayList(java.util.ArrayList) DB2XMLString(org.jkiss.dbeaver.ext.db2.info.DB2XMLString)

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