Comments - Error : INSERT INTO in dynammic column (CREATE_COLUMN function) with Java Connector.

4 années, 1 mois ago Axel Dumas

Hello !

I have solved the problem... It was a verry silly mistake from me.

Firstly. It's not CREATE_COLUMN but COLUMN_CREATE...it's better. ^^

Secondly. I have used my own method to make SELECT queries, not the UPDATE method.

Thridly (here, it's interesting for others). With prepared statement, you can't make :

In your query : COLUMN_CREATE(?)

MariaDbBlob optionalDataBlob = new MariaDbBlob("'value', '12'".getBytes());
sqlQuery.getPreparedStatement().setBlob(4, optionalDataBlob);

You have to do many "?" to insert your keys and values. So you have to do :

In your query : COLUMN_CREATE(?, ?) //or more "?"

//And you just insert strings.
sqlQuery.getPreparedStatement().setString(4, "value");
sqlQuery.getPreparedStatement().setString(5, "12");

That's all. I hope this mistake will help someone else.

Thanks you, Sincerely.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.