• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

moving cursors to next row

 
paddy_1974
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i would like to move the cursor to the next row but is shows driver does not support this property. any help is welcome.
thanx
here is 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.*;
import java.sql.ResultSet;
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(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
//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,ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
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");

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();

}catch(ClassNotFoundException e)
{System.out.println("error");
}catch(SQLException ex)
{System.out.println("error" + ex.getMessage());
}catch(IOException ee){System.out.println("IO Error");}
}
}

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic