我正在我的库中创建对db2数据库的支持
我有一些代码可以在支持jdbc的多个SQL数据库上工作
但是db2在尝试使用现有的代码库时给我带来了一个问题
尝试使用prepared语句插入数据库表时
这样地。。。
INSERT INTO main.Parent (col) VALUES (?);
我犯了这样的错误。。。
Caused by: com.urosjarc.dbmessiah.exceptions.EngineException: Failed to process insert results from:
INSERT INTO main.Parent (col) VALUES (?);
1) col: VARCHAR = '-1934310868'
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;ent (col) VALUES (?);<space>, DRIVER=4.33.31
jdbc端是标准的,我知道它应该可以工作。。。
var ps: PreparedStatement? = null
var rs: ResultSet? = null
var rs2: ResultSet? = null
//Execute query
try {
//Prepare statement
ps = conn.prepareStatement(query.sql, Statement.RETURN_GENERATED_KEYS)
//Custom logic for inserting values to result set...
ps.setString(1, "asdf")
//Get info
val numUpdates = ps.executeUpdate()
//If no updates happend close all
if (numUpdates == 0) {
this.closeAll(ps = ps)
return null
}
//Continue with getting ids for inserts
} catch (e: Throwable) {
this.closeAll(ps = ps)
throw EngineException(msg = "Failed to process insert results from: $query", cause = e)
}
如果我在jetbrains idea数据库控制台上运行相同的查询
插入主体。父(列)值(?);
插入正在工作。。。
我正在使用jdbc驱动程序。。。
this.runtimeOnly("com.ibm.db2:jcc:11.5.9.0")
这是怎么回事?