KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > dao > BlockDAO


1
2  /*
3  -- GeiNuke --
4 Copyright (c) 2005 by Roberto Sidoti [geinuke@users.sourceforge.net]
5  http://www.hostingjava.it/-geinuke/
6
7 This file is part of GeiNuke.
8
9     GeiNuke is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     GeiNuke is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with GeiNuke; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */

23 package com.geinuke.dao;
24
25 import java.sql.SQLException JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 import com.geinuke.common.UserI;
30 import com.geinuke.vo.BlockDBVO;
31
32
33 public class BlockDAO extends GeiDAO{
34
35     
36     public BlockDAO() throws Exception JavaDoc {
37         super();
38         
39     }
40     /**
41      *
42      * @return an ArrayList of BlockDBVO
43      * @throws SQLException
44      */

45     public ArrayList JavaDoc getAllBlocks()throws SQLException JavaDoc{
46         ArrayList JavaDoc list=null;
47         List JavaDoc llist=null;
48         try{
49             sqlMap().startTransaction();
50             llist=sqlMap().queryForList("getAllBlocks","");
51             sqlMap().commitTransaction();
52         }finally{
53             sqlMap().endTransaction();
54         }
55         list=new ArrayList JavaDoc(llist);
56         return list;
57     }
58     
59     public ArrayList JavaDoc getAllStoredBlocks()throws SQLException JavaDoc{
60         ArrayList JavaDoc list=null;
61         List JavaDoc llist=null;
62         try{
63             sqlMap().startTransaction();
64             llist=sqlMap().queryForList("getAllStoredBlocks","");
65             sqlMap().commitTransaction();
66         }finally{
67             sqlMap().endTransaction();
68         }
69         list=new ArrayList JavaDoc(llist);
70         return list;
71     }
72     
73     public void updateDBBlock(BlockDBVO blo)throws Exception JavaDoc{
74         try{
75             this.sqlMap().startTransaction();
76             this.sqlMap().update("updateDBBlock",blo);
77             sqlMap().commitTransaction();
78         }finally{
79             this.sqlMap().endTransaction();
80         }
81     
82     }
83     
84     public void delDBBlock(int id)throws Exception JavaDoc{
85         try{
86             this.sqlMap().startTransaction();
87             this.sqlMap().delete("delDBBlock",new Integer JavaDoc(id));
88             sqlMap().commitTransaction();
89         }finally{
90             this.sqlMap().endTransaction();
91         }
92     
93     }
94     
95     public void insertDBStoredBlock(BlockDBVO blo)throws Exception JavaDoc{
96         try{
97             this.sqlMap().startTransaction();
98             this.sqlMap().insert("insertDBStoredBlock",blo);
99             sqlMap().commitTransaction();
100         }finally{
101             this.sqlMap().endTransaction();
102         }
103     
104     }
105     
106     public BlockDBVO getBlockById(int id)throws SQLException JavaDoc{
107         BlockDBVO res=null;
108         
109         try{
110             sqlMap().startTransaction();
111             res=(BlockDBVO)sqlMap().queryForObject("getBlockById",new Integer JavaDoc(id));
112             sqlMap().commitTransaction();
113         }finally{
114             sqlMap().endTransaction();
115         }
116         
117         return res;
118     }
119     
120     public BlockDBVO getBlockByName(String JavaDoc name)throws SQLException JavaDoc{
121         BlockDBVO res=null;
122         
123         try{
124             sqlMap().startTransaction();
125             res=(BlockDBVO)sqlMap().queryForObject("getBlockByName",name);
126             sqlMap().commitTransaction();
127         }finally{
128             sqlMap().endTransaction();
129         }
130         
131         return res;
132     }
133     
134     public ArrayList JavaDoc getBlocksForUser(UserI user)throws SQLException JavaDoc{
135         ArrayList JavaDoc list=null;
136         List JavaDoc llist=null;
137         try{
138             sqlMap().startTransaction();
139             llist=sqlMap().queryForList("getBlocksForUser",user);
140             sqlMap().commitTransaction();
141         }finally{
142             sqlMap().endTransaction();
143         }
144         list=new ArrayList JavaDoc(llist);
145         return list;
146     }
147
148 }
149
Popular Tags