Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fail to update.

 
joo how
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


the result was
java.sql.SQLException: No data found
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid cursor position; no keyset defined


anyone can help ?

[Added code tags - see UseCodeTags for details]
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you haven't established the cursor position.

You can only update something that you have already retrieved or use a Where clause in standard sql/jdbc.

WP
 
joo how
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you teach me what i need to do ?? i am new in this == was helping my friend to solve this problem.
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

You can see an example here. If you're still having trouble post a small example that shows how you create the query and just update one field.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't shown us what sort of result set you have, as this only works on certain types (after a quick read of the API)

http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSet.html
 
joo how
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:Welcome to JavaRanch!

You can see an example here. If you're still having trouble post a small example that shows how you create the query and just update one field.


thanks! Greg.
I type the exactly what the page have, but still give me the same error. the example :


updateButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){

int id = 520;
String city = "KL";


try{

statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");
resultSet.first();

resultSet.updateInt("EmpID", id);
resultSet.updateString("City", city);

resultSet.updateRow();
JOptionPane.showMessageDialog(null,"Record updated.");


}catch(Exception ex){
System.out.println(ex.toString());
}
}
});


 
joo how
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:You haven't shown us what sort of result set you have, as this only works on certain types (after a quick read of the API)

http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSet.html


do you mean this i missed?

statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
joo how wrote:
Wendy Gibbons wrote:You haven't shown us what sort of result set you have, as this only works on certain types (after a quick read of the API)

http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSet.html


do you mean this i missed?

statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");


yes in the first post, but not the later post.
 
joo how
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:
joo how wrote:
Wendy Gibbons wrote:You haven't shown us what sort of result set you have, as this only works on certain types (after a quick read of the API)

http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSet.html


do you mean this i missed?

statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");


yes in the first post, but not the later post.



I added resultSet.absolute(1);
but still giving me the error : java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row.
 
joo how
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys! thanks! i solved it
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good for you! It would be nice if you could explain how you fixed it. Then everyone learns!
 
joo how
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha. sure!

one of my friend told me the reason why error in row is because
1. One or more required fields were not filled
2. One of entered values do not conform field type (character values in numeric or date fields)
3. You trying to enter a value into field which is of Autonumber type.
4. You have a relationship between tables that requires you to put into foreign key field one of existing values from another table. If you put value that don't exist in another table you see the same error.

then i found there is one data type in access was wrong. so, after i changed it. it works!
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, thanks! I hope you'll stick around and ask and/or answer some more questions here!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic