Matlab Database gives Java exception

6 views (last 30 days)
I have used the Matlab Database toolbox for a long time but today it suddenly fails. If I go go Apps>Database Explorer I get the error:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.toolbox.database.databasePrefs
at com.mathworks.toolbox.database.gui.DatabaseToolstripTab.<init>(DatabaseToolstripTab.java:242)
...
If for example I write
setdbprefs('DataReturnFormat','structure');
I get the error
Error using javaObject
No class com.mathworks.toolbox.database.databasePrefs can be located on the Java class path
Error in setdbprefs (line 58)
DatabasePrefs = javaObject('com.mathworks.toolbox.database.databasePrefs');
If I write
database(server_name,'','','com.microsoft.sqlserver.jdbc.SQLServerDriver', ...
['jdbc:sqlserver://',server_name,':',num2str(port_nr),';database=',database_name,';integratedSecurity=true;']);
I get the error
Error using database (line 309)
Java exception occurred:
java.lang.NoClassDefFoundError: Could not initialize class com.mathworks.toolbox.database.databasePrefs
at com.mathworks.toolbox.database.databaseConnect.makeDatabaseConnection(databaseConnect.java:140)
I have reinstalled Matlab including the Database toolbox and I have reinstalled Java. I have also downloaded the jdbc driver again in case there was some damage to those files. Still it does not work. I do not know of any changes on my computer since yesterday where everything works.
Thanks for any inputs. Benjamin

Accepted Answer

Rahul Goel
Rahul Goel on 26 Oct 2015
Hi Benjamin,
You can try the following steps to see if it resolves it:
1. Go to the preference directory by executing the following command in the MATLAB command prompt:
>>winopen(prefdir)
2. Look for the file named 'database', change the name of the file to something different ie: 'database_old'
3. Restart MATLAB and check that the file still have the same name ie: 'database_old'.
Hope this helps.

More Answers (1)

Benjamin
Benjamin on 29 Oct 2015
Thanks! Worked :)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!