• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

fail to update.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys! thanks! i solved it
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, thanks! I hope you'll stick around and ask and/or answer some more questions here!
 
reply
    Bookmark Topic Watch Topic
  • New Topic