"General error Unable to open registry key Temporary (volatile) ..." from Access ODBC
Asked Answered
F

7

17

I tried the following:

private String password = "";
private String dbName = "dataHC.accdb";
private String bd = dbName + ";PWD=" + password;
String  url   = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+bd+";";

private Connection conn = null;

//Connect
public void connect() {
    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        conn = DriverManager.getConnection(url);
        if (conn != null)
            System.out.println("Conexión a base de datos "+dbName+". listo");
    }catch(SQLException e){
        System.out.println(e);
    }catch(ClassNotFoundException e){
        System.out.println(e);
    }
}

Font: http://www.jc-mouse.net/base-de-datos/consultas-con-parametros-en-access-y-java

And I obtain this error:

[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x7f8 Thread 0x1174 DBC

specifically

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x7f8 Thread 0x1174 DBC 0x8dc8d78                                                              Jet'.
Exception in thread "main" java.lang.NullPointerException
    at depuracionDB.consultap(depuracionDB.java:67)
    at depuracionDB.main(depuracionDB.java:103)

I am using eclipse IDE Luna and Java version "1.7.0_45" (64 bits)

Fauve answered 7/10, 2014 at 20:12 Comment(4)
That error is often the result of some other process having the Access database open exclusively. Ensure that no other process has the database open (you can just restart your computer to be extra sure) and try running your Java code again.Ossify
Thanks! I have restarted my computer and it worked!Contemplative
I also get this error when I don't have the Microsoft Access Database Engine installed: microsoft.com/en-us/download/details.aspx?id=13255Ballast
I ran into this error, because I had the path: as C:Users\path here, while it was supposed to be C:\Users\path hereTantamount
O
28

Causes

General error Unable to open registry key Temporary (volatile) Ace DSN for process ...

This is the top-level error message produced by the Access Database Engine (a.k.a. "ACE") ODBC driver when the current process is unable to open the Access database file for one of the following reasons:

  1. Some other process has opened the database "exclusively".

  2. Some other process originally opened the database file in Access as "shared" and has some pending structural modification that requires "exclusive" access to the file. Examples of such pending modifications are edits to Module code that have not yet been saved, or having a Form or Report open in Design View.

  3. The account under which the current process is running does not have sufficient filesystem permissions to open the database file or the folder in which it resides.

  4. The account under which the current process is running does not have sufficient registry permissions to access the values under the HKLM\SOFTWARE\ODBC key.

  5. The database file simply does not exist.

  6. The database you are trying to open requires a newer version of Microsoft Access.

When only the top-level error message is reported, the earlier "Jet" ODBC driver produced somewhat more intuitive error messages. When the other process had done an "Open Exclusive" on the file the error message was

Could not use '(unknown)'; file already in use.

and when the file had pending design changes the error message said

The database has been placed in a state by an unknown user that prevents it from being opened or locked.

However, when we only see the top-level message produced by the ACE ODBC driver all we see is

General error Unable to open registry key Temporary (volatile) Ace DSN for process ...

That is because both drivers return multiple error messages, but they return them in a different order. The Jet messages are ...

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] The database has been placed in a state by an unknown user that prevents it from being opened or locked.

ERROR [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xed4 Thread 0x1204 DBC 0xab004 Jet'.

ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed

ERROR [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xed4 Thread 0x1204 DBC 0xab004 Jet'.

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] The database has been placed in a state by an unknown user that prevents it from being opened or locked.

... while the ACE messages are:

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0xf6c Thread 0x1568 DBC 0x6347fec Jet'.

ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0xf6c Thread 0x1568 DBC 0x6347fec Jet'.

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] The database has been placed in a state by an unknown user that prevents it from being opened or locked.

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0xf6c Thread 0x1568 DBC 0x6347fec Jet'.

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0xf6c Thread 0x1568 DBC 0x6347fec Jet'.

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] The database has been placed in a state by an unknown user that prevents it from being opened or locked.

Solutions

Scenarios 1 and 2 (another process has an "exclusive" lock on the file):

Ensure that the database file is not opened by any other process – often that means just closing the Access application itself – and then re-try the ODBC operation from your external application. Rebooting your machine is one way to ensure that any other such processes have been terminated and have relinquished their claim to the database file.

Scenario 3 (insufficient file/folder permissions):

Either adjust the permissions or move the file to a location where the user can open the file. Placing the database file in the root folder of a drive is a common cause of this type of problem.

Scenario 4 (insufficient registry permissions):

Adjust the registry permissions to allow the account to access the HKLM\SOFTWARE\ODBC key. The most common cause in this case is that an IIS process is running under an account that does not have normal "user" privileges. In that case remember that you should not be using Access databases with IIS anyway.

Scenario 5 (database file does not exist):

Fix the connection string so that it contains a valid path to an existing file.

Scenario 6 (database file requires a newer version of Access):

Upgrade Microsoft Access or the Access Database Engine Redistributable (if available).

Ossify answered 11/10, 2014 at 18:3 Comment(7)
Thank you! My issue was the scenario 1. My solution: restart the computerContemplative
Thank you, I just recently installed VS2015SP3 and I started getting this issue. I'm glad it was a simple fix and apparently unrelated to SP3. Thanks!Scent
I am using this driver via R (rsession.exe). The error relates to the registry. The solution was to give my account, which rsession.exe runs under, full control permission on the HKEY_LOCAL_MACHINE\SOFTWARE\ODBC registry key. This is strange because my PC's local Administrators group already had full control permissions on that key, and my account is a member of that group.Lycanthrope
Narrow down the problem. Start with a simple connection string and build it up from there. See this answer.Buckskin
Hi, my database path name has an ampersand in it. "...\mthly calcs & projections\...". Unfortunately, the path name cannot be changed. How to I deal with this case. Is there a way to specify the database path to the driver so it accepts the path with an ampersand? Maybe escaping it somehow or encoding it differently?Apomict
"&" doesn't work because ; is interpreted as an option delimiter.Apomict
I have asked the question here more formally.Apomict
B
4

Cause 6 (otherwise not covered) Forgetting to change the filename you're trying to open, after you've changed the name of the file. i.e. trying to open a non-existent file.

Bathometer answered 22/4, 2015 at 19:37 Comment(1)
Similar to this I changed my *.accdb filename to a different filename in a different folder and managed to leave out the pathname.Haik
Z
4

I got this same problem and none of the solutions here helped me. But when I changed the path to the database to ".\database.accdb' it worked!

Zwick answered 28/11, 2019 at 5:9 Comment(1)
It works. But why?Ascensive
A
1

Cause 5 (not covered by Gord's otherwise excellent explanation)

User error - For example, trying to use the ACE driver to read something it's not designed to handle (like an Excel file) that was being read with the Jet ODBC driver in an earlier version of the function. Even if the message is rathen vague, it is correctly catching an error at open time rather than after you think the open was successful. :/

Accidence answered 3/2, 2015 at 19:17 Comment(0)
H
1

In this case you need to mention the entire path of your access db file. And in the url mentioned below a space is mandatory between two extensions(*.mdb, *.accdb)

e.g.:

String database="C:/Users/GIRI/Desktop/fdsfkdsfj/abc.accdb";
String url="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + database + ";DriverID=22;READONLY=true";
Hanway answered 6/3, 2016 at 15:12 Comment(0)
A
-1
  try
            {
                         String conUrl = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + filepath;

                       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                           con=DriverManager.getConnection(conUrl);
            }
            catch(SQLException s)
            {
                   System.out.println(s);
            }

I think this link can help you http://java2carrer.blogspot.in/2013/06/insert-data-into-ms-access-from-excel.html

Adalbertoadalheid answered 8/10, 2014 at 13:53 Comment(0)
C
-1

Please try this code I tried it on win 7 ultimate 64 bit with office 2013 64bit

package dbase.dbconnection;

import java.sql.*;

public class MSAccessDbConnect {

    public static void main(String args[]) throws Exception {

        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        String password = "";
        String dbName = "D:/maven_ejb_train/DATA/EmpTest.accdb";
        String bd = dbName; // + ";PWD=" + password;

        String connURL = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="
                + dbName;
        System.out.println("connURL ===== " + connURL);

        String sql2 = "select * from Employees ";

        Connection conn = DriverManager.getConnection(connURL, "", "");
        System.out.println("aaa 111");
        ResultSet rs = conn.createStatement().executeQuery(sql2);
        System.out.println("aaa 222");

        while (rs.next()) {
            System.out.println("Name: " + rs.getString("EMP_NA") + " ID: "
                    + rs.getString("EMP_NO"));

        }
        rs.close();
        conn.close();
    }
}
Cathiecathleen answered 23/1, 2017 at 12:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.