public static boolean compileUnit( DBRProgressMonitor monitor, DBCCompileLog compileLog, OracleSourceObject unit) throws DBCException { final DBEPersistAction[] compileActions = unit.getCompileActions(); if (ArrayUtils.isEmpty(compileActions)) { return true; } try (JDBCSession session = DBUtils.openUtilSession( monitor, unit.getDataSource(), "Compile '" + unit.getName() + "'")) { boolean success = true; for (DBEPersistAction action : compileActions) { final String script = action.getScript(); compileLog.trace(script); if (monitor.isCanceled()) { break; } try { try (DBCStatement dbStat = session.prepareStatement(DBCStatementType.QUERY, script, false, false, false)) { dbStat.executeStatement(); } action.handleExecute(null); } catch (DBCException e) { action.handleExecute(e); throw e; } if (action instanceof OracleObjectPersistAction) { if (!logObjectErrors( session, compileLog, unit, ((OracleObjectPersistAction) action).getObjectType())) { success = false; } } } final DBSObjectState oldState = unit.getObjectState(); unit.refreshObjectState(monitor); if (unit.getObjectState() != oldState) { unit.getDataSource() .getContainer() .fireEvent(new DBPEvent(DBPEvent.Action.OBJECT_UPDATE, unit)); } return success; } }
@Override public IStatus run(DBRProgressMonitor monitor) { if (ownerMonitor != null) { monitor = ownerMonitor; } monitor.beginTask(CoreMessages.dialog_connection_wizard_start_connection_monitor_start, 4); Thread.currentThread() .setName(CoreMessages.dialog_connection_wizard_start_connection_monitor_thread); try { container.setName(container.getConnectionConfiguration().getUrl()); monitor.worked(1); long startTime = System.currentTimeMillis(); super.run(monitor); connectTime = (System.currentTimeMillis() - startTime); if (connectError != null || monitor.isCanceled()) { return Status.OK_STATUS; } monitor.worked(1); DBPDataSource dataSource = container.getDataSource(); if (dataSource == null) { throw new DBException(CoreMessages.editors_sql_status_not_connected_to_database); } // monitor.subTask("Initialize connection"); // dataSource.initialize(monitor); // monitor.worked(1); monitor.subTask( CoreMessages.dialog_connection_wizard_start_connection_monitor_subtask_test); DBPDataSourceInfo info = dataSource.getInfo(); if (info != null) { try { productName = info.getDatabaseProductName(); productVersion = info.getDatabaseProductVersion(); driverName = info.getDriverName(); driverVersion = info.getDriverVersion(); } catch (Exception e) { log.error("Can't obtain connection metadata", e); } } else { try (DBCSession session = DBUtils.openUtilSession(monitor, dataSource, "Test connection")) { if (session instanceof Connection) { try { Connection connection = (Connection) session; DatabaseMetaData metaData = connection.getMetaData(); productName = metaData.getDatabaseProductName(); productVersion = metaData.getDatabaseProductVersion(); driverName = metaData.getDriverName(); driverVersion = metaData.getDriverVersion(); } catch (Exception e) { log.error("Can't obtain connection metadata", e); } } } } new DisconnectJob(container).schedule(); monitor.subTask(CoreMessages.dialog_connection_wizard_start_connection_monitor_success); } catch (DBException ex) { connectError = ex; } monitor.done(); return Status.OK_STATUS; }