Java 如何使用JDBCIO(apache beam)执行存储过程/例程
我正在尝试使用ApacheBeam的JDBCIO执行postgres例程 到目前为止,我已经尝试:Java 如何使用JDBCIO(apache beam)执行存储过程/例程,java,postgresql,jdbc,apache-beam,apache-beam-io,Java,Postgresql,Jdbc,Apache Beam,Apache Beam Io,我正在尝试使用ApacheBeam的JDBCIO执行postgres例程 到目前为止,我已经尝试: .apply(JdbcIO.<MyData>write() .withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create( "org.postgresql.Driver", "jdbc:
.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);
}
})
);
我已经设法用一个简单的insert语句使它工作,但理想情况下我想调用一个例程。任何帮助都将不胜感激 非常简单:
.withStatement("select test_routine(first := ?, second := ?, age := ?))
.withStatement("select test_routine(first := ?, second := ?, age := ?))