KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nilostep > xlsql > sql > xlSqlInsert


1 /*(Header: NiLOSTEP / xlSQL)
2
3     Copyright (C) 2004 NiLOSTEP Information Sciences, all
4     rights reserved.
5     
6     This program is licensed under the terms of the GNU
7     General Public License.You should have received a copy
8     of the GNU General Public License along with this
9     program;
10 */

11
12 package com.nilostep.xlsql.sql;
13
14 import com.nilostep.xlsql.database.xlDatabase;
15 import com.nilostep.xlsql.database.*;
16
17 import java.sql.*;
18
19 /**
20  * DOCUMENT ME!
21  *
22  * @author Jim Caprioli
23  */

24 public class xlSqlInsert implements xlSqlCommand {
25     //~ Instance variables ·····················································
26

27     protected com.nilostep.xlsql.database.xlDatabase db;
28     protected String JavaDoc _schema;
29     protected String JavaDoc _table;
30
31     /**
32      * Creates a new instance of type xlSqlInsert.
33      *
34      *
35      * @param database
36      * @param schema
37      * @param table
38      */

39     public xlSqlInsert(com.nilostep.xlsql.database.xlDatabase database,
40                        String JavaDoc schema,
41                        String JavaDoc table) {
42         if (database == null) {
43             throw new NullPointerException JavaDoc("xlSQL: database null");
44         } else {
45             db = database;
46         }
47
48         if (schema == null) {
49             throw new NullPointerException JavaDoc("xlSQL: schema null");
50         } else {
51             _schema = schema;
52         }
53
54         if (table == null) {
55             throw new NullPointerException JavaDoc("xlSQL: table null");
56         } else {
57             _table = table;
58         }
59     }
60
61     /**
62      * TODO: javadoc
63      *
64      * @return true if allowed
65      *
66      * @throws SQLException
67      */

68     public boolean execAllowed() throws SQLException {
69         boolean ret = true;
70         if (db.getRows(_schema, _table) > 65535) {
71                 ret = false;
72         }
73         return ret;
74     }
75
76     /**
77      * TODO: javadoc
78      *
79      * @throws SQLException
80      */

81     public void execute() throws SQLException {
82         db.addRow(_schema, _table);
83         db.touchSchema(_schema);
84         db.touchTable(_schema, _table);
85     }
86 }
Popular Tags