• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

java.sql.SQLException: No value specified for parameter 1

 
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all.

I've an Entity:


and a named query:



Within a controller, i do the query


I fill an array and call the method:



When i exec the query, this exception was thrown:

javax.persistence.PersistenceException: Exception thrown when executing query
at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:433)
at org.datanucleus.api.jpa.JPAQuery.getResultList(JPAQuery.java:211)
at com.bss.easycooking.libdataeasycooking.controller.ArticoliJpaController.findArticoliByCatMer(ArticoliJpaController.java:49)
...
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2611)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2586)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2510)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2259)
...

It say that the parameter was not set...why? I forget something? thanks
 
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know what version of JPA you are using? Setting parameters for "in" wasn't supported until JPA 2.0.
 
daniele licitra
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne, thanks for reply.



I use 2.1.0, in fact in the entity i can use javax.persistence.Index notation
 
daniele licitra
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Workaround:


Instead of using a named query, i write the query inside the method and set the parameters with a MessageFormat. It's less efficient but it works.

There is a way to fix the use of named query?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!