1818import java .awt .Dimension ;
1919import java .awt .Toolkit ;
2020import java .sql .Connection ;
21- import java .sql .SQLException ;
2221import java .text .SimpleDateFormat ;
2322import java .util .Arrays ;
2423import java .util .Date ;
3029
3130import org .utplsql .sqldev .dal .RealtimeReporterDao ;
3231import org .utplsql .sqldev .dal .RealtimeReporterEventConsumer ;
33- import org .utplsql .sqldev .exception . GenericDatabaseAccessException ;
32+ import org .utplsql .sqldev .model . DatabaseTools ;
3433import org .utplsql .sqldev .model .runner .PostRunEvent ;
3534import org .utplsql .sqldev .model .runner .PostSuiteEvent ;
3635import org .utplsql .sqldev .model .runner .PostTestEvent ;
4544import org .utplsql .sqldev .ui .runner .RunnerPanel ;
4645import org .utplsql .sqldev .ui .runner .RunnerView ;
4746
48- import oracle .dbtools .raptor .utils .Connections ;
49- import oracle .javatools .db .DBException ;
50- import oracle .jdeveloper .db .ConnectionException ;
51-
5247public class UtplsqlRunner implements RealtimeReporterEventConsumer {
5348 private static final Logger logger = Logger .getLogger (UtplsqlRunner .class .getName ());
5449
@@ -80,34 +75,16 @@ private void setConnection(final String connectionName) {
8075 if (connectionName == null ) {
8176 throw new NullPointerException ("Cannot initialize a RealtimeConsumer without a ConnectionName" );
8277 } else {
83- try {
84- producerConn = Connections .getInstance ()
85- .cloneConnection (Connections .getInstance ().getConnection (connectionName ));
86- consumerConn = Connections .getInstance ()
87- .cloneConnection (Connections .getInstance ().getConnection (connectionName ));
88- } catch (ConnectionException | DBException e ) {
89- final String msg = "Error creating producer and consumer connections due to " + e .getMessage ();
90- logger .severe (() -> msg );
91- throw new GenericDatabaseAccessException (msg , e );
92- }
78+ producerConn = DatabaseTools .cloneConnection (connectionName );
79+ consumerConn = DatabaseTools .cloneConnection (connectionName );
9380 }
9481 this .connectionName = connectionName ;
9582 }
96-
97- private void closeConnection (Connection conn ) {
98- try {
99- if (!conn .isClosed ()) {
100- conn .close ();
101- }
102- } catch (SQLException e ) {
103- logger .warning (() -> "could not close connection" );
104- }
105- }
10683
10784 public void dispose () {
10885 // running in SQL Developer
109- closeConnection (producerConn );
110- closeConnection (consumerConn );
86+ DatabaseTools . closeConnection (producerConn );
87+ DatabaseTools . closeConnection (consumerConn );
11188 }
11289
11390 @ Override
@@ -267,7 +244,7 @@ private void produce() {
267244 logger .fine (() -> "All events produced for reporter id " + reporterId + "." );
268245 } catch (Exception e ) {
269246 logger .severe (() -> "Error while producing events for reporter id " + reporterId + ": "
270- + (e != null ? e .getMessage () : "" ));
247+ + (e != null ? e .getMessage () : "??? " ));
271248 }
272249 }
273250
@@ -277,9 +254,9 @@ private void consume() {
277254 final RealtimeReporterDao dao = new RealtimeReporterDao (consumerConn );
278255 dao .consumeReport (reporterId , this );
279256 logger .fine (() -> "All events consumed." );
280- } catch (final Exception e ) {
257+ } catch (Exception e ) {
281258 logger .severe (() -> "Error while consuming events for reporter id " + reporterId + ": "
282- + (e != null ? e .getMessage () : "" ));
259+ + (e != null ? e .getMessage () : "??? " ));
283260 }
284261 if (run .getTotalNumberOfTests () < 0 ) {
285262 run .setStatus (UtplsqlResources .getString ("RUNNER_NO_TESTS_FOUND_TEXT" ));
0 commit comments