How to use two PostgreSQL DB versions in a single Java Application? - java

In our Java project we have already connected two DB's to fetch data using two connection pools.
But now one of our DB is upgraded to PostgreSQL 12 and the other DB has the old PostgreSQL 8 version.
We have imported "postgresql-42.2.11.jar" in the project, Can this jar connect both versions or should we import the old "postgresql-8.1-407.jdbc3.jar" too. If so, will we get any error for using two PostgreSQL jars.
But the surprise is, The project works in local system perfectly connecting two versions of DB with one jar ("postgresql-42.2.11.jar"), Just throwing an warning "WARNING [http-nio-8084-exec-55] org.postgresql.jdbc.PgConnection. Unsupported Server Version: 8.1.11",
But after making it live in linux server its not working, it throws an abrupt error as "Exception org.postgresql.util.PSQLException: FATAL: invalid value for parameter "TimeZone": "Asia/Kolkata"".

It looks to me like the 'Kolkata' spelling was not added until June 2008, first appearing in v8.1.12, one minor version newer than you are using.

Related

How to fix Derby issue for Apache Netbeans IDE 15

Unable to start server for Derby in IDE 15.
Tried to use Derby version 14, didn't work. Tried to change the location of the folder, didn't work.
When I press start server, it just hangs there, does no further processing.
Unresolved NetBeans Bug NETBEANS-3424 Unable to use Derby DB version 10.15.1.3 in Netbeans 11.2 looks relevant to your problem, though you are using different software releases of Derby, Java and NetBeans and your issue is with starting the server rather than establishing a connection.
I can reproduce the connection failure issue on NetBeans 15 using JDK 19 and Derby 10.16.1.1. After selecting the sample database connection jdbc:derby://localhost:1527/sample [app on APP] and selecting Connect... from the context menu this error is displayed:
Although that linked bug report is open and unresolved, a helpful user posted a workaround in the comments so that a suitable driver can be found:
In the Services panel in NetBeans select the entry Databases > Drivers > Java DB (Embedded), right click and select Customize... from the context menu.
The Customize JDBC Driver window will be displayed.
Click the Add... button three times to add the jars derbytools.jar, derbyshared.jar and derbyoptionaltools.jar from the lib directory of your Derby installation (which is named C:\Apache\db-derby-10.16.1.1-bin in my case, but yours is almost certainly something else).
After doing that your Customize JDBC Driver window for your Java DB (Embedded) driver should look similar to this:
Similarly, for the Databases > Drivers > Java DB (Network) entry add the jars derbytools.jar and derbyshared.jar so that your Customize JDBC Driver window looks like this:
After adding those jars to the two drivers you should immediately be able to connect to the APP database using the connection jdbc:derby://localhost:1527/sample [app on APP], and view its tables:
Notes:
You are using Java 8 which is unsupported in NetBeans 15. Update your IDE to use JDK 11 or greater.
You don't need to explicitly start the server by selecting Databases > Java DB > Start Server. Instead, just select Connect... for jdbc:derby://localhost:1527/sample [app on APP]

Required character converter is not available. ERRORCODE=-4220, SQLSTATE=null

The application I migrate to Java8 was running on Java7. After the migration i had to update the db2jcc.jar to latest version and yet I have the error below:
Required character converter is not available. ERRORCODE=-4220, SQLSTATE=null
I have checked and tried the topic Getting error code 4220 with null SQL State
My DB version : DB2 v10.5.0.11
The db2 Jar I use : db2jcc-9.5.jar
Has anyone faced this before?
Regards
Your question included
My DB version : DB2 v10.5.0.11
The db2 Jar I use : db2jcc-9.5.jar
The exception text included:
[Camel Thread #2 - JmsConsumer[null]] WARN **** - SQLException: com.ibm.db2.jcc.a.SqlException:
[jcc][t4][10199][10462][3.52.95] Required character converter is not available. ERRORCODE=-4220, SQLSTATE=null
Notice the db2 jdbc driver version, [3.52.95] included in the exception text.
This is an old driver that comes with db2 version 9.5 fixpack2a, long out of support.
You need to be using a recent type 4 jdbc driver for Db2, and the version of the db2 jdbc driver will appear in the exception text as a three part number with a dot separating the parts.
For Db2-LUW v10.5 the currently available version of the db2 type 4 jdbc driver is 4.19.80 although you can use higher versions.
You can download the recent jdbc driver versions from this IBM website, you will need to register with IBM first, although the download is free.

Hibernate and MSSQL 2016 issue

I'm facing a problem with a Java application (JVM 1.6) that is using Hibernate 3.6 to access a Microsoft SQL Server via Microsoft JDBC Driver for SQL Server.
When working with SQL JDBC driver 3.0 and MSSQL 2008 - 2014 all is working just fine.
But when I'm trying to use MSSQL 2016, the latest "Microsoft JDBC Driver 6.0" (sqljdbc4.jar) - I get a bunch of those errors:
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
It happens on different entities, and can happen on a get or update operations.
My question: is this an issue with Hibernate that also needs to be updated to a newer version?
I wasn't able to find any information about compatibility issues when accessing MSSQL 2016 via Java/Hibernate.
Thanks!
If possible can you try to use JVM 1.7 and sqljdbc41.jar? Better if you able to use JVM 1.8 and sqljdbc42.jar.
Microsoft recently Open Source their driver on GitHub. You can raise issue on their github project.
As per my understanding for SQL Server 2016 you need either sqljdbc41.jar or sqljdbc42.jar
Further you can found more official documentation on MSDN.
Microsoft JDBC Driver 6.0 and 4.2 for SQL Server:
To support backward compatibility and possible upgrade scenarios, the JDBC Drivers 6.0 and 4.2 include four JAR class libraries in each installation package: sqljdbc.jar, sqljdbc4.jar, sqljdbc41.jar, and sqljdbc42.jar. Note: sqljdbc.jar, sqljdbc4.jar are provided only for backwards compatibility, and do not contain new features included with driver versions 6.0, 4.2, and 4.1.

Problems in h2 version 1.4.x when using the "shutdown compact" statement

Is there some known issue with the mv engine in newer h2 versions and the "shutdown compact" statement ?
I have some java code written originally using the h2 v1.3.175 jar library to create and access embedded databases on a hobby programming project that worked fine, but I recently decided to upgrade the jar to the current version v1.4.181 and i began having "chunk not found" errors , and after that the database seems to get corrupted and i cant connect either from my java code or the web console.
The error is: General error: "java.lang.IllegalStateException: Chunk 10 not found [1.4.181/6]" [50000-181] HY000/50000
After checking my java code i found that the problem seems to be the "shutdown compact" statement i was using in my code before disconnecting the database. Deleting that statement solved the problem.

Errors accessing MSSQL form Xpages using ExtlibX - Driver or JVM not supported

I am trying to connect to SQL from Xpages, so I installed the latest extlibx 9 and downloaded the drivers from microsoft and added it to notes9\data\jvm\lib\ext
Now I get the following errors when trying to query SQL from my xpage:
Error I get in xpages extlibx when using Microsoft SQL Driver sqljdbc.jar
Error while reading the relational data
JRE (Java Runtime Environment) version 1.6 stöds inte av den här drivrutinen. Använd klassbiblioteket sqljdbc4.jar som stöder JDBC 4.0.
In English: JRE (Java Runtime Environment) version 1.6 is not supported by this driver. Use class library sqljdbc4.jar which supports JDBC 4.0.
Error I get in xpages extlibx when using Microsoft SQL Driver sqljdbc4.jar
Error while reading the relational data
Error while creating connection
SQL Server version 8 stöds inte av den här drivrutinen. ClientConnectionId:9195a17a-22f4-4377-a41a-be6f213b05ff
In English: SQL Server version 8 is not supported by this driver
A few years ago there was a file called extlib.driver.mssql_1.0.0.201109061401 which worked just fine using the same SQL server I am using now. but I cannot find that file anymore.
what should I do to get SQL queries working?
Ok, I will answer my own question here
The reason for getting these errors is because I was using the wrong driver.
There are two different version of the drivers so make sure you use the right one
This one do not work
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
This one works
http://www.microsoft.com/en-us/download/details.aspx?id=2505

Categories