Here is My Code for doing this`
public static void addSong(String[] fileDetail, JTable SongData_Table)
{
try {
con = DBConnection.getCon();
stmt = con.createStatement();
stmt.executeUpdate("insert into songs values (null,'" + fileDetail[0] + "', '" + fileDetail[1] + "',null,null)");
ResultSet rs = stmt.executeQuery("select * from songs");
TableModel model = DbUtils.resultSetToTableModel(rs);
SongData_Table.setModel(model);
if (con != null) {
stmt.close();
con.close();
}
} catch (SQLException e) {
System.out.println("Error in Stmt " + e);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…