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,342 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now