use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DBDDocumentXML method serializeDocument.
@Override
public void serializeDocument(@NotNull DBRProgressMonitor monitor, @NotNull OutputStream stream, String encoding) throws DBException {
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(new OutputStreamWriter(stream, encoding));
transformer.transform(new DOMSource(document), output);
} catch (Exception e) {
throw new DBException("Error serializing XML document", e);
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class WMIDataSource method initialize.
@Override
public void initialize(@NotNull DBRProgressMonitor monitor) throws DBException {
final DBPConnectionConfiguration connectionInfo = container.getActualConnectionConfiguration();
try {
WMIService service = WMIService.connect(connectionInfo.getServerName(), connectionInfo.getHostName(), connectionInfo.getUserName(), connectionInfo.getUserPassword(), null, connectionInfo.getDatabaseName());
this.rootNamespace = new WMINamespace(null, this, connectionInfo.getDatabaseName(), service);
} catch (UnsatisfiedLinkError e) {
throw new DBException("Can't link with WMI native library", e);
} catch (Throwable e) {
throw new DBException("Can't connect to WMI service", e);
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class WMINamespace method loadNamespaces.
List<WMINamespace> loadNamespaces(DBRProgressMonitor monitor) throws DBException {
try {
WMIObjectCollectorSink sink = new WMIObjectCollectorSink(monitor, getService());
getService().enumInstances("__NAMESPACE", sink, WMIConstants.WBEM_FLAG_SHALLOW);
sink.waitForFinish();
List<WMINamespace> children = new ArrayList<>();
for (WMIObject object : sink.getObjectList()) {
String nsName = CommonUtils.toString(object.getValue("Name"));
children.add(new WMINamespace(this, dataSource, nsName, null));
object.release();
}
DBUtils.orderObjects(children);
return children;
} catch (WMIException e) {
throw new DBException(e, getDataSource());
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class JDBCCallableStatementImpl method getResultSet.
@Nullable
@Override
public JDBCResultSet getResultSet() throws SQLException {
JDBCResultSet resultSet = makeResultSet(getOriginal().getResultSet());
if (resultSet == null && procedure != null) {
JDBCResultSetCallable procResults = new JDBCResultSetCallable(getConnection(), this);
try {
Collection<? extends DBSProcedureParameter> params = procedure.getParameters(getConnection().getProgressMonitor());
if (!CommonUtils.isEmpty(params)) {
for (DBSProcedureParameter param : params) {
if (param.getParameterKind() == DBSProcedureParameterKind.OUT || param.getParameterKind() == DBSProcedureParameterKind.INOUT) {
procResults.addColumn(param.getName(), param.getParameterType());
}
}
}
} catch (DBException e) {
log.warn("Error extracting callable results", e);
}
procResults.addRow();
return procResults;
}
return resultSet;
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class JDBCDataSource method initialize.
@Override
public void initialize(@NotNull DBRProgressMonitor monitor) throws DBException {
if (!container.getDriver().isEmbedded() && container.getPreferenceStore().getBoolean(ModelPreferences.META_SEPARATE_CONNECTION)) {
synchronized (allContexts) {
this.metaContext = new JDBCExecutionContext(this, "Metadata");
this.metaContext.connect(monitor, true, null, false);
}
}
try (JDBCSession session = DBUtils.openMetaSession(monitor, this, ModelMessages.model_jdbc_read_database_meta_data)) {
JDBCDatabaseMetaData metaData = session.getMetaData();
if (this.sqlDialect instanceof JDBCSQLDialect) {
try {
((JDBCSQLDialect) this.sqlDialect).initDriverSettings(this, metaData);
} catch (Throwable e) {
log.error("Error initializing dialect driver settings", e);
}
}
try {
databaseMajorVersion = metaData.getDatabaseMajorVersion();
databaseMinorVersion = metaData.getDatabaseMinorVersion();
} catch (Throwable e) {
log.error("Error determining server version", e);
}
try {
dataSourceInfo = createDataSourceInfo(metaData);
} catch (Throwable e) {
log.error("Error obtaining database info");
}
} catch (SQLException ex) {
throw new DBException("Error getting JDBC meta data", ex, this);
} finally {
if (dataSourceInfo == null) {
log.warn("NULL datasource info was created");
dataSourceInfo = new JDBCDataSourceInfo(container);
}
}
}
Aggregations