You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by iostream <si...@gmail.com> on 2017/10/24 12:02:37 UTC

Failed to query ignite

*Hi,

I have created a table in my ignite cluster (v2.1) using the following DDL
-*

CREATE TABLE test 
(
  id             LONG,
  name           VARCHAR,
  PRIMARY KEY (id)
  
)
WITH "backups=1,affinityKey=id";

*I am trying to query the table using IgniteJdbcThinDriver. The code to
query is as follows -*

String sql = "/select * from test where id = ?/";
List params = new ArrayList();
params.add(1L);
ResultSet rs = null;
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
Connection conn =
DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/");
PreparedStatement stmt = conn.prepareStatement(sql);
if (null != params) {
	int i = 1;
	for (Object param : params) {
	stmt.setObject(i, param);
        i++;
	}
}
rs = stmt.executeQuery();
conn.close();

*I am getting the following error -*

java.sql.SQLException: Failed to query Ignite.
	at
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:123)
	at
org.apache.ignite.internal.jdbc.thin.JdbcThinPreparedStatement.executeWithArguments(JdbcThinPreparedStatement.java:221)
	at
org.apache.ignite.internal.jdbc.thin.JdbcThinPreparedStatement.executeQuery(JdbcThinPreparedStatement.java:68)
	at
com.walmart.ecommerce.fulfillment.node.commons.manager.dlr.work.Tester.main(Tester.java:34)
Caused by: class org.apache.ignite.IgniteCheckedException: Error server
response: [req=JdbcQueryExecuteRequest [schemaName=null, pageSize=1024,
maxRows=0, sqlQry=select * from test where id = ?, args=[1]],
resp=JdbcResponse [res=null, status=1, err=javax.cache.CacheException: class
org.apache.ignite.IgniteCheckedException: null]]
	at
org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo.sendRequest(JdbcThinTcpIo.java:253)
	at
org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo.queryExecute(JdbcThinTcpIo.java:227)
	at
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:109)
	... 3 more



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

Re: Failed to query ignite

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,

Thanks for reproducer.
I've make some changes and run test against 2.1, 2.2 and 2.3 version.
Test with affinity key fails on 2.1 and 2.2 versions and looks ok on 2.3
version.

Seems, there was a bug in 2.1 and it is already fixed in 2.3.

PFA repro.

On Thu, Oct 26, 2017 at 10:39 AM, iostream <si...@gmail.com> wrote:

> One more thing to add - when I remove "affinityKey" from ID, I am able to
> query successfully. The error occurs when I set "ID" as my affinityKey. Is
> it a known bug?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Andrey V. Mashenkov

Re: Failed to query ignite

Posted by iostream <si...@gmail.com>.
One more thing to add - when I remove "affinityKey" from ID, I am able to
query successfully. The error occurs when I set "ID" as my affinityKey. Is
it a known bug?



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

Re: Failed to query ignite

Posted by iostream <si...@gmail.com>.
Reproducer code-

ResultSet rs = null;
try {
			Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
			Connection conn = DriverManager
					.getConnection("jdbc:ignite:thin://127.0.0.1/");

			// create table
			PreparedStatement stmt = conn.prepareStatement(
					"CREATE TABLE test9 (id BIGINT,name VARCHAR,PRIMARY KEY (id))WITH
\"backups=1,affinityKey=id\"");
			stmt.executeUpdate();

			// Try to query
			PreparedStatement stmt2 = conn.prepareStatement("select * from test8
where id = ?");
			stmt2.setObject(1, 1L);
			rs = stmt2.executeQuery();
			System.out.println(rs);
			conn.close();
			
} catch (ClassNotFoundException e) {
			e.printStackTrace();
} catch (SQLException e) {
			e.printStackTrace();
}
	



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

Re: Failed to query ignite

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,

Looks like a bug.

Can you share a simple repro?
So, it can be easily checked against master or ignite-2.3 branch if it is
already fixed or a ticket should be created.




On Wed, Oct 25, 2017 at 5:28 PM, iostream <si...@gmail.com> wrote:

> I think i have found the problem here. When I query my cache on the PRIMARY
> KEY, the query throws exception. When I removed PRIMARY KEY from "id",
> query
> is working fine. How do I query on the PRIMARY KEY ?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Andrey V. Mashenkov

Re: Failed to query ignite

Posted by iostream <si...@gmail.com>.
I think i have found the problem here. When I query my cache on the PRIMARY
KEY, the query throws exception. When I removed PRIMARY KEY from "id", query
is working fine. How do I query on the PRIMARY KEY ?



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

Re: Failed to query ignite

Posted by iostream <si...@gmail.com>.
Hi Andrew,

I created a table with BIGINT instead of LONG data type in cache. I am still
getting the same error when I try to query using java.Lang.Long

DDL-

CREATE TABLE test4 
(
  id             /BIGINT/,
  name           VARCHAR,
  PRIMARY KEY (id)
  
)
WITH "backups=1,affinityKey=id";




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

Re: Failed to query ignite

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,

Got it.
Ignite has H2 in underneath. Try to use BIGINT as it should be mappe to
java Long type.

On Tue, Oct 24, 2017 at 9:54 PM, iostream <si...@gmail.com> wrote:

> Hi Andrew,
>
> The result set was /null/ because the query failed in ignite. This is the
> only stack trace printed.
>
> The problem occurs only when I query on LONG column "id". When I query on
> VARCHAR column "name" (/eg. select * from test where name = "abc"/), I am
> able to get the result set.
>
> What is the correct way to set argument to query on a field whose data type
> is LONG?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Andrey V. Mashenkov

Re: Failed to query ignite

Posted by iostream <si...@gmail.com>.
Hi Andrew,

The result set was /null/ because the query failed in ignite. This is the
only stack trace printed. 

The problem occurs only when I query on LONG column "id". When I query on
VARCHAR column "name" (/eg. select * from test where name = "abc"/), I am
able to get the result set. 

What is the correct way to set argument to query on a field whose data type
is LONG?



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

Re: Failed to query ignite

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,

Looks like stacktrace is incomplete and it doesn't contains any reason
why JdbcResponse
has 'null' res field.

Please, if connection string is correct (by default 10800 port should be
used) and share full logs.
Also, it is possible you close connection before results be retrieved from
ResultSet.

On Tue, Oct 24, 2017 at 3:02 PM, iostream <si...@gmail.com> wrote:

> *Hi,
>
> I have created a table in my ignite cluster (v2.1) using the following DDL
> -*
>
> CREATE TABLE test
> (
>   id             LONG,
>   name           VARCHAR,
>   PRIMARY KEY (id)
>
> )
> WITH "backups=1,affinityKey=id";
>
> *I am trying to query the table using IgniteJdbcThinDriver. The code to
> query is as follows -*
>
> String sql = "/select * from test where id = ?/";
> List params = new ArrayList();
> params.add(1L);
> ResultSet rs = null;
> Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
> Connection conn =
> DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/");
> PreparedStatement stmt = conn.prepareStatement(sql);
> if (null != params) {
>         int i = 1;
>         for (Object param : params) {
>         stmt.setObject(i, param);
>         i++;
>         }
> }
> rs = stmt.executeQuery();
> conn.close();
>
> *I am getting the following error -*
>
> java.sql.SQLException: Failed to query Ignite.
>         at
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.
> execute0(JdbcThinStatement.java:123)
>         at
> org.apache.ignite.internal.jdbc.thin.JdbcThinPreparedStatement.
> executeWithArguments(JdbcThinPreparedStatement.java:221)
>         at
> org.apache.ignite.internal.jdbc.thin.JdbcThinPreparedStatement.
> executeQuery(JdbcThinPreparedStatement.java:68)
>         at
> com.walmart.ecommerce.fulfillment.node.commons.
> manager.dlr.work.Tester.main(Tester.java:34)
> Caused by: class org.apache.ignite.IgniteCheckedException: Error server
> response: [req=JdbcQueryExecuteRequest [schemaName=null, pageSize=1024,
> maxRows=0, sqlQry=select * from test where id = ?, args=[1]],
> resp=JdbcResponse [res=null, status=1, err=javax.cache.CacheException:
> class
> org.apache.ignite.IgniteCheckedException: null]]
>         at
> org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo.
> sendRequest(JdbcThinTcpIo.java:253)
>         at
> org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo.
> queryExecute(JdbcThinTcpIo.java:227)
>         at
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.
> execute0(JdbcThinStatement.java:109)
>         ... 3 more
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Andrey V. Mashenkov