アットウィキロゴ

4337

package baby;
 
import tool.*;
 
public class pro {
 
       int s,datanumber;
    String[] data=new String[5000];
 
  int creditnumber;
String[] creditp=new String[50];
String[] style=new String[50];
int[] strlong=new int[50];
     String[][] datax=new String[500000][10];
   String[] title=new String[500];
int[] codex=new int[500];
 
 
    public static void main(String[] args) {
        pro te=new pro();
    }
    pro(){
 
 
           String db,tab;
 
 
         creditnumber=2;
        creditp[1]="codex";
        creditp[2]="wiki"; 
        style[1]="INTEGER";
        style[2]="VARCHAR";
        style[3]="VARCHAR";
 
 strlong[2]=200;
 
 
        db="drama";
        tab="drama";
 
 
        table sub7=new table();
        sub7.credit=creditp;
        sub7.creditnumber=creditnumber;
        sub7.style=style;
        sub7.strlong=strlong;
        sub7.makedata(db,tab);
 
        int tr;
 
        for(tr=1;tr<7645;tr++){
readfile sub2=new readfile();
        sub2.makedata("data/"+tr+".csv","UTF-8");
        data=sub2.data;
        datanumber=sub2.datanumber;
 
        System.out.println(tr);
        for(s=1;s<datanumber+1;s++){
 String[] x=data[s].split(",");
 
 if(x[0].length()>45)x[0]="longlong";
 if(x[1].length()>180)x[1]="longlong";
 if(x[0].indexOf("*")>-1)x[0]="hatena";
  if(x[0].indexOf("'")>-1)x[0]="hatena";
 datax[s][1]=""+tr;
        datax[s][2]=x[1];
        }
 
 
        insert sub5=new insert();
        sub5.creditnumber=creditnumber;
        sub5.style=style;
        sub5.data=datax;
        sub5.datanumber=datanumber;
        sub5.makedata(db,tab);
 
        }
 
        int number;
 
        select sub4=new select();
        sub4.makedata(db,tab,"https://ja.wikipedia.org/wiki/%E5%B3%B6%E3%81%8B%E3%81%8A%E3%82%8A");
        number=sub4.number;
        title=sub4.title;
        codex=sub4.codex;
 
 
     System.out.println(number);   
 
 
 
 
    }
 
 
 
}
 
 
package baby;
 
import java.sql.*;
import java.io.*;
 
class insert {
 
    Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
 
String[] style=new String[50];
int creditnumber;
  String[][] data=new String[5000][50];  
int datanumber;
 
int p;
 
    void makedata(String db,String tab) {
 
        String str;
 
        int s,sx;
 
        for(p=1;p<datanumber+1;p++){
 
 
       str="";
 
        for(sx=1;sx<creditnumber;sx++){
        if(style[sx].equals("VARCHAR"))str=str+change(data[p][sx])+",";
        if(style[sx].equals("INTEGER"))str=str+data[p][sx]+",";
        }
        sx=creditnumber;
        if(style[sx].equals("VARCHAR"))str=str+change(data[p][sx]);
        if(style[sx].equals("INTEGER"))str=str+data[p][sx];
 
    String url = "jdbc:h2:"+db+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
 try{
 Class.forName("org.h2.Driver");
 
dbx = DriverManager.getConnection(url, usr, pwd); 
 
 
      stx = dbx.createStatement();
 
      String sql = "INSERT INTO "+tab+" VALUES("+str+")";
 
    int num = stx.executeUpdate(sql);
 
    stx.close();
 } catch (Exception ex) { ex.printStackTrace();} 
 
        }
 
 
  }
String change(String str){
String str1;
str1="'"+str+"'";
return str1;
}
}
 
package baby;
 
import java.sql.*; 
 
public class table{
 
    Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
int creditnumber;
String[] credit=new String[50];
String[] style=new String[50];
int[] strlong=new int[50];
 
 
 
 
    void makedata(String db,String tab){
 
 
 
        String str;
 
        str="";
        int s;
        for(s=1;s<creditnumber;s++){
        if(style[s].equals("INTEGER"))str=str+credit[s]+" "+style[s]+",";
        if(style[s].equals("VARCHAR"))str=str+credit[s]+" "+style[s]+"("+strlong[s]+"),";
        }
        s=creditnumber;
        if(style[s].equals("INTEGER"))str=str+credit[s]+" "+style[s];
        if(style[s].equals("VARCHAR"))str=str+credit[s]+" "+style[s]+"("+strlong[s]+")";
 
 
 
 
    String url = "jdbc:h2:"+db+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
 try{
 Class.forName("org.h2.Driver");
 
dbx = DriverManager.getConnection(url, usr, pwd); 
 
 
      stx = dbx.createStatement();
 
      String sqx = "CREATE TABLE " +tab+"("+str+")"; 
 
 
      stx.executeUpdate(sqx);
 
 } catch (Exception ex) { ex.printStackTrace();} 
 
 
 
 
 
 
    }
}
 
最終更新:2016年07月28日 08:13