How to validate my password with the value in the oracle database and also what is the difference between return 0 and return 1 in java -


I am not so good in Java. I am making an application and I have been entered as a password in a text box I want to validate the value with the value stored in the database for the password. If both values ​​do not match, I have to show an error message. I am creating a web service for this Java code that I am using. What's the difference between return 0 , return1 , return (value) ?? how can I do this? Can anyone give me a sample code example? I have made a connection to a different category and created an object for it - dbsource.

  package com.daoImpl; Import java.sql.ResultSet; Import java.sql.SQLException; Import java.sql.Statement; Import java.util.ArrayList; Import java.util.list; Import com.dto.LoginBean; Public class ApplicationStatusDAO {DBSource dbsouce = new DBSOS (); Public listing & lt; LoginBean & gt; User Login () {List & lt; LoginBean & gt; ListloginBean = New ArrayList & lt; LoginBean & gt; (); Loginin Login = Null; Description stmt = null; {String query = "choose * from user_self" *; Try {stmt = dbsouce.getConnection (). CreateStatement (); Results set rs = stmt.executeQuery (query); While (rsnext ()) {loginbean = New LoginBean (); System.out.println ("result:" + rsgetstring ("uname") + "" + rsgetstring ("s_gender") + "+ + rsgetstring (" s_lname ")); loginbean.setUname (rs.getString (" uname " ); Loginbean.setPass (rs.getString ("passed"); loginbean.setGender (rs.getString ("s_gender")); loginbean.setLname (rs.getString ("s_lname")); listloginBean.add (loginbean );} System.out.println ("list size" + listloginBean.size ());} hold (SQLException e) {System.out.println ("result set error:" + e);}} hold (exception E) {// TODO auto generated blocking block e.printStackTrace ();} login bean in return list;}  

second category of use:

  Import java.util.List; Import javax.ws.rs.GET; Import javax.ws.rs.Path; Import Javax.ws.rs.produces; import javax.ws.rs.QueryParam; import com.daoImpl.ApplicationStatusDAO; import com.dto.LoginBean; @Path ("/ self service") public class service display {@GET @Produces ("Application / JS") @ path ("Login /") Public LoginBean loginAuth (@QueryParam ("uname") string uname, @ QueryParam ("pass") string pass) {login without login = new login bin (); System.out.println ("login-user-name =" + anonymous + "password =" + pass); ApplicationStatusDAO application StatusDAO = New ApplicationStatusDAO (); & Lt; LoginBean & gt; Bean = app STATUSDAO.userLogin (); (Login Bean A: Bean) {if (uname.equals (aa.getUname ()) and pass.equals (aa.getPass ())} {System.out.println ("ssssssssssssssssssssss"); LoginBean.setGender ( Aa.getGender (); loginBean.setUname (aa.getUname ()); LoginBean.setLname (aa.getLname ()); Returning Bean;} and {System.out.println ("fffffffffffffffff"); // Login Login without 1 = new login bin (); //loginBean1.setFname (device name is not correct); // Return back to bean 1;}} return login bean;}  

Get the password from the user and store it in a string object.

  Get the "system" from the system using the name = "yourpassword"; // or the scanner string user name = "username";  

Now create a function where you will get the data from the table

  public int present () {// Create a query for Oracle data base string Select yourQry = "Yourtable *, where password = '" + + pass + "' and user name = '" + user Name + "'". // Use this query when you are fetching data from the user Resultset rs; Find your data in // resultset if (rs.next ()) {// if data is received, return 1; // In other languages ​​(C, C ++) 0 and 1 are considered as true or false, // 1 means true} and {return 0; // 0 is false (no datafound)}}  

Now this function can be found in the main ()

  Call from int a = present (); If (a == 0) {System.out.print ("Data Not Found") and {System.out.print ("Data Found")}  

Comments