hi i would like to move the cursor to the next row and print the required values in the output. but it's showing driver doesnot support this property/ what could be the cause.i am using jdk1.3 here the code //program to creat table, to enter values from the user //the values are written into the created table import java.sql.*; import java.io.*; class inserttable { public static void main(String a[]) {
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection =DriverManager.getConnection("jdbc dbc:rajesh","sa",""); if(connection==null) { System.out.println("there is some error in connection"); } Statement statement = connection.createStatement(); //String def = "create table MARKS " + //"(NAME VARCHAR(32), " + //"PHYSICS VARCHAR(32), "+ //"MATHS VARCHAR(32)) "; //statement.executeUpdate(def); String stri = "INSERT into MARKS (Name, Physics, Maths) values(?,?,?)"; PreparedStatement stmt = connection.prepareStatement(stri); InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br=new BufferedReader(ir); System.out.println("Enter student name"); String Name = br.readLine(); System.out.println("Enter physics marks"); String Physics = br.readLine(); System.out.println("Enter maths marks"); String Maths= br.readLine(); stmt.setString(1, Name); stmt.setString(2,Physics); stmt.setString(3,Maths); stmt.executeUpdate(); ResultSet rs = stmt.executeQuery("select * from marks"); //here am getting problem, it's not givifng this output i require while (rs.next() ){ System.out.println("name ==>"+rs.getString("Name")+"\n"); System.out.println("physics ==>"+rs.getString("Physics")+"\n"); System.out.println("Maths ==>"+rs.getString("Maths")+"\n"); rs.close(); } statement.close(); connection.close();
Did you try setting the result set type to scrollable? E.G.
paddy_1974
Greenhorn
Joined: Jan 06, 2001
Posts: 6
posted
0
Originally posted by Jim Baiter: [B]Did you try setting the result set type to scrollable? E.G. [/B]
the above statement does not work. pls help me.am using jdk1.3 am attaching my code below //program to creat table, to enter values from the user //the values are written into the created table import java.sql.*; import java.io.*; import java.sql.ResultSet; class inserttable { public static void main(String a[]) {
paddy_1974, Your name is not JavaRanch compliant. You'll get in trouble with a sheriff. Change it before you get caught and get put in jail! I don't think you get to pass go and collect $200 either. Please read the FAQ to learn how to format your code so it's more readable. If you do that, I promise to take a crack at your problem. -Peter
paddy_1974
Greenhorn
Joined: Jan 06, 2001
Posts: 6
posted
0
hi here is my code: psl help //program to creat table, to enter values from the user //the values are written into the created table // the error is driver does not support this property after accepting input values namely name,physics,maths etc.
[This message has been edited by Thomas Paul (edited January 09, 2001).]
Peter Tran
Bartender
Joined: Jan 02, 2001
Posts: 783
posted
0
Ugh...Your code is still not formatted correctly. Please read the FAQ link to learn how-to format your code correctly. If you were me, would you want to read code formatted like this? -Peter [This message has been edited by Peter Tran (edited January 09, 2001).]
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
I think this line may be causing the problem: ResultSet rs = stmt.executeQuery("select * from marks"); stmt is actually a PreparedStatement object. Although PreparedStatement is a child of Statement and therefore supports the executeQuery(String) method, I have no idea how it is actually implemented. It may be that the PreparedStatement class in the JdbcOdbc set doesn't correctly support this. Try running the query off a new Statement object. And get rid of the "ResultSet.TYPE_SCROLL_SENSITIVE" commands. Those are part of JDBC 2 and may not be supported by the driver you are using. In any case, they are not needed.