Skip to content

Commit f5cc951

Browse files
simplify, use methods from DatabaseTools
1 parent 0dbcad0 commit f5cc951

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

sqldev/src/main/java/org/utplsql/sqldev/coverage/CodeCoverageReporter.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.net.URL;
2121
import java.nio.charset.StandardCharsets;
2222
import java.sql.Connection;
23-
import java.sql.SQLException;
2423
import java.util.ArrayList;
2524
import java.util.Arrays;
2625
import java.util.List;
@@ -29,13 +28,10 @@
2928
import org.utplsql.sqldev.dal.UtplsqlDao;
3029
import org.utplsql.sqldev.exception.GenericDatabaseAccessException;
3130
import org.utplsql.sqldev.exception.GenericRuntimeException;
31+
import org.utplsql.sqldev.model.DatabaseTools;
3232
import org.utplsql.sqldev.model.FileTools;
3333
import org.utplsql.sqldev.ui.coverage.CodeCoverageReporterDialog;
3434

35-
import oracle.dbtools.raptor.utils.Connections;
36-
import oracle.javatools.db.DBException;
37-
import oracle.jdeveloper.db.ConnectionException;
38-
3935
public class CodeCoverageReporter {
4036
private static final Logger logger = Logger.getLogger(CodeCoverageReporter.class.getName());
4137

@@ -67,19 +63,8 @@ private void setConnection(final String connectionName) {
6763
logger.severe(() -> msg);
6864
throw new NullPointerException();
6965
} 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);
8368
}
8469
}
8570

@@ -115,13 +100,13 @@ private void run() {
115100
() -> "Could not launch " + file + "in browser. No default browser defined on this system.");
116101
}
117102
} 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 + ".";
119104
logger.severe(() -> msg);
120105
throw new GenericRuntimeException(msg, e);
121106
} finally {
122107
try {
123-
conn.close();
124-
} catch (SQLException e) {
108+
DatabaseTools.closeConnection(conn);
109+
} catch (GenericDatabaseAccessException e) {
125110
// ignore
126111
}
127112
if (frame != null) {

0 commit comments

Comments
 (0)