[英]How to execute stored procedure/routine with JDBCIO (apache beam)
i'm trying to execute a postgres routine using JDBCIO for apache beam.我正在尝试使用 JDBCIO for apache beam 执行 postgres 例程。
So far I have tried:到目前为止,我已经尝试过:
.apply(JdbcIO.<MyData>write()
.withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(
"org.postgresql.Driver", "jdbc:postgresql://localhost:5432/postgres")
.withUsername("postgres")
.withPassword("password"))
.withStatement("do $$\n" +
"begin " +
"perform test_routine(first := ?, second := ?, age := ?) " +
"end\n" +
"$$;")
.withPreparedStatementSetter(new JdbcIO.PreparedStatementSetter<MyData>() {
public void setParameters(MyData element, PreparedStatement query)
throws SQLException {
query.setString(1,element.mfirst);
query.setString(2, element.second);
query.setInt(3, element.age);
}
})
);
Unfortunately that gives me the error:不幸的是,这给了我错误:
org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0
I have managed to get it working with a simple insert statement, but ideally would like to call a routine.我已经设法用一个简单的插入语句让它工作,但理想情况下想调用一个例程。 Any help would be appreciated.任何帮助,将不胜感激。
非常简单:
.withStatement("select test_routine(first := ?, second := ?, age := ?))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.