1 | import org.odmg.Database;
|
---|
2 | import org.odmg.Implementation;
|
---|
3 | import org.odmg.ODMGException;
|
---|
4 | import org.odmg.OQLQuery;
|
---|
5 | import org.odmg.QueryException;
|
---|
6 | import org.odmg.Transaction;
|
---|
7 | import rasj.RasImplementation;
|
---|
8 |
|
---|
9 | class rasjQuery implements Runnable{
|
---|
10 |
|
---|
11 | public static String RASDAMAN_URL = "http://localhost:7001";
|
---|
12 | public static String query= "select csv(c[0:200,0:200]) from NIR AS c";
|
---|
13 | public static String RASDAMAN_DATABASE = "RASBASE";
|
---|
14 |
|
---|
15 | private Implementation impl;
|
---|
16 | private Database db;
|
---|
17 |
|
---|
18 | public rasjQuery(){
|
---|
19 |
|
---|
20 | this.impl=new RasImplementation(RASDAMAN_URL);
|
---|
21 | this.db=this.impl.newDatabase();
|
---|
22 |
|
---|
23 | }
|
---|
24 |
|
---|
25 | public rasjQuery(Implementation impl,Database db){
|
---|
26 |
|
---|
27 | this.impl=impl;
|
---|
28 | this.db=this.impl.newDatabase();
|
---|
29 | }
|
---|
30 |
|
---|
31 | public void run(){
|
---|
32 |
|
---|
33 | try{
|
---|
34 | this.db.open(RASDAMAN_DATABASE, Database.OPEN_READ_ONLY);
|
---|
35 | Transaction tr = this.impl.newTransaction();
|
---|
36 | OQLQuery q = this.impl.newOQLQuery();
|
---|
37 | tr.begin();
|
---|
38 | q.create(query);
|
---|
39 | Object r=q.execute();
|
---|
40 | tr.commit();
|
---|
41 | this.db.close();
|
---|
42 | }catch(Exception e){
|
---|
43 |
|
---|
44 | e.printStackTrace();
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|