You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by arpiticx <ar...@gmail.com> on 2018/10/03 13:52:03 UTC

Apache Ignite 2.6.0 JDBC Thin Client Multiple Endpoints Issues

Hi,

I am running 3 ignite nodes in a cluster and trying to connect using jdbc
thin driver with multiple end points and getting error when trying to get
connection. Here is my code for connecting to ignite cluster using jdbc thin
driver and multiple endpoints. Any help is appreciated

*Connection Pool Coniguration*

private static void initializeIgnitePool()
	{
		try
		{
			
			System.out.println("Configuring cache database connection pool");
//			String
igniteUrl="jdbc:ignite:cfg://cache=default@file:$$home_path$$"+File.separator+"$$config_file_name$$";
//			String
igniteUrl="jdbc:ignite:cfg://cache=default@file:/opt/apache-ignite-fabric-2.6.0-bin/config/icrm-ignite-config.xml";
			String igniteUrl="jdbc:ignite:thin://192.168.0.117:10800,
192.168.0.62:10800, 192.168.0.115:10800";
					
			BasicDataSource bds=new BasicDataSource();
				
				
			bds.setDriverClassName("org.apache.ignite.IgniteJdbcThinDriver");
			bds.setUrl(igniteUrl);
//				bds.setMaxActive(200);
//				bds.setMaxWait(30);
				bds.setMaxIdle(60);
				bds.setTestOnBorrow(false);
				bds.setLogAbandoned(false);
				bds.setValidationQuery("select 1 ");
				ds=bds;
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
}


*Code for inserting multiple records*

for(int i=0;i<2000;i++)
			{
				try {
					Connection conn=pool.getConnection();
					PreparedStatement ps=conn.prepareStatement("insert into test1
(id,fname) values (?,?)");
					ps.setInt(1,i);
					ps.setString(2, "arpit-"+i);
					
					int u=ps.executeUpdate();
					System.out.println("Rows inserted :"+u);
					
					ps.close();
					conn.close();
					Thread.sleep(1000);
				} catch (Exception e) {
					System.out.println(i+" ==============> "+e.getMessage()+"
<==========================");
				}
			}



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Apache Ignite 2.6.0 JDBC Thin Client Multiple Endpoints Issues

Posted by arpiticx <ar...@gmail.com>.
Hi,

Thanks for pointing out the mistake. After correcting, the issue as
resolved.

Arpit



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Apache Ignite 2.6.0 JDBC Thin Client Multiple Endpoints Issues

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

The address list is comma-separated and should not contain any spaces:

                        String igniteUrl="jdbc:ignite:thin://
192.168.0.117:10800,192.168.0.62:10800,192.168.0.115:10800";

JDBC seems to be confused if spaces are used between entries. I think you
should not expect to have naked spaces in URLs.

Regards,
-- 
Ilya Kasnacheev


ср, 3 окт. 2018 г. в 16:52, arpiticx <ar...@gmail.com>:

> Hi,
>
> I am running 3 ignite nodes in a cluster and trying to connect using jdbc
> thin driver with multiple end points and getting error when trying to get
> connection. Here is my code for connecting to ignite cluster using jdbc
> thin
> driver and multiple endpoints. Any help is appreciated
>
> *Connection Pool Coniguration*
>
> private static void initializeIgnitePool()
>         {
>                 try
>                 {
>
>                         System.out.println("Configuring cache database
> connection pool");
> //                      String
> igniteUrl="jdbc:ignite:cfg://cache=default@file
> :$$home_path$$"+File.separator+"$$config_file_name$$";
> //                      String
> igniteUrl="jdbc:ignite:cfg://cache=default@file
> :/opt/apache-ignite-fabric-2.6.0-bin/config/icrm-ignite-config.xml";
>                         String igniteUrl="jdbc:ignite:thin://
> 192.168.0.117:10800,
> 192.168.0.62:10800, 192.168.0.115:10800";
>
>                         BasicDataSource bds=new BasicDataSource();
>
>
>
> bds.setDriverClassName("org.apache.ignite.IgniteJdbcThinDriver");
>                         bds.setUrl(igniteUrl);
> //                              bds.setMaxActive(200);
> //                              bds.setMaxWait(30);
>                                 bds.setMaxIdle(60);
>                                 bds.setTestOnBorrow(false);
>                                 bds.setLogAbandoned(false);
>                                 bds.setValidationQuery("select 1 ");
>                                 ds=bds;
>                 }
>                 catch(Exception e)
>                 {
>                         e.printStackTrace();
>                 }
> }
>
>
> *Code for inserting multiple records*
>
> for(int i=0;i<2000;i++)
>                         {
>                                 try {
>                                         Connection
> conn=pool.getConnection();
>                                         PreparedStatement
> ps=conn.prepareStatement("insert into test1
> (id,fname) values (?,?)");
>                                         ps.setInt(1,i);
>                                         ps.setString(2, "arpit-"+i);
>
>                                         int u=ps.executeUpdate();
>                                         System.out.println("Rows inserted
> :"+u);
>
>                                         ps.close();
>                                         conn.close();
>                                         Thread.sleep(1000);
>                                 } catch (Exception e) {
>                                         System.out.println(i+"
> ==============> "+e.getMessage()+"
> <==========================");
>                                 }
>                         }
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>