当前位置: 技术问答>java相关
帮我看一下空指针(NullPointerException)在那里出现?
来源: 互联网 发布时间:2017-04-17
本文导语: 帮我看一下空指针(NullPointerException)在那里出现? public int guestLogin() { int guestID = getGuestMaxID(); while (!addGuest(guestID)) { guestID = getGuestMaxID(); } return guestID; ...
帮我看一下空指针(NullPointerException)在那里出现?
public int guestLogin() {
int guestID = getGuestMaxID();
while (!addGuest(guestID)) {
guestID = getGuestMaxID();
}
return guestID;
}
public int getGuestMaxID() {
int numMaxID = 1;
SQL = "select max(ID)+1 as numMaxID from guestuser";
try {
rs = myDbTrans.executeQuery(SQL);
if (rs.next()) {
numMaxID = rs.getInt("numMaxID");
}
rs.close();
if (numMaxID == 0) {
numMaxID = 1;
}
}
catch (SQLException e) {e.printStackTrace();
}
return numMaxID;
}
public ResultSet executeQuery(String sql) throws SQLException {
ResultSet rs = null;
try {
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
}
catch (SQLException ex) {
ex.printStackTrace();
System.out.println("dbTrans.executeQuery:"+ex.getMessage());
throw ex;
}
return rs;
}
public int guestLogin() {
int guestID = getGuestMaxID();
while (!addGuest(guestID)) {
guestID = getGuestMaxID();
}
return guestID;
}
public int getGuestMaxID() {
int numMaxID = 1;
SQL = "select max(ID)+1 as numMaxID from guestuser";
try {
rs = myDbTrans.executeQuery(SQL);
if (rs.next()) {
numMaxID = rs.getInt("numMaxID");
}
rs.close();
if (numMaxID == 0) {
numMaxID = 1;
}
}
catch (SQLException e) {e.printStackTrace();
}
return numMaxID;
}
public ResultSet executeQuery(String sql) throws SQLException {
ResultSet rs = null;
try {
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
}
catch (SQLException ex) {
ex.printStackTrace();
System.out.println("dbTrans.executeQuery:"+ex.getMessage());
throw ex;
}
return rs;
}
|
public int guestLogin() {
int guestID = getGuestMaxID();
while (!addGuest(guestID)) {
guestID = getGuestMaxID();
}
return guestID;
}
public int getGuestMaxID() {
int numMaxID = 1;
SQL = "select max(ID)+1 as numMaxID from guestuser";
try {
rs = myDbTrans.executeQuery(SQL);
if (rs.next()) {
numMaxID = rs.getInt("numMaxID");
}
rs.close();
if (numMaxID == 0) {
numMaxID = 1;
}
}
catch (SQLException e) {e.printStackTrace();
}
return numMaxID;
}
public ResultSet executeQuery(String sql) throws SQLException {
ResultSet rs = null;
try {
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
}
catch (SQLException ex) {
ex.printStackTrace();
System.out.println("dbTrans.executeQuery:"+ex.getMessage());
throw ex;
}
return rs;
}
int guestID = getGuestMaxID();
while (!addGuest(guestID)) {
guestID = getGuestMaxID();
}
return guestID;
}
public int getGuestMaxID() {
int numMaxID = 1;
SQL = "select max(ID)+1 as numMaxID from guestuser";
try {
rs = myDbTrans.executeQuery(SQL);
if (rs.next()) {
numMaxID = rs.getInt("numMaxID");
}
rs.close();
if (numMaxID == 0) {
numMaxID = 1;
}
}
catch (SQLException e) {e.printStackTrace();
}
return numMaxID;
}
public ResultSet executeQuery(String sql) throws SQLException {
ResultSet rs = null;
try {
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
}
catch (SQLException ex) {
ex.printStackTrace();
System.out.println("dbTrans.executeQuery:"+ex.getMessage());
throw ex;
}
return rs;
}