I am trying to connect to my Redshift database from my android app using the JDBC driver(JDBC42 driver) provided by AWS. In the process of connecting, I am getting "java.lang.ClassNotFoundException: Didn't find class "java.sql.DriverAction" on path: DexPathList".
Details of the JAR files included are:
- implementation files('libs/aws-java-sdk-core-1.11.118.jar')
- implementation files('libs/aws-java-sdk-redshift-1.11.118.jar')
- implementation files('libs/aws-java-sdk-sts-1.11.118.jar')
- implementation files('libs/commons-codec-1.9.jar')
- implementation files('libs/commons-logging-1.1.3.jar')
- implementation files('libs/httpclient-4.5.2.jar')
- implementation files('libs/httpcore-4.4.4.jar')
- implementation files('libs/jackson-annotations-2.10.1.jar')
- implementation files('libs/jackson-core-2.10.1.jar')
- implementation files('libs/jackson-databind-2.10.1.jar')
- implementation files('libs/jackson-dataformat-cbor-2.10.1.jar')
- implementation files('libs/joda-time-2.8.1.jar')
- implementation files('libs/log4j-1.2.17.jar')
- implementation files('libs/RedshiftJDBC42-no-awssdk-1.2.45.1069.jar')
In the build.gradle file I have had to include the following as I was facing Java Resource merge issues:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
The Java compile version is:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Below is my Java Code to make the connection:
Properties props = new Properties();
props.setProperty("user", "admin");
props.setProperty("password", "08021994Feb");
try{
Class.forName("com.amazon.redshift.jdbc42.Driver");
Connection con = DriverManager.getConnection(URL, props);
}
I have been successful in connecting to Redshift database using the above mentioned URL and username password via SQL Workbench but the same is not working out here. I have tried with a bunch of different versions of the JAR files but nothing has worked out. Am I missing something here?