-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [Délestage] Base bloquée en écriture
PostPosted: Fri Jun 08, 2007 5:31 pm 
Newbie

Joined: Fri Jun 08, 2007 5:26 pm
Posts: 2
Dans une appli je sauvegarde le SGBD qui est un fichier Firebird (géré par Hibernate) nommé BASE.FDB par sa copie dans un fichier nommé COPIE.FDB et cela fonctionne.

Maintenant je dois faire la copie de la sauvegarde COPIE.FDB sur BASE.FDB.

Cette action génère l'erreur suivante :

Code:
   java.io.FileOutputStream.open(Native Method) 
   java.io.FileOutputStream.<init>(Unknown Source) 
   java.io.FileOutputStream.<init>(Unknown Source) 
   util.Fichier.copieFichier(Fichier.java:103) 
   pages.base.RestaurerAction.doRestaurer(RestaurerAction.java:62) 
   pages.base.RestaurerAction.xExecute(RestaurerAction.java:32) 
   pages.global.GlobalAction.execute(GlobalAction.java:66) 
...

... et le message suivant :

Code:
Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus

Si je réalise la copie avant un accès à la base (donc dès le démarrage de tomcat et de l'application J2EE) cela fonctionne.

Dès qu'il y a eu un accès à la base auparavant : la fonction retour l'erreur.

Pourtant à chaque requête je crée une session et ensuite je ferme la session.

Voici la classe HibernateUtil :

Code:
package dao.requete;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil
{
    private static final String HIBERNATE_FICHIER_CONFIGURATION = "hibernate.cfg.xml";

    private static SessionFactory sessionFactory;

    public static final ThreadLocal<Session> threadSession = new ThreadLocal<Session>();

    public static Configuration cfg;

   
    public static Session currentSession() throws HibernateException
    {
        Session s = threadSession.get();
        // Open a new Session, if this Thread has none yet
        if (s == null)
        {
            s = sessionFactory.openSession();
            threadSession.set(s);
        }
        return s;
    }

    public static void closeSession() throws HibernateException
    {
        Session s = threadSession.get();
        threadSession.set(null);
        if (s != null)
        {
            s.close();
        }
       
       
    }

    public static void initConfig(String pathBase)
    {
        cfg = new Configuration().configure(HIBERNATE_FICHIER_CONFIGURATION);
       
        cfg.setProperty("hibernate.connection.url", "jdbc:firebirdsql:localhost/3050:" + pathBase);
        // System.out.println(cfg.getProperty("hibernate.connection.url"));
               
        cfg.setProperty("hibernate.dialect",
                "org.hibernate.dialect.FirebirdDialect");
        cfg.setProperty("hibernate.cglib.use_reflection_optimizer", "false");
        cfg.setProperty("hibernate.connection.autocommit", "false");
        //cfg.setProperty("hibernate.transaction.auto_close_session", "true");
       
        // Create the SessionFactory
        sessionFactory = cfg.buildSessionFactory();

    }
}

... et la classe HibernateDaoFactory :

Code:
package dao.requete;

import org.hibernate.HibernateException;
import org.hibernate.Session;

public class HibernateDaoFactory
{
    private static Session session;

   
    public static Session creerConnexion() throws HibernateException
    {
        session = HibernateUtil.currentSession();
        return session;
    }

    public static IDaoUtilisateur getDaoUtilisateur()
    {
        return new DaoUtilisateur();
    }

...

}


Comment libérer le fichier BASE.FDB juste avant son remplacement ?

Merci.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.