报错的代码
public void addMusic(Music music){
conn = DBUtil.getCon();
String sql = "insert into tb_music(musicName,singer,size) values(?,?,?)";
try {
ps = conn.prepareStatement(sql);
ps.setString(1, music.getMusicName());
ps.setString(2, music.getSinger());
ps.setString(3, music.getSize());
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.closeStatement(ps);
DBUtil.closeCon(conn);
}
}
public String addMusic(){
musicDao.addMusic(music);
return "musicQuerySuccess";
}
------解决思路----------------------
错误很明显,music 没有值