I have transferred my PostgreSQL database from an old server to an OCI (Oracle Cloud Infrastructure) instance. The old server was running PostgreSQL version 8.4, and the OCI instance has been upgraded to PostgreSQL 15.3. I'm currently using Java 8 and want to connect to the database using Java.
When I try to connect to the PostgreSQL database from my local machine, the connection is successful, and I can perform all operations. However, when I try to connect to the PostgreSQL database from the OCI instance, the connection works, and I can fetch and update data, but I encounter an error when trying to insert data. The error message is as follows:
### Error updating database. Cause: org.postgresql.util.PSQLException: Returning autogenerated keys is only supported for 8.2 and later servers.
### SQL: insert into t_buyer_cart (visitorno, chartno, lineno, thingno, flag, added_by, added_on, updated_by, updated_on, del_flag) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
### Cause: org.postgresql.util.PSQLException: Returning autogenerated keys is only supported for 8.2 and later servers.; uncategorized SQLException for SQL []; SQL state [0A000]; error code [0]; Returning autogenerated keys is only supported for 8.2 and later servers.; nested exception is org.postgresql.util.PSQLException: Returning autogenerated keys is only supported for 8.2 and later servers.
To resolve this issue, I have tried the following steps:
pom.xml
file (both set to 777).Despite trying these steps, the issue remains unresolved. Anyone have an idea behind the occurrence of this type of issue and how to resolve it?
I'm happy to report that we have successfully resolved the issue related to the JDBC driver in our project. I want to share the solution in case it helps others facing a similar problem.
The Problem: We were using Maven to manage dependencies in our project, and we updated the JDBC driver version in the pom.xml file. Maven automatically downloaded the new JDBC driver JAR file and placed it in the /opt/tomcat/apache-tomcat-8/webapps/example/WEB-INF/lib directory. However, even though the correct version was downloaded, our application was not using the updated JDBC driver, and we encountered an error.
The Solution: After some investigation, we discovered that the application was not picking up the JDBC driver from the /opt/tomcat/apache-tomcat-8/webapps/example/WEB-INF/lib directory as expected. Instead, we manually copied the JDBC driver JAR file to the /opt/tomcat/apache-tomcat-8/lib directory, which is the common library directory for Tomcat.
By placing the JDBC driver in the common library directory and restarting Tomcat, the driver became available to all applications deployed on Tomcat, including our project. This approach resolved the version-related issue, and our application is now using the correct and updated JDBC driver successfully.