--- /dev/null
+package twitter.log;
+
+public class TweetDBObject {
+
+ private long id;
+
+ private String following;
+ private String date;
+ private long replyStatusID;
+ private long replyUserID;
+ private String text;
+ private String created;
+ private long userFavorite;
+ private long followers;
+ private long friend;
+ private long userId;
+ private String lang;
+ private String location;
+ private String name;
+ private String profileBackgroundColor;
+ private String profileBackgroundImageURL;
+ private String profileImageURL;
+ private String profileSidebarBorderColor;
+ private String profileSidebarFillColor;
+ private String profileTextColor;
+ private String screenName;
+ private long statusesCount;
+ private String timeZone;
+ private String url;
+ private long utc;
+ private String contributorsEnable;
+ private String geoEnable;
+ private String profileBackgroundTiled;
+ private String isProtected;
+ private String verified;
+ private String source;
+ private String favorite;
+ private String retweet;
+ private String truncated;
+
+ public String getContributorsEnable() {
+ return contributorsEnable;
+ }
+ public String getCreated() {
+ return created;
+ }
+ public String getDate() {
+ return date;
+ }
+ public String getFavorite() {
+ return favorite;
+ }
+ public long getFollowers() {
+ return followers;
+ }
+ public String getFollowing() {
+ return following;
+ }
+ public long getFriend() {
+ return friend;
+ }
+ public String getGeoEnable() {
+ return geoEnable;
+ }
+ public long getId() {
+ return id;
+ }
+ public String getIsProtected() {
+ return isProtected;
+ }
+ public String getLang() {
+ return lang;
+ }
+ public String getLocation() {
+ return location;
+ }
+ public String getName() {
+ return name;
+ }
+ public String getProfileBackgroundColor() {
+ return profileBackgroundColor;
+ }
+ public String getProfileBackgroundImageURL() {
+ return profileBackgroundImageURL;
+ }
+ public String getProfileBackgroundTiled() {
+ return profileBackgroundTiled;
+ }
+ public String getProfileImageURL() {
+ return profileImageURL;
+ }
+ public String getProfileSidebarBorderColor() {
+ return profileSidebarBorderColor;
+ }
+ public String getProfileSidebarFillColor() {
+ return profileSidebarFillColor;
+ }
+ public String getProfileTextColor() {
+ return profileTextColor;
+ }
+ public long getReplyStatusID() {
+ return replyStatusID;
+ }
+ public long getReplyUserID() {
+ return replyUserID;
+ }
+ public String getRetweet() {
+ return retweet;
+ }
+ public String getScreenName() {
+ return screenName;
+ }
+ public String getSource() {
+ return source;
+ }
+ public long getStatusesCount() {
+ return statusesCount;
+ }
+ public String getText() {
+ return text;
+ }
+ public String getTimeZone() {
+ return timeZone;
+ }
+ public String getTruncated() {
+ return truncated;
+ }
+ public String getUrl() {
+ return url;
+ }
+ public long getUserFavorite() {
+ return userFavorite;
+ }
+ public long getUserId() {
+ return userId;
+ }
+ public long getUtc() {
+ return utc;
+ }
+ public String getVerified() {
+ return verified;
+ }
+ public void setContributorsEnable(String contributorsEnable) {
+ this.contributorsEnable = contributorsEnable;
+ }
+ public void setCreated(String created) {
+ this.created = created;
+ }
+ public void setDate(String date) {
+ this.date = date;
+ }
+ public void setFavorite(String favorite) {
+ this.favorite = favorite;
+ }
+ public void setFollowers(long followers) {
+ this.followers = followers;
+ }
+ public void setFollowing(String following) {
+ this.following = following;
+ }
+ public void setFriend(long friend) {
+ this.friend = friend;
+ }
+ public void setGeoEnable(String geoEnable) {
+ this.geoEnable = geoEnable;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public void setIsProtected(String isProtected) {
+ this.isProtected = isProtected;
+ }
+ public void setLang(String lang) {
+ this.lang = lang;
+ }
+ public void setLocation(String location) {
+ this.location = location;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public void setProfileBackgroundColor(String profileBackgroundColor) {
+ this.profileBackgroundColor = profileBackgroundColor;
+ }
+ public void setProfileBackgroundImageURL(String profileBackgroundImageURL) {
+ this.profileBackgroundImageURL = profileBackgroundImageURL;
+ }
+ public void setProfileBackgroundTiled(String profileBackgroundTiled) {
+ this.profileBackgroundTiled = profileBackgroundTiled;
+ }
+ public void setProfileImageURL(String profileImageURL) {
+ this.profileImageURL = profileImageURL;
+ }
+ public void setProfileSidebarBorderColor(String profileSidebarBorderColor) {
+ this.profileSidebarBorderColor = profileSidebarBorderColor;
+ }
+ public void setProfileSidebarFillColor(String profileSidebarFillColor) {
+ this.profileSidebarFillColor = profileSidebarFillColor;
+ }
+ public void setProfileTextColor(String profileTextColor) {
+ this.profileTextColor = profileTextColor;
+ }
+ public void setReplyStatusID(long replyStatusID) {
+ this.replyStatusID = replyStatusID;
+ }
+ public void setReplyUserID(long replyUserID) {
+ this.replyUserID = replyUserID;
+ }
+ public void setRetweet(String retweet) {
+ this.retweet = retweet;
+ }
+ public void setScreenName(String screenName) {
+ this.screenName = screenName;
+ }
+ public void setSource(String source) {
+ this.source = source;
+ }
+ public void setStatusesCount(long statusesCount) {
+ this.statusesCount = statusesCount;
+ }
+ public void setText(String text) {
+ this.text = text;
+ }
+ public void setTimeZone(String timeZone) {
+ this.timeZone = timeZone;
+ }
+ public void setTruncated(String truncated) {
+ this.truncated = truncated;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ public void setUserFavorite(long userFavorite) {
+ this.userFavorite = userFavorite;
+ }
+ public void setUserId(long userId) {
+ this.userId = userId;
+ }
+ public void setUtc(long utc) {
+ this.utc = utc;
+ }
+ public void setVerified(String verified) {
+ this.verified = verified;
+ }
+ @Override
+ public String toString() {
+ return "TweetDBObject [contributorsEnable=" + contributorsEnable
+ + ", created=" + created + ", date=" + date + ", favorite="
+ + favorite + ", followers=" + followers + ", following="
+ + following + ", friend=" + friend + ", geoEnable=" + geoEnable
+ + ", id=" + id + ", isProtected=" + isProtected + ", lang="
+ + lang + ", location=" + location + ", name=" + name
+ + ", profileBackgroundColor=" + profileBackgroundColor
+ + ", profileBackgroundImageURL=" + profileBackgroundImageURL
+ + ", profileBackgroundTiled=" + profileBackgroundTiled
+ + ", profileImageURL=" + profileImageURL
+ + ", profileSidebarBorderColor=" + profileSidebarBorderColor
+ + ", profileSidebarFillColor=" + profileSidebarFillColor
+ + ", profileTextColor=" + profileTextColor + ", replyStatusID="
+ + replyStatusID + ", replyUserID=" + replyUserID + ", retweet="
+ + retweet + ", screenName=" + screenName + ", source=" + source
+ + ", statusesCount=" + statusesCount + ", text=" + text
+ + ", timeZone=" + timeZone + ", truncated=" + truncated
+ + ", url=" + url + ", userFavorite=" + userFavorite
+ + ", userId=" + userId + ", utc=" + utc + ", verified="
+ + verified + "]";
+ }
+
+ public TweetDBObject() {
+ }
+}
--- /dev/null
+package twitter.log;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import twitter.manage.TweetConfiguration;
+
+/**
+ * Tweetログ保存用データベースへのアクセス
+ * @author nishio
+ *
+ */
+public class TwitterLogDao {
+ //データベース接続文字列
+ private static final String DATABASE = TweetConfiguration.DATABASE;
+ private static final String DATABASE_CONNECTION = TweetConfiguration.DATABASE_CONNECTION;
+
+ //データベース接続
+ private Connection databaseConnection = null;
+
+ //データベーステーブルの定義
+ private static final String createTableSql =
+ "CREATE TABLE IF NOT EXISTS TWEET(" +
+ " id INTEGER PRIMARY KEY," +
+ " following TEXT," +
+ " date TEXT," +
+ " replyStatusID INTEGER," +
+ " replyUserID INTEGER," +
+ " text TEXT," +
+ " created TEXT," +
+ " description TEXT," +
+ " userFavorite INTEGER," +
+ " followers INTEGER," +
+ " friend INTEGER," +
+ " userId INTEGER," +
+ " lang TEXT," +
+ " location TEXT," +
+ " name TEXT," +
+ " profileBackgroundColor TEXT," +
+ " profileBackgroundImageURL TEXT," +
+ " profileImageURL TEXT," +
+ " profileSidebarBorderColor TEXT," +
+ " profileSidebarFillColor TEXT," +
+ " profileTextColor TEXT," +
+ " screenName TEXT," +
+ " statusesCount INTEGER," +
+ " timeZone TEXT," +
+ " url TEXT," +
+ " utc INTEGER," +
+ " contributorsEnable TEXT," +
+ " geoEnable TEXT," +
+ " profileBackgroundTiled TEXT," +
+ " isProtected TEXT," +
+ " verified TEXT," +
+ " source TEXT," +
+ " favorite TEXT," +
+ " retweet TEXT," +
+ " truncated TEXT)" ;
+
+ //データ挿入SQL
+ private static final String insertDataSql =
+ "INSERT INTO TWEET VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
+
+ //データ取得SQL
+ private static final String selectDataSql =
+ "SELECT * FROM TWEET;";
+
+ /**
+ * データベース接続
+ */
+ public void connectDB() {
+ try {
+ Class.forName( DATABASE );
+ this.databaseConnection = DriverManager.getConnection( DATABASE_CONNECTION );
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * データベースの接続を終了する
+ */
+ public void closeDB() {
+ if( this.databaseConnection != null ) {
+ try {
+ this.databaseConnection.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * テーブルを作成する
+ */
+ public void createTable() {
+ Statement statement;
+ try {
+ statement = this.databaseConnection.createStatement();
+ statement.execute( createTableSql );
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ TwitterLogDao dao = new TwitterLogDao();
+ dao.connectDB();
+
+ dao.createTable();
+
+ dao.closeDB();
+ }
+}