java继承问题
public abstract class Person{
public Person(){}
public Person(String userName){
this.userName = userName;
}
private String userName = "";
}
public class Manager extends Person{
public Manager(){}
public Manager(String userName,String userSalary)
try{
//数据库连接 Connectin conn =?
//查询结果集 ResultSet rs =?
// select userSalary from user where userName= "+ userName +"";
//取出薪水 正常
this.userSalary = rs.getFloat(1);
super(userName);
//释放连接
}catch(SQLException ex){
}
private float salary = 0.f;
}
问题:
super(userName)的时候,为什么编译通不过
我怀疑是不是当和数据库操作的时候,有可能出现异常的时候,所以不能够初始化父类
不知道理解的对不对, 如果是,该如何处理,如果不是,有时什么原因造成的?