|
20 | 20 | import java.net.URL; |
21 | 21 | import java.nio.charset.StandardCharsets; |
22 | 22 | import java.sql.Connection; |
23 | | -import java.sql.SQLException; |
24 | 23 | import java.util.ArrayList; |
25 | 24 | import java.util.Arrays; |
26 | 25 | import java.util.List; |
|
29 | 28 | import org.utplsql.sqldev.dal.UtplsqlDao; |
30 | 29 | import org.utplsql.sqldev.exception.GenericDatabaseAccessException; |
31 | 30 | import org.utplsql.sqldev.exception.GenericRuntimeException; |
| 31 | +import org.utplsql.sqldev.model.DatabaseTools; |
32 | 32 | import org.utplsql.sqldev.model.FileTools; |
33 | 33 | import org.utplsql.sqldev.ui.coverage.CodeCoverageReporterDialog; |
34 | 34 |
|
35 | | -import oracle.dbtools.raptor.utils.Connections; |
36 | | -import oracle.javatools.db.DBException; |
37 | | -import oracle.jdeveloper.db.ConnectionException; |
38 | | - |
39 | 35 | public class CodeCoverageReporter { |
40 | 36 | private static final Logger logger = Logger.getLogger(CodeCoverageReporter.class.getName()); |
41 | 37 |
|
@@ -67,19 +63,8 @@ private void setConnection(final String connectionName) { |
67 | 63 | logger.severe(() -> msg); |
68 | 64 | throw new NullPointerException(); |
69 | 65 | } else { |
70 | | - try { |
71 | | - // must be closed manually |
72 | | - conn = Connections.getInstance() |
73 | | - .cloneConnection(Connections.getInstance().getConnection(connectionName)); |
74 | | - } catch (ConnectionException e) { |
75 | | - final String msg = "ConnectionException while setting connection: " + e.getMessage(); |
76 | | - logger.severe(() -> msg); |
77 | | - throw new GenericDatabaseAccessException(msg, e); |
78 | | - } catch (DBException e) { |
79 | | - final String msg = "DBException while setting connection: " + e.getMessage(); |
80 | | - logger.severe(() -> msg); |
81 | | - throw new GenericDatabaseAccessException(msg, e); |
82 | | - } |
| 66 | + // must be closed manually |
| 67 | + conn = DatabaseTools.cloneConnection(connectionName); |
83 | 68 | } |
84 | 69 | } |
85 | 70 |
|
@@ -115,13 +100,13 @@ private void run() { |
115 | 100 | () -> "Could not launch " + file + "in browser. No default browser defined on this system."); |
116 | 101 | } |
117 | 102 | } catch (Exception e) { |
118 | | - final String msg = "Error while running code coverage: " + e.getMessage(); |
| 103 | + final String msg = "Error while running code coverage for " + pathList + "."; |
119 | 104 | logger.severe(() -> msg); |
120 | 105 | throw new GenericRuntimeException(msg, e); |
121 | 106 | } finally { |
122 | 107 | try { |
123 | | - conn.close(); |
124 | | - } catch (SQLException e) { |
| 108 | + DatabaseTools.closeConnection(conn); |
| 109 | + } catch (GenericDatabaseAccessException e) { |
125 | 110 | // ignore |
126 | 111 | } |
127 | 112 | if (frame != null) { |
|
0 commit comments