After updating the attachement field with new file, mysql file path cosists with no slashs. Could anyone show me the path to fix it?
This is my file attachment button:
private void attachActionPerformed(java.awt.event.ActionEvent evt){
JFileChooser chooser=new JFileChooser();
chooser.showOpenDialog(null);
File f=chooser.getSelectedFile();
String file=f.getAbsolutePath();
file_attach.setText(file);
}
This is my update button code:
private void update_fieldsActionPerformed(java.awt.event.ActionEvent evt){
try{
String add1=course_catergory.getSelectedItem().toString();
String add2=code_course.getText();
String add3=course_type.getSelectedItem().toString();
String add4=course_name.getText();
String add5=file_attach.getText();
String sql="UPDATE course SET category='"+add1+"' ,course_code='"+add2+"' ,course_type='"+add3+
"' ,course_name='"+add4+"' ,attach_file='"+add5+"' where course_code='"+add2+"' ";
pst=conn.prepareStatement(sql);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Successfully updated.");
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
update_course_table();
}