learn java
The moose likes JDBC and Relational Databases and the fly likes how to execute complex queries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "how to execute complex queries" Watch "how to execute complex queries" New topic

how to execute complex queries

Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
hai all,
I wrote a app where i will give complex sql queries which may contain several joins. my program works with simple sql queries but throws exception when i give this complex quries. then how to solve this prob.
I use createStatement() method.
one more thing is when & how to use callablestatements?

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Well, concerning your complex query issue, without seeing:
1. The Code
2. The error message
I would have no idea what your problem is.
And to answer your other question, CallableStatement are used to call Stored Procedures. See The JDBC Tutorial-Stored Procedures

GenRocket - Experts at Building Test Data
Joe Ess

Joined: Oct 29, 2001
Posts: 9077

CallableStatement is used to call stored procedures on the database. You are probably better served by Statement (for one-use calls) or PreparedStatement (for often-used queries). The first step in debugging a SQL query is making sure the query is correct SQL. Try to run the query in the database (i.e. MS Sql Server Enterprise Manager or Oracle SQL Plus console). If the query works in the database but not in your Java code then the problem is somewhere in your program. That should get you started.

[How To Ask Questions On JavaRanch]
jQuery in Action, 2nd edition
subject: how to execute complex queries