diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-11-08 11:45:08 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-11-08 11:45:08 +0100 |
commit | ff34cdc13bc8ba0943cded8009b9869a455894f6 (patch) | |
tree | 52ecf63d0a223e11961c11c26aec5d747546daf3 /src/main/java/io/trygvis/esper/testing/AtomDao.java | |
parent | bddca73748f7eace28cdd76282fcfd33971e9995 (diff) | |
download | esper-testing-ff34cdc13bc8ba0943cded8009b9869a455894f6.tar.gz esper-testing-ff34cdc13bc8ba0943cded8009b9869a455894f6.tar.bz2 esper-testing-ff34cdc13bc8ba0943cded8009b9869a455894f6.tar.xz esper-testing-ff34cdc13bc8ba0943cded8009b9869a455894f6.zip |
o Basic gitorious atom importer.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/AtomDao.java')
-rw-r--r-- | src/main/java/io/trygvis/esper/testing/AtomDao.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/AtomDao.java b/src/main/java/io/trygvis/esper/testing/AtomDao.java new file mode 100644 index 0000000..0215545 --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/AtomDao.java @@ -0,0 +1,37 @@ +package io.trygvis.esper.testing; + +import java.sql.*; + +public class AtomDao { + private final PreparedStatement selectLastUpdate; + private final PreparedStatement insertAtomFeed; + private final PreparedStatement updateAtomFeed; + + public AtomDao(Connection c) throws SQLException { + selectLastUpdate = c.prepareStatement("SELECT last_update FROM atom_feed WHERE url=?"); + insertAtomFeed = c.prepareStatement("INSERT INTO atom_feed(url, last_update) VALUES(?, ?)"); + updateAtomFeed = c.prepareStatement("UPDATE atom_feed SET last_update=? WHERE url=?"); + } + + public Timestamp getAtomFeed(String url) throws SQLException { + selectLastUpdate.setString(1, url); + ResultSet rs = selectLastUpdate.executeQuery(); + if (!rs.next()) { + return null; + } + + return rs.getTimestamp(1); + } + + public void insertAtomFeed(String url, Timestamp lastUpdate) throws SQLException { + insertAtomFeed.setString(1, url); + insertAtomFeed.setTimestamp(2, lastUpdate); + insertAtomFeed.executeUpdate(); + } + + public void updateAtomFeed(String url, Timestamp lastUpdate) throws SQLException { + updateAtomFeed.setTimestamp(1, lastUpdate); + updateAtomFeed.setString(2, url); + updateAtomFeed.executeUpdate(); + } +} |