JDBC批量插入数据(批量插入指定目录下的文件信息)

   /*首先利用PL/SQL创建一个过程

CREATE OR REPLACE PROCEDURE INS_FILES(P1 IN VARCHAR2,P2 IN VARCHAR2,P3 IN number)
AS
BEGIN
     INSERT INTO tb_files(fid,fname,fpath,indexed) VALUES (SEQ_fid.nextval,P1,P2,P3);
END INS_FILES;*/


 

 public static void recursion(String path){
  
        File file=new File(path);
        File[] files=file.listFiles();
        try{
              for(int i=0;i<files.length;i++)
                { 
                   if(files[i].isFile())
                         {   
                              conn.callablestatement.setString(1,files[i].getName().toString());
                              conn.callablestatement.setString(2,files[i].getPath().toString());
                              conn.callablestatement.setInt(3,0);
                              conn.executeCall();
                              count++;
                          }
                   else if(files[i].isDirectory())
                             recursion(files[i].getAbsolutePath());//对于目录进一步检索
                  
                 }
             }catch(Exception e){ e.printStackTrace(); }
      }
    public void storeFilesToDB(String rootpath){
       conn = new JDBCConnection();
       conn.setCallableStatement(SQL.call_ins_files);
       recursion(rootpath);
       conn.close();
       System.out.println("共有"+count+"个文件.");
    }

你可能感兴趣的:(JDBC批量插入数据(批量插入指定目录下的文件信息))