请求帮助,急!!万分感谢!!!
我做一个用户管理页面;出现:java.lang.NullPointerException
public void deleteById(Long id) throws UesNameException {
deleteByIds(new Long[] { id });
}
public void deleteByIds(Long[] ids) throws UesNameException {
Connection connection = null;
PreparedStatement stmt = null;
try {
// -->A.
connection = getConnection();
// -->B.
String sql = "delete from useadmin where id=?";
stmt = connection.prepareStatement(sql);
for (int i = 0; i < ids.length; i++) {
Long id = ids[i];
stmt.setLong(1, id.longValue());
stmt.addBatch();
}
int[] rowCounts = stmt.executeBatch();
System.out.println(rowCounts.length + " row(s) deleted");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
}
}
//-------------------------JDBC 连接数据库页面:------------------------------------------------//
public void deleteById(Long id) throws UesNameException {
deleteByIds(new Long[] { id });
}
public void deleteByIds(Long[] ids) throws UesNameException {
Connection connection = null;
PreparedStatement stmt = null;
try {
// -->A.
connection = getConnection();
// -->B.
String sql = "delete from useadmin where id=?";
stmt = connection.prepareStatement(sql);
for (int i = 0; i < ids.length; i++) {
Long id = ids[i];
stmt.setLong(1, id.longValue());
stmt.addBatch();
}
int[] rowCounts = stmt.executeBatch();
System.out.println(rowCounts.length + " row(s) deleted");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
}
}
//-------------------------DeleteNameAction页面:------------------------------------------------//
//--> C.
DeleteNameForm fm = (DeleteNameForm) form;
Long id = fm.getId();
//--> M.
getServices().deleteById(id);
//--> V.
return mapping.findForward("uesccess");
//-------------------------显示页面:------------------------------------------------//
id Name Pws Pwss Gender Age Email Tal QQ Msg
1 admin 123456 123456 f 1235445 shidfsfsfdf@163.com 2112345678 84859195 shangha <a href="DeleteName.do">删除</a> 修改 新建
2 123 123 123 M 0 0 0 <a href="DeleteName.do">删除</a> 修改 新建