Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2004

Tip: Looking for answers? Try searching our database.

executeQuery() in Statement class ....

Thread view: 
Raquel - 18 Jun 2004 06:33 GMT
This piece of code in a JDBC program executes fine:

  Statement st = conn.createStatement();
  ResultSet rec = st.executeQuery( "SELECT DEPTNO FROM TABLE1");

But when I see the documentation for "Statement" at the following URL, it
does not show executeQuery() as a method at all in Statement class. The
closest method available is execute(). So, how does executeQuery work
successfully?

http://java.sun.com/j2se/1.4.2/docs/api/java/beans/Statement.html

Actually I am confused by the description of execute(). It says:

The execute method finds a method whose name is the same as the methodName
property, and invokes the method on the target.

Could someone explain to me what this is? Probably this is the answer to
my original question.

TIA
Raquel.
Gerd Nachtsheim - 18 Jun 2004 06:44 GMT
> This piece of code in a JDBC program executes fine:
>
[quoted text clipped - 7 lines]
>
> http://java.sun.com/j2se/1.4.2/docs/api/java/beans/Statement.html

<http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html>

might be a better place to look for the JDBC docs

HTH

Gerd
Signature

Gerd Nachtsheim mailto:gerdn@users.sourceforge.net ICQ:#13126958

Raquel - 18 Jun 2004 06:59 GMT
Wow!! I was looking at the wrong place for EVERYTHING till now I
guess...Gerd, would you be so kind to explain to me as to what the
difference is betweent the two sites above. I see 'beans' keyword extra in
the site I was referring to.

Tia
Raquel.
David Harper - 18 Jun 2004 08:06 GMT
> I was looking at the wrong place for EVERYTHING till now I
> guess...Gerd, would you be so kind to explain to me as to what the
> difference is betweent the two sites above. I see 'beans' keyword
> extra in the site I was referring to.

They refer to two entirely different packages in Java.

This one ...

http://java.sun.com/j2se/1.4.2/docs/api/java/beans/Statement.html

is part of the documentation for the java.beans package, which contains
classes which encapsulate the Java Beans technology. If you're
unfamiliar with that term, you might want to browse the Java Beans tutorial:

http://java.sun.com/docs/books/tutorial/javabeans/

On the other hand, this link ...

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html

is part of the documentation for the java.sql package, which (slightly
confusingly) provides classes for Java's JDBC (Java DataBase
Connectivity) technology. There's a good tutorial on JDBC here:

http://java.sun.com/docs/books/tutorial/jdbc/

Since you're working with JDBC, you need the docs for java.sql rather
than java.beans.

If you're hazy about the concept of packages in Java, here's a good
introduction:

http://java.sun.com/docs/books/tutorial/java/interpack/packages.html

Hope this helps.

David Harper
Cambridge, England
Raquel - 18 Jun 2004 08:17 GMT
Thank you so much David. Will go through the tutorials you recommend.

Regards,
Raquel.
oleg gerassimenko - 22 Jun 2004 15:06 GMT
Have a look at a PreparedStatement class which is a subclass of
Statement. It has an executeQuery() method for SELECT and
executeUpdate() for INSERT,UPDATE,DELETE statements.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.