Edit:
I am using Spring Framework which means my application has an embedded Tomcat Servlet. I am then using the following gradle command to compile my application into an executable JAR file:./gradlew clean build
I deploy this file to my server and execute it using this commandSERVER_PORT=9090 java -jar gs-rest-service-0.3.0.jar
Please note that this works fine without the database included in the JAR file (i.e. I can make HTTP requests and pass back information). My problem consists with the Exception error message I receive below.
I'm trying to connect my executable JAR file to my database but I keep getting this error: java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost/projectdb
From research into previous questions I understand that I may need to add or SET the classpath for the JDBC jar file so that when the JAR file executes it knows where to find it. However I don't know how to do this and other answers seem unclear.
I'm using Postgresql and I'm trying to implement this on my server using Ubuntu 14.04. This works fine on my local machine but that's because the JDBC is included as a referenced library. Here is a snippet of code from the log.
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost/projectdb
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at server.DatabaseAccessor.<init>(DatabaseAccessor.java:31)
at server.controllers.ActivityController.<init>(ActivityController.java:18)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
Any useful help and information would be grateful. Thanks.