• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in sql method

Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can someone help me with an error
I have this method

With a breakpoint i see the query works

When reach "sql" variable i receive the data i was expecting

'Wilson' and = '2015-04-14 10:00:00.0'"

But when i move to the next line "check" tehre is something wrong because the size is 0....why??

Check the image please

Thank you


SEVERE: Servlet.service() for servlet [spring] in context with path [/ProjetoESTG] threw exception [Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query] with root cause
java.sql.SQLSyntaxErrorException: ORA-01722: invalid number

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:884)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811)
at gmc.gestaxi.dao.impl.ReservaDaoImpl.checkCondutorServico(ReservaDaoImpl.java:127)
at gmc.gestaxi.service.impl.ReservaServiceImpl.checkCondutorServico(ReservaServiceImpl.java:67)

[Thumbnail for sql.jpg]
Jeanne Boyarsky
author & internet detective
Posts: 36026
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by "the size is zero." It looks like Oracle is complaining about one of the parameters. Are any of these fields set to integer in the database?

Also, note that you should be using bind variables rather than concatenating the values in the String. The later subjects you to SQL Injection.
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thank you for your answer, i have resolved this issue like this

Now it works like it should but a ihave another problem in a query. In netbeans and oracle the query works like i want, but in jsp servlet returns the address twice

this is the query

and the result in netbeans is correct, but look in jsp...they are the same...and this is wrong

[Thumbnail for querySqlNetbeans.jpg]
[Thumbnail for sqlJsp.jpg]
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!