ORVE WS (Dynamic) (9) Persisting retrieved records and other control information (1). H2 DB proposal
0. Introduction
As ORVE WS will have a daily usage, it is important to have a control, so it is required to:- Persist all retrieved records.
- Have a logging system for failures.
- Know the last date the records were requested with success.
- Persist the which "ids" where not successfully retrieved.
So we need a simple database management system for this purpose as this is not a critical system. It can be helped by a property file.
A DBMS candidate for this is H2. Hibernate JPA is a good system to access this DBMS using Java.
It can be downloaded from the H2 page, and unzipped into a folder.
Open a console and go to the "bin" subfolder and run
1.Installing and testing H2
It can be downloaded from the H2 page, and unzipped into a folder.
Open a console and go to the "bin" subfolder and run
java -jar h2*.jar
but if we want that anybody can access our database this command should be executed
java -jar h2*.jar -webAllowOthers -tcpAllowOthers
A new tab is opened in Firefox
If we open a new window in another browser and type this URL "127.0.1.1:8082" we can get another console window.
NOTES:
- When using the "Test Connection" button for the first time, it is created a new database file. In this case the JDBC URL field (jdbc:h2:~/test) indicates that the database file is in the ~ folder (/home/myuser) and is something similar to "test*" (in my case is "test.mv.db"). But you must supply a user and a password and remember these values or else you will not be able to connect to this recently created database.
- When using this button the next times, no database is created, and if you don't provide the user and password, the test will fail.
2. Server mode
If we fillthe JDBC URL field with:
jdbc:h2:tcp://localhost/~/test
Then the access is server mode as a server (localhost) is referenced
3. Where are my Data Files?
I think that "~" represents my home directory (/home/myuser) in Ubuntu, so //localhost/~/test references "/home/myuser/test.mv.db" file
This file name can have some changes depending on the h2 version.
4. Creating SICRES30 Schema
Let's create the schema SICRES30 for organizing purposes. Type
CREATE SCHEMA SICRES30
And the schema appears in the console
Comments
Post a Comment