This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Statement, PreparedStatement, CallableStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Statement, PreparedStatement, CallableStatement" Watch "Statement, PreparedStatement, CallableStatement" New topic
Author

Statement, PreparedStatement, CallableStatement

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
The inheritance hierarchy for JDBC statements puzzles me a little.
Specifically, why would PreparedStatement and CallableStatement want to inherit some of the methods of Statement?

For example, I tried the following:


I tried code similar to the above with MS SQL Server 2000 driver, only to be given an exception.
Why does the JDBC API allow this behaviour?
Is there ever a reason why you'd do such a thing?
Is it a fair statement that some of the Statement methods should never be called on a PreparedStatement (and CallableStatement) instance?

Advice is most appreciated.


Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Statement, PreparedStatement, CallableStatement