use of org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement in project dbeaver by serge-rider.
the class ExasolTableCache method prepareChildrenStatement.
@SuppressWarnings("rawtypes")
@Override
protected JDBCStatement prepareChildrenStatement(@NotNull JDBCSession session, @NotNull ExasolSchema exasolSchema, @Nullable ExasolTable exasolTable) throws SQLException {
String sql;
if (exasolTable != null)
sql = String.format(SQL_COLS_TAB, ExasolUtils.quoteString(exasolSchema.getName()), ExasolUtils.quoteString(exasolTable.getName()));
else
sql = String.format(SQL_COLS_ALL, ExasolUtils.quoteString(exasolSchema.getName()));
JDBCStatement dbstat = session.createStatement();
((JDBCStatementImpl) dbstat).setQueryString(sql);
return dbstat;
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement in project dbeaver by serge-rider.
the class ExasolTableUniqueKeyCache method prepareObjectsStatement.
@SuppressWarnings("rawtypes")
@NotNull
@Override
protected JDBCStatement prepareObjectsStatement(JDBCSession session, ExasolSchema exasolSchema, ExasolTable forTable) throws SQLException {
String sql;
if (forTable != null) {
sql = String.format(SQL_UK_TAB, ExasolUtils.quoteString(exasolSchema.getName()), ExasolUtils.quoteString(forTable.getName()));
} else {
sql = String.format(SQL_UK_ALL, ExasolUtils.quoteString(exasolSchema.getName()));
}
JDBCStatement dbStat = session.createStatement();
((JDBCStatementImpl) dbStat).setQueryString(sql);
return dbStat;
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement in project dbeaver by serge-rider.
the class ExasolJDBCObjectSimpleCacheLiterals method prepareObjectsStatement.
@SuppressWarnings("rawtypes")
@Override
protected JDBCStatement prepareObjectsStatement(@NotNull JDBCSession session, @NotNull OWNER owner) throws SQLException {
JDBCStatement dbStat = session.createStatement();
//escape parameters
for (int i = 0; i < queryParameters.length; i++) {
queryParameters[i] = (Object) ExasolUtils.quoteString(queryParameters[i].toString());
}
executeQuery = String.format(query, queryParameters);
((JDBCStatementImpl) dbStat).setQueryString(executeQuery);
return dbStat;
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement in project dbeaver by serge-rider.
the class TableToolDialog method getScriptListener.
@Override
protected SQLScriptProgressListener<PostgreObject> getScriptListener() {
return new SQLScriptStatusDialog<PostgreObject>(getShell(), getTitle() + " progress", null) {
@Override
protected void createStatusColumns(Tree objectTree) {
TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
msgColumn.setText("Message");
}
@Override
public void processObjectResults(@NotNull PostgreObject object, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
if (statement == null) {
return;
}
TreeItem treeItem = getTreeItem(object);
if (treeItem != null) {
try {
int warnNum = 0;
SQLWarning warning = ((JDBCStatement) statement).getWarnings();
while (warning != null) {
if (warnNum == 0) {
treeItem.setText(1, warning.getMessage());
} else {
TreeItem warnItem = new TreeItem(treeItem, SWT.NONE);
warnItem.setText(0, "");
warnItem.setText(1, warning.getMessage());
}
warnNum++;
warning = warning.getNextWarning();
}
if (warnNum == 0) {
treeItem.setText(1, "Done");
}
} catch (SQLException e) {
// ignore
}
treeItem.setExpanded(true);
}
}
@Override
public void endObjectProcessing(@NotNull PostgreObject object, Exception error) {
super.endObjectProcessing(object, error);
if (error != null) {
TreeItem treeItem = getTreeItem(object);
if (treeItem != null) {
treeItem.setText(1, error.getMessage());
}
}
}
};
}
use of org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement in project dbeaver by serge-rider.
the class ExasolUtils method readSessions.
public static Collection<ExasolServerSession> readSessions(DBRProgressMonitor progressMonitor, JDBCSession session) throws SQLException {
LOG.debug("read sessions");
List<ExasolServerSession> listSessions = new ArrayList<>();
//check dba view
try {
try (JDBCStatement dbStat = session.createStatement()) {
try (JDBCResultSet dbResult = dbStat.executeQuery(SESS_DBA_QUERY)) {
while (dbResult.next()) {
listSessions.add(new ExasolServerSession(dbResult));
}
}
}
//now try all view
} catch (SQLException e) {
try (JDBCStatement dbStat = session.createStatement()) {
try (JDBCResultSet dbResult = dbStat.executeQuery(SESS_ALL_QUERY)) {
while (dbResult.next()) {
listSessions.add(new ExasolServerSession(dbResult));
}
}
}
}
return listSessions;
}
Aggregations