1 package dinamica.security; 2 3 import dinamica.*; 4 import javax.sql.DataSource ; 5 import java.sql.*; 6 7 16 public class ChangePassword extends GenericTransaction 17 { 18 19 22 public int service(Recordset inputParams) throws Throwable 23 { 24 25 int rc = 0; 26 27 super.service(inputParams); 29 30 String jndiName = (String )getContext().getAttribute("dinamica.security.datasource"); 32 if (jndiName==null) 33 throw new Throwable ("Context attribute [dinamica.security.datasource] is null, check your security filter configuration."); 34 35 DataSource ds = Jndi.getDataSource(jndiName); 37 Connection conn = ds.getConnection(); 38 this.setConnection(conn); 39 40 try 41 { 42 43 conn.setAutoCommit(false); 44 45 Db db = getDb(); 47 48 Recordset user = db.get(getSQL(getResource("getuserkey.sql"), inputParams)); 50 user.next(); 51 Integer userID = user.getInteger("user_id"); 52 inputParams.setValue("userid", userID); 53 54 db.exec(getSQL(getResource("update.sql"), inputParams)); 56 57 db.exec(getSQL(getResource("insert-passlog.sql"), inputParams)); 59 60 conn.commit(); 61 62 } 63 catch (Throwable e) 64 { 65 if (conn!=null) 66 conn.rollback(); 67 throw e; 68 } 69 finally 70 { 71 if (conn!=null) 72 conn.close(); 73 } 74 75 return rc; 76 77 } 78 79 } 80 | Popular Tags |