jdbc交互数据库

来源:互联网 发布:美少女梦工厂4工作数据 编辑:程序博客网 时间:2024/06/08 08:59
    private static final Log log = LogFactory.getLog(AppUserDaoImpl.class);    @Override    public Boolean updateImg(String userId, String url) {        // TODO Auto-generated method stub        String sql = "update org_employee set sphoto=? where id=?";        Connection conn = null;        PreparedStatement ps = null;        try {            conn = DBConnection.getConnection();            if (conn == null) {                log.error("AppUserDaoImpl: 无法获得数据库连接!");                throw new SQLException("AppUserDaoImpl: 无法获得数据库连接!");            }            ps = conn.prepareStatement(sql);            int i = 1;            ps.setString(i++, url);            ps.setString(i++, userId);            ps.executeUpdate();        } catch (Exception ex) {            log.error("InsertParkmsg异常" + ex);        } finally {            DBConnection.closeConnection(conn);        }        return true;    }
原创粉丝点击