我指的是这个线程:
Twitter - 查询特定地理位置半径内的推文
但我的问题是我想直接将其导入数据库MySQL,而不是System.out.println。
怎么做?
到目前为止我有这个代码:
stmt = conne.prepareStatement("INSERT INTO tweet(ID,date,name,text) VALUES (?,?,?,?)");
stmt.setInt(1, (int) status.getId());
stmt.setString(2, getTimeStamp());
stmt.setString(3, status.getUser().getScreenName());
Query query = new Query("india");
GeoLocation location = new GeoLocation(20.593684, 78.962880);
String unit = Query.KILOMETERS;
query.setGeoCode(location, 2, unit);
QueryResult result;
result = twitter.search(query);
List<Status> tweets = result.getTweets();
for (Status tweet : tweets){
stmt.setString(4, status.getText());
}
然后,我看到这样的输出错误:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Cannot use this builder any longer, build() has already been called
我发现我有两个build(),这是 TwitterStream 的一个和 TwitterFactory 的一个:
TwitterStream twitterStream5 = new TwitterStreamFactory(cb5.build()).getInstance();
TwitterFactory tf = new TwitterFactory(cb5.build());
Twitter twitter = tf.getInstance();
但我仍然不知道如何纠正它。
感谢您的任何评论!