Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Update Operation in JDBC (http://www.programmingforums.org/showthread.php?t=11460)

jorrigal Oct 3rd, 2006 9:59 AM

Update Operation in JDBC
 
I am trying to update the database but it is showing the errors . I put the code , mysql table and the error showed at execution. Please cheak it.

:

File name is Firstapp.java
import java.sql.*;
import java.util.*;
import java.io.*;
class Firstapp
{
        public static void main(String[] args) throws Exception,SQLException
        {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con=DriverManager.getConnection("jdbc:odbc:mysql","","");
                Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                ResultSet rs=stmt.executeQuery("select * from account");
//Update Operation
rs.absolute(5);
                rs.updateString("accname","evan");
                rs.updateRow();
               
                rs.close();
                stmt.close();
                con.close();
        }
}

Is the code for Update Operation is correct

The table in mysql is
:

mysql> select * from account;
+-------+---------+
| accno | accname |
+-------+---------+
|        1 | pavan  |
|        2 | avan        |
|        3 | lavan  |
|        4 | ravan  |
|        5 | fvan        |
+-------+---------+


it is not showing any error while compilation
Following is the error showing the while execution

:

Exception in thread "main" java.sql.SQLException: [MySQL][ODBC 3.51 Driver][mysqld-4.0.13-nt]Degree of derived table does not m
atch column list
                at sun.jdbc.odbc.JdbcOdbcResultSet.setPos(Unknown Source)
                at sun.jdbc.odbc.JdbcOdbcResultSet.updateRow(Unknown Source)
                at Firstapp.main(Firstapp.java:40)


Insert and deleter operations are working fine and i could not able to find the problem with update operation.
Please any body help me.


All times are GMT -5. The time now is 1:07 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC