Skip to content

Commit 296d275

Browse files
committed
Fixed newlines
1 parent 16bdc2e commit 296d275

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed

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

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,80 +13,80 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.morph.maps;
17-
18-
import java.io.Closeable;
19-
import java.io.IOException;
20-
import java.sql.Connection;
21-
import java.sql.PreparedStatement;
22-
import java.sql.ResultSet;
23-
import java.sql.SQLException;
16+
package org.culturegraph.mf.morph.maps;
17+
18+
import java.io.Closeable;
19+
import java.io.IOException;
20+
import java.sql.Connection;
21+
import java.sql.PreparedStatement;
22+
import java.sql.ResultSet;
23+
import java.sql.SQLException;
2424
import java.sql.Statement;
25-
import javax.naming.InitialContext;
26-
import javax.naming.NamingException;
27-
import javax.sql.DataSource;
28-
29-
import org.culturegraph.mf.exceptions.MorphException;
25+
import javax.naming.InitialContext;
26+
import javax.naming.NamingException;
27+
import javax.sql.DataSource;
28+
29+
import org.culturegraph.mf.exceptions.MorphException;
3030
import org.slf4j.Logger;
3131
import org.slf4j.LoggerFactory;
32-
33-
34-
/**
35-
* @author Daniel
36-
*
37-
*/
38-
public final class JndiSqlMap extends AbstractReadOnlyMap<String, String> implements Closeable {
39-
40-
private static final Logger LOG = LoggerFactory.getLogger(JndiSqlMap.class);
41-
private DataSource datasource;
42-
private String query;
32+
33+
34+
/**
35+
* @author Daniel
36+
*
37+
*/
38+
public final class JndiSqlMap extends AbstractReadOnlyMap<String, String> implements Closeable {
39+
40+
private static final Logger LOG = LoggerFactory.getLogger(JndiSqlMap.class);
41+
private DataSource datasource;
42+
private String query;
4343
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-
}
56-
57-
protected DataSource getDatasource() {
58-
return datasource;
59-
}
60-
61-
public void setDatasource(final String name) {
62-
try {
63-
this.datasource = (DataSource) new InitialContext().lookup(name);
64-
} catch (NamingException e) {
65-
throw new MorphException(e);
66-
}
67-
}
68-
69-
public void setQuery(final String query) {
70-
this.query = query;
71-
}
72-
73-
@Override
74-
public String get(final Object key) {
75-
String resultString = null;
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+
}
56+
57+
protected DataSource getDatasource() {
58+
return datasource;
59+
}
60+
61+
public void setDatasource(final String name) {
62+
try {
63+
this.datasource = (DataSource) new InitialContext().lookup(name);
64+
} catch (NamingException e) {
65+
throw new MorphException(e);
66+
}
67+
}
68+
69+
public void setQuery(final String query) {
70+
this.query = query;
71+
}
72+
73+
@Override
74+
public String get(final Object key) {
75+
String resultString = null;
7676
final ResultSet resultSet;
7777
PreparedStatement stmt = null;
78-
Connection con = null;
78+
Connection con = null;
7979
try {
8080
con = datasource.getConnection();
81-
stmt = con.prepareStatement(query);
82-
stmt.setString(1, key.toString());
83-
resultSet = stmt.executeQuery();
84-
if (resultSet.first()) {
85-
resultString = resultSet.getString(1);
86-
}
87-
resultSet.close();
88-
} catch (SQLException e) {
89-
throw new MorphException(e);
81+
stmt = con.prepareStatement(query);
82+
stmt.setString(1, key.toString());
83+
resultSet = stmt.executeQuery();
84+
if (resultSet.first()) {
85+
resultString = resultSet.getString(1);
86+
}
87+
resultSet.close();
88+
} catch (SQLException e) {
89+
throw new MorphException(e);
9090
} finally {
9191
if(stmt != null){
9292
try {
@@ -102,8 +102,8 @@ public String get(final Object key) {
102102
LOG.error("Can't close Connection.", e);
103103
}
104104
}
105-
}
106-
return resultString;
107-
}
108-
109-
}
105+
}
106+
return resultString;
107+
}
108+
109+
}

0 commit comments

Comments
 (0)