strolch/li.strolch.persistence.post...
Robert von Burg 46ccb921df [Major] Refactored how a TX is closed
- So sadly just auto closing a TX using try-resource from Java7 is a bad idea.
- Doing that leads to problems when an exception is thrown, then the close is called (duh) but this leads to commit being called.
- Since the Java language does not offer a decent way to detect if the close is being called in the context of an exception i was forced to add a tx.commitOnClose() and tx.rollbackOnClose().
- The default is that when a TX is opened, then the close strategy is rollback; the API user must call tx.commitOnClose() before the TX is closed by the braces, or as late as possible, to make sure that if an exception is thrown the transaction is rolled back, and not committed.
- The API was also extended with a tx.fail(msg):StrolchTransactionException so that if the implementor detects an unrecoverable error, one can write: throw tx.fail(“my reason”);

This was sadly an unavoidable late 1.0.0 change
Conflicts:
	li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java
2015-02-03 23:21:28 +01:00
..
src [Major] Refactored how a TX is closed 2015-02-03 23:21:28 +01:00
.gitignore moved everything to a subdirectory for repo merge 2014-09-16 08:52:23 +02:00
LICENSE moved everything to a subdirectory for repo merge 2014-09-16 08:52:23 +02:00
README.md moved everything to a subdirectory for repo merge 2014-09-16 08:52:23 +02:00
pom.xml [Project] Bumped version from 1.0.0-RC1 to 1.0.0-SNAPSHOT 2014-09-20 15:23:11 +02:00

README.md

li.strolch.persistence.postgresql

Build Status

PostgreSQL Persistence Implementation for Strolch

Setup

  1. Install PostgreSQL version with at least version 9.1: $ sudo aptitude install postgresql postgresql-client

  2. Set a password for user 'postgres' $ sudo -u postgres psql postgres postgres=# \password postgres

  3. Create the user and DB: $ sudo -u postgres psql $ postgres=# create user testUser with password 'test'; create database testdb; GRANT ALL PRIVILEGES ON DATABASE testdb to testuser; GRANT CONNECT ON DATABASE testdb TO testuser ;

    For tests:

     create user testUser with password 'test';
     create database testdb;
     GRANT ALL PRIVILEGES ON DATABASE testdb to testuser;
     GRANT CONNECT ON DATABASE testdb TO testuser ;
    
     create user testuser1 with password 'test';
     create database testdb1;
     GRANT ALL PRIVILEGES ON DATABASE testdb1 to testuser1;
     GRANT CONNECT ON DATABASE testdb1 TO testuser1 ;
    
     create user testuser2 with password 'test';
     create database testdb2;
     GRANT ALL PRIVILEGES ON DATABASE testdb2 to testuser2;
     GRANT CONNECT ON DATABASE testdb2 TO testuser2 ;
    
  4. Added new component, setting properties for PostgreSQL DB: PersistenceHandler li.strolch.persistence.api.StrolchPersistenceHandler li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler false <db.url>jdbc:postgresql://localhost/testdb</db.url> <db.username>testUser</db.username> <db.password>test</db.password>

  5. Create tables, or allow strolch to due it for you.

Appendix

  1. To drop the user and DB: postgres=# revoke ALL PRIVILEGES ON DATABASE testdb from testuser; postgres=# drop user testuser; postgres=# drop database testdb;
  2. Create a database: $ createdb -p 5432 -O drupal -U drupal -E UTF8 testingsiteone -T template0
  3. Dropping the database $ dropdb -p 5432 -U drupal testingsiteone
  4. Dumping the database pg_dump -p 5432 -h localhost -Fc -U drupal --no-owner testingsiteone > /tmp/testingsiteone_(date +"%Y-%m-%d_%s").pgdump
  5. Restoring the database $ pg_restore -p 5432 -h localhost -Fc -d testingsiteone -U drupal --no-owner < /tmp/path-to-the-file.pgdump

References

http://www.pixelite.co.nz/article/installing-and-configuring-postgresql-91-ubuntu-1204-local-drupal-development