File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Who implements Connection Interface & PreparedStatement Vs connection.executeQuery. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Who implements Connection Interface & PreparedStatement Vs connection.executeQuery." Watch "Who implements Connection Interface & PreparedStatement Vs connection.executeQuery." New topic
Author

Who implements Connection Interface & PreparedStatement Vs connection.executeQuery.

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 757
1) Which class implements Connection interface ?

2) When to use PreparedStatement and when to use connection.executeQuery(....); ???

Thanks.


Jigar Naik


Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Is this homework? Generally we don't like to simply answer questions. What do you think the answers are? Have you read the JavaDocs on PreparedStatement and Connection?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 757
i dont have any idea which class implements Connection,

and about prepared statement when we want to execute a query more frequently we should use prepared statement am i right ?

ok i'm going through JDBC Basic Tutorials.
[ June 19, 2007: Message edited by: Jigar Naik ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

java.sql.Connection (along with all the other JDBC interfaces) are implemented by the driver you choose.

PreparedStatements have a number of advantages over Statements. They represent precompiled, cached statements so should perform better than ad-hoc statements. They also use parameter binding which hides the logic required to escape database specific formatting issues: i.e. need to escape quotes, or ensure date strings are formatted a particular way.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Who implements Connection Interface & PreparedStatement Vs connection.executeQuery.