Skip to main content

All Questions

1 vote
2 answers
193 views

How to handle SQL queries to a database with a propability of 100+ combinations?

I have 9 fields to my user interface , each one is representing a column in my database table. So the problem is that i need to cover all the possible combinations of the 9 fields and send specific ...
Νίκος Ανδρεάδης's user avatar
0 votes
1 answer
108 views

Mysql PreparedStatement Query returns 0 rows though table has newly inserted data

I'm porting an old java program that polls the db every few minutes. It simply queries a certain table and based on the row values processes them (i have to maintain the polling, can't change to CDC ...
Obb's user avatar
  • 163
0 votes
0 answers
57 views

PreparedStatement automatically adds the \

I'm trying to make a query using the PreparedStatemant: private static final String DEFAULT_GET_PROCS_DT_LOG = "(SELECT concat(date_format(max(dt_start),'%Y-%m-%d'),'%') FROM table)"; ...
Alex's user avatar
  • 109
0 votes
2 answers
868 views

What's a more efficient way to use multiple values in Insert statement w/ PreparedStatement?

Basically, how can I change the following so I don't have multiple question marks?: public static int insert(int id, String name, String address, String phone, int age) throws SQLException { ...
Kyle's user avatar
  • 23
0 votes
1 answer
190 views

Java SQL Prepared Statement Update not working [duplicate]

I have the problem that I just can't get the following code to run. I've tried and changed all of them but I always get an error, maybe you have an idea where the error is? public class TestCommand ...
Azalen's user avatar
  • 5
1 vote
0 answers
218 views

Extra Single Quotes in Prepared Statement with JDBC

I'm trying to use JDBC to insert some records to a MySQL database. While trying to insert dynamic values to my prepared statement it seems I'm getting extra single quotes added. I'm not entirely sure ...
HaltPotato's user avatar
0 votes
1 answer
827 views

Query parameter not recognized on PreparedStatement when used in combination with substring_index()

I am using a PreparedStatement to execute queries from within my Java code: String query = "select title from video where substring_index(path,'\\',-1) = ?;" PreparedStatement ps = con....
Bate's user avatar
  • 73
1 vote
2 answers
15k views

java.sql.SQLSyntaxErrorException: Youhave an error in your SQL syntax; check the manual that corresponds to your MariaDB server version

I use MySQL, why MariaDB in the error message? I have tried replacing the parameters `? by known values and it worked. The problem is in the "?" as a placeholder for parameters 1 and 2 in ...
GollumInsane's user avatar
0 votes
0 answers
24 views

mysql PreparedStatement update not working. Exception is not clear [duplicate]

Background: Need to write PreparedStatement to update table in mysql. Using PreparedStatement, I am able to do Select and Insert by passing parameters in different methods of same class. But somehow ...
Himanshu Tech's user avatar
0 votes
1 answer
288 views

Redundant "Reset stmt" before "Execute" when setting useServerPrepStmts and cachePrepStmts to true in MySQL Connector/J

I'm using MySQL Connector/J (version 8.0.28) as the driver on client side. Following is part of my code for test purpose: PreparedStatement ps = null; String url = "jdbc:mysql://10.86.49.16:3306/...
Yuankai Xue's user avatar
0 votes
1 answer
85 views

Java - Prepared Statement only works with one element for MySQL, otherwise it's working in MariaDB

I run a prepared statement to insert stuff in my database in batch. The code is working fine if we use MariaDB, but it's not when using MySQL. I've tried to run the query manually with MySQL and it's ...
Mattew Eon's user avatar
  • 1,793
0 votes
0 answers
754 views

UPSERT vs typical INSERT or UPDATE prepared statement

my system is having a database either mySQL or Oracle. I am writing a function to: Check data in the database if id exists, if data exists then do an UPDATE otherwise do an INSERT My question is, is ...
Joerdan Devera's user avatar
0 votes
1 answer
10k views

Error SQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax [duplicate]

I've been trying to do a JDBC connection with MySQL using the preparedStatement. Here is my code so far: package uni.jdbc.preparedStatement; import java.sql.*; public class Main { public static ...
Guilherme Aguiar's user avatar
-2 votes
1 answer
246 views

Error with JDBC Mysql SELECT!! Syntax error [duplicate]

when I tried to run a SELECT on MySQL through java application, I got the message of syntax error. Already tried to run this query on MySQL Workbench and it works normally. Error: java.sql....
Gabriel Cardoso's user avatar
1 vote
0 answers
21 views

JDBC Query doesn't work, but the same prepared statement works on MySQL Workbench [duplicate]

When I tried to execute the following java code I face the issue java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version ...
LittleLeg's user avatar

15 30 50 per page
1
2 3 4 5
29