Using Java's Statement executeQuery method for getting SQL select results
Questions tagged [executequery]
133 questions
14
votes
2 answers
execute result of select statement
How can I execute the results of my select query. The query below gives me some SQL statements back as result. I want to execute does statements, how to do this? All this is executed in SQL Sever Management Studio.
Query:
SELECT 'UPDATE Rolecopy SET…

Bas
- 597
- 5
- 10
- 22
14
votes
2 answers
Is COMMIT required after every EXECUTE IMMEDIATE?
I have multiple EXECUTE IMMEDIATE commands within one oracle procedure.
EXECUTE IMMEDIATE 'DELETE FROM tbl1';
EXECUTE IMMEDIATE 'INSERT INTO tbl1...';
COMMIT;
EXECUTE IMMEDIATE 'DELETE FROM tbl3';
EXECUTE IMMEDIATE 'INSERT INTO tbl3 ...';…

Angelina
- 2,175
- 10
- 42
- 82
9
votes
1 answer
Avoid Parameter Binding When Executing Query with SQLAlchemy
I am using SQLALchemy to execute queries on Teradata. One of the queries I execute is a DDL statement to replace a stored procedure:
REPLACE PROCEDURE DEV_MIGRATION_TOOL.UNIT_TEST_NEW_STORED_PROCEDURE()
UNIT_TEST_NEW_STORED_PROCEDURE:
BEGIN
…

Alexis.Rolland
- 5,724
- 6
- 50
- 77
7
votes
2 answers
Why does Linq need a setter for a 'read-only' object property?
I'm using a Linq DataContext.ExecuteQuery("some sql statement") to populate a list of objects
var incomes = db.ExecuteQuery(sqlIncomeStatement(TimeUnit));
The IncomeAggregate is an object I made to hold the result of the records…

Dick de Reus
- 779
- 1
- 7
- 15
7
votes
2 answers
MYSQL error:com.mysql.jdbc.NotUpdatable
I am getting this error
javax.servlet.ServletException: com.mysql.jdbc.NotUpdatable: Result
Set not updatable.
I know this error is regarding the primary key but for all my tables I initially insert a primary key.So for this table also I have a…

Standin.Wolf
- 1,224
- 1
- 10
- 32
6
votes
1 answer
sql query execute with PreparedStatement
I have the follow code in a servlet -
String loginID = request.getParameter("loginId").toString();
String loginPassword = request.getParameter("loginPassword").toString();
String strSQLcount = "SELECT COUNT(*)…

URL87
- 10,667
- 35
- 107
- 174
5
votes
2 answers
How to map an extra field from ExecuteQuery() in LINQ-TO-SQL but retain the LINQ entity
Lets say I have a Position table and a related Team table
I need to get a list of Position entities, plus the Team name from a related table, out of an ExecuteQuery() call. As in:
var list = dc.ExecuteQuery("SELECT Position.*, Team.Name AS…

PeteShack
- 707
- 1
- 8
- 20
5
votes
2 answers
LINQ-to-SQL: ExecuteQuery(Type, String) populates one field, but not the other
I've written an app that I use as an agent to query data from a database and automatically load it into my distributed web cache.
I do this by specifying an sql query and a type in a configuration. The code that actually does the querying looks like…

Daniel Schaffer
- 56,753
- 31
- 116
- 165
5
votes
2 answers
How to work with objects of unknown type returned from DataContext.ExecuteQuery
So, with the advent of the dynamic keyword in C# 4.0 I am hoping I can find a better solution to the problem of dealing with types returned by DataContext.ExecuteQuery when arbitrary columns are selected.
In the past I have either created a new type…

Ed S.
- 122,712
- 22
- 185
- 265
5
votes
2 answers
Is it possible to return multiple result sets using ExecuteQuery in Linq to Sql?
I know that you can return multiple results from a stored procedure and through the method generated by the designer.
However, I'm trying to do the same using ExecuteQuery but it doesn't seem like it's possible.
Has anyone tried or know whether this…

Jiho Han
- 1,610
- 1
- 19
- 41
5
votes
4 answers
SSIS Execute SQL Query task cannot find stored procedure
I am working on an existing SSIS package to add custom logging to it. I am trying to test it, and I have an Execute SQL Task that I didn't create that is getting the following error.
Executing the query
"ap_pfl_DropProfileTables"
failed with the…

nleidwinger18
- 169
- 1
- 2
- 12
4
votes
2 answers
Why i can't read the next rows in ResultSet
I have a problem i'm trying to read another row in my ResultSet but dunno why can't my loop just end at rs.next(). Yes, i got more than 1 rows in tblPracownicy. I check ResultSet content with while(rs.next())system.out.println(rs.getRow(1)) before…

Bulit
- 975
- 6
- 15
- 26
4
votes
5 answers
Must declare the scalar variable
I wrote this SQL in a stored procedure but not working,
declare @tableName varchar(max) = 'TblTest'
declare @col1Name varchar(max) = 'VALUE1'
declare @col2Name varchar(max) = 'VALUE2'
declare @value1 varchar(max)
declare @value2…

Müslüm ÖZTÜRK
- 961
- 1
- 11
- 30
3
votes
4 answers
Linq performance: Two queries, the first response immediately and the second is very slow
I have two queries very similars, using the Linq ExecuteQuery method the first take 30 seconds, while the second query is inmediate.
I execute the queries too in Microsoft SQL Server Management Studio and the two queries have a response time of 0…

Juan Carlos Velez
- 2,840
- 2
- 34
- 48
3
votes
1 answer
Query through PreparedStatement in H2 throws exception: This method is not allowed for a prepared statement; use a regular statement instead
A simple query fails when run through a prepared statement while using JDBC 4 to access an H2 database in Java 11.
When running this line:
try ( ResultSet rs = pstmt.executeQuery( sql ) ; ) {
…I get this error:
org.h2.jdbc.JdbcSQLException: This…

Basil Bourque
- 303,325
- 100
- 852
- 1,154