File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Inserting a row using insertRow() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Inserting a row using insertRow() method" Watch "Inserting a row using insertRow() method" New topic

Inserting a row using insertRow() method

Gurpreet Sachdeva
Ranch Hand

Joined: Feb 20, 2001
Posts: 90
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:
import java.sql.*;
class data1 {
public static void main(String args[]) throws Exception
Connection con = DriverManager.getConnection("jdbc dbc:mydsn1");
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet rs = stmt.executeQuery("SELECT * from emp2");
rs.updateInt(1, 2);
rs.updateInt(3, 3);
rs.insertRow();//This line gives me ArrayIndexOutOfBoundsException
}catch(Exception e){System.out.println("SQL Exception raised "+ e);}
Please help me.
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="" TARGET=_blank rel="nofollow"></A>
Gurpreet Sachdeva
Ranch Hand

Joined: Feb 20, 2001
Posts: 90
Please Help me I need it urgently.
Dorj Galaa
Ranch Hand

Joined: May 29, 2001
Posts: 113
this is jdbcOdbcbridge bug

Senior software engineer
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

The same problem was answered about 3 posts back (eventually)
you'll have to either find a driver that supports programmatic updates or stick with the more basic (and reliable) SQL DML statements.
I agree. Here's the link:
subject: Inserting a row using insertRow() method
It's not a secret anymore!