Ticket #133: rasjQuery.java

File rasjQuery.java, 1.1 KB (added by Ernesto Rodriguez, 12 years ago)
Line 
1import org.odmg.Database;
2import org.odmg.Implementation;
3import org.odmg.ODMGException;
4import org.odmg.OQLQuery;
5import org.odmg.QueryException;
6import org.odmg.Transaction;
7import rasj.RasImplementation;
8
9class 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}