Solved

Error is 'Statement::executeQuery This statement did not return a result set" even though I was not expecting a RS

Posted on 2006-10-24
6
1,343 Views
Last Modified: 2008-01-09
This is the query: StringBuffer sbQuery = new StringBuffer("");
            sbQuery.append("INSERT INTO ");
            sbQuery.append("inv_grp ");
            sbQuery.append("(inv_grp.assoc_cd, ");
            sbQuery.append("inv_grp.clb_cd,  ");            
            sbQuery.append("inv_grp.inv_grp_name, ");      
            sbQuery.append("inv_grp.inv_grp_desc, ");      
            sbQuery.append("inv_grp.inv_grp_disc, ");      
            sbQuery.append("inv_grp.status, ");      
            sbQuery.append("inv_grp.gl_account)  ");
            sbQuery.append("VALUES (?, ");
            sbQuery.append("?,  ");            
            sbQuery.append("?,   ");
            sbQuery.append("?,   ");
            sbQuery.append("?,   ");
            sbQuery.append("?,   ");
            sbQuery.append("?)   ");
            SQL sql = new SQL();
            
            try{
                        dbConn = sql.getConnectionObj();       
                        pStmt = dbConn.prepareStatement(sbQuery.toString());
                        pStmt.setString(1, UserAssocCd2);
                        pStmt.setString(2, UserClbCd2);
                        pStmt.setString(3, GroupName);                        
                        pStmt.setString(4, GroupDesc);
                        pStmt.setString(5, Discount);
                        pStmt.setString(6, Status);
                        pStmt.setString(7, GlAccount);
                        pStmt.executeQuery();
                  }

Here, the DB was updated with the input parameter values. As you can see I am trying to collect a result set. However, the error is saying that the statement did not return a result set. Thanks a lot  for your help.
0
Comment
Question by:jdharsha
  • 3
  • 2
6 Comments
 

Author Comment

by:jdharsha
ID: 17796237
Modification: I am not trying to collect a RS. Thanks.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17796418
pStmt.executeQuery();

should be

pStmt.executeNonQuery();
0
 

Author Comment

by:jdharsha
ID: 17797114

it seems that pStmt does not have a method pStmt.executeNonQuery(). Are you sure that it is a valid method, because I cant see it in Pstmt methods.
The problem, I guess, stems from the fact that the method executeQuery returns a resultSet. I just want to do an insert and dont need a result set. is there any method that i can use for this task. Thanks for your help.
0
 

Author Comment

by:jdharsha
ID: 17797145
I need to use executeUpdate instead of executeQuery. thats it. Thanks a lot anyways, for your time. I really appreciate it
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 17797545
looks like you are using java and not .net ...
http://msdn2.microsoft.com/en-us/library/ms378190.aspx

the member would hence be
pStmt.executeUpdate();
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question