I am using a third party application hosted on tomcat which allows only jdbc connections for querying database. In the new datasource configuration wizard, I have inserted the below details
URL: jdbc:calcite:model=/someLocation/jdbcConnectionModel.json
Driver: org.apache.calcite.jdbc.Driver
/someLocation/jdbcConnectionModel.json content:
inline:
{
version: '1.0',
schemas: [
{
type: 'custom',
name: 'TEST',
factory: 'org.apache.calcite.adapter.geode.rel.GeodeSchemaFactory',
operand: {
locatorHost: 'serverUrl',
locatorPort: '10150',
regions: 'testRegion',
pdxSerializablePackagePath: 'org.apache.calcite.adapter.geode.domain.*'
}
}
]
}
I have copied following jars in tomcat's lib folder which the app can access:
calcite-geode-1.17.0.jar
calcite-core-1.17.0.jar
commons-compiler-jdk-3.0.9.jar
But it gives an error:
Error testing connection, verify DataSource configuration and try again: Cannot load JDBC driver class 'org.apache.calcite.jdbc.Driver'
Is there something I am missing?
I have tried from java code and it works:
public class RelationalJdbcExample {
final static String geodeModelJson =
"inline:"
+ "{\n"
+ " version: '1.0',\n"
+ " schemas: [\n"
+ " {\n"
+ " type: 'custom',\n"
+ " name: 'TEST',\n"
+ " factory: 'org.apache.calcite.adapter.geode.rel.GeodeSchemaFactory',\n"
+ " operand: {\n"
+ " locatorHost: 'serverUrl', \n"
+ " locatorPort: '10150', \n"
+ " regions: 'testRegion', \n"
+ " pdxSerializablePackagePath: 'org.apache.calcite.adapter.geode.domain.*' \n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ "}";
public static Connection getGemfireConnection() throws ClassNotFoundException, SQLException{
Class.forName("org.apache.calcite.jdbc.Driver");
Properties info = new Properties();
info.put("model", geodeModelJson);
Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
return connection;
}
public static void main(String[] args) {
Statement statement;
try {
Connection connection = getGemfireConnection();
CalciteConnection calciteConnection =
connection.unwrap(CalciteConnection.class);
statement = calciteConnection.createStatement();
String query= "SELECT \"a\".\"testAttr\" FROM \"TEST\".\"testRegion\" AS \"a\" ";
ResultSet resultSet = statement.executeQuery(query);
System.out.println("resultSet===="+resultSet);
while (resultSet.next()) {
ResultSetMetaData metaData = resultSet.getMetaData();
System.out.println(metaData.toString());
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
}
The above code fetches data from the cache and returns it correctly. Please help.