I was just trying to insert a row using the insertRow() method of ResultSet class but it is giving me an ArrayIndexOutOfBoundsException. The code was as under: <pre> import java.sql.*; class data1 { public static void main(String args[]) throws Exception { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc dbc:mydsn1"); Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery("SELECT * from emp2"); rs.moveToInsertRow(); rs.updateInt(1, 2); rs.updateInt(2,35); rs.updateInt(3, 3); rs.insertRow();//This line gives me ArrayIndexOutOfBoundsException rs.moveToCurrentRow(); }catch(Exception e){System.out.println("SQL Exception raised "+ e);} } } </pre> Please help me. Regards Gurpreet Sachdeva
Regards<BR>Gurpreet Sachdeva<P>For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: <A HREF="http://www.go4java.lookscool.com" TARGET=_blank rel="nofollow">http://www.go4java.lookscool.com</A>
The same problem was answered about 3 posts back (eventually) http://www.javaranch.com/ubb/Forum3/HTML/001683.html you'll have to either find a driver that supports programmatic updates or stick with the more basic (and reliable) SQL DML statements. Jamie