diff options
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/gitorious/GitoriousEventDao.java')
-rw-r--r-- | src/main/java/io/trygvis/esper/testing/gitorious/GitoriousEventDao.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousEventDao.java b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousEventDao.java new file mode 100644 index 0000000..603609e --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousEventDao.java @@ -0,0 +1,27 @@ +package io.trygvis.esper.testing.gitorious; + +import java.sql.*; + +public class GitoriousEventDao { + private final PreparedStatement countEntryId; + private final PreparedStatement insertChange; + + public GitoriousEventDao(Connection c) throws SQLException { + countEntryId = c.prepareStatement("SELECT count(entry_id) FROM gitorious_event WHERE entry_id=?"); + insertChange = c.prepareStatement("INSERT INTO gitorious_event(entry_id, text) VALUES(?, ?)"); + } + + public int countEntryId(String entryId) throws SQLException { + countEntryId.setString(1, entryId); + try(ResultSet rs = countEntryId.executeQuery()) { + rs.next(); + return rs.getInt(1); + } + } + + public void insertChange(String entryId, String text) throws SQLException { + insertChange.setString(1, entryId); + insertChange.setString(2, text); + insertChange.executeUpdate(); + } +} |