1 package ch.ige.edossier.web.server.dao;
2
3 import java.sql.Connection;
4 import java.sql.PreparedStatement;
5 import java.sql.SQLException;
6 import ch.ige.edossier.util.DBHelper;
7 import ch.ige.edossier.web.vo.RoleAdrDossierVO;
8
9
17 public class RoleAdrDossierDAO
18 {
19
24 public void insert( RoleAdrDossierVO roleAdrDossierVO ) throws Exception
25 {
26 Connection con = null;
27 PreparedStatement ps = null;
28
29 try
30 {
31 con = DBHelper.getInstance().getEsolutionConnection();
32
33 ps = con.prepareStatement(
34 "INSERT INTO edossier.role_adr_dossier(" +
35 "dossier_id, " +
36 "role_id, " +
37 "address_id ) " +
38 "VALUES(?,?,?)"
39 );
40
41 ps.setInt( 1, roleAdrDossierVO.getDossierId() );
42 ps.setInt( 2, roleAdrDossierVO.getRoleId() );
43 ps.setInt( 3, roleAdrDossierVO.getAddressId() );
44
45 if( ps.executeUpdate() != 1 )
46 {
47 throw new SQLException();
48 }
49
50 }
51 finally
52 {
53 DBHelper.getInstance().close( con, ps );
54 }
55 }
56
57
58
64 public int delete( int dossier_id ) throws SQLException
65 {
66 Connection con = null;
67 PreparedStatement ps = null;
68
69 try
70 {
71 con = DBHelper.getInstance().getEsolutionConnection();
72
73 ps = con.prepareStatement(
74 "DELETE FROM edossier.role_adr_dossier where dossier_id = ? "
75 );
76 ps.setInt( 1, dossier_id );
77
78 return ps.executeUpdate();
79 }
80 finally
81 {
82 DBHelper.getInstance().close( con, ps );
83 }
84 }
85 }
86