I am trying to connect to h2 database with pgPort from my c++ application.
I am getting the following error while trying to do prepared statement from
libpgxx. Anyone got similar error and have a workaround?
Error in java
00:16:09.956 [H2 PG Server (pg://10.123.10.88:5435) thread] ERROR
org.h2.message.TraceWriterAdapter.write(TraceWriterAdapter.java:65) -
jdbc[7] exception
org.h2.jdbc.JdbcSQLException: Parameter "#1" is not set; SQL statement:
INSERT INTO sequence(id) VALUES($1) [90012-176]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:344) ~[
h2-1.3.176.jar:1.3.176]
at org.h2.message.DbException.get(DbException.java:178) ~[h2-1.3.176.jar:
1.3.176]
at org.h2.message.DbException.get(DbException.java:154) ~[h2-1.3.176.jar:
1.3.176]
at org.h2.expression.Parameter.checkSet(Parameter.java:81) ~[h2-1.3.176.jar
:1.3.176]
at org.h2.command.Prepared.checkParameters(Prepared.java:165) ~[h2-1.3.
176.jar:1.3.176]
at org.h2.command.CommandContainer.update(CommandContainer.java:78) ~[h2-
1.3.176.jar:1.3.176]
at org.h2.command.Command.executeUpdate(Command.java:254) ~[h2-1.3.176.jar:
1.3.176]
at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:199
) [h2-1.3.176.jar:1.3.176]
at org.h2.server.pg.PgServerThread.process(PgServerThread.java:348) [h2-1.3
.176.jar:1.3.176]
at org.h2.server.pg.PgServerThread.run(PgServerThread.java:91) [h2-1.3.
176.jar:1.3.176]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_40]
Error in c++ application
Connecting
Connected
Backend version supports prepared statements.
Preparing
Prepared
Working
Worked
Exec INSERT
ERROR: General error: "java.lang.ArrayIndexOutOfBoundsException: 0" [50000-
176]
DETAIL: org.h2.jdbc.JdbcSQLException: General error:
"java.lang.ArrayIndexOutOfBoundsException:
0" [50000-176]
ERROR: Parameter "#1" is not set; SQL statement:
INSERT INTO sequence(id) VALUES($1) [90012-176]
DETAIL: org.h2.jdbc.JdbcSQLException: Parameter "#1" is not set; SQL
statement:
INSERT INTO sequence(id) VALUES($1) [90012-176]
My c++ code
std::cout << "Connecting\n";
pqxx::connection conn("dbname=mem:my_table
hostaddr=10.123.10.88 port=5435 user=sa password=sa");
std::cout << "Connected\n";
if ( !conn.supports(pqxx::connection_base::
cap_prepared_statements) ) {
std::cout << "Backend version does not support
prepared statements. Skipping.\n";
return 1;
}
std::cout << "Backend version supports prepared
statements.\n";
std::cout << "Preparing\n";
conn.prepare("insert_db_sequence", "INSERT INTO
sequence(id) VALUES($1)");
std::cout << "Prepared\n";
std::cout << "Working\n";
pqxx::work w(conn);
std::cout << "Worked\n";
std::cout << "Exec INSERT\n";
int a = 71717;
w.prepared("insert_db_sequence")(a).exec();
std::cout << "Exec'ed INSERT\n";
std::cout << "Committing\n";
w.commit();
std::cout << "Committed\n";
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.