• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

resultset or prepared stmt?.

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
this is one of the questions from the mock exams.
question:
---------
import java.sql.*;
Additional code here
Connection c; c=DriverManager.getConnection("jdbc:msql://host:12/dta");
String str = "update employee set salary=50000
where lname=\'jones\'";
What code would execute the SQL statement above?
options:
-------
Choice 1
Statement s = c.createStatement();
ResultSet rs = s.executeUpdate(str);
Choice 2
PreparedStatement s = c.prepareStatement(str);
ResultSet rs = s.executeUpdate();
Choice 3
c.setSQL(str);
ResultSet rs = c.execute();
Choice 4
ResultSet rs = c.executeUpdate(str);
Choice 5
CallableStatement s = c.createCall(str);
ResultSet rs = s.executeCall();
what would be the appropriate answer?.
arun.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 and 2 are wrong because executeUpdate does not return a ResultSet object.
3 is wrong because there is no such method as setSQL() for a Connection object.
4 is wrong because there is no method executeUpdate() for a Connection object.
5 is wrong because there is no such method as createCall in a Connection object and no such method as executeCall() in a CallableStatement object.
So the correct answer is none of the above.
reply
    Bookmark Topic Watch Topic
  • New Topic