Hi,

Please properly subscribe to the mailing list so that the community can
receive email notifications for your messages. To subscribe, send empty
email to [email protected] and follow simple instructions in
the reply.


ssrini9 wrote
> Provided below Code snippet and the error messge. Please help. 
> 
> Code:
> *****
> 
>       public static BasicDataSource getDbcpDataSource(String cacheName) throws
> Exception {
>               
>               Class.forName("org.apache.ignite.IgniteJdbcDriver");
> 
>               if (dataSource == null) {
>                       BasicDataSource ds = new BasicDataSource();
>                       ds.setUrl("jdbc:ignite://localhost:11211/" + cacheName);
>                       ds.setMinIdle(5);
>                       ds.setMaxIdle(10);
>                       ds.setMaxTotal(20);
>                       ds.setMaxOpenPreparedStatements(100);
>                       dataSource = ds;
>               }
> 
>               return dataSource;
> 
>       }
> 
>       public static void verifyDbcpConnetionPooling(String cacheName) throws
> Exception {
>               try (BasicDataSource dataSource = getDbcpDataSource(cacheName);
>                               Connection connection = 
> dataSource.getConnection();
>                               PreparedStatement pstmt = 
> connection.prepareStatement("select id,
> firstName, lastName from Person");) {
>                       System.out.println("The Connection Object is of Class: 
> " +
> connection.getClass());
>                       try (ResultSet resultSet = pstmt.executeQuery();) {
>                               while (resultSet.next()) {
>                                       System.out.println(
>                                                       resultSet.getString(1) 
> + "," + resultSet.getString(2) + "," +
> resultSet.getString(3));
>                               }
>                       } catch (Exception e) {
>                               connection.rollback();
>                               e.printStackTrace();
>                       }
>               }
>       }
> 
> Error Message : 
> ************
> 
> Exception in thread "main" java.sql.SQLException: Cannot create
> PoolableConnectionFactory (Failed to establish connection.)
>       at
> org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2294)
>       at
> org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2039)
>       at
> org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1533)
>       at com.ge.test.App.verifyDbcpConnetionPooling(App.java:47)
>       at com.ge.test.App.main(App.java:17)
> Caused by: java.sql.SQLException: Failed to establish connection.
>       at
> org.apache.ignite.internal.jdbc.JdbcConnection.isValid(JdbcConnection.java:459)
>       at
> org.apache.commons.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:918)
>       at
> org.apache.commons.dbcp2.PoolableConnection.validate(PoolableConnection.java:283)
>       at
> org.apache.commons.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:357)
>       at
> org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2307)
>       at
> org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2290)
>       ... 4 more
> Caused by: class
> org.apache.ignite.internal.client.GridClientFutureTimeoutException: Failed
> to get future result due to waiting timed out.
>       at
> org.apache.ignite.internal.client.impl.GridClientFutureAdapter.get(GridClientFutureAdapter.java:106)
>       at
> org.apache.ignite.internal.jdbc.JdbcConnection.isValid(JdbcConnection.java:456)
>       ... 9 more

This error just means that the driver could not connect to Ignite. Are you
sure that there is a server running on localhost:11211?

-Val



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Unable-to-create-dbcp-PoolableConnectionFactory-tp8712p8746.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to