• 周三. 12 月 11th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Error: ResultSet was not produced – Java From 5gw.org

King Wang

4 月 9, 2022

xmlns=”http://www.w3.org/1999/xhtml” dir=”ltr” lang=”en”>
Error: ResultSet was not produced – Java
/**
* Bytes CSS
* Style: ‘bytes.answers’; Style ID: 18
*/
@import url(“/clientscript/vbulletin_css/style-12635a82-00018.css”);

 
 
470,370 Members | 1,562 Online

Error: ResultSet was not produced

This is the code I’m using to isert record in SQL but it produced the "ResultSet error not produced" and even it did not inserted the mobile field, but the field is set to "not null" still it was showing null.

Expand|Select|Wrap|Line Numbers
  1. <%    
  2.         try
  3.     {
  4.             String n=request.getParameter("name");
  5.             String u=request.getParameter("uname");
  6.             String p=request.getParameter("pwd");
  7.             String y=request.getParameter("Year");
  8.             String g=request.getParameter("Gender");
  9.             String e=request.getParameter("EmailID");
  10.             String c=request.getParameter("Moblie");
  11.             String a=request.getParameter("Address");
  12.     Connection con=DriverManager.getConnection("jdbc:odbc:uinfo; uid=System; pwd=tandon");
  13.             Statement st=con.createStatement();
  14.             ResultSet rs=st.executeQuery("insert into uinfo values(‘"+n+"’,’"+u+"’,’"+p+"’,’"+y+"’,’"+g+"’,’"+e+"’,’"+c+"’,’"+a+"’);");
  15.              if(rs.next())
  16.                      {
  17.                         %> <jsp:forward page="U_Login.jsp" /> <%
  18.                      }
  19.             else
  20.                 {
  21.                 out.println("please retry");
  22.           %><br><br> <a href="http://bytes.com/SignUp.jsp">Back to Home</a> <%
  23.                    }         
  24.   con.close();
  25.  
  26.          }               
  27.         catch(Exception e)
  28.          {
  29.          out.println(e);
  30.          }
  31.         %>

May 24 ’13
#1

3 1726


(adsbygoogle = window.adsbygoogle || []).push({});

Oralloy

983
Expert 512MB

tejasvee1234,

If I remember correctly, when the executeQuery() method works on an INSERT statement, it doesn’t produce a result set, as there are no values generated. Try using the execute() method, instead.

The first thing to do is see if your SQL is correctly formed; usually done by printing it out. Then once the SQL is correct, then you can do the insert.

Judging from your comment, though, you need to use the execute() method, and check the boolean result, instead.

Luck,
Oralloy

May 26 ’13
#2

PreethiGowri

126
64KB

ExecuteUpdate has to be used instead of ExecuteQuery for insert, update and delete queries. Write something like,

Expand|Select|Wrap|Line Numbers
  1.  Statement st=con.createStatement();
  2.             int rs=st.executeUpdate("insert into uinfo values(‘"+n+"’,
  3. ‘"+u+"’,’"+p+"’,’"+y+"’,’"+g+"’,’"+e+"’,
  4. ‘"+c+"’,’"+a+"’);");
  5.              if(rs != 0)
  6.                      {
  7.                         %> <jsp:forward page="U_Login.jsp" /> <%
  8.                      }

May 27 ’13
#3

Oralloy

983
Expert 512MB

PreethiGowri,

Thank you, I learned a trick. Much appreciated.

Oralloy

May 28 ’13
#4


Message
 
Cancel Changes

Post your reply

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

Similar topics


3 posts

views

Thread by Martin Lucas-Smith |
last post: by


2 posts

views

Thread by pminkov |
last post: by


7 posts

views

Thread by Greg Buchholz |
last post: by


3 posts

views

Thread by cyber0ne |
last post: by


6 posts

views

Thread by massic80 |
last post: by


reply

views

Thread by perto1 |
last post: by

By using this site, you agree to our Privacy Policy and Terms of Use.


(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-90111-7’, ‘bytes.com’);
ga(‘send’, ‘pageview’);

loadBytesTracking()

//0){location.replace(‘https://bytes.com/showthread.php?p=’+cpostno);};} }

if(typeof window.orig_onload == “function”) window.orig_onload();
}

//]]>

发表回复