diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-14 15:15:31 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-14 15:15:31 +1200 |
commit | 7310ee5f15729ea8517bfb6b0890a46da1217610 (patch) | |
tree | 44504738f127708420179a7dbbe2942cb67d0849 /src/org/traccar/database/QueryBuilder.java | |
parent | 8e8da7019aab023ae255d0ed6d16b94d303fd468 (diff) | |
parent | 0a6faa86c4b634fa3a94633506c4422623e36f1e (diff) | |
download | trackermap-server-7310ee5f15729ea8517bfb6b0890a46da1217610.tar.gz trackermap-server-7310ee5f15729ea8517bfb6b0890a46da1217610.tar.bz2 trackermap-server-7310ee5f15729ea8517bfb6b0890a46da1217610.zip |
Merge Java 7 update (fix #1273)
Diffstat (limited to 'src/org/traccar/database/QueryBuilder.java')
-rw-r--r-- | src/org/traccar/database/QueryBuilder.java | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index 88183f525..17165db82 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -36,7 +36,7 @@ import org.traccar.model.Factory; public class QueryBuilder { - private final Map<String, List<Integer>> indexMap = new HashMap<String, List<Integer>>(); + private final Map<String, List<Integer>> indexMap = new HashMap<>(); private Connection connection; private PreparedStatement statement; private final String query; @@ -106,7 +106,7 @@ public class QueryBuilder { // Add to list List<Integer> indexList = paramMap.get(name); if (indexList == null) { - indexList = new LinkedList<Integer>(); + indexList = new LinkedList<>(); paramMap.put(name, indexList); } indexList.add(index); @@ -133,7 +133,7 @@ public class QueryBuilder { name = name.toLowerCase(); List<Integer> result = indexMap.get(name); if (result == null) { - result = new LinkedList<Integer>(); + result = new LinkedList<>(); } return result; } @@ -264,8 +264,7 @@ public class QueryBuilder { } else if (method.getReturnType().equals(byte[].class)) { setBytes(name, (byte[]) method.invoke(object)); } - } catch (IllegalAccessException error) { - } catch (InvocationTargetException error) { + } catch (IllegalAccessException | InvocationTargetException error) { } } } @@ -293,13 +292,11 @@ public class QueryBuilder { try { - ResultSet resultSet = statement.executeQuery(); - - try { + try (ResultSet resultSet = statement.executeQuery()) { ResultSetMetaData resultMetaData = resultSet.getMetaData(); - List<ResultSetProcessor<T>> processors = new LinkedList<ResultSetProcessor<T>>(); + List<ResultSetProcessor<T>> processors = new LinkedList<>(); Method[] methods = prototype.getClass().getMethods(); @@ -328,8 +325,7 @@ public class QueryBuilder { public void process(T object, ResultSet resultSet) throws SQLException { try { method.invoke(object, resultSet.getBoolean(name)); - } catch (IllegalAccessException error) { - } catch (InvocationTargetException error) { + } catch (IllegalAccessException | InvocationTargetException error) { } } }); @@ -339,8 +335,7 @@ public class QueryBuilder { public void process(T object, ResultSet resultSet) throws SQLException { try { method.invoke(object, resultSet.getInt(name)); - } catch (IllegalAccessException error) { - } catch (InvocationTargetException error) { + } catch (IllegalAccessException | InvocationTargetException error) { } } }); @@ -350,8 +345,7 @@ public class QueryBuilder { public void process(T object, ResultSet resultSet) throws SQLException { try { method.invoke(object, resultSet.getLong(name)); - } catch (IllegalAccessException error) { - } catch (InvocationTargetException error) { + } catch (IllegalAccessException | InvocationTargetException error) { } } }); @@ -361,8 +355,7 @@ public class QueryBuilder { public void process(T object, ResultSet resultSet) throws SQLException { try { method.invoke(object, resultSet.getDouble(name)); - } catch (IllegalAccessException error) { - } catch (InvocationTargetException error) { + } catch (IllegalAccessException | InvocationTargetException error) { } } }); @@ -372,8 +365,7 @@ public class QueryBuilder { public void process(T object, ResultSet resultSet) throws SQLException { try { method.invoke(object, resultSet.getString(name)); - } catch (IllegalAccessException error) { - } catch (InvocationTargetException error) { + } catch (IllegalAccessException | InvocationTargetException error) { } } }); @@ -383,8 +375,7 @@ public class QueryBuilder { public void process(T object, ResultSet resultSet) throws SQLException { try { method.invoke(object, new Date(resultSet.getTimestamp(name).getTime())); - } catch (IllegalAccessException error) { - } catch (InvocationTargetException error) { + } catch (IllegalAccessException | InvocationTargetException error) { } } }); @@ -399,9 +390,6 @@ public class QueryBuilder { } result.add(object); } - - } finally { - resultSet.close(); } } finally { |