|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +package com.dtstack.flink.sql.side.db2; |
| 20 | + |
| 21 | +import com.dtstack.flink.sql.side.FieldInfo; |
| 22 | +import com.dtstack.flink.sql.side.JoinInfo; |
| 23 | +import com.dtstack.flink.sql.side.SideTableInfo; |
| 24 | +import com.dtstack.flink.sql.side.rdb.all.RdbAllReqRow; |
| 25 | +import com.dtstack.flink.sql.util.DtStringUtil; |
| 26 | +import com.google.common.collect.Maps; |
| 27 | +import org.apache.flink.api.java.typeutils.RowTypeInfo; |
| 28 | +import org.slf4j.Logger; |
| 29 | +import org.slf4j.LoggerFactory; |
| 30 | + |
| 31 | +import java.sql.Connection; |
| 32 | +import java.sql.DriverManager; |
| 33 | +import java.util.List; |
| 34 | +import java.util.Map; |
| 35 | + |
| 36 | +/** |
| 37 | + * Date: 2019/11/20 |
| 38 | + * Company: www.dtstack.com |
| 39 | + * |
| 40 | + * @author xiuzhu |
| 41 | + */ |
| 42 | + |
| 43 | +public class Db2AllReqRow extends RdbAllReqRow { |
| 44 | + |
| 45 | + private static final Logger LOG = LoggerFactory.getLogger(Db2AllReqRow.class); |
| 46 | + |
| 47 | + private static final String DB2_DRIVER = "com.ibm.db2.jcc.DB2Driver"; |
| 48 | + |
| 49 | + public Db2AllReqRow(RowTypeInfo rowTypeInfo, JoinInfo joinInfo, List<FieldInfo> outFieldInfoList, SideTableInfo sideTableInfo) { |
| 50 | + super(new Db2AllSideInfo(rowTypeInfo, joinInfo, outFieldInfoList, sideTableInfo)); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public Connection getConn(String dbURL, String userName, String password) { |
| 55 | + try { |
| 56 | + Class.forName(DB2_DRIVER); |
| 57 | + Connection conn = DriverManager.getConnection(dbURL, userName, password); |
| 58 | + return conn; |
| 59 | + } catch (Exception e) { |
| 60 | + LOG.error("", e); |
| 61 | + throw new RuntimeException("", e); |
| 62 | + } |
| 63 | + } |
| 64 | +} |
0 commit comments