use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.
the class DB2MaterializedQueryTableCache method prepareChildrenStatement.
@Override
protected JDBCStatement prepareChildrenStatement(@NotNull JDBCSession session, @NotNull DB2Schema db2Schema, @Nullable DB2MaterializedQueryTable forMqt) throws SQLException {
String sql;
if (forMqt != null) {
sql = SQL_COLS_TAB;
} else {
sql = SQL_COLS_ALL;
}
JDBCPreparedStatement dbStat = session.prepareStatement(sql);
dbStat.setString(1, db2Schema.getName());
if (forMqt != null) {
dbStat.setString(2, forMqt.getName());
}
return dbStat;
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.
the class DB2NicknameCache method prepareChildrenStatement.
@Override
protected JDBCStatement prepareChildrenStatement(@NotNull JDBCSession session, @NotNull DB2Schema db2Schema, @Nullable DB2Nickname forNickname) throws SQLException {
String sql;
if (forNickname != null) {
sql = SQL_COLS_NICK;
} else {
sql = SQL_COLS_ALL;
}
JDBCPreparedStatement dbStat = session.prepareStatement(sql);
dbStat.setString(1, db2Schema.getName());
if (forNickname != null) {
dbStat.setString(2, forNickname.getName());
}
return dbStat;
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.
the class DB2RemoteServerOptionCache method prepareObjectsStatement.
@Override
protected JDBCStatement prepareObjectsStatement(@NotNull JDBCSession session, @NotNull DB2RemoteServer remoteServer) throws SQLException {
final JDBCPreparedStatement dbStat = session.prepareStatement(SQL);
dbStat.setString(1, remoteServer.getName());
// dbStat.setString(4, remoteServer.getVersion());
return dbStat;
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.
the class NetezzaMetaModel method getViewDDL.
public String getViewDDL(DBRProgressMonitor monitor, GenericTable sourceObject) throws DBException {
GenericDataSource dataSource = sourceObject.getDataSource();
try (JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Read Netezza view source")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement("SELECT v.definition " + "FROM _v_view v, _v_objs_owned o " + "WHERE v.objid = o.objid AND o.DATABASE=? AND v.VIEWNAME=?")) {
dbStat.setString(1, sourceObject.getContainer().getName());
dbStat.setString(2, sourceObject.getName());
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
if (dbResult.nextRow()) {
return "CREATE OR REPLACE VIEW " + sourceObject.getName() + " AS\n" + dbResult.getString(1);
}
return "-- Netezza view definition not found";
}
}
} catch (SQLException e) {
throw new DBException(e, dataSource);
}
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement in project dbeaver by serge-rider.
the class OracleDataType method getComponentType.
@Property(viewable = true, order = 8)
public OracleDataType getComponentType(@NotNull DBRProgressMonitor monitor) throws DBCException {
if (componentType != null) {
return componentType;
}
OracleSchema schema = getSchema();
if (schema == null || !TYPE_CODE_COLLECTION.equals(typeCode) || !getDataSource().isAtLeastV10()) {
return null;
}
try (JDBCSession session = DBUtils.openMetaSession(monitor, getDataSource(), "Load collection types")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement("SELECT ELEM_TYPE_OWNER,ELEM_TYPE_NAME,ELEM_TYPE_MOD FROM SYS.ALL_COLL_TYPES WHERE OWNER=? AND TYPE_NAME=?")) {
dbStat.setString(1, schema.getName());
dbStat.setString(2, getName());
try (JDBCResultSet dbResults = dbStat.executeQuery()) {
if (dbResults.next()) {
String compTypeSchema = JDBCUtils.safeGetString(dbResults, "ELEM_TYPE_OWNER");
String compTypeName = JDBCUtils.safeGetString(dbResults, "ELEM_TYPE_NAME");
//String compTypeMod = JDBCUtils.safeGetString(dbResults, "ELEM_TYPE_MOD");
componentType = OracleDataType.resolveDataType(monitor, getDataSource(), compTypeSchema, compTypeName);
} else {
log.warn("Can't resolve collection type [" + getName() + "]");
}
}
}
} catch (Exception e) {
log.warn("Error reading collection types", e);
}
return componentType;
}
Aggregations