java - I am getting en error for the misplaced return statement while retriving the values for a particular ssnum from the mysql database -


public customer getcustomer(string ssnum) throws customerhomeexception, classnotfoundexception {   string query = "select ssn, customer_name customer ";   resultset rs = smt.executequery(query);   customer customer = null;   while (rs.next()) {     if (ssnum.equals(rs.getstring("ssn"))) {       customer = new customer(rs.getstring("ssn"), rs.getstring("customer_name"));     }     return customer;   }   } catch (sqlexception e) {     throw new customerhomeexception("failed create customerhome", e);   } } 

i'm getting error return statement placed while retriving value mysql database. value exists.

method getcustomer expecting return customer @ end of function definition. , returning in middle of while loop. compiler complaining add or place return statement method suppose to, because not happening while or if executed every time.

private static int hello() {     (int = 0; < 2; i++) {         return 0;     }     return -1; } 

i hope helps.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -