aspose file tools*
The moose likes JDBC 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
Bookmark "Inserting a row using insertRow() method" Watch "Inserting a row using insertRow() method" New topic
Author

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:
<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>
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.
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inserting a row using insertRow() method