Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

SQLQuery "Prepared value already set!" error

Hi, I'm making a pool mechanism to cache SQLQuery so i won't need to create the object each time i need a query. the problem is that the second time i get the SQLQuery and make readMultiple, i get "Prepared value already set! error.

for example: SQLQuery query = new SQLQuery(MyClass.class, "name in (?)"); String names = new String[2]; names[0] = "avi"; names[1] = "moshe"; query.setParameters(names);

Do you have any idea what is wrong?

Avi. h4. Attachments


{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2924]{quote}

asked 2009-03-04 02:58:51 -0500

sabag2's avatar

updated 2013-08-08 09:52:00 -0500

jaissefsfex's avatar
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

This is a bug with parametrized SQLQuery and IN clauses.

It will be fixed for 7.0.

The only workaround is creating a dynamic query with IN,

or replacing the IN statement with ORs:


x in (?,?,?)


x =? or x =? or x =?


answered 2009-03-05 07:11:29 -0500

edit flag offensive delete link more

another note: when the where clause is "name = ?" the problem not reoccur, it just occur when i make "name in (?)".

Avi. h4. Attachments


answered 2009-03-04 06:57:03 -0500

sabag2's avatar
edit flag offensive delete link more


I can also confirm I get this error when running more than one query.

I execute the following code:

SQLQuery<TradeWrapper> query = new SQLQuery<TradeWrapper>(TradeWrapper.class, stringQuery, queryArgs);
SQLQuery<TradeWrapper> query2 = new SQLQuery<TradeWrapper>(TradeWrapper.class, stringQuery, queryArgs);
SQLQuery<TradeWrapper> query3 = new SQLQuery<TradeWrapper>(TradeWrapper.class, stringQuery, queryArgs);

Entry[] results = null;
Entry[] results2 = null;
Entry[] results3 = null;
try {
  results = (Entry[]) space.readMultiple(query, null, Integer.MAX_VALUE);
  results2 = (Entry[]) space.readMultiple(query2, null, Integer.MAX_VALUE);
  results3 = (Entry[]) space.readMultiple(query3, null, Integer.MAX_VALUE);
} catch (Exception e) {

If I do not use an in clause it executes fine with no probs
portfolio = ?

However if I do portfolio in (?, ?, ?, ?, ?, ?, ?)

The first results array gets populated but when calling space for the second time

com.j_spaces.core.client.sql.SQLQueryException: Failed to execute SQLQuery : [select * gigaspaces.model.TradeWrapper where (portfolio in (?, ?, ?, ?, ?, ?, ?) and (context = ?))] at com.j_spaces.core.client.sql.QueryManager.executeSQLQuery(QueryManager.java:413) at com.j_spaces.core.client.sql.QueryManager.readMultiple(QueryManager.java:463) at com.j_spaces.core.cluster.action.ClusterSpaceReadMultipleActionListener.readMultiple(ClusterSpaceReadMultipleActionListener.java:48) at com.j_spaces.core.cluster.action.ClusterSpaceReadMultipleActionListener.onAction(ClusterSpaceReadMultipleActionListener.java:30) at com.j_spaces.core.cluster.action.ClusterSpaceReadMultipleActionListener.onAction(ClusterSpaceReadMultipleActionListener.java:23) at com.j_spaces.core.client.AbstractSpaceProxy.readMultiple(AbstractSpaceProxy.java:610) at com.j_spaces.core.client.AbstractSpaceProxy.readMultiple(AbstractSpaceProxy.java:593) at com.bofa.ib.dms.tradeselection.impl.criteria.CriteriaCacheMain.main(CriteriaCacheMain.java:72) Caused by: java.sql.SQLException: Select failed Prepared value already set! at com.j_spaces.jdbc.SelectQuery.executeOnSpace(SelectQuery.java:282) at com.j_spaces.core.client.sql.QueryManager.executeSqlStatment(QueryManager.java:228) at com.j_spaces.core.client.sql.QueryManager.executeSQLQuery(QueryManager.java:307) ... 7 more Caused by: java.sql.SQLException: Prepared value already set! at com.j_spaces.jdbc.parser.PreparedNode.prepareValues(PreparedNode.java:36) at com.j_spaces.jdbc.parser.AbstractInNode.prepareValues(AbstractInNode.java:29) at com.j_spaces.jdbc.parser.ExpNode.prepareValues(ExpNode.java:93) at com.j_spaces.jdbc.AbstractDMLQuery.prepare(AbstractDMLQuery.java:402) at com.j_spaces.jdbc.SelectQuery.executeOnSpace(SelectQuery.java:145) ... 9 more

Edited by: Palmit Nijjar on Mar 5, 2009 4:03 AM h4. Attachments


palm_w1's avatar palm_w1  ( 2009-03-05 03:58:13 -0500 )edit

Attaching class that reporduces the error h4. Attachments


palm_w1's avatar palm_w1  ( 2009-03-05 07:08:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2009-03-04 02:58:51 -0500

Seen: 227 times

Last updated: Mar 05 '09