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);
} |
Partager