Problems with query in the bank using PreparedStatement

0

I have a problem with using preparedStatement. I have a very large SQL query (very large String), so it gives syntax error. However, when I remove some parts of the code, the error is different by increasing exactly how much I removed from the string

Example:

String sql = "select col1, col2, col3, col4, col5, col6 from table where col4 = 4 and col5 = 2";

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 4 and col5

But when I delete an excerpt from the string the error changes:

String sql = select col1, col2, col3, col4, col5 from table where col4 = 4 and col5 = 2;

Erro: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 4 and col5 = 2'

Notice that "= 2" appears in the error, which is exactly the number of characters I took from the string.

Do you have any other options besides Statement or PreparedStatement to use? Or does anyone have a solution for this?

    
asked by anonymous 02.10.2018 / 21:33

0 answers