1 | import org.odmg.Database;
|
---|
2 | import org.odmg.ODMGException;
|
---|
3 | import org.odmg.Transaction;
|
---|
4 |
|
---|
5 | import rasj.RasImplementation;
|
---|
6 |
|
---|
7 | public class TestConnect {
|
---|
8 |
|
---|
9 | private static String server = "localhost";
|
---|
10 | private static String port = "7001";
|
---|
11 | private static String databaseName = "RASBASE";
|
---|
12 | private static String user = "rasadmin";
|
---|
13 | private static String password = "rasadmin";
|
---|
14 |
|
---|
15 | public static void main(String[] args) {
|
---|
16 |
|
---|
17 | Database database = null;
|
---|
18 | try {
|
---|
19 | RasImplementation app = new RasImplementation("http://" + server + ":" + port);
|
---|
20 | app.setUserIdentification(user, password);
|
---|
21 |
|
---|
22 | database = app.newDatabase();
|
---|
23 | database.open(databaseName, Database.OPEN_READ_WRITE);
|
---|
24 |
|
---|
25 | Transaction transaction = app.newTransaction();
|
---|
26 | transaction.begin();
|
---|
27 | // do some stuff here...
|
---|
28 | transaction.commit();
|
---|
29 |
|
---|
30 | } catch (ODMGException e) {
|
---|
31 | e.printStackTrace();
|
---|
32 | } finally {
|
---|
33 | if (database != null) {
|
---|
34 | try {
|
---|
35 | database.close();
|
---|
36 | } catch (ODMGException e) {
|
---|
37 | e.printStackTrace();
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|