Postgres/Matlab: "JDBC driver file was not found on MATLAB Java classpath“

4 Ansichten (letzte 30 Tage)
Laura Iten
Laura Iten am 4 Apr. 2017
Kommentiert: Maite Diez am 26 Mär. 2020
I followed the instructions on https://ch.mathworks.com/help/database/ug/postgresql-jdbc-mac.html#bt8lyc7-3 but something doesn't work. I still get the error message "JDBC driver file was not found on MATLAB Java classpath“. Is it possible that my version of Postgres is too new (9.6.2) i.e. not the correct one? Can I change that information somewhere in the "conn" properties?
Is it possible that my .jar file needs some other program? (I have installed the latest Java version.) Or does it need to be in a specific folder?
I have absolutely no idea what is wrong, whether all the necessary programs are installed correctly, whether my Postgres verison causes the error... Any help is greatly appreciated.

Antworten (2)

Prannay Jain
Prannay Jain am 6 Apr. 2017
Make sure that you are using the correct version of JDBC driver and adding the full path to the database driver JAR file in "javaclasspath.txt". MATLAB uses JDK 1.7 or lower and the JDBC driver should match the corresponding JDK version. You can find the java version that your MATLAB is using by running,
>> version -java
For example, if you are using Java 7 then you should use the JDBC 4.1 version. You can find more information about Java and JDBC version on https://jdbc.postgresql.org/download.html
If it still does not work try to install Java 7 on your machine.
  2 Kommentare
Laura Iten
Laura Iten am 7 Apr. 2017
Thanks for you help.
So >> version -java
ans =
Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot™ 64-Bit Server VM mixed mode
When I try to install Java 7, my computer proudly tells me I have a newer version already installed (Java 8). Therefore JDBC 4.2 should be the correct version, which is the version I have downloaded.
I still don't get why I can't configure my PostgreSQL database. Do you think the issue could be my Postgres version? Do you have any other idea, how to fix this? If possible I would love to avoid installing an older PostgreSQL version, as I would have to redo the entire setup. But of course I would do that if it's the only way to query directly from Matlab.
Maite Diez
Maite Diez am 26 Mär. 2020
Hi
I have the same problem as Laura. It also appears "JDBC driver file was not found on MATLAB Java classpath“.
However, I have 'Java 1.8.0_152-b16 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode'. And I downloaded postgresql-42.2.11 version, so they must agree.
My problem is that I don´t know how to add the full path to "javaclasspath.txt".
Any help is greatly appreciated.

Melden Sie sich an, um zu kommentieren.


Prannay Jain
Prannay Jain am 7 Apr. 2017
As I mentioned above, the JDBC driver should match the corresponding JDK version of your MATLAB. Since your MATLAB shows Java 1.7, install JDBC 4.1 version. It should resolve the issue. I am assuming that you might be using JDBC driver 4.2 which is causing the issue.
The version of Postgre SQL server should not matter. It is just the compatibility of JDBC driver that matters with the Java shipped with MATLAB. In general, it is recommended to also install the same version of JDK (you can have other JDK versions also installed) in Operating System as the version of Java shipped with MATLAB.
  1 Kommentar
Laura Iten
Laura Iten am 10 Apr. 2017
Thanks, at least now I get a different error message:
step 5 When continuing on https://ch.mathworks.com/help/database/ug/postgresql-jdbc-mac.html#bt8lyc7-3 Click Test to test the connection. If your connection succeeded, Database Explorer displays Connection Successful!
--> yes, i get a successful connection
Enter a data source name in the Data Source Name field in the Create a New JDBC data source dialog box. Use a new data source name that does not appear in the existing list of data source names. Click Save. The new JDBC data source appears in the list of data sources in the Connect to a Data Source dialog box.
--> If I click save, it will tell me:
"Unknown text on line number 1 of ASCII file .../JCBD_Config/postgresq-42.0.0.jre7(1).jar"
Why is it expectin a ASCII file? What did I do wrong?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by