I have SQL that pulls data for a given timeframe. I want to run the SQL multiple times and merge/union the results together into one result set. Currently I copy the SQL and change the date ranges. As an example: Since I need to repeat this for multiple years, I would like to make the year a parameter and execute
Tag: prepared-statement
What is the right way to deal with the PreparedStatement in the Java program flow?
There are two methods in which the PreparedStatement is used. The first method is called in the second method. First method: Second method: The class in which both methods are located extends the JDBCBaseManager. JDBCBaseManager: The ResultSet in the second method still contains the results from the first method. I already tried to close the connection and open it again
how to set concatenated string parameter in preparedstatement
I have the following java code: I get the following exception in codeline 3-: Invalid column index What did I do wrong? how to set params correctly? Answer Take the bind parameters out of the string literal: Or, create a single bind parameter and pass in the concatenated value:
Python(Flask,JayDeBeApi) RuntimeError: No matching overloads found for prepareStatement
as mentioned in the title i get this error when i try to execute a prepared statement. The full error is: As far as i can understand is, that propably that since i am trying to use a prepared statement, that the compiler can not find something to overload the ? placeholder. Code snippet: The error seems to happen at
How can I parameterize an SQL table without vulnerability to SQL injection
I’m writing a C# class library in which one of the features is the ability to create an empty data table that matches the schema of any existing table. For example, this: The above code works, but it has a glaring security vulnerability: SQL injection. My first instinct is to parameterize the query like so: But this leads to the
How do I use prepared statements with an OleDbDataAdapter?
I’m writing an API that will query a database given certain parameters. Some of those parameters will be supplied by the calling app (which should be trustworthy), but some of them will be supplied …
Is it possible to create a prepared statement and reuse it later with Java under postgres?
I am trying to test a few things out with postgres. I want to know if it’s possible to create define a PreparedStatement such as String statement = “Insert into table_one values (?)”; …
Is insert.addBatch() accessible outside of this for loop?
I have multiple for loops where I am setting the values to be inserted into a MySQL DB. My question is will insert.addBatch(); detect the insert values if it is outside of the for loop. Below is an …
How to get rid of many placeholders (question marks) in java sql statements
I want to insert a row to table using JDBC. But table has a big number of columns, so I don’t want to specify all of them into a statement. Is there another way of specifying column values? INSERT …
How to get SQL prepared statement based on user input (scanner)
I have difficulties with creating prepared statement which SELECT and print out rows which fulfill condition: SELECT ReservationStartDate, ReservationEndDate FROM treservations WHERE …