Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Oct 3rd, 2006, 9:59 AM   #1
jorrigal
Newbie
 
Join Date: Oct 2006
Posts: 4
Rep Power: 0 jorrigal is on a distinguished road
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.
jorrigal is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
oledb update record problem biran C# 6 May 12th, 2006 12:13 AM
Update a Module Dietrich Python 2 Apr 29th, 2006 2:19 PM
JTree Display Update masamae Java 2 Jul 25th, 2005 11:41 AM
problem with JDBC for talking to Microsoft Access database using a Java Applet captainK Java 4 Mar 20th, 2005 12:01 PM
Type Mismatch Error = 13 Benjizzle Visual Basic 5 Mar 15th, 2005 6:23 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:33 PM.

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