You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Chesnay Schepler <ch...@apache.org> on 2021/08/19 18:26:18 UTC

Re: Process suspend when get Hana connection in open method of sink function

If the Hana driver cannot be loaded then the most likely reason is that 
the dependency is not actually on the classpath.
Please double-check that your user jar bundles the dependency.

On 18/08/2021 15:05, Chenzhiyuan(HR) wrote:
>
> Dear all:
>
> I have a problem when I want to sink data to Hana database.
>
> Process is suspended when get Hana connection in the open method of 
> sink function as below.
>
> My flink version is 1.10.
>
> public class HrrmPayValueSumToHana extends 
> RichSinkFunction<HrmsPayValueAccumulator>  {
>
> @Override
> public void open(Configuration parameters) throws Exception {
> super.open(parameters);
> connection = HrrmUtils./getHanaConnection/();    // process is 
> suspended here
> }
>
> @Override public void invoke() {
>   …….
> }
> @Override public void close() throws Exception {
>   ……….
> }
>
> }
>
> public static Connection getHanaConnection() { Connection con = null; 
> try { Class./forName/(HrrmConstants./HANA_DRIVER_CLASS/); con = 
> DriverManager./getConnection/(HrrmConstants./HANA_SOURCE_DRIVER_URL/, 
>             HrrmConstants./HANA_SOURCE_USER/, 
> HrrmConstants./HANA_SOURCE_PASSWORD/);    } catch (Exception e) { /LOG/.error("-----------hana get connection has exception , msg = ", e); 
>     } return con; }
>
> Hana driver dependency as below:
>
> <dependency>     <groupId>com.sap.cloud.db.jdbc</groupId>     
> <artifactId>ngdbc</artifactId>     <version>2.3.62</version> </dependency>
>