List of usage examples for twitter4j Place getFullName
String getFullName();
From source file:br.com.porcelli.hornetq.integration.twitter.support.TweetMessageConverterSupport.java
License:Apache License
public static ServerMessage buildMessage(final String queueName, final Status status) { final ServerMessage msg = new ServerMessageImpl(status.getId(), InternalTwitterConstants.INITIAL_MESSAGE_BUFFER_SIZE); msg.setAddress(new SimpleString(queueName)); msg.setDurable(true);/* w w w. j av a 2s. c om*/ msg.putStringProperty(TwitterConstants.KEY_MSG_TYPE, MessageType.TWEET.toString()); msg.putStringProperty(TwitterConstants.KEY_CREATED_AT, read(status.getCreatedAt())); msg.putStringProperty(TwitterConstants.KEY_ID, read(status.getId())); msg.putStringProperty(TwitterConstants.KEY_TEXT, read(status.getText())); msg.putStringProperty(TwitterConstants.KEY_SOURCE, read(status.getSource())); msg.putStringProperty(TwitterConstants.KEY_TRUNCATED, read(status.isTruncated())); msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID, read(status.getInReplyToStatusId())); msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_USER_ID, read(status.getInReplyToUserId())); msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_SCREEN_NAME, read(status.getInReplyToScreenName())); msg.putStringProperty(TwitterConstants.KEY_RETWEET, read(status.isRetweet())); msg.putStringProperty(TwitterConstants.KEY_FAVORITED, read(status.isFavorited())); msg.putStringProperty(TwitterConstants.KEY_ENTITIES_URLS_JSON, read(status.getURLEntities())); msg.putStringProperty(TwitterConstants.KEY_ENTITIES_HASHTAGS_JSON, read(status.getHashtagEntities())); msg.putStringProperty(TwitterConstants.KEY_ENTITIES_MENTIONS_JSON, read(status.getUserMentionEntities())); msg.putStringProperty(TwitterConstants.KEY_CONTRIBUTORS_JSON, read(status.getContributors())); if (status.getUser() != null) { buildUserData("", status.getUser(), msg); } GeoLocation gl; if ((gl = status.getGeoLocation()) != null) { msg.putStringProperty(TwitterConstants.KEY_GEO_LATITUDE, read(gl.getLatitude())); msg.putStringProperty(TwitterConstants.KEY_GEO_LONGITUDE, read(gl.getLongitude())); } Place place; if ((place = status.getPlace()) != null) { msg.putStringProperty(TwitterConstants.KEY_PLACE_ID, read(place.getId())); msg.putStringProperty(TwitterConstants.KEY_PLACE_URL, read(place.getURL())); msg.putStringProperty(TwitterConstants.KEY_PLACE_NAME, read(place.getName())); msg.putStringProperty(TwitterConstants.KEY_PLACE_FULL_NAME, read(place.getFullName())); msg.putStringProperty(TwitterConstants.KEY_PLACE_COUNTRY_CODE, read(place.getCountryCode())); msg.putStringProperty(TwitterConstants.KEY_PLACE_COUNTRY, read(place.getCountry())); msg.putStringProperty(TwitterConstants.KEY_PLACE_STREET_ADDRESS, read(place.getStreetAddress())); msg.putStringProperty(TwitterConstants.KEY_PLACE_TYPE, read(place.getPlaceType())); msg.putStringProperty(TwitterConstants.KEY_PLACE_GEO_TYPE, read(place.getGeometryType())); msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_TYPE, read(place.getBoundingBoxType())); msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_COORDINATES_JSON, read(place.getBoundingBoxCoordinates().toString())); msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_GEOMETRY_COORDINATES_JSON, read(place.getGeometryCoordinates().toString())); } msg.putStringProperty(TwitterConstants.KEY_RAW_JSON, status.toString()); return msg; }
From source file:com.appspot.bitlyminous.handler.twitter.NearByHandler.java
License:Apache License
/** * Builds the places status.//from ww w . ja v a 2 s . co m * * @param nearbyPlaces the nearby places * * @return the string */ private String buildPlacesStatus(List<Place> nearbyPlaces) { StringBuilder builder = new StringBuilder(); // GoogleStaticMapsGateway googleStaticMapsGateway = getGoogleStaticMapsGateway(); for (Place place : nearbyPlaces) { builder.append(place.getFullName()); builder.append(" "); builder.append(place.getStreetAddress()); builder.append("."); // TODO-Later. Fix the bounding box problem. // builder.append(shortenUrl(googleStaticMapsGateway.getMap(place.getGeolat(), place.getGeolong()))); builder.append("."); break; } return builder.toString(); }
From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java
License:Apache License
public static void convert(Place place, Struct struct) { if (null == place) { return;// ww w . j a va2 s . c o m } struct.put("Name", place.getName()).put("StreetAddress", place.getStreetAddress()) .put("CountryCode", place.getCountryCode()).put("Id", place.getId()) .put("Country", place.getCountry()).put("PlaceType", place.getPlaceType()) .put("URL", place.getURL()).put("FullName", place.getFullName()); }
From source file:DataCollections.PlaceHelper.java
public Place_dbo convertPlacetoPlace_dbo(Place place) { Place_dbo placedbo = new Place_dbo(); placedbo.values[Place_dbo.map.get("place_id")].setValue(place.getId()); placedbo.values[Place_dbo.map.get("name")].setValue(place.getName()); placedbo.values[Place_dbo.map.get("full_name")].setValue(place.getFullName()); placedbo.values[Place_dbo.map.get("country")].setValue(place.getCountry()); placedbo.values[Place_dbo.map.get("country_code")].setValue(place.getCountryCode()); placedbo.values[Place_dbo.map.get("place_type")].setValue(place.getPlaceType()); placedbo.values[Place_dbo.map.get("url")].setValue(place.getURL()); placedbo.values[Place_dbo.map.get("contained_within_place")] .setValue(getAllContainedWithIngPlaces(place.getContainedWithIn())); placedbo.values[Place_dbo.map.get("boundingbox_coord")] .setValue(stringifyBoundingBoxCoordinates(place.getBoundingBoxCoordinates())); double[] centroid = computeCentroid(place.getBoundingBoxCoordinates()); placedbo.values[Place_dbo.map.get("centroid_lon")].setValue(String.valueOf(centroid[0])); placedbo.values[Place_dbo.map.get("centroid_lat")].setValue(String.valueOf(centroid[1])); return placedbo; }
From source file:edu.cmu.cs.lti.discoursedb.io.twitter.converter.TwitterConverterService.java
License:Open Source License
/** * Maps a Tweet represented as a Twitter4J Status object to DiscourseDB * /*from w w w.j ava2 s. c o m*/ * @param discourseName the name of the discourse * @param datasetName the dataset identifier * @param tweet the Tweet to store in DiscourseDB */ public void mapTweet(String discourseName, String datasetName, Status tweet, PemsStationMetaData pemsMetaData) { if (tweet == null) { return; } Assert.hasText(discourseName, "The discourse name has to be specified and cannot be empty."); Assert.hasText(datasetName, "The dataset name has to be specified and cannot be empty."); if (dataSourceService.dataSourceExists(String.valueOf(tweet.getId()), TweetSourceMapping.ID_TO_CONTRIBUTION, datasetName)) { log.trace("Tweet with id " + tweet.getId() + " already exists in database. Skipping"); return; } log.trace("Mapping Tweet " + tweet.getId()); Discourse discourse = discourseService.createOrGetDiscourse(discourseName); twitter4j.User tUser = tweet.getUser(); User user = null; if (!userService.findUserByDiscourseAndUsername(discourse, tUser.getScreenName()).isPresent()) { user = userService.createOrGetUser(discourse, tUser.getScreenName()); user.setRealname(tUser.getName()); user.setEmail(tUser.getEmail()); user.setLocation(tUser.getLocation()); user.setLanguage(tUser.getLang()); user.setStartTime(tweet.getUser().getCreatedAt()); AnnotationInstance userInfo = annoService.createTypedAnnotation("twitter_user_info"); annoService.addFeature(userInfo, annoService.createTypedFeature(String.valueOf(tUser.getFavouritesCount()), "favorites_count")); annoService.addFeature(userInfo, annoService.createTypedFeature(String.valueOf(tUser.getFollowersCount()), "followers_count")); annoService.addFeature(userInfo, annoService.createTypedFeature(String.valueOf(tUser.getFriendsCount()), "friends_count")); annoService.addFeature(userInfo, annoService.createTypedFeature(String.valueOf(tUser.getStatusesCount()), "statuses_count")); annoService.addFeature(userInfo, annoService.createTypedFeature(String.valueOf(tUser.getListedCount()), "listed_count")); if (tUser.getDescription() != null) { annoService.addFeature(userInfo, annoService.createTypedFeature(String.valueOf(tUser.getDescription()), "description")); } annoService.addAnnotation(user, userInfo); } Contribution curContrib = contributionService.createTypedContribution(ContributionTypes.TWEET); DataSourceInstance contribSource = dataSourceService.createIfNotExists(new DataSourceInstance( String.valueOf(tweet.getId()), TweetSourceMapping.ID_TO_CONTRIBUTION, datasetName)); curContrib.setStartTime(tweet.getCreatedAt()); dataSourceService.addSource(curContrib, contribSource); AnnotationInstance tweetInfo = annoService.createTypedAnnotation("twitter_tweet_info"); if (tweet.getSource() != null) { annoService.addFeature(tweetInfo, annoService.createTypedFeature(tweet.getSource(), "tweet_source")); } annoService.addFeature(tweetInfo, annoService.createTypedFeature(String.valueOf(tweet.getFavoriteCount()), "favorites_count")); if (tweet.getHashtagEntities() != null) { for (HashtagEntity hashtag : tweet.getHashtagEntities()) { annoService.addFeature(tweetInfo, annoService.createTypedFeature(hashtag.getText(), "hashtag")); } } if (tweet.getMediaEntities() != null) { for (MediaEntity media : tweet.getMediaEntities()) { //NOTE: additional info is available for MediaEntities annoService.addFeature(tweetInfo, annoService.createTypedFeature(media.getMediaURL(), "media_url")); } } //TODO this should be represented as a relation if the related tweet is part of the dataset if (tweet.getInReplyToStatusId() > 0) { annoService.addFeature(tweetInfo, annoService .createTypedFeature(String.valueOf(tweet.getInReplyToStatusId()), "in_reply_to_status_id")); } //TODO this should be represented as a relation if the related tweet is part of the dataset if (tweet.getInReplyToScreenName() != null) { annoService.addFeature(tweetInfo, annoService.createTypedFeature(tweet.getInReplyToScreenName(), "in_reply_to_screen_name")); } annoService.addAnnotation(curContrib, tweetInfo); GeoLocation geo = tweet.getGeoLocation(); if (geo != null) { AnnotationInstance coord = annoService.createTypedAnnotation("twitter_tweet_geo_location"); annoService.addFeature(coord, annoService.createTypedFeature(String.valueOf(geo.getLongitude()), "long")); annoService.addFeature(coord, annoService.createTypedFeature(String.valueOf(geo.getLatitude()), "lat")); annoService.addAnnotation(curContrib, coord); } Place place = tweet.getPlace(); if (place != null) { AnnotationInstance placeAnno = annoService.createTypedAnnotation("twitter_tweet_place"); annoService.addFeature(placeAnno, annoService.createTypedFeature(String.valueOf(place.getPlaceType()), "place_type")); if (place.getGeometryType() != null) { annoService.addFeature(placeAnno, annoService.createTypedFeature(String.valueOf(place.getGeometryType()), "geo_type")); } annoService.addFeature(placeAnno, annoService .createTypedFeature(String.valueOf(place.getBoundingBoxType()), "bounding_box_type")); annoService.addFeature(placeAnno, annoService.createTypedFeature(String.valueOf(place.getFullName()), "place_name")); if (place.getStreetAddress() != null) { annoService.addFeature(placeAnno, annoService.createTypedFeature(String.valueOf(place.getStreetAddress()), "street_address")); } annoService.addFeature(placeAnno, annoService.createTypedFeature(String.valueOf(place.getCountry()), "country")); if (place.getBoundingBoxCoordinates() != null) { annoService.addFeature(placeAnno, annoService.createTypedFeature( convertGeoLocationArray(place.getBoundingBoxCoordinates()), "bounding_box_lat_lon_array")); } if (place.getGeometryCoordinates() != null) { annoService.addFeature(placeAnno, annoService.createTypedFeature( convertGeoLocationArray(place.getGeometryCoordinates()), "geometry_lat_lon_array")); } annoService.addAnnotation(curContrib, placeAnno); } Content curContent = contentService.createContent(); curContent.setText(tweet.getText()); curContent.setAuthor(user); curContent.setStartTime(tweet.getCreatedAt()); curContrib.setCurrentRevision(curContent); curContrib.setFirstRevision(curContent); DataSourceInstance contentSource = dataSourceService.createIfNotExists(new DataSourceInstance( String.valueOf(tweet.getId()), TweetSourceMapping.ID_TO_CONTENT, datasetName)); dataSourceService.addSource(curContent, contentSource); if (pemsMetaData != null) { log.warn("PEMS station meta data mapping not implemented yet"); //TODO map pems meta data if available } }
From source file:geo.GetGeoDetails.java
License:Apache License
/** * Usage: java twitter4j.examples.geo.GetGeoDetails [place id] * * @param args message/* w ww . ja v a 2 s .c om*/ */ public static void main(String[] args) { String s = "939067979a7f3b95"; try { Twitter twitter = new TwitterFactory(Data.getConf().build()).getInstance(); Place place = twitter.getGeoDetails(s); System.out.println("name: " + place.getName()); System.out.println("country: " + place.getCountry()); System.out.println("country code: " + place.getCountryCode()); System.out.println("full name: " + place.getFullName()); System.out.println("id: " + place.getId()); System.out.println("place type: " + place.getPlaceType()); System.out.println("street address: " + place.getStreetAddress()); Place[] containedWithinArray = place.getContainedWithIn(); if (containedWithinArray != null && containedWithinArray.length != 0) { System.out.println(" contained within:"); for (Place containedWithinPlace : containedWithinArray) { System.out.println(" id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName()); } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to retrieve geo details: " + te.getMessage()); System.exit(-1); } }
From source file:geo.GetSimilarPlaces.java
License:Apache License
/** * Usage: java twitter4j.examples.geo.GetSimilarPlaces [latitude] [longitude] [place id] * * @param args message//www . j a va2s.c o m */ public static void main(String[] args) { if (args.length < 3) { System.out.println( "Usage: java twitter4j.examples.geo.GetSimilarPlaces [latitude] [longitude] [name] [place id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); GeoLocation location = new GeoLocation(Double.parseDouble(args[0]), Double.parseDouble(args[1])); String name = args[2]; String containedWithin = null; if (args.length >= 4) { containedWithin = args[3]; } ResponseList<Place> places = twitter.getSimilarPlaces(location, name, containedWithin, null); if (places.size() == 0) { System.out.println("No location associated with the specified condition"); } else { for (Place place : places) { System.out.println("id: " + place.getId() + " name: " + place.getFullName() + " name: " + place.getFullName()); Place[] containedWithinArray = place.getContainedWithIn(); if (containedWithinArray != null && containedWithinArray.length != 0) { System.out.println(" contained within:"); for (Place containedWithinPlace : containedWithinArray) { System.out.println(" id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName()); } } } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to find similar places: " + te.getMessage()); System.exit(-1); } }
From source file:geo.ReverseGeoCode.java
License:Apache License
/** * Usage: java twitter4j.examples.geo.ReverseGeoCode [latitude] [longitude] * * @param args message//from ww w.ja v a 2 s .c om */ public static void main(String[] args) { if (args.length < 2) { System.out.println("Usage: java twitter4j.examples.geo.ReverseGeoCode [latitude] [longitude]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); GeoQuery query = new GeoQuery( new GeoLocation(Double.parseDouble(args[0]), Double.parseDouble(args[1]))); ResponseList<Place> places = twitter.reverseGeoCode(query); if (places.size() == 0) { System.out.println("No location associated with the specified lat/lang"); } else { for (Place place : places) { System.out.println("id: " + place.getId() + " name: " + place.getFullName()); Place[] containedWithinArray = place.getContainedWithIn(); if (containedWithinArray != null && containedWithinArray.length != 0) { System.out.println(" contained within:"); for (Place containedWithinPlace : containedWithinArray) { System.out.println(" id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName()); } } } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to retrieve places: " + te.getMessage()); System.exit(-1); } }
From source file:geo.SearchPlaces.java
License:Apache License
/** * Usage: java twitter4j.examples.geo.SearchPlaces [ip address] or [latitude] [longitude] * * @param args message// w ww . j a v a 2 s. c o m */ public static void main(String[] args) { if (args.length < 1) { System.out.println( "Usage: java twitter4j.examples.geo.SearchPlaces [ip address] or [latitude] [longitude]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); GeoQuery query; if (args.length == 2) { query = new GeoQuery(new GeoLocation(Double.parseDouble(args[0]), Double.parseDouble(args[1]))); } else { query = new GeoQuery(args[0]); } ResponseList<Place> places = twitter.searchPlaces(query); if (places.size() == 0) { System.out.println("No location associated with the specified IP address or lat/lang"); } else { for (Place place : places) { System.out.println("id: " + place.getId() + " name: " + place.getFullName()); Place[] containedWithinArray = place.getContainedWithIn(); if (containedWithinArray != null && containedWithinArray.length != 0) { System.out.println(" contained within:"); for (Place containedWithinPlace : containedWithinArray) { System.out.println(" id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName()); } } } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to retrieve places: " + te.getMessage()); System.exit(-1); } }
From source file:gh.polyu.user.TrackUsers.java
License:Apache License
public void track(final int no, final int p) { final TwitterDBHandle handle = new TwitterDBHandle(); handle.intialTwitterDBhandle();/* w w w.jav a 2 s . c om*/ while (alive) { alive = false; StatusListener listener = new StatusListener() { ArrayList<_TweetLink> listlink = new ArrayList<_TweetLink>(); int cnt = 0; String oldmonth = "20138"; String table = "UserTweet20138"; String oldday = ""; String currentday = ""; String currentmonth = ""; long lastinsert = 0l; long nowinsert = 0l; int newday = 0; String newtime = ""; @Override public void onStatus(Status status) { if (status.getId() == 123 && status.getText().equals("YOU are WORNG!.")) { System.out.println("Connection Need to be rebuilt!!"); alive = true; } else if (status.getLang().equals("en")) { _TweetLink tweet = new _TweetLink(); String Test = status.getText(); tweet.setText(Test); Date time = status.getCreatedAt(); tweet.setTime(time); tweet.setUserName(status.getUser().getName()); HashtagEntity[] hashtagentity = status.getHashtagEntities(); StringBuffer hashen = new StringBuffer(); for (int i = 0; i < hashtagentity.length; i++) { hashen.append(hashtagentity[i].getText()); hashen.append(";"); } tweet.setHashtag(hashen.toString()); URLEntity[] URLEn = status.getURLEntities(); StringBuffer URL = new StringBuffer(); for (int i = 0; i < URLEn.length; i++) { URL.append(URLEn[i].getURL()); URL.append(";"); } tweet.setURL(URL.toString()); //user mention UserMentionEntity[] userEn = status.getUserMentionEntities(); StringBuffer mentuser = new StringBuffer(); for (int i = 0; i < userEn.length; i++) { mentuser.append(userEn[i].getId()); mentuser.append(";"); } tweet.setUerMention(mentuser.toString()); //if(mentuser.length()!=0); //System.out.println("mentuser: "+ mentuser); //tweetID tweet.setTweetID(status.getId()); //if(ID!=null) // original twitterID tweet.setOriginID(status.getInReplyToStatusId()); //original user ID tweet.setOriginUser(status.getInReplyToUserId()); // user ID User users = status.getUser(); tweet.setTweetUser(users.getId()); //places Place Pl = status.getPlace(); String place = ""; if (Pl != null) { place = Pl.getFullName(); //System.out.println("place "+place); } tweet.setPlace(place); // Retweetcoun long num = 0; if (status.getRetweetedStatus() != null) { num = status.getRetweetedStatus().getRetweetCount(); //System.out.println("retweetcount"+num); tweet.setRetweetCount(num); tweet.setRetweet(1); } else { tweet.setRetweetCount(0); tweet.setRetweet(0); } // if(Retweet!=null) //System.out.println("Retweetcount: "+ Retweet); //isfavourate boolean favourate = status.isFavorited(); /*if(favourate) { fav = 1; tweet.setFavourate(fav); fav =0; System.out.println("isf "+ fav); }*/ // is retweet //String other = status.toString(); // tweet.setOther(other); listlink.add(tweet); Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; int day = cal.get(Calendar.DAY_OF_MONTH); currentmonth = String.valueOf(year) + String.valueOf(month); currentday = String.valueOf(day); if (currentmonth.equals(oldmonth)) { if (currentday.equals(oldday)) ; else { newday = 1; SimpleDateFormat formatter = new SimpleDateFormat("MMddHH:mm:ss "); Date curDate = new Date(System.currentTimeMillis());// newtime = formatter.format(curDate); } } else { try { handle.database_connection(); table = "UserTweet" + String.valueOf(year) + String.valueOf(month); System.out.println("create new table " + table); String CREATE_TABLE = "create table " + table + "(TweetID varchar(100), UserName varchar(200), TwitterUser varchar(145), OriginID varchar(100), OriginUser varchar(100), place varchar(100), RetweetCount varchar(100), isRetweet int(5), Text varchar(500), Time datetime," + "Hashtag varchar(200), URL varchar(200), UerMention varchar(200))"; Statement st = handle.conn.createStatement(); st.execute(CREATE_TABLE); String Create_Index = "alter table " + table + " add index time (Time)"; st.execute(Create_Index); String Create_Index2 = "alter table " + table + " add index userID (TwitterUser)"; st.execute(Create_Index2); String key = "ALTER TABLE " + table + " ADD PRIMARY KEY (TweetID)"; st.execute(key); } catch (SQLException e) { e.printStackTrace(); } handle.close_databasehandle(); try { TwitterDBHandle handle2 = new TwitterDBHandle(); handle2.intialTwitterDBhandle2(); handle2.database_connection(); table = "UserTweet" + String.valueOf(year) + String.valueOf(month); System.out.println("create new table " + table); String CREATE_TABLE = "create table " + table + "(TweetID varchar(100), UserName varchar(200), TwitterUser varchar(145), OriginID varchar(100), OriginUser varchar(100), place varchar(100), RetweetCount varchar(100), isRetweet int(5), Text varchar(500), Time datetime," + "Hashtag varchar(200), URL varchar(200), UerMention varchar(200))"; Statement st = handle2.conn.createStatement(); st.execute(CREATE_TABLE); String Create_Index = "alter table " + table + " add index time (Time)"; st.execute(Create_Index); String Create_Index2 = "alter table " + table + " add index userID (TwitterUser)"; st.execute(Create_Index2); String key = "ALTER TABLE " + table + " ADD PRIMARY KEY (TweetID)"; st.execute(key); handle2.close_databasehandle(); } catch (SQLException e) { e.printStackTrace(); } } //System.out.println("OTHER: "+ other); if ((cnt++) % 1000 == 0) { if (newday == 1) { newday = 0; oldday = currentday; GmailSend gs = new GmailSend("cscchenyoyo@gmail.com", "910316ccy"); gs.send("THREAD" + p + " :" + "program no" + no + "message" + newtime, "I am still alive"); newtime = ""; } try { handle.database_connection(); handle.userTweet(table, listlink); nowinsert = System.currentTimeMillis(); System.err.println( "No: " + no + "program " + "totally " + cnt + " tweets downloaded!\n" + new Date(nowinsert) + " " + new Date(lastinsert)); lastinsert = nowinsert; nowinsert = 0l; handle.close_databasehandle(); } catch (SQLException e) { handle.close_databasehandle(); e.printStackTrace(); // TODO Auto-generated catch block TwitterDBHandle handle2 = new TwitterDBHandle(); handle2.intialTwitterDBhandle2(); handle2.database_connection(); try { handle2.userTweet(table, listlink); nowinsert = System.currentTimeMillis(); System.err.println("New Database No: " + no + "program " + "totally " + cnt + " tweets downloaded!\n" + new Date(nowinsert) + new Date(lastinsert)); lastinsert = nowinsert; nowinsert = 0l; handle2.close_databasehandle(); } catch (SQLException e1) { // TODO Auto-generated catch block GmailSend gs = new GmailSend("cscchenyoyo@gmail.com", "910316ccy"); try { gs.SendSSLMessage("cscchenyoyo@gmail.com", "program error", "both databases are down"); } catch (MessagingException ee) { // TODO Auto-generated catch block e.printStackTrace(); } } GmailSend gs = new GmailSend("cscchenyoyo@gmail.com", "910316ccy"); try { gs.SendSSLMessage("cscchenyoyo@gmail.com", "program error", "change database to another one"); } catch (MessagingException ee) { // TODO Auto-generated catch block e.printStackTrace(); } } listlink.clear(); } } } @Override public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { //System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId()); } @Override public void onTrackLimitationNotice(int numberOfLimitedStatuses) { //System.out.println("Got track limitation notice:" + numberOfLimitedStatuses); } @Override public void onScrubGeo(long userId, long upToStatusId) { //System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId); } @Override public void onStallWarning(StallWarning warning) { //System.out.println("Got stall warning:" + warning); } @Override public void onException(Exception ex) { ex.printStackTrace(); } }; TwitterStream twitterStream = new TwitterStreamFactory().getInstance(); twitterOAuth twtOauth = new twitterOAuth(); twtOauth.AuthoritywithS(twitterStream, key); twitterStream.addListener(listener); twitterStream.filter(new FilterQuery(0, follow)); /* try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ } }