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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

708 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

12 Experts available now in Live!

Get 1:1 Help Now