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[]) {
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");
rs.beforeFirst();
//Vector my=new Vector();
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");
//System.out.println(my.getString("Name")+"\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");}
}
}