diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-05-10 19:47:27 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-05-10 19:47:27 +0200 |
commit | 82e095b443ca60603cf7261e73f41d5bfdb0ae56 (patch) | |
tree | b493dcc183dae0ebc99fb889914d889821726b48 /src/main/Main.java | |
parent | 2b673df3123e3e1fd4edd6861abe316336e1d69c (diff) | |
download | Datafiller-82e095b443ca60603cf7261e73f41d5bfdb0ae56.tar.gz |
Move SQLException processing in processTweet to Main
Huge diff comes from whitespace diff. Now the tweet is printed with
its line number in error cases, and all further insertions are aborted.
Diffstat (limited to 'src/main/Main.java')
-rw-r--r-- | src/main/Main.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/Main.java b/src/main/Main.java index b5df23f..bd4055f 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -63,14 +63,19 @@ public class Main { } private void tweetsToDb(ITweetReader reader) throws IOException { - Tweet tweet; + Tweet tweet = null; + int tweetNo = 1; try (Connection connection = cb.create()) { /* create the object that fills the database */ DataFiller filler = new DataFiller(connection); while ((tweet = reader.getTweet()) != null) { filler.processTweet(tweet); + ++tweetNo; } } catch (SQLException ex) { + if (tweet != null) { + System.err.println("Faulty tweet: " + tweet); + } Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "DB error", ex); } |