| 1 package org.javabb.dao.jdbc; 2 3 import java.sql.SQLException ; 4 import java.sql.Statement ; 5 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 import org.javabb.dao.entity.IUserSecurityDAO; 9 import org.springframework.jdbc.CannotGetJdbcConnectionException; 10 import org.springframework.jdbc.core.support.JdbcDaoSupport; 11 12 public class JdbcUserSecurityDAO extends JdbcDaoSupport implements 13 IUserSecurityDAO { 14 15 private final Log log = LogFactory.getLog(JdbcUserSecurityDAO.class); 16 17 20 public void createHashCode(Long userId, String hashCode) throws Exception { 21 Statement stmt = null; 22 try { 23 log.debug("Creating new userHashCode to userId " + userId); 24 stmt = this.getConnection().createStatement(); 25 stmt.executeUpdate("UPDATE jbb_users SET user_code='"+ hashCode +"' where id_user=" + userId); 26 log.debug("HashCode created"); 27 } catch (CannotGetJdbcConnectionException e) { 28 e.printStackTrace(); 29 } catch (SQLException e) { 30 e.printStackTrace(); 31 }finally{ 32 try { 33 getConnection().commit(); 34 stmt.close(); 35 stmt = null; 36 } catch (SQLException e) {} 37 } 38 39 } 40 41 public void refreshSession(Object obj) {} 42 } 43 | Popular Tags |