lapartdombre | Voici mon code
Code :
- File[] list = repertoire.listFiles();
- for ( int i = 0; i < list.length; i++)
- {
- //if ( repertoire.isFile ( ) )
- {
-
- name=list[i].getName();
- taille=list[i].length();
- date= new java.sql.Date(list[i].lastModified());
- date2=new Date(list[i].lastModified());
- chaine= date.toString();
- chaine =""+chaine.substring(8,10)+"/" + chaine.substring(5,7) +"/" + chaine.substring(0,4)+" " + date2.toString().substring(11,16) +"";
- String fileName = list[i].getAbsolutePath().replace('\\','/');
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver" );
- conn = DriverManager.getConnection(url,user,passWord);
-
- java.sql.PreparedStatement ps2 ;
- System.out.println("insert into BASEQ.BQ_STDLIST2 ( BASEQ.BQ_STDLIST2.STD_CODE , BASEQ.BQ_STDLIST2.STD_TAILLE , BASEQ.BQ_STDLIST2.STD_DT_INT , BASEQ.BQ_STDLIST2.STD_DOC)values( '"+name +"' ,"+taille +", TO_DATE('"+chaine+"','DD/MM/YYYY HH24:MI'),?) " );
- ps2 = conn.prepareStatement("insert into BASEQ.BQ_STDLIST2 ( BASEQ.BQ_STDLIST2.STD_CODE , BASEQ.BQ_STDLIST2.STD_TAILLE , BASEQ.BQ_STDLIST2.STD_DT_INT , BASEQ.BQ_STDLIST2.STD_DOC)values( '"+name +"' ,"+taille +", TO_DATE('"+chaine+"','DD/MM/YYYY HH24:MI'),?) " );
- file = new File(fileName);
- fileLength = file.length();
- fis = new FileInputStream(file);
- // définition des variables dans la requete
- ps2.setBinaryStream(1, fis, (int)fileLength);
- // envoi de la requête pré-compilée avec les paramêtres
- int test =ps2.executeUpdate();
- fis.close();
- }
- catch (Exception e)
- {
- System.out.println(e.getMessage());
- }
|
|