jQuery in Action, 3rd edition
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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="http://www.go4java.lookscool.com" TARGET=_blank rel="nofollow">http://www.go4java.lookscool.com</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) 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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Inserting a row using insertRow() method
It's not a secret anymore!