You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Traku traku <tr...@gmail.com> on 2016/01/13 18:21:07 UTC
DataStream jdbc sink
Hi everyone.
I'm trying to migrate some code to flink 0.10 and I'm having a problem.
I try to create a custom sink to insert the data to a postgresql database.
My code was this.
var.output(
// build and configure OutputFormat
JDBCOutputFormat
.buildJDBCOutputFormat()
.setDrivername("org.postgresql.Driver")
.setDBUrl("jdbc:postgresql://127.0.0.1:5432/test")
.setUsername("postgres")
.setPassword("")
.setQuery("insert into XXX values (?,?,?);")
.finish()
);
Could you help me?
Best regards.
Re: DataStream jdbc sink
Posted by Traku traku <tr...@gmail.com>.
thank you!!
2016-01-13 20:51 GMT+01:00 Matthias J. Sax <mj...@apache.org>:
> Hi,
>
> use JDBCOutputFormatBuilder to set all required parameters:
>
> > JDBCOutputFormatBuilder builder =
> JDBCOutputFormat.buildJDBCOutputFormat();
> > builder.setDBUrl(...)
> > // and more
> >
> > var.write(builder.finish, OL);
>
> -Matthias
>
>
> On 01/13/2016 06:21 PM, Traku traku wrote:
> > Hi everyone.
> >
> > I'm trying to migrate some code to flink 0.10 and I'm having a problem.
> >
> > I try to create a custom sink to insert the data to a postgresql
> > database. My code was this.
> >
> > var.output(
> > // build and configure OutputFormat
> > JDBCOutputFormat
> > .buildJDBCOutputFormat()
> > .setDrivername("org.postgresql.Driver")
> > .setDBUrl("jdbc:postgresql://127.0.0.1:5432/test
> > <http://127.0.0.1:5432/test>")
> > .setUsername("postgres")
> > .setPassword("")
> > .setQuery("insert into XXX values (?,?,?);")
> > .finish()
> > );
> >
> > Could you help me?
> >
> > Best regards.
> >
> >
>
>
Re: DataStream jdbc sink
Posted by "Matthias J. Sax" <mj...@apache.org>.
Hi,
use JDBCOutputFormatBuilder to set all required parameters:
> JDBCOutputFormatBuilder builder = JDBCOutputFormat.buildJDBCOutputFormat();
> builder.setDBUrl(...)
> // and more
>
> var.write(builder.finish, OL);
-Matthias
On 01/13/2016 06:21 PM, Traku traku wrote:
> Hi everyone.
>
> I'm trying to migrate some code to flink 0.10 and I'm having a problem.
>
> I try to create a custom sink to insert the data to a postgresql
> database. My code was this.
>
> var.output(
> // build and configure OutputFormat
> JDBCOutputFormat
> .buildJDBCOutputFormat()
> .setDrivername("org.postgresql.Driver")
> .setDBUrl("jdbc:postgresql://127.0.0.1:5432/test
> <http://127.0.0.1:5432/test>")
> .setUsername("postgres")
> .setPassword("")
> .setQuery("insert into XXX values (?,?,?);")
> .finish()
> );
>
> Could you help me?
>
> Best regards.
>
>