Skip to content

Commit 34cffed

Browse files
committed
Cleanup: Remove dead code from JndiSqlMap
An earlier version of the `JndiSqlMap` managed the JDBC connection on object level instead of method level. When this behaviour was changed, some old unused variables and methods remained in the file. These are removed with this commit.
1 parent ac7a3f7 commit 34cffed

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

src/main/java/org/culturegraph/mf/morph/maps/JndiSqlMap.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.sql.PreparedStatement;
2222
import java.sql.ResultSet;
2323
import java.sql.SQLException;
24-
import java.sql.Statement;
24+
2525
import javax.naming.InitialContext;
2626
import javax.naming.NamingException;
2727
import javax.sql.DataSource;
@@ -33,26 +33,13 @@
3333

3434
/**
3535
* @author Daniel
36-
*
36+
*
3737
*/
3838
public final class JndiSqlMap extends AbstractReadOnlyMap<String, String> implements Closeable {
3939

4040
private static final Logger LOG = LoggerFactory.getLogger(JndiSqlMap.class);
4141
private DataSource datasource;
4242
private String query;
43-
private Connection connection;
44-
45-
46-
@Override
47-
public void close() throws IOException {
48-
try {
49-
if (connection != null) {
50-
connection.close();
51-
}
52-
} catch (SQLException e) {
53-
throw new MorphException(e);
54-
}
55-
}
5643

5744
protected DataSource getDatasource() {
5845
return datasource;
@@ -61,7 +48,7 @@ protected DataSource getDatasource() {
6148
public void setDatasource(final String name) {
6249
try {
6350
this.datasource = (DataSource) new InitialContext().lookup(name);
64-
} catch (NamingException e) {
51+
} catch (final NamingException e) {
6552
throw new MorphException(e);
6653
}
6754
}
@@ -85,25 +72,30 @@ public String get(final Object key) {
8572
resultString = resultSet.getString(1);
8673
}
8774
resultSet.close();
88-
} catch (SQLException e) {
75+
} catch (final SQLException e) {
8976
throw new MorphException(e);
9077
} finally {
9178
if(stmt != null){
9279
try {
9380
stmt.close();
94-
} catch (SQLException e) {
81+
} catch (final SQLException e) {
9582
LOG.error("Can't close SQL-Statement.", e);
9683
}
9784
}
9885
if(con != null){
9986
try {
10087
con.close();
101-
} catch (SQLException e) {
88+
} catch (final SQLException e) {
10289
LOG.error("Can't close Connection.", e);
10390
}
10491
}
10592
}
10693
return resultString;
10794
}
10895

96+
@Override
97+
public void close() throws IOException {
98+
// Nothing to do
99+
}
100+
109101
}

0 commit comments

Comments
 (0)