| Author |
ResultSet TYPE
|
Arun Maalik
Ranch Hand
Joined: Oct 25, 2005
Posts: 216
|
|
import java.sql.*; public class first{ public static void main(String[] args){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e){ System.out.println(e); } try{ String str="select * from authors where au_id=?"; Connection con=DriverManager.getConnection("jdbc dbc:MyDataSource","sa",""); PreparedStatement pstmt=con.prepareStatement(str); pstmt.setString(1,"672-71-3249"); ResultSet rs=pstmt.executeQuery(); System.out.println(rs.next()); String st=rs.getString("au_fname"); System.out.println(rs.isBeforeFirst()); System.out.println("Author first name is "+ st); } catch(SQLException e){ System.out.println(e); } catch(Exception e){ System.out.println(e); } } } Dear sir by the above code Result set will be type forward only. As we know that in static sql statment we add a method like con.createStatment(int,int,int); by this statement we change the state of result set like ResultSet.TYPE_SCROLL_SENSITIVE etc but with the preParedStatemnt what i have to add so that we can change the state of ResultSet in the above code it's throwing a Exception that ResultSet is type forward only.by following code System.out.println(rs.isBeforeFirst()); withRegard Arun
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26218
|
|
Arun, con.prepareStatement() has a signature that takes three parameters: 1) SQL 2) ResultSetType 3) ResultSetConcurrency What are you trying to accomplish with the printlns? There might be a cleaner way.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Arun Maalik
Ranch Hand
Joined: Oct 25, 2005
Posts: 216
|
|
Thanks sir I have understood.
|
 |
 |
|
|
subject: ResultSet TYPE
|
|
|