Greetings.
To my best knowledger, you can use Parameters only for QUERIES and DML,
but not for DDL statements.
Although you can have a look
at https://github.com/manticore-projects/MJdbcUtils which I wrote
exactly for this kind of challenges.
It rewrites your parameterised SQL Statement and I used it for ORACLE's
CREATE TABLE ... AS SELECT ... FROM (where the SELECT must not contain
parameters).
Good luck and cheers
Andreas
On Fri, 2023-04-14 at 04:44 -0700, airjairj wrote:
> The following code is what i'm using for the alter table, nothing
> special but it results in an exception:
> Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in
> SQL statement "ALTER TABLE TableName ADD [*]? BOOLEAN"; expected
> "identifier"; SQL statement:
> ALTER TABLE TableName ADD ? BOOLEAN [42001-214]
>
> The code:
> PreparedStatement preparedStatement = null;
> try {
> final String QUERY_SQL = "ALTER TABLE TableName ADD ? BOOLEAN";
> preparedStatement = connection.prepareStatement(QUERY_SQL);
> preparedStatement.setString(1, User.getUsername());
> preparedStatement.executeUpdate();
> preparedStatement.close();
> } catch (SQLException e) {
> ...
>
>
> For context:
> I'm trying to add a colum (of boolean) to the table named like the
> user and it works if i copy and paste the instruction on the browser
> and run it, am i missing something?
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/h2-database/c7651d96-15fb-42e2-b4c1-bdee0ac1f2dan%40googlegroups.com
> .
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/h2-database/7190f68f2ec4abe866f54d833003b416d6195d11.camel%40manticore-projects.com.