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,344 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 143

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 143

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

Suggested Solutions

Title # Comments Views Activity
Upgrading my SSIS package in VS 2012 6 60
SQL Server 2008 R2, need a pivot/cross tab query... 4 29
SQL R 21 26
Getting invalid Syntax SQL. 3 19
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

860 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