By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,805 Members | 1,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,805 IT Pros & Developers. It's quick & easy.

How to resolve NoResultSet-Produce problem in JAVA?

Gobindap
P: 25
Whenever I try either to insert new record of update existing record in the database it produces NoResultSet-Produce error but it makes effect in database. How to resolve this problem. The code I have used is as below:
Expand|Select|Wrap|Line Numbers
  1. try {
  2.         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  3.         con = DriverManager.getConnection("jdbc:odbc:MarksheetDB", " ", "222222");
  4.     Statement st = con.createStatement();
  5.     String sql="update valueTable set field1='value1', field2='value2' where ID = 1";
  6. ResultSet rs = st.executeQuery(sql); 
  7.     } catch (Exception e) {
  8.        JOptionPane.showMessageDialog(null, e);
  9.     }
Apr 8 '13 #1

✓ answered by r035198x

Do not use executeQuery to run insert and update statements. Only use it for selects. Use executeUpdate instead.

Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
Do not use executeQuery to run insert and update statements. Only use it for selects. Use executeUpdate instead.
Apr 8 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.