Sandesh's answer works great, but uses the PostgreSql driver. AWS provides the Redshift driver, which is better than the PostgreSql driver. Other things will remain the same. I hope this information can help others.
1) JDBC Driver will change from org.postgresql.Driver to com.amazon.redshift.jdbcXX.Driver , where XX is the version of Redshift driver. e.g. 42
2) Jdbc url will change from postgreSQL to redshift .
import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import java.util.Properties; public class RedShiftJDBC { public static void main(String[] args) { Connection conn = null; Statement statement = null; try {
Red boy
source share