can you share the full code .

On Sun, Jul 1, 2018 at 12:49 PM chrisr123 <chris.rueg...@gmail.com> wrote:

>
> I'm trying to determine if I'm specifying type information properly when
> doing an INSERT using
> the JDBCAppendTableSink API.   Specifically, how do I specify timestamp and
> date types? It looks like
> I need to use Type.SQL_TIMESTAMP for a timestamp but BasicTypeInfo for
> types
> like varchar, etc?
>
> I am having trouble finding complete examples. I got this to work below but
> I wanted to confirm I'm
> doing things the correct way?
>
> This is for an append-only into a Derby Database table.
>
> My DDL
> # simple table with a timestamp, varchar, bigint
> create table mydb.pageview_counts
> (window_end     timestamp not null,
>  username       varchar(40) not null,
>  viewcount      bigint not null);
>
> My Insert Statement
> // Write Result Table to Sink
> // Configure Sink
> JDBCAppendTableSink pageViewSink = JDBCAppendTableSink.builder()
>         .setDrivername("org.apache.derby.jdbc.ClientDriver")
>         .setDBUrl("jdbc:myhost://captain:1527/mydb")
>         .setUsername("foo")
>         .setPassword("bar")
>         .setBatchSize(1)
>         .setQuery("INSERT INTO mydb.pageview_counts
> (window_end,username,viewcount)
> VALUES (?,?,?)")
>
>
> .setParameterTypes(Types.SQL_TIMESTAMP,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.LONG_TYPE_INFO)
>         .build();
>
>
>
>
>
> --
> Sent from:
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
>

Reply via email to