Click here to Skip to main content
15,916,188 members
Home / Discussions / Java
   

Java

 
AnswerRe: Bluetooth low Energy Sensor Pin
Richard MacCutchan5-Aug-17 1:34
mveRichard MacCutchan5-Aug-17 1:34 
Questionwhy do we need serialization?if we dont do serialization what will happen.SCenarios please Pin
Prakashhhh2-Aug-17 7:35
Prakashhhh2-Aug-17 7:35 
AnswerRe: why do we need serialization?if we dont do serialization what will happen.SCenarios please Pin
Richard MacCutchan2-Aug-17 20:45
mveRichard MacCutchan2-Aug-17 20:45 
Question[Java] New to programming Pin
CoderKlip30-Jul-17 12:46
CoderKlip30-Jul-17 12:46 
AnswerRe: [Java] New to programming Pin
Richard MacCutchan30-Jul-17 20:40
mveRichard MacCutchan30-Jul-17 20:40 
AnswerRe: [Java] New to programming Pin
jschell1-Aug-17 8:00
jschell1-Aug-17 8:00 
AnswerRe: [Java] New to programming Pin
OM Bharatiya15-Aug-17 7:06
OM Bharatiya15-Aug-17 7:06 
Questionnot able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
LOKENDRA YADAV15-Jul-17 9:46
LOKENDRA YADAV15-Jul-17 9:46 
------------
Java
public String getLogin(StudentTO sto)

{
String u=sto.getUsername();
String p=sto.getPassword();

System.out.println(sto.getUsername());
System.out.println(sto.getPassword());





String sql="select * from studentstable";
System.out.println(sql);



Object obj=JdbcTemplate.queryForObject(sql, new RowMapper() {




  public Object mapRow(ResultSet rs) throws SQLException {



  rs.beforeFirst();

      while (rs.next()) {

      String userdb=rs.getString("username");
      String passdb=rs.getString("password");
      String roledb=rs.getString("role");
      String string="";


  if(userdb.equals(u) && passdb.equals(p) && roledb.equalsIgnoreCase("admin")) { 
      System.out.println("ADMIN_ROLE");

      string="ADMIN";

      return string;//this result i want to return in my method as String


  }else if(userdb.equals(u) && passdb.equals(p) && roledb.equalsIgnoreCase("user")) {

      System.out.println("USER_ROLE");

      string="USER";

      return string;//this result i want to return in my method as String

  }

------------------ after this code the return statement is not coming as object-------------------
Java
Object obj=string;

  }//end ofwhile (rs.next())


      return obj;      <-------------------------------------------//error line



  }//end of Object mapRow(ResultSet rs)


 

});//end queryForObject



StudentTO sto1=(StudentTO)obj;

System.out.println(sto1);

  return sto1.toString(); 


}


i only want my method String getLogin() to give m result as ADMIIN or USER

modified 15-Jul-17 16:11pm.

AnswerRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
Richard MacCutchan15-Jul-17 20:47
mveRichard MacCutchan15-Jul-17 20:47 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
LOKENDRA YADAV15-Jul-17 22:28
LOKENDRA YADAV15-Jul-17 22:28 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
Richard MacCutchan16-Jul-17 1:29
mveRichard MacCutchan16-Jul-17 1:29 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
LOKENDRA YADAV16-Jul-17 2:42
LOKENDRA YADAV16-Jul-17 2:42 
GeneralRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
Richard MacCutchan16-Jul-17 2:45
mveRichard MacCutchan16-Jul-17 2:45 
SuggestionRe: not able to return the result to String method getLogin()? result should return "admin" or "user" as a String Pin
Richard Deeming17-Jul-17 1:30
mveRichard Deeming17-Jul-17 1:30 
Questionvideo tracking Pin
Member 129924425-Jul-17 18:12
Member 129924425-Jul-17 18:12 
AnswerRe: video tracking Pin
Django_Untaken5-Jul-17 19:30
Django_Untaken5-Jul-17 19:30 
QuestionObserver Pattern - Restart Thread Again When Exception Occurs Pin
Django_Untaken5-Jul-17 8:52
Django_Untaken5-Jul-17 8:52 
AnswerRe: Observer Pattern - Restart Thread Again When Exception Occurs Pin
Richard MacCutchan5-Jul-17 21:55
mveRichard MacCutchan5-Jul-17 21:55 
QuestionNo value specified for parameter 2 Pin
karengsh3-Jul-17 5:27
karengsh3-Jul-17 5:27 
AnswerRe: No value specified for parameter 2 Pin
Richard Deeming3-Jul-17 5:29
mveRichard Deeming3-Jul-17 5:29 
GeneralRe: No value specified for parameter 2 Pin
karengsh3-Jul-17 5:33
karengsh3-Jul-17 5:33 
GeneralRe: No value specified for parameter 2 Pin
Richard Deeming3-Jul-17 7:06
mveRichard Deeming3-Jul-17 7:06 
GeneralRe: No value specified for parameter 2 Pin
karengsh3-Jul-17 16:33
karengsh3-Jul-17 16:33 
GeneralRe: No value specified for parameter 2 Pin
Richard MacCutchan3-Jul-17 21:20
mveRichard MacCutchan3-Jul-17 21:20 
GeneralRe: No value specified for parameter 2 Pin
karengsh4-Jul-17 5:51
karengsh4-Jul-17 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.