id=Integer.parseInt(field.getText());
password=passwd.getText();
Connection con=null;
con=conn.ConnDataBase();
try {
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM account where id='"+id+"' and password='"+password+"'");
if(rs.next())
{
account.setBalance(rs.getDouble("balance"));
account.setEmail(rs.getString("email"));
account.setId(rs.getLong("id"));
account.setName(rs.getString("name"));
account.setPersonId(rs.getLong("personId"));
} 提示错误:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at view.BankG$1.actionPerformed(BankG.java:97)[就是这行account.setBalance(rs.getDouble("balance")); ]
1.数据库连接字符串是否正确
2.account是否已实例化
很明显 rs 不为null所以 只需检查 account 就可以了
如果错误的最终源头在[就是这行account.setBalance(rs.getDouble("balance")); ]这行
那就是account为null引起的
如果除了这行还有setBalance方法内部的某行出错,那就说明是rs.getDouble("balance")的返回值为null,对参数进行某操作时异常了