Win a copy of liveProject: Build an ML Recommender System this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

error in compling --can anyone help

 
Ranch Hand
Posts: 937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a bean to validate the userid and pwd frm db. when i complied it i got a error in one method
here is the code..

/*
* UserIdFormTempBean.java
*
* Created on January 27, 2003, 2:18 PM
*/
package beans.userid;
/**
*
* @author surag
*/

import java.lang.*;
import java.io.*;
import java.sql.*;
import java.util.*;

public class UserIdFormTempBean implements Serializable {


private String userid;

private String pwd;

private Hashtable errors;

private String useridFromDB;

private String pwdFromDB;

//private int noOfAttempts;

public UserIdFormTempBean()
{
userid= "";
pwd="";
// noOfAttempts=0;
System.out.println("Bean Instantiated" + this.userid);
errors= new Hashtable();
}

public int validate()
{
int userIdErr=0;
int pwdErr=0;
int allErr=0;
userid= userid.trim();
pwd= pwd.trim();
if ( userid.equals(null)|| userid.equals(""))
{
errors.put("USERID","Invalid UserId ");
System.out.println("userid error");
userIdErr=1;
allErr=1;
}

if( userIdErr==0)

{
if(!validateUSERIDFromTable( userid))
{

System.out.print( " userid frm db error");
userIdErr=1;
allErr=1;
}

return userIdErr;
}

if (pwd.equals(null)||(pwd.equals("") ))
{

errors.put( "pwd", "Invalid PassWord");
System.out.println("pwd error");
pwdErr=1;
allErr=1;
}


if( pwdErr==0)

{
if(!validatePWDFromTable(pwd))
{

System.out.print( " PASSWORD frm db error");
pwdErr=1;
allErr=1;
}

return pwdErr;


}

if (userIdErr==0)
errors.put("userid","");

if ( pwdErr==0)
errors.put("pwd","");


return allErr;


}

//end of validations



public void setUserId( String USERID){

this.userid= USERID;
System.out.println(" USERID = "+USERID);
}

public void setPwd( String PWD){

this .pwd =PWD;

System.out.println( "PWD="+ PWD);

}


public String getUserid(){

return userid;

}


public String getPwd(){

return pwd;


}







}

private boolean validateUSERIDFromTable(String userid){
boolean vuseridOK= true;
Connection con = null;
Statement stmt= null;
ResultSet rs= null;
String qry = "SELECT LOGIN_ID, PWD FROM SECURITY_USERS WHERE LOGIN_ID= " +userid;
System.out.println("qry in vvalidateUSERIDFromTable="+ qry);
try { Driver myDriver= (Driver)Class.forName("xxxx.jdbc.pool.Driver").newInstance();
con= myDriver.connect("jdbc:xxxx ool:xxxPool", null);
stmt=con.createStatement();
rs=stmt.executeQuery(qry);

if (rs.next())
{

System.out.println("valid userid="+ qry);
}
else
{
errors.put("userid", " Invalid UserID, Please check USERID and try again");

vuseridOK = false;

}

rs.close();
stmt.close();
con.close();


} catch (Exception e){

System.out.println("Datebase connection error "+e );

}

return vuseridOK;

}





private boolean validatePWDFromTable( String pwd)
{
boolean vpwdOK= true;
Connection con = null;
Statement stmt= null;
ResultSet rs= null;
String qry = "SELECT LOGIN_ID, PWD FROM SECURITY_USERS WHERE PASSWORD= " +pwd;
System.out.println("qry in vvalidatePWDFromTable="+ qry);
try
{ Driver myDriver= (Driver)Class.forName("xxxx.jdbc.pool.Driver").newInstance();
con= myDriver.connect("jdbc:xxxx ool:xxxPool", null);
stmt=con.createStatement();
rs=stmt.executeQuery(qry);

if (rs.next())
{

System.out.println("valid userid="+ qry );
}
else
{
errors.put("userid", " Invalid PASSWORD, Please check PASSWORD and try again");

vpwdOK = false;
}

rs.close();
stmt.close();
con.close();

}
catch (Exception e)
{

System.out.println("Datebase connection error "+e );
}

return vpwdOK;

}




}
 
sunitha reghu
Ranch Hand
Posts: 937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SOLVED THAT ....AN EXTRA }
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is the code without errors
but remember one thing while coding , do indenting with ur code for easy debugging n find out the compile-time errors.

/*
* UserIdFormTempBean.java
*
* Created on January 27, 2003, 2:18 PM
*/
package beans.userid;
/**
*
* @author surag
*/

import java.lang.*;
import java.io.*;
import java.sql.*;
import java.util.*;
public class UserIdFormTempBean implements Serializable {
private String userid;
private String pwd;
private Hashtable errors;
private String useridFromDB;
private String pwdFromDB;
//private int noOfAttempts;
public UserIdFormTempBean()
{
userid= "";
pwd="";
// noOfAttempts=0;
System.out.println("Bean Instantiated" + this.userid);
errors= new Hashtable();
}
public int validate()
{
int userIdErr=0;
int pwdErr=0;
int allErr=0;
userid= userid.trim();
pwd= pwd.trim();
if ( userid.equals(null)|| userid.equals(""))
{
errors.put("USERID","Invalid UserId ");
System.out.println("userid error");
userIdErr=1;
allErr=1;
}
if( userIdErr==0)
{
if(!validateUSERIDFromTable( userid))
{
System.out.print( " userid frm db error");
userIdErr=1;
allErr=1;
}
return userIdErr;
}
if (pwd.equals(null)||(pwd.equals("") ))
{
errors.put( "pwd", "Invalid PassWord");
System.out.println("pwd error");
pwdErr=1;
allErr=1;
}
if( pwdErr==0)
{
if(!validatePWDFromTable(pwd))
{
System.out.print( " PASSWORD frm db error");
pwdErr=1;
allErr=1;
}
return pwdErr;
}
if (userIdErr==0)
errors.put("userid","");
if ( pwdErr==0)
errors.put("pwd","");
return allErr;
}
public void setUserId( String USERID){
this.userid= USERID;
System.out.println(" USERID = "+USERID);
}
public void setPwd( String PWD){
this .pwd =PWD;
System.out.println( "PWD="+ PWD);
}
public String getUserid(){
return userid;
}
public String getPwd(){
return pwd;
}
private boolean validateUSERIDFromTable(String userid){
boolean vuseridOK= true;
Connection con = null;
Statement stmt= null;
ResultSet rs= null;
String qry = "SELECT LOGIN_ID, PWD FROM SECURITY_USERS WHERE LOGIN_ID= " +userid;
System.out.println("qry in vvalidateUSERIDFromTable="+ qry);
try {
Driver myDriver= (Driver)Class.forName("xxxx.jdbc.pool.Driver").newInstance();
con= myDriver.connect("jdbc:xxxx ool:xxxPool", null);
stmt=con.createStatement();
rs=stmt.executeQuery(qry);
if (rs.next())
{
System.out.println("valid userid="+ qry);
}
else
{
errors.put("userid", " Invalid UserID, Please check USERID and try again");
vuseridOK = false;
}
rs.close();
stmt.close();
con.close();
} catch (Exception e){
System.out.println("Datebase connection error "+e );
}
return vuseridOK;
}
private boolean validatePWDFromTable( String pwd)
{
boolean vpwdOK= true;
Connection con = null;
Statement stmt= null;
ResultSet rs= null;
String qry = "SELECT LOGIN_ID, PWD FROM SECURITY_USERS WHERE PASSWORD= " +pwd;
System.out.println("qry in vvalidatePWDFromTable="+ qry);
try
{
Driver myDriver= (Driver)Class.forName("xxxx.jdbc.pool.Driver").newInstance();
con= myDriver.connect("jdbc:xxxx ool:xxxPool", null);
stmt=con.createStatement();
rs=stmt.executeQuery(qry);
if (rs.next())
{
System.out.println("valid userid="+ qry );
}
else
{
errors.put("userid", " Invalid PASSWORD, Please check PASSWORD and try again");
vpwdOK = false;
}
rs.close();
stmt.close();
con.close();
}catch (Exception e){
System.out.println("Datebase connection error "+e );
}
return vpwdOK;
}
}
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic