1 /*
2 * PROJECT : DAR Runtime and Tools
3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org
4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE
5 * Version 2.1, February 1999
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 package org.enableit.db.isql.biz;
22
23 import java.util.List;
24
25 import org.enableit.db.DBException;
26 import org.enableit.db.GenericDBProxy;
27
28
29 /***
30 * @author tim.stephenson
31 */
32 public class Isql {
33 public static final int QUERY_STATEMENT = 1;
34 public static final int UPDATE_STATEMENT = 0;
35
36 public Isql() {
37 }
38
39 public IsqlModel execute(IsqlModel model)
40 throws DBException {
41 List dbResults = null;
42
43 switch (model.getStatementType(model.getQuery())) {
44 case QUERY_STATEMENT:
45 dbResults = GenericDBProxy.executeQuery(model.getProvider(),
46 model.getQuery());
47 model.setResults(dbResults);
48
49 int rowsFound = (dbResults == null) ? 0 : dbResults.size();
50
51 model.setResponse("Query found " + rowsFound + " rows.");
52
53 break;
54 case UPDATE_STATEMENT:
55 GenericDBProxy.executeUpdate(model.getProvider(), model.getQuery());
56
57 // TODO i18n this message
58 model.setResponse("Update completed.");
59
60 break;
61 }
62
63 return model;
64 }
65 }
This page was automatically generated by Maven