Created
January 29, 2016 12:27
-
-
Save AARomanov1985/33c004a8bed663379035 to your computer and use it in GitHub Desktop.
Универсальный метод обработки SQL-запросов
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Record> getResult(String query) { | |
List<Record> out = new ArrayList<>(); | |
try (Statement statement = connection.createStatement()) { | |
logConnect(query); | |
ResultSet result = statement.executeQuery(query); | |
while (result.next()) { | |
Record record = new Record(); | |
try { | |
for (int i = 1;; i++) { | |
record.addValue(result.getString(i)); | |
} | |
} catch (SQLException sqlex) { | |
log.log(this.getClass().getName() + ": метод getResult(String query): " + sqlex.fillInStackTrace(), Log.Detail.NORMAL); | |
} | |
out.add(record); | |
} | |
} catch (SQLException ex) { | |
log.log(this.getClass().getName() + ": исключение в методе getFidList: " + ex.fillInStackTrace(), Log.Detail.ERROR); | |
} | |
return out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment