I made a little tool that makes it real easy to access and modify openoffice databases from Java, without having to open oo-base.
Here's a code snippet from the unit test:
Here's the SVN repository:
https://petrus.svn.sourceforge.net/svnroot/petrus/tools/OpenOfficeBaseJPA/
Here's a code snippet from the unit test:
OpenOfficeBaseJPA instance = new OpenOfficeBaseJPA(new File("testdb/TestDatabase.odb"));
EntityManager em = instance.createEntityManager();
Integer rowcount = (Integer) em.createNativeQuery(
"select count(*) from \"PUBLIC\".\"TestTable\"")
.getSingleResult();
em.getTransaction().begin();
em.createNativeQuery(
"insert into \"PUBLIC\".\"TestTable\" (\"TestField\") values ('Testvalue')")
.executeUpdate();
em.getTransaction().commit();
Integer rowcount2 = (Integer) em.createNativeQuery(
"select count(*) from \"PUBLIC\".\"TestTable\"")
.getSingleResult();
assertTrue(rowcount+1==rowcount2);
em.close();
instance.saveChanges();
Thread.sleep(10);
instance = new OpenOfficeBaseJPA(new File("testdb/TestDatabase.odb"));
em = instance.createEntityManager();
Integer rowcount3 = (Integer) em.createNativeQuery(
"select count(*) from \"PUBLIC\".\"TestTable\"")
.getSingleResult();
assertEquals(rowcount2,rowcount3);
Here's the SVN repository:
https://petrus.svn.sourceforge.net/svnroot/petrus/tools/OpenOfficeBaseJPA/
Comments