01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: generic.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.database.testdatabasedrivers;
09:
10: import com.uwyn.rife.database.Datasource;
11: import com.uwyn.rife.database.TestDbQueryManagerImpl;
12: import com.uwyn.rife.database.exceptions.DatabaseException;
13: import com.uwyn.rife.database.queries.CreateTable;
14: import com.uwyn.rife.database.queries.DropTable;
15: import com.uwyn.rife.database.queries.Insert;
16: import com.uwyn.rife.database.queries.Select;
17:
18: public class generic extends TestDbQueryManagerImpl {
19: protected CreateTable mCreateStructure = null;
20: protected Insert mStore = null;
21: protected Select mCount = null;
22: protected DropTable mRemoveStructure = null;
23:
24: public generic(Datasource datasource) {
25: super (datasource);
26:
27: mCreateStructure = new CreateTable(getDatasource()).table(
28: "TestTable").column("id", int.class,
29: CreateTable.NOTNULL).column("valuecol", String.class,
30: 32, CreateTable.NOTNULL).primaryKey("ID_PK", "id");
31:
32: mStore = new Insert(getDatasource()).into(
33: mCreateStructure.getTable()).fieldParameter("id")
34: .fieldParameter("valuecol");
35:
36: mCount = new Select(getDatasource()).from(
37: mCreateStructure.getTable()).field("count(*)");
38:
39: mRemoveStructure = new DropTable(getDatasource())
40: .table(mCreateStructure.getTable());
41: }
42:
43: public boolean install() throws DatabaseException {
44: return _install(mCreateStructure);
45: }
46:
47: public void store(int id, String value) throws DatabaseException {
48: _store(mStore, id, value);
49: }
50:
51: public int count() throws DatabaseException {
52: return _count(mCount);
53: }
54:
55: public boolean remove() throws DatabaseException {
56: return _remove(mRemoveStructure);
57: }
58: }
|