Hello,
I am running the example that came with the hibernate installation. I am testing it against MySQL. It appears that the example successfully created and populated the AuctionItem, AuctionUser, and the Bid tables. I verified the tables's contents in the mysql browser.
But the example program appears to choke while querying AuctionItem and AuctionUser tables. The error seems to be in the SQL syntax built in the query. There seems to be a '?' in the query where it should not have been. Since, this example must have been used by thousands of folks by now, the problem could not have been in the syntax. I must not have done something right. I appreciate any help. I need some direction to look at to start fixing the problem.
As a side note, I searched in this forum with keywords 'mysql' and the search found a bunch of topics. But clicking on the topic led me to an error page; this happened with every item I found in the search. Is there something I need to do to get this right? Sorry if this question was already answered.
Thanks
Jagadeesh.
Hibernate version: 3.0 beta 1
Full stack trace of any exception that occurs:
h bid.bidder order by item.ends desc
[java] 18:00:30,234 DEBUG QueryTranslatorImpl:228 - SQL: select auctionite0_.id as id0_, bids1_.id as id1_, user2_.id as id2_, auctionite0_.descr
iption as descript2_0_0_, auctionite0_.ends as ends0_0_, auctionite0_.condition as condition0_0_, auctionite0_.seller as seller0_0_, auctionite0_.succ
essfulBid as successf6_0_0_, bids1_.amount as amount1_1_, bids1_.`datetime` as y4_1_1_, bids1_.bidder as bidder1_1_, bids1_.item as item1_1_, bids1_.i
sBuyNow as isBuyNow1_, user2_.userName as userName2_2_, user2_.`password` as y3_2_2_, user2_.email as email2_2_, user2_.firstName as firstName2_2_, us
er2_.`initial` as y6_2_2_, user2_.lastName as lastName2_2_, bids1_.item as item__, bids1_.id as id__ from AuctionItem auctionite0_ left outer join Bid
bids1_ on auctionite0_.id=bids1_.item left outer join AuctionUser user2_ on bids1_.bidder=user2_.id order by auctionite0_.ends desc limit ?
[java] 18:00:30,234 DEBUG AbstractBatcher:252 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[java] 18:00:30,234 DEBUG SQL:290 - select auctionite0_.id as id0_, bids1_.id as id1_, user2_.id as id2_, auctionite0_.description as descript2_0
_0_, auctionite0_.ends as ends0_0_, auctionite0_.condition as condition0_0_, auctionite0_.seller as seller0_0_, auctionite0_.successfulBid as successf
6_0_0_, bids1_.amount as amount1_1_, bids1_.`datetime` as y4_1_1_, bids1_.bidder as bidder1_1_, bids1_.item as item1_1_, bids1_.isBuyNow as isBuyNow1_
, user2_.userName as userName2_2_, user2_.`password` as y3_2_2_, user2_.email as email2_2_, user2_.firstName as firstName2_2_, user2_.`initial` as y6_
2_2_, user2_.lastName as lastName2_2_, bids1_.item as item__, bids1_.id as id__ from AuctionItem auctionite0_ left outer join Bid bids1_ on auctionite
0_.id=bids1_.item left outer join AuctionUser user2_ on bids1_.bidder=user2_.id order by auctionite0_.ends desc limit ?
[java] Hibernate: select auctionite0_.id as id0_, bids1_.id as id1_, user2_.id as id2_, auctionite0_.description as descript2_0_0_, auctionite0_.
ends as ends0_0_, auctionite0_.condition as condition0_0_, auctionite0_.seller as seller0_0_, auctionite0_.successfulBid as successf6_0_0_, bids1_.amo
unt as amount1_1_, bids1_.`datetime` as y4_1_1_, bids1_.bidder as bidder1_1_, bids1_.item as item1_1_, bids1_.isBuyNow as isBuyNow1_, user2_.userName
as userName2_2_, user2_.`password` as y3_2_2_, user2_.email as email2_2_, user2_.firstName as firstName2_2_, user2_.`initial` as y6_2_2_, user2_.lastN
ame as lastName2_2_, bids1_.item as item__, bids1_.id as id__ from AuctionItem auctionite0_ left outer join Bid bids1_ on auctionite0_.id=bids1_.item
left outer join AuctionUser user2_ on bids1_.bidder=user2_.id order by auctionite0_.ends desc limit ?
[java] 18:00:30,234 DEBUG AbstractBatcher:341 - preparing statement
[java] 18:00:30,234 DEBUG JDBCExceptionReporter:49 - SQL Exception
[java] java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
syntax to use near '?' at line 1
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
[java] at com.mysql.jdbc.ServerPreparedStatement.serverPrepare(ServerPreparedStatement.java:1485)
[java] at com.mysql.jdbc.ServerPreparedStatement.<init>(ServerPreparedStatement.java:151)
[java] at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1309)
[java] at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1281)
[java] at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:349)
[java] at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:300)
[java] at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:81)
[java] at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:978)
[java] at org.hibernate.loader.Loader.doQuery(Loader.java:346)
[java] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:193)
[java] at org.hibernate.loader.Loader.doList(Loader.java:1303)
[java] at org.hibernate.loader.Loader.list(Loader.java:1286)
[java] at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:872)
[java] at org.hibernate.impl.SessionImpl.find(SessionImpl.java:973)
[java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:84)
[java] at org.hibernate.auction.Main.viewAllAuctionsSlow(Main.java:87)
[java] at org.hibernate.auction.Main.main(Main.java:367)
[java] 18:00:30,234 WARN JDBCExceptionReporter:57 - SQL Error: 1064, SQLState: 42000
[java] 18:00:30,234 ERROR JDBCExceptionReporter:58 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near '?' at line 1
[java] 18:00:30,249 DEBUG JDBCExceptionReporter:49 - could not execute query [select auctionite0_.id as id0_, bids1_.id as id1_, user2_.id as id2
_, auctionite0_.description as descript2_0_0_, auctionite0_.ends as ends0_0_, auctionite0_.condition as condition0_0_, auctionite0_.seller as seller0_
0_, auctionite0_.successfulBid as successf6_0_0_, bids1_.amount as amount1_1_, bids1_.`datetime` as y4_1_1_, bids1_.bidder as bidder1_1_, bids1_.item
as item1_1_, bids1_.isBuyNow as isBuyNow1_, user2_.userName as userName2_2_, user2_.`password` as y3_2_2_, user2_.email as email2_2_, user2_.firstName
as firstName2_2_, user2_.`initial` as y6_2_2_, user2_.lastName as lastName2_2_, bids1_.item as item__, bids1_.id as id__ from AuctionItem auctionite0
_ left outer join Bid bids1_ on auctionite0_.id=bids1_.item left outer join AuctionUser user2_ on bids1_.bidder=user2_.id order by auctionite0_.ends
desc]
[java] java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
syntax to use near '?' at line 1
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
[java] at com.mysql.jdbc.ServerPreparedStatement.serverPrepare(ServerPreparedStatement.java:1485)
[java] at com.mysql.jdbc.ServerPreparedStatement.<init>(ServerPreparedStatement.java:151)
[java] at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1309)
[java] at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1281)
[java] at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:349)
[java] at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:300)
[java] at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:81)
[java] at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:978)
[java] at org.hibernate.loader.Loader.doQuery(Loader.java:346)
[java] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:193)
[java] at org.hibernate.loader.Loader.doList(Loader.java:1303)
[java] at org.hibernate.loader.Loader.list(Loader.java:1286)
[java] at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:872)
[java] at org.hibernate.impl.SessionImpl.find(SessionImpl.java:973)
[java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:84)
[java] at org.hibernate.auction.Main.viewAllAuctionsSlow(Main.java:87)
[java] at org.hibernate.auction.Main.main(Main.java:367)
[java] 18:00:30,265 WARN JDBCExceptionReporter:57 - SQL Error: 1064, SQLState: 42000
[java] 18:00:30,265 ERROR JDBCExceptionReporter:58 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near '?' at line 1
[java] 18:00:30,265 DEBUG JDBCTransaction:99 - rollback
[java] 18:00:30,265 DEBUG SessionImpl:363 - transaction completion
[java] 18:00:30,265 DEBUG SessionImpl:232 - closing session
[java] 18:00:30,265 DEBUG SessionImpl:311 - disconnecting session
[java] 18:00:30,265 DEBUG AbstractBatcher:392 - closing JDBC connection (open PreparedStatements: 1, globally: 1) (open ResultSets: 0, globally:
0)
[java] 18:00:30,265 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
[java] 18:00:30,312 DEBUG SessionImpl:363 - transaction completion
[java] org.hibernate.exception.SQLGrammarException: could not execute query
[java] at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
[java] at org.hibernate.loader.Loader.doList(Loader.java:1306)
[java] at org.hibernate.loader.Loader.list(Loader.java:1286)
[java] at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:872)
[java] at org.hibernate.impl.SessionImpl.find(SessionImpl.java:973)
[java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:84)
[java] at org.hibernate.auction.Main.viewAllAuctionsSlow(Main.java:87)
[java] at org.hibernate.auction.Main.main(Main.java:367)
[java] Caused by: java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near '?' at line 1
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
[java] at com.mysql.jdbc.ServerPreparedStatement.serverPrepare(ServerPreparedStatement.java:1485)
[java] at com.mysql.jdbc.ServerPreparedStatement.<init>(ServerPreparedStatement.java:151)
[java] at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1309)
[java] at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1281)
[java] at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:349)
[java] at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:300)
[java] at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:81)
[java] at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:978)
[java] at org.hibernate.loader.Loader.doQuery(Loader.java:346)
[java] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:193)
[java] at org.hibernate.loader.Loader.doList(Loader.java:1303)
[java] ... 6 more
[java] Exception in thread "main"
BUILD FAILED
C:\Program Files\hibernate-3.0\build.xml:619: Java returned: 1
Total time: 7 seconds
C:\Program Files\hibernate-3.0>
Name and version of the database you are using: MySQL 4.1
Debug level Hibernate log excerpt: info
|