Menu

read only access

Help
2008-08-15
2014-01-19
  • Christian Reuschling

    Hello gods of HSQLDB,

    I want to ask whether there is a possibility to access a database with one process as in-process database (over the jdbc:hsqldb:file: connection), and - in parallel - with other processes, also as file-connection, but in READ ONLY mode. Thus, a 'one provider-several consumers' scenario could be realized.

    Everything I found was the readonly=true flag inside the database property file - I think in this case read access for several processes would be possible, but no write access even from one process.

    Thanks in advance for your help - even if you will tell me that this is not possible ;)

    Christian Reuschling

     
    • Fred Toussi

      Fred Toussi - 2008-08-16

      You want one process to write and others to read from the database. This is not possible because each process has data caches and cannot see changes that are made by other processes.

       
      • Blaine Simpson

        Blaine Simpson - 2008-08-16

        You should still be able to achieve your goals by using a  normal account connection from your R/W process, and use a R/O account for connections from the others.  By R/O account, I mean you create an account and grant it only SEL/USE privs.

         
        • Christian Reuschling

          Hello unsaved,

          I have tried your scenario with the different users, but I still get the exception:

          java.sql.SQLException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@1000e634[file    

          seems that it is even not possible, as I worried it - thanks for your replies

          Chris

           
          • Blaine Simpson

            Blaine Simpson - 2008-08-18

            You need to run a Server to access the database from multiple processes (for reasons that Fred explained).  The Server JVM uses "file" type JDBC URLs to open (and directly access, if necessary) the instance.  The other processes connect to the server through "hsql" type JDBC URLs.

            I've used this idiom hundreds of times to provide read-only access to a subset of db objects, for apps and users that don't need full access.

             

Log in to post a comment.

MongoDB Logo MongoDB