KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > command > CommandList


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.command;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.result.LocalResult;
10 import org.h2.util.ObjectArray;
11
12 public class CommandList extends Command {
13
14     private Command command;
15     private String JavaDoc remaining;
16     
17     // TODO lock if possible!
18

19     public CommandList(Parser parser, Command c, String JavaDoc remaining) {
20         super(parser);
21         this.command = c;
22         this.remaining = remaining;
23     }
24     
25     public ObjectArray getParameters() {
26         return command.getParameters();
27     }
28     
29     private void executeRemaining() throws SQLException JavaDoc {
30         Command command = session.prepareLocal(remaining);
31         if(command.isQuery()) {
32             command.query(0);
33         } else {
34             command.update();
35         }
36     }
37     
38     public int update() throws SQLException JavaDoc {
39         int updateCount = command.executeUpdate();
40         executeRemaining();
41         return updateCount;
42     }
43     
44     public LocalResult query(int maxrows) throws SQLException JavaDoc {
45         LocalResult result = command.query(maxrows);
46         executeRemaining();
47         return result;
48     }
49     
50     public boolean isQuery() {
51         return command.isQuery();
52     }
53     
54     public boolean isTransactional() {
55         return true;
56     }
57
58     public boolean isReadOnly() {
59         return false;
60     }
61
62 }
63
Popular Tags