source: ether_eccad/trunk/ECCAD_INTERFACE/WEB-INF/src/org/medias/eccad/persistance/jdbc/CodeDAOjdbc.java @ 68

Last change on this file since 68 was 68, checked in by cbipsl, 14 years ago

commit v1 eccad

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1package org.medias.eccad.persistance.jdbc;
2
3import java.sql.Connection;
4import java.sql.ResultSet;
5import java.sql.SQLException;
6import java.sql.Statement;
7import java.util.LinkedList;
8import java.util.List;
9
10import org.medias.eccad.persistance.dao.CodeDAO;
11import org.medias.eccad.persistance.exception.PersistanceException;
12
13public class CodeDAOjdbc extends GeneriqueDAOjdbc implements CodeDAO {
14
15        public List<String> getListCodeByGrille(long id_grille) throws PersistanceException {
16                Statement requete;
17                String sql;
18                Connection conn = getConnection();
19                List<String> code = new LinkedList<String>();
20               
21                try {
22                        requete = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
23                        sql = " select legend_code" 
24                                + " from grille join codification using (id_codification)"
25                                + " join code using (id_codification) where id_grille = " + id_grille + " order by id_code;";
26                       
27                        ResultSet resultat = requete.executeQuery(sql);
28                       
29                        while (resultat.next()) {
30                                code.add(resultat.getString("legend_code").toLowerCase());
31                        }
32                }
33                catch (SQLException sqle) {
34                        throw new PersistanceException(sqle, "getListCodeByGrille");
35                }
36               
37                finally {
38                        closeConnection();
39                }
40               
41                return code;
42        }
43
44        public Long getNumberCode(long id_grille) throws PersistanceException {
45                Statement requete;
46                String sql;
47                Connection conn = getConnection();
48                Long code = null;
49               
50                try {
51                        requete = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
52                        sql = " select number_code" 
53                                + " from code where num_code = " + id_grille + ";";
54                       
55                        ResultSet resultat = requete.executeQuery(sql);
56                       
57                        if (resultat.next()) {
58                                code = resultat.getLong("number_code");
59                        }
60                }
61                catch (SQLException sqle) {
62                        throw new PersistanceException(sqle, "getListCodeByGrille");
63                }
64               
65                finally {
66                        closeConnection();
67                }
68               
69                return code;
70        }
71
72}
Note: See TracBrowser for help on using the repository browser.