I tried to install JDBC driver for PostgreSQL on my Macbook Air M1 but it didn't installed. It says "Safari can’t open the file “postgresql-42.3.1.jar” because no available application can open it." How can i run it on my mac. JDBC installation error on mac m1
-
2you don't need to "install" it. Just copy the file somewhere and add it to the classpath of your Java application. – Nov 24 '21 at 19:37
-
Do you have `Java(JDK)` installed? That seems to be a work in progress for the `M1` chip. See [Java/JDK for the Apple M1 chip](https://stackoverflow.com/questions/64788005/java-jdk-for-the-apple-m1-chip). – Adrian Klaver Nov 24 '21 at 19:53
-
@AdrianKlaver No, not a work-in-progress, not any more so than any other implementation of Java. Apple is an active and official member of the OpenJDK project. Mac computers with M1 chip are one of the several platforms supported fully on the OpenJDK project as of Java 17. See [*JEP 391: macOS/AArch64 Port*](https://openjdk.java.net/jeps/391). And previous versions of Java for macOS/AArch64 are provided by multiple vendors such as Azul Systems. – Basil Bourque Nov 24 '21 at 23:30
-
Why is Safari involved? You do not use a web browser to operate a [JDBC driver](https://en.wikipedia.org/wiki/JDBC_driver). – Basil Bourque Nov 24 '21 at 23:33
1 Answers
Merely include the JDBC driver’s JAR file as a dependency within your Java app as you would any other library.
- If using a dependency management tool (highly recommended) such as Maven or Gradle, add a configuration entry for the JDBC driver. The tool will locate, download, and place the JDBC driver’s JAR file into your project.
- If manually managing your dependencies, download the driver and place within the correct folder for your project.
At deployment time, the JDBC driver is automatically registered with the JVM via the SPI facility in Java. This works as long as the driver appears on the Java Classpath.
One exception is for web-app servers such as Apache Tomcat. In such a case, you may need to install the JDBC driver manually into a special location for that server rather than within your app. This has been covered many times on Stack Overflow, so search to learn more.
The driver PostgreSQL JDBC Driver 42.3.1 from here is a Type 4 driver. This means it is written entirely in Java. So that driver will run on any machine capable of running a JVM. A Mac computer with an Apple M1 chip is nothing special in this regard, and is quite capable of making JDBC connections to a Postgres server.
The fact that you report an error message from Safari is quite confusing. The Safari web browser has nothing to do with running Java apps nor JDBC drivers.

- 303,325
- 100
- 852
- 1,154
-
is there any video tutorial from where i can learn to install it properly as i am currently in 1st year of my CSE and don't know much about the technical stuffs.....i have a exam of java on coming weeks which include the topic 'how to use java with database using jdbc'. please help me – ADITYA RAJ Nov 25 '21 at 05:53
-
1@ADITYARAJ There is no 'real' installation involved. You download the JAR file, and add it to the classpath or modulepath of the application you're using (or better yet, use Maven or Gradle to do it for you). Exactly how you manage the classpath for your own Java application is covered in any good introductory text on Java. For other applications, you may need to consult their documentation on how the classpath is managed. – Mark Rotteveel Nov 25 '21 at 08:49
-
1@ADITYARAJ Given this is for school, if you have problems, you should ask your teacher/lecturer or teaching assistant first. – Mark Rotteveel Nov 25 '21 at 08:49
-
@MarkRotteveel Thanks a lot sir.....i have successfully established the connection between PostgreSQL and JAVA. i just added the .jar files in libraries. – ADITYA RAJ Nov 25 '21 at 12:55