diff options
-rw-r--r-- | src/data/Tweet.java | 2 | ||||
-rw-r--r-- | src/data/User.java | 6 | ||||
-rw-r--r-- | src/database/NamedPreparedStatement.java | 21 | ||||
-rw-r--r-- | src/database/QueryUtils.java | 10 |
4 files changed, 24 insertions, 15 deletions
diff --git a/src/data/Tweet.java b/src/data/Tweet.java index 320adbb..de14b19 100644 --- a/src/data/Tweet.java +++ b/src/data/Tweet.java @@ -12,7 +12,7 @@ public class Tweet { @ValidatingJsonDeserializer.Nullable public long in_reply_to_user_id; public DateTime created_at; - public long favorite_count; + public int favorite_count; @ValidatingJsonDeserializer.Nullable @ValidatingJsonDeserializer.Validator public Place place; diff --git a/src/data/User.java b/src/data/User.java index 2584391..45a0d09 100644 --- a/src/data/User.java +++ b/src/data/User.java @@ -11,9 +11,9 @@ public class User { public String name; @ValidatingJsonDeserializer.Nullable public String time_zone; - public long statuses_count; - public long followers_count; - public long friends_count; + public int statuses_count; + public int followers_count; + public int friends_count; public String location; public String screen_name; public DateTime created_at; diff --git a/src/database/NamedPreparedStatement.java b/src/database/NamedPreparedStatement.java index c899376..ebb775b 100644 --- a/src/database/NamedPreparedStatement.java +++ b/src/database/NamedPreparedStatement.java @@ -4,6 +4,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Timestamp; +import java.sql.Types; import java.util.ArrayList; import java.util.Calendar; import java.util.List; @@ -50,21 +51,29 @@ public class NamedPreparedStatement { return indices; } - public void setLong(String name, long l) throws SQLException { + public void setInt(String name, Integer i) throws SQLException { for (int paramIndex : getParamIndices(name)) { - stmt.setLong(paramIndex, l); + if (i == null) { + stmt.setNull(paramIndex, Types.INTEGER); + } else { + stmt.setInt(paramIndex, i); + } } } - public void setString(String name, String str) throws SQLException { + public void setLong(String name, Long l) throws SQLException { for (int paramIndex : getParamIndices(name)) { - stmt.setString(paramIndex, str); + if (l == null) { + stmt.setNull(paramIndex, Types.BIGINT); + } else { + stmt.setLong(paramIndex, l); + } } } - public void setString(String name, int i) throws SQLException { + public void setString(String name, String str) throws SQLException { for (int paramIndex : getParamIndices(name)) { - stmt.setInt(paramIndex, i); + stmt.setString(paramIndex, str); } } diff --git a/src/database/QueryUtils.java b/src/database/QueryUtils.java index c307b40..4f87428 100644 --- a/src/database/QueryUtils.java +++ b/src/database/QueryUtils.java @@ -96,7 +96,7 @@ public class QueryUtils { Tweet tweet) throws SQLException { tweetStatement.setLong("tweetid", tweet.id); tweetStatement.setTimestamp("createdat", tweet.created_at); - tweetStatement.setLong("favcount", tweet.favorite_count); + tweetStatement.setInt("favcount", tweet.favorite_count); tweetStatement.setLong("retweetcount", tweet.retweet_count); tweetStatement.setString("text", tweet.text); if (tweet.coordinates != null) { @@ -110,7 +110,7 @@ public class QueryUtils { if (tweet.retweeted_status != null) { tweetStatement.setLong("retweetid", tweet.retweeted_status.id); } else { - tweetStatement.setLong("retweetid", 0); + tweetStatement.setLong("retweetid", null); } tweetStatement.setLong("replyid", tweet.in_reply_to_user_id); // TODO: place is not a string... @@ -125,9 +125,9 @@ public class QueryUtils { profileStatement.setLong("userid", twuser.id); profileStatement.setString("displayname", twuser.name); profileStatement.setString("timezone", twuser.time_zone); - profileStatement.setLong("tweetcount", twuser.statuses_count); - profileStatement.setLong("followercount", twuser.followers_count); - profileStatement.setLong("followedcount", twuser.friends_count); + profileStatement.setInt("tweetcount", twuser.statuses_count); + profileStatement.setInt("followercount", twuser.followers_count); + profileStatement.setInt("followedcount", twuser.friends_count); profileStatement.setString("location", twuser.location); profileStatement.setString("tweetname", twuser.screen_name); profileStatement.setTimestamp("createdat", twuser.created_at); |