1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| public String commandButton1_action() {
public Statement StmtP;
public Connection conn;
public ResultSet CrsP;
public CallableStatement callp;
try
{
String s1 = "jdbc:oracle:thin:@adress...:1521:ORCL";
System.out.println( "Connecting with: " );
System.out.println( s1 );
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
this.conn = DriverManager.getConnection( s1,"user","pass");
this.StmtP=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
System.out.println("Connection successful !");
String user_a = (inputText1.getValue().toString()).toUpperCase();
String pass_a = (inputSecret1.getValue().toString()).toUpperCase();
this.CrsP=StmtP.executeQuery("select autent('"+user_a+"','"+pass_a+"') R from dual");
this.CrsP.beforeFirst();
this.CrsP.next();
System.out.println(CrsP.getString("R"));
if (CrsP.getString("R").equals("1")) {
System.out.println("Pass ok");
return "welcome";
}
else {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "resume","detail");
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, message);
return "failure";
}
}
catch ( SQLException e ) {
System.out.println ("\n*** Java Stack Trace ***\n");
e.printStackTrace();
System.out.println ("\n*** SQLException caught ***\n");
while ( e != null ) {
System.out.println ("SQLState: " + e.getSQLState ());
System.out.println ("Message: " + e.getMessage ());
System.out.println ("Error Code: " + e.getErrorCode ());
e = e.getNextException ();
}
}
} |
Partager