Linked Questions
70 questions linked to/from Multiple queries executed in java in single statement
10
votes
3
answers
26k
views
Can I execute multiple queries separated by semicolon with MySQL Connector/J? [duplicate]
My jdbc driver for mysql db is of version 5.1.25.
I want to execute sql query like so:
statement.execute("select fullName from user where user_id=1; select fullName from user where user_id=2");
And ...
2
votes
2
answers
13k
views
How to run several select queries with same statement and result set? [duplicate]
I am trying to write simple Java web application to get data from a database.
I need to run several select queries on different database tables.
String queryOne = "select firstname from employees ...
0
votes
0
answers
4k
views
How to run multiple queries in single statement in mariadb using jdbc [duplicate]
This is my SQL code, a simple transaction. When I run it on MariaDB using run as script it works well, but it doesn't work with run as SQL Statement.
START TRANSACTION;
SELECT * from employee;
insert ...
0
votes
1
answer
1k
views
How to run multiple queries in single statement [duplicate]
This is my SQL code, a simple transaction. When i run it on phpmyadmin it's work well.
START TRANSACTION;
SELECT received_money FROM bank_accounts WHERE `uuid` = "2eaef3e4-eeb6-41f7-9ecf-...
-1
votes
1
answer
1k
views
How to insert and select global temporary table using jdbc oracle? [duplicate]
String query = "INSERT INTO St (id) values ('Admin'); " +
"select * from Student where id in (select id from St);";
Getting error if try to execute the above query
Exception in thread "...
2
votes
1
answer
901
views
SQL variables in query cause unexpected SQL syntax error [duplicate]
There is a database that holds music - artists, albums and tracks. Each album has several tracks, each track has it's own track_number inside the album.
I try to execute an SQL request that shifts one ...
0
votes
1
answer
380
views
Java JDBC MySQL multiple INSERTS in one executeUpdate() [duplicate]
I'm using JDBC to make my Java application handle SQL statements to my MySQL database.
For some reason it can't do multiple insert statements in one executeUpdate() method.
My code looks like this:
...
1
vote
0
answers
330
views
Execute multiple queries in java using MySQL JDBC [duplicate]
My objective is to be able to run Descriptive Statistics mySQL queries on my tables on Java. Some of these queries consist of several parts to get one result such as getting a median of a column which ...
1
vote
3
answers
228
views
concatenated sql statement insert [duplicate]
I have a script that needs to insert multiple things inside one statement, like
sql = "INSERT INTO `table` (something, something) VALUES (smth,smth); INSERT INTO `table` (something, something) VALUES ...
1
vote
0
answers
95
views
setAllowMultiQueries in MySQL Connector/J 6.0.4 [duplicate]
In MySQL Connector/J 5.1.39 there was com.mysql.jdbc.jdbc2.optional.MysqlDataSource.setAllowMultiQueries() to allow multiple statements in SQL queries.
In new version 6.0.4 MysqlDataSource is moved ...
3
votes
0
answers
94
views
How use the MYSQL query in jdbc [duplicate]
I want to remove the duplicate records from mysql db. And tried below query which will do as expected by manually. But I just want to execute this from JDBC, but It throws exception.
Query:
CREATE ...
0
votes
0
answers
72
views
How to execute an SQL script that contains multiple related statements? [duplicate]
I have the following SQL script (stored in a .sql file) imported into my java program as a string (I changed some variable names so its easier to read):
SET @variable1 := (
//setting the value of ...
0
votes
0
answers
46
views
MySQL unexpected syntax error during JDBC execution [duplicate]
I'm executing a script through a Java web service I wrote to execute on a MySQL database.
When executing the query in phpMyAdmin it completes successfully, however as soon as it is executed by my web ...
0
votes
1
answer
42
views
Why does my JDBC/MySQL code throw an error when running SQL 'delete from cart where cart.ID in ...' inside a function? [duplicate]
so i was trying to run these lines of code
public void refresh() {
try {
String strUpdate = "SET SQL_SAFE_UPDATES = 0; \n"
+ "delete from ...
1
vote
0
answers
26
views
MySQL Query which is correct in MySQL WorkBench gives SQLSyntaxErrorException in JDBC [duplicate]
Can somebody explain what I am doing wrong. I want to make table from JDBC, I executed the query in MySQLWorkBench works fine. When I want to execute it from JDBC constant gives ...