summaryrefslogtreecommitdiff
path: root/src/database/QueryUtils.java
diff options
context:
space:
mode:
authorMaurice Laveaux <m.laveaux@student.tue.nl>2014-05-07 14:02:23 +0200
committerMaurice Laveaux <m.laveaux@student.tue.nl>2014-05-07 14:02:23 +0200
commita9de546d1867c4a2f130cf55c208719eb6b27f54 (patch)
tree45d22cd9a7f402205ff29f48e37d153e6e51e96b /src/database/QueryUtils.java
parentae7f9a9708b5e2504852262c2af245e0ea68275b (diff)
downloadDatafiller-a9de546d1867c4a2f130cf55c208719eb6b27f54.tar.gz
Removed the extranous DBQuery and simpel property
* InputReader reads from Scanner.
Diffstat (limited to 'src/database/QueryUtils.java')
-rw-r--r--src/database/QueryUtils.java36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/database/QueryUtils.java b/src/database/QueryUtils.java
index a120d1c..5b08655 100644
--- a/src/database/QueryUtils.java
+++ b/src/database/QueryUtils.java
@@ -1,5 +1,8 @@
package database;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import org.json.JSONException;
import org.json.JSONObject;
/**
@@ -14,27 +17,32 @@ public class QueryUtils {
*
* @return A valid database query.
*/
- public static DBQuery insertProfile() {
- String query = "INSERT INTO twitteruser (userid,displayname,timezone,tweetcount,"
+ public static String insertProfile() {
+ return "INSERT INTO twitteruser (userid,displayname,timezone,tweetcount,"
+ "followercount,followedcount,location) "
+ "SELECT ?, ?, ?, ?, ?, ?, ? "
+ "WHERE NOT EXISTS "
+ "(SELECT * FROM twitteruser WHERE userid= ? )";
- return new DBQuery(query);
}
- public static DBQuery insertTweet() {
- String query = "INSERT INTO tweet (tweetid,createdat,favcount,retweetcount,text) "
- + "SELECT ?, ?, ?, ?, ? WHERE NOT EXISTS (SELECT * FROM tweet WHERE tweetid= ? )";
- return new DBQuery(query);
+ public static String insertTweet() {
+ return "INSERT INTO tweet (tweetid,createdat,favcount,retweetcount,text) "
+ + "SELECT ?, ?, ?, ?, ? "
+ + "WHERE NOT EXISTS "
+ + "(SELECT * FROM tweet WHERE tweetid=? )";
+ }
+
+ public static String insetHash() {
+ return "INSERT INTO hashtag (tweetid, hashtag) "
+ + "SELECT ?, ? ";
}
- public static void setInsertParams(DBQuery query, JSONObject tweet) {
- /*query.getPrepared().setLong(1, tweet.getLong("id"));
- pst.setString(2, tweet.getString("created_at"));
- pst.setLong(3, tweet.getLong("favorite_count"));
- pst.setLong(4, tweet.getLong("retweet_count"));
- pst.setString(5, tweet.getString("text"));
- pst.setLong(6, tweet.getLong("id"));*/
+ public static void setInsertParams(PreparedStatement statement, JSONObject tweet) throws JSONException, SQLException {
+ statement.setLong( 1, tweet.getLong( "id"));
+ statement.setString(2, tweet.getString("created_at"));
+ statement.setLong( 3, tweet.getLong( "favorite_count"));
+ statement.setLong( 4, tweet.getLong( "retweet_count"));
+ statement.setString(5, tweet.getString("text"));
+ statement.setLong( 6, tweet.getLong( "id"));
}
}