bonjour,
j'ai utilisé une requête qui sert a importer un fichier csv dans une base de données:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
DATA LOCAL INFILE 'C:\\Users\\Desktop\\TT (4).csv' INTO TABLE incident FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n'  (id_incident, status, vendor, priority, criticality_tt, title, description, affected_ci, affected_service, assignee, assignment_group, reassignment_count, open_time, close_time, outage_start, reassignment_time, outage_end, impact, solution, assignment_manager_name, assign_deptmgr, opened_by, closed_by, closure_code, update_action, last_updated_by);
je veux faire cette opération avec JFileChooser alors j'ai essayé avec ce code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 JFileChooser fc=new JFileChooser(); 
fc.showOpenDialog(this);
File f=fc.getSelectedFile();
String path=f.getAbsolutePath();
try
{ 
    FileInputStream fin=new FileInputStream(f);
int len=(int)f.length(); 
        java.sql.PreparedStatement ps1=con.prepareStatement("LOAD DATA LOCAL INFILE '?' INTO TABLE incident FIELDS TERMINATED BY ';' ENCLOSED BY '\"' ESCAPED BY '\\\\' LINES TERMINATED BY '\\n'  (id_incident, status, vendor, priority, criticality_tt, title, description, affected_ci, affected_service, assignee, assignment_group, reassignment_count, open_time, close_time, outage_start, reassignment_time, outage_end, impact, solution, assignment_manager_name, assign_deptmgr, opened_by, closed_by, closure_code, update_action, last_updated_by)");
ps1.setBinaryStream(1, fin, len); 
int status =ps1.executeUpdate();
if(status > 0) 
{ 
    j1.setText("Successfully inserted in DB"); 
}
else
{ 
        j2.setText(" not inserted!"); 
        } 
}
catch(Exception e)
{System.out.println(e);
}
il n'affiche pas d'erreur et pas de résultat.
merci d'avance.