ããã«ã¡ã¯ãããããã¡ãã§ãã
ååã«å¼ãç¶ãã¾ãã¦ãã¯ã¦ãªããã¯ãã¼ã¯ããããã¯ãã¼ã¯ã®ãã¼ã¿ãJavaã使ã£ã¦æ½åºãã解æãè¡ãæ¹æ³ã®ããã°ã©ã ã®ä½ãæ¹ã«ã¤ãã¦ã話ãããã¨æãã¾ããæ¬ç¨¿ã¯ã以ä¸ã®è¨äºã®ç¶ãã¨ãªãã¾ãã®ã§ããæ¿ç¥ããä¸ããã
ãã¦ååã¯ãURLã§ã¯ãªããç¹å®ã®ããµã¤ããã«ä»ããããããã¯ãã¼ã¯ãä¸æã«åå¾ããæ¹æ³ã«ã¤ãã¦ã説æãããã¾ããããã®æ¹æ³ãè¡ãã°ãéå»è¨äºã«ã¤ããããããã¯ãã¼ã¯ã®å ¨ã¦ã®ãã¼ã¿ãæ½åºãããã¨ãåºæ¥ããã¨æãã¾ãã
ãã ãããç¨åº¦å¤§éã®ãã¼ã¿ãæ±ãã®ã§ããã°ãããã¹ããã¡ã¤ã«ã§å¦çããã®ã¯ã¡ãã£ã大å¤ã§ãããï¼ããã§ãä»åã¯ãåå¾ãããã¼ã¿ããç°¡æãã¼ã¿ãã¼ã¹ã§ãããsqliteãã«æ ¼ç´ããå¹ççã«åæããæ¹æ³ã«ã¤ãã¦ãç´¹ä»ãããã¨æãã¾ãã
ã¨ããã§çããããã¼ã¿ãã¼ã¹ã¨ããã¨ãã©ããã£ããã®ãæãæµ®ãã¹ã¾ããï¼ã¦ã§ãç³»ã®äººã§ããã°MySQLãæ¥åç³»ã®äººã§ããã°Oracleãäºåç³»ã®äººã§ããã°Accessãªãããæ³åãããããããã¾ããããä¸ã®ä¸ã«ã¯è²ã ãªãã¼ã¿ãã¼ã¹ã»ã½ããã¦ã§ã¢ã¯æãã¾ãããå人ã§ã¡ãã£ã¨ãããã¼ã¿ãæ±ãã«ã¯sqliteãå§åçã«ããããã§ããããããã¨çç±ã¯ããã®ã§ããã
- ç¡åã§ä½¿ãã
- ããã©ã¼ãã³ã¹ãçé
- ãµã¼ãã®æ§ç¯ãä¸è¦
ã§ä½¿ãããã¨ã大ããªã¡ãªããã§ãããããã©ã¼ãã³ã¹ã«ã¤ãã¦ã¯ããFirefoxã®å é¨ãã¼ã¿ã管çãããçµã¿è¾¼ã¿ã§ä½¿ã£ãããã¦ãã¢ã¬ã§ããï¼ãã£ã¦ã¤ã¡ã¼ã¸ããç¡ãã£ãã®ã§ãããæ°åä¸è¡åä½ã®ãã¼ã¿ã§ãæ¯è¼çããããæ±ãã¾ããï¼åè:ããã©ã¼ãã³ã¹æ¯è¼ CassandraãMongodbãSQLiteãH2ãMySQLãPostgres - C/pHeR Memo - Java ã¨ããEclipse ã¨ãã)
ã¾ãããµã¼ããæ§ç¯ããå¿ è¦ããªãããã¼ã¿ã®ããã¯ã¢ããã移è¡ããã³ããã§OKãã¨ããããã¼ããªDIYã¨ã³ã¸ãã¢ã«ã¯æé©ã§ãã
ååã¯ããHTMLã§HelloWorldã£ã¦è¡¨ç¤ºããããã¨ã®ãåºæ¥ãã°OKã§ãï¼ãã¨è¨ãã¾ããããä»åã¯ããã«å ãã¦ç°¡åãªSQLã®ç¥èãå¿ è¦ã«ãªãã¾ããï¼ã¾ãããªãã¨ãåããã¾ã§ã¯åºæ¥ãã¨æãã¾ããï¼ããã£ããè¨ãã¨ããselectæã§HelloWorldã£ã¦è¡¨ç¤ºããããã¨ãåºæ¥ããããã®ç¥èãã§ããããï¼ãªããããããï¼ã¡ãã£ã¨èªä¿¡ããªã人ã¯ããã®è¾ºã®æ¬ãã©ããï¼
ãããããã
ãã£ããã¼( ï½¥`д・´)
ãã¼ã¿ãã¼ã¹ãã¡ã¤ã«ã®ä½æ
ãã¦ãä»åã¯ã¡ãã£ã¨äºåæºåã«æéããããã¾ããä»åã®ä¾ã§ã¯MacOSXã§ã®ä¾ãæãã¦ãã¾ãããWindowsãLinuxã®ç°å¢ã§ããä¼¼ããããªãã¼ã¯ã¼ãã§æ¤ç´¢ãã¦é ããã°ãã ãããåé¡ãªãããããã¨æãã¾ãã
ã¾ãæåã«ãSQLiteStudioãã¤ã³ã¹ãã¼ã«ãã¾ãã
ããã¯ãsqliteå½¢å¼ã®ãã¼ã¿ãã¼ã¹ãã¡ã¤ã«ã確èªãããã¨ãåºæ¥ããã¼ã«ã§ããå¥ã«æ°ã«å ¥ã£ããã®ãããã°ãã£ã¡ã使ã£ã¦ããããã°ããã®ã§ãããGNOMEç°å¢ã§åããã®ã§ãæ°ã«å ¥ã£ã¦ä½¿ã£ã¦ãã¾ãï¼ç¬ï¼ãObjectBrowserã¿ãããªæãã®ãã¼ã«ã§ããã
ãã¦ã³ãã¼ããã¦éãã¨ããããªæãã®ç»é¢ã«ãªãã¨æãã¾ãã
ãã®ç»é¢ã®å·¦ããï¼çªç®ã®ãã¿ã³ãæ¼ãã¨ããã¼ã¿ãã¼ã¹ãã¡ã¤ã«ã®ä½æç»é¢ã«ãªãã¾ãã
ãã¼ã¿ãã¼ã¹ãã¡ã¤ã«åã¯HatenaBookmark.dbã«ã§ããã¦ããã¾ãããã
ãã¡ã¤ã«ãä½æã§ããããç½ç´è¨å·ã®ãã¿ã³ãããä¸è¨ã®SQLæãå®è¡ãã¾ãã
ããã§ã²ã¨ã¾ãOKã§ãã
ã©ã¤ãã©ãªã®åå¾ã¨ä¸ãããã
ã次ã¯ããã¤ãã®éãã©ã¤ãã©ãªã追å ãã¾ããä»å使ãã®ã¯ãã¡ãã
ã¨ããããææ°ã®ã©ã¤ãã©ãªãåå¾ãã¦ããã¾ãããããã¨ã¯ãåååæ§ã©ã¤ãã©ãªã追å ãããã¾ãããã
ãããªæãã§ããããã¨å¼æ°ã«ãä½æãããã¡ã¤ã«ã®ãã¹ã追å ãã¦ä¸ããã
Windowsã¨ãã§ããã°ãC:Â¥UsersÂ¥userÂ¥DesktopÂ¥HatenaBookmark.dbã¨ãã§ãããã¼ãå ´æã¯ãã¢ã¯ã»ã¹ã§ããå ´æã§ããã°ãã©ãã§ã大ä¸å¤«ã ã¨æãã¾ãã
ã½ã¼ã¹ã³ã¼ãã®è²¼ãä»ãã¨å®è¡
ãã¦ãããã§å¾ã¯ãã³ããã§OKï¼ãã§ããã
ã½ã¼ã¹ã³ã¼ã解説
ã§ã¯ç°¡åã«è§£èª¬ããã²ã¨ã¾ãã39è¡ç®ãã43è¡ç®ã§ãã¼ã¿ãã¼ã¹ã¸ã®ã³ãã¯ã·ã§ã³ãéå§ãã¦ãã¾ãã
String dbUrl = "jdbc:sqlite:" + args[2];
String driver = "org.sqlite.JDBC";
DriverManager.setLoginTimeout(10000);
Class.forName(driver).newInstance();
sconn = DriverManager.getConnection(dbUrl);
sconn.setAutoCommit(false);
追å ããå¼æ°ã§ãæå®ããæ¥ç¶å ã«ã¤ãªããã¨ãã¦ããããã§ãããã¨ããããèªåã³ãããã¢ã¼ãã¯ãªãã«ãã¦ããã¾ããã
ã次ã«ãBOOKMARKS表ã®ãã¼ã¿ãä¸æ¦ãªãã¬ãã·ã¥ãã¾ãã
pstmt = sconn.prepareStatement("delete from BOOKMARKS");
pstmt.executeUpdate();
ããã¦æå¾ã«72è¡ç®ãã80è¡ç®ããã¼ã¿ã®Insertæã§ãããå ã»ã©ã®Deleteæã§ã¯ä½ãæå³ã¯ããã¾ãããããã®SQLã¯ãprepareStatementã¨ããå½¢å¼ã§æ¸ããã¦ãã¾ãããã®å½¢å¼ã§æ¸ããã¦ããå ´åãSQLæå ã«"?"ã¨æ¸ãã¦ããã°ãsetStringãªã©ã®å½ä»¤ã§ããã®?ã®åºç¾åæ°ã®å¾ã®å¤ãç½®ãæãããã¨ãåºæ¥ã¾ãã
Â
pstmt = sconn.prepareStatement("insert into BOOKMARKS(URL,EID,BOOKMARKUSER,STARCOUNT,TIMESTAMP,COMMENT,TAG) values(?,?,?,?,?,?,?) ");
pstmt.setString(1, page.getUrl());
pstmt.setString(2, page.getEid());
pstmt.setString(3, bookmark.getUser());
pstmt.setInt(4, 0);
pstmt.setDate(5, new java.sql.Date(bookmark.getTimestamp().getTime()));
pstmt.setString(6, bookmark.getComment());
pstmt.setString(7, bookmark.getTags());
pstmt.executeUpdate();
 ãªã©ã¯ã«ã§ãããã¤ã³ãå¤æ°ã¿ãããªããã§ãããè¦ãç®ããã£ãããã¾ãããããã©ã¼ãã³ã¹çã«ããã¡ãã®ã»ããæ©ããªããã¨æãã¾ãã
ã§ã£ãããã¼ã¿ã¯ãã¼ã¿ãã¼ã¹ã使ããï¼
ãã¦ãããã§ãã°ããå¾ ã£ã¦ããã¼ãã«ã®ãã¼ã¿ã確èªããã¨ããããªæãã§è¡¨ç¤ºãããã¨æãã¾ãã
ä»åãåå¾ããéå»ï¼ï¼è¨äºã®ãã¼ã¿ã確èªããã¨ãå ¨é¨ã§4,710件ã®ããã¯ãã¼ã¯ãã¼ã¿ãåå¾ã§ãã¾ããããã£ã±ããããããã大ãããã¼ã¿ã解æããã®ã§ããã°ããã¼ã¿ãã¼ã¹ã«å ¥ãã¦ããã°ä¾¿å©ã§ããããã
ä¾ãã°ãã誰ãããã¯ãã¼ã¯ãã¦ããããã ããï¼ãã¨ãããã¨ã確èªããããã«ã¯ããããªæãã®SQLæãæµãã°ç°¡åã§ãããã
SQLã®å®è¡çµæããããéå»ã«ããã¯ãã¼ã¯ãã¦ããã人ãã¹ãï¼ï¼ããä½ãã¨ãããªæãã«ãªãã¾ããã
ã¦ã¼ã¶ã¼ | ä»¶æ° |
---|---|
id:lacucaracha | 40 |
id:keisolutions | 29 |
id:hisatsugu79 | 23 |
id:cild | 21 |
id:cyberglass | 21 |
id:hatebupost | 21 |
id:Daisuke-Tsuchiya | 19 |
id:SikisimaHisayuki | 19 |
id:hitode99 | 18 |
id:treve2013 | 16 |
ã»ã«ã¯ããæããï¼ç¬ï¼ããããã£ããã¼ã¿ãå ã«è²ã ã¨è§£æãã¦ãã£ãã楽ããããã§ããâªJavaãSQLããç¡å³ä¹¾ç¥ãªãµã³ãã«ãã¼ã¿ã使ãããããå®éã®ãã¼ã¿ãå¼ã£ãã»ããåå¼·ãã¯ãã©ãã¾ããã
ãããããããã°ã®è¨äºã«ããããããããããµã¼ãã¹ãéçºããããããäºå©ä¼ã®æ¢ç´¢æ´»åããã¦ã¿ãããããè²ã ã¨ãã¼ã¿ã¨ãã¦ããããããããã¾ãï¼ç¬ï¼ãã¿ãªãã¾ãããããã°æ¯éï¼
ããä½ããä¸æãªç¹ããæä¼ãã§ãããã¨ãããã°ãã©ããtwitterã«ã¦ã質åã¯ãã¤ã§ãæ¿ã£ã¦ãã¾ãï¼è¿ãã®ã¯æ°ãåããæã§ããã©ï¼ã®ã§ããªããªãã¨ï¼
ã§ã¯ã§ã¯ãä»æ¥ã¯ãã®è¾ºã§ã