Hi Philipp,

yes, definitely there are some core functions.


I only changed following methods:

 * changes only working in Postgres
    * initializeJdbc
    * ensureTableExists
    * generatePreparedStatement
    * createTable
    * executePreparedStatement
    * enum SqlAttribute 
 * new methods only for Postgres
    * ensureSchemaExists
    * createSchema


All other methods are reusable and the change in the connect-method
should be valid for all other JBDC.


I already tried to create an extended class but got some undefined
error messages.

For now I created a PostgresJBDCClient class and rechanged the IoT-DB
Sink back to normal referencing to the JDBCClient like before. All
changes are now committet in the feature/postgis branch

Greetings
Florian


Am Montag, den 18.05.2020, 16:39 +0200 schrieb Philipp Zehnder:
> Hi Florian,
> 
> yes I agree. We should put database specific implementations in a
> separate class into the package of the sink.
> 
> Do you think we have to duplicate the whole class or can we leave
> some core functionalities in the JDBClient?
> 
> Philipp
> 
> > On 15. May 2020, at 16:33, Florian Micklich <[email protected]>
> > wrote:
> > 
> > Hi all,
> > 
> > I just made a quick test and as aspected it is not compatible with
> > the
> > IoT-DB anymore. So what are the best options?
> > 
> > I would say, move each working JDBClient into the depending Sink
> > folder
> > and rename it like IoTDbClient and PostgresClient. Similar solution
> > is
> > used for example in the InfluxDbClient sink folder.
> > 
> > What do you think?
> > 
> > Kind regards
> > Florian
> > 
> > 
> > 
> > Am Freitag, den 15.05.2020, 15:29 +0200 schrieb Florian Micklich:
> > > Hi all,
> > > 
> > > I did some changes in the postgres sink and depending
> > > JdbcClient.class.
> > > 
> > > 
> > > Here is the small changelog:
> > > 
> > >   A. I improved the error messages if wrong host/port oder user
> > >      authentication is used.
> > >   B. Changing the  enum SqlAttribute data types for Double and
> > > String. In
> > >      Postgres double leads to an error described in STREAMPIPES-
> > > 127.
> > >      Instead DOUBLE PRECISION has to be used [1]. Also changes
> > > String
> > >      from varchar255 to TEXT. This allows "unlimited" string
> > > lentgh.
> > >   C. Added two new db settings: 
> > >       * Use schema name [2] instead of only public. 
> > >       * Drop Table if Exists Option. This deletes the table if
> > > table
> > > exists, so old will be removed and the same table name can be
> > > used.
> > >   D. Because of C. some changes had to be made in the
> > > JdbcClient.class
> > >      and also in the initializeJdbc method with two new
> > > parameters.
> > >   E. Extended documentation and string.en with the new parameters
> > > 
> > > This changes can be found in the feature/postgis-sink branch. The
> > > compatibility with the IoT-DB, which also uses the class
> > > JdbcClient.class, still needs to be tested! My first guess is,
> > > that
> > > this may not be compatible, but because of STREAMPIPES-127 it
> > > seems
> > > to
> > > be necessary to use another JdbcClien client anyway. At the
> > > moment I
> > > used some default values(public and false) to start the
> > > IotDB.class
> > > Sink like without compiling error.
> > > 
> > > 
> > >    initializeJdbc(
> > >            parameters.getGraph().getInputStreams().get(0).getEven
> > > tSc
> > > he
> > > ma().getEventProperties(),
> > >            parameters.getIotDbHost(),
> > >            parameters.getIotDbPort(),
> > >            "",         // Database does not exist in  IoTDB model
> > >            "root." + parameters.getDbStorageGroup(),
> > >            parameters.getUsername(),
> > >            parameters.getPassword(),
> > >            ".*",
> > >            "org.apache.iotdb.jdbc.IoTDBDriver",
> > >            "iotdb",
> > >            LOG,
> > >            "public",
> > >            false);
> > > 
> > > Greetings
> > > Florian
> > > 
> > > [1] https://www.postgresql.org/docs/current/datatype-numeric.html
> > > [2] https://www.postgresqltutorial.com/postgresql-schema/
> > > [3] https://www.postgresql.org/docs/current/sql-droptable.html
> 
> 

Reply via email to