Kawai Wiki

Rev

Rev 49 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
12 soliveira 1
package org.kawai.dao.jdbc;
2
 
3
import java.sql.Connection;
49 soliveira 4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
12 soliveira 6
 
7
import org.mentabean.BeanSession;
8
 
195 helio.frota 9
/**
10
 * Abstract DAO class AbstractJdbcDAO.
11
 *
12
 * @author Sergio Oliveira
13
 *
14
 */
12 soliveira 15
public abstract class AbstractJdbcDAO {
195 helio.frota 16
 
17
    /** Attribute session of AbstractJdbcDAO. */
18
    protected BeanSession session;
19
    /** Attribute conn of AbstractJdbcDAO. */
20
    protected Connection conn;
21
 
22
    /**
23
     * Parametric constructor.
24
     * @param session BeanSession
25
     */
26
    public AbstractJdbcDAO(BeanSession session) {
27
        this.session = session;
28
        this.conn = session.getConnection();
29
    }
30
 
31
    /**
32
     * Close connection resources.
33
     * @param stmt PreparedStatement
34
     * @param rset ResultSet
35
     */
36
    public final static void close(PreparedStatement stmt, ResultSet rset) {
37
 
38
        if (rset != null) try { rset.close(); } catch(Exception e) { e.printStackTrace(); }
39
        if (stmt != null) try { stmt.close(); } catch(Exception e) { e.printStackTrace(); }
40
    }
41
 
42
    /**
43
     * Close prepatedStatement.
44
     * @param stmt PreparedStatement
45
     */
46
    public final static void close(PreparedStatement stmt) {
47
        close(stmt, null);
48
    }
49
}