Hi!

I want to backup my h2.db, which is almost accessed by at max half a dozen 
people at one time, normally only one:


   1. Approach was to copy it and just to log off the user and make 
   manually sure nobody else would access the database. Is this a working 
   approach, although unsafe?
   2. Because I did not find first solution very attractive I was looking 
   for another option and find the excerpt from the h2 tutorial from its home 
   page.


So I can do an online backup (while Database is connected to my Tomcat web 
app):

"Online Backup 

The BACKUP SQL statement and the Backup tool both create a zip file with 
the database file. However, the contents of this file are not human 
readable. 

The resulting backup is transactionally consistent, meaning the consistency 
and atomicity rules apply. 

BACKUP TO 'backup.zip'
"

  
So my persistenceUnit is connected to 12 persistence classes, which 
represents the 12 tables of the database. I made my queries with 

```java  [code]
    @PersistenceContext(unitName="persistenceUnit")
    EntityManager entityManager;

        public List<TableLock> findAllTableLocks() {
            return entityManager.createQuery("select o from TableLock o", 
TableLock.class).getResultList();
        }
```java [/code]

But this is not working for my example:

[code]
            try {
                filename = "/media/usb/backup.zip";//filename +"2";
                q =  entityManager.createNamedQuery("BACKUP TO 
\'"+filename+"\'", TableLock.class).executeUpdate();
                entityManager.getTransaction().commit();

            } catch (Exception e) {
                e.printStackTrace();
            }
[/code]

will throw an 
InvalidDataAccessApiUsageException! Why?


Any hints appreciated!


Thanks in advance, cause I am little stuck...


Peter

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to