Deployment Zone

Amazon Redshift, PostgreSQL and JDBC driver woes

Amazon Redshift is PostgreSQL 8.x compatible though Amazon also offers JDBC drivers specific to Redshift which may result in better error messages? (I've dealt with enough cryptic errors from Redshift JDBC drivers that I just don't believe this.)

In any case, attempting to use PostgreSQL drivers in the same JVM as Redshift JDBC drivers may cause the Redshift drivers to be loaded for a valid jdbc:postgresql:// protocol due this dual nature heritage. This can cause all sorts of chaos when the driver throws strange exceptions in places you don't expect and you're left wondering why perfectly formatted PGSQL 9.x statements are failing to execute against a PGSQL 9.x database.

The key is to use the 1.1.7 (or later) version of Amazon Redshift's JDBC drivers and then add the non-standard OpenSourceSubProtocolOverride=true parameter to your non-Redshift JDBC URLs. Again, non-Redshift JDBC URLs:

jdbc:postgresql://somehost.amazonaws.com:5432/db?ApplicationName=UsefulMetadata&OpenSourceSubProtocolOverride=true 

Bonus tip: if you're using the JDBC drivers from a Scala/sbt project you can just drop the *.jar in the lib/ directory (off the project root, a sibling of src/). Don't forget to git add -f lib/jdbc-driver.jar - assuming your .gitignore has rules in it like *.jar.

Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus

AltStyle によって変換されたページ (->オリジナル) /