I would like to insert data into sql from JList. However, the getModel() at ListModel is stating that "cannot find symbol"
This is the action when the next button from previous form is clicked:
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
DefaultListModel list = new DefaultListModel();
System.out.println(""+songsdetails.get(0));
for(int i=0; i <songsdetails.size();i++){
list.addElement(songsdetails.get(i));
}
jList1.setModel(list);
}
}
This is the code for current form:
private void jButtonNextActionPerformed(java.awt.event.ActionEvent evt) {
DefaultListModel list = new DefaultListModel();
try {
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/sdmusic","root","");
st=cn.prepareStatement("INSERT `Username`, `SongsSelection` FROM `user` WHERE `Username`=? 'SongsSelection' = ?");
ListModel model = list.getModel();
for(int i = 0; i < model.getSize(); i++) {
System.out.println(model.getElementAt(i));
}