技术杂记 您所在的位置:网站首页 kettle数据库连接池配置 技术杂记

技术杂记

2023-03-24 18:56| 来源: 网络整理| 查看: 265

  kettle内置的jndi管理是simple-jndi,功能确实比较简单,我需要监控kettle性能,druid确实是很不错的选择,但没有提供对应的支持,我改进了druid源码,实现了simple-jndi的接口,就可以在simple-jndi/jdbc.properties中配置druid数据源了,通过druid可以得到很多监控数据。

  具体druid的使用请参考官方教程:https://github.com/alibaba/druid/wiki/%E9%A6%96%E9%A1%B5,相当详细。

  具体代码如下:

/* * Copyright 1999-2101 Alibaba Group Holding Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *  http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.alibaba.druid.support.simplejndi;import java.sql.SQLException;import java.util.Properties;import org.osjava.sj.loader.convert.Converter;import com.alibaba.druid.pool.DruidDataSource;import com.alibaba.druid.pool.DruidDataSourceFactory;import com.alibaba.druid.support.logging.Log;import com.alibaba.druid.support.logging.LogFactory;/** * 支持simple-jndi * 配置示例: * pgDruidTest/converter=com.alibaba.druid.support.simplejndi.DruidDataSourceConverterpgDruidTest/type=javax.sql.DataSourcepgDruidTest/driverClassName=org.postgresql.DriverpgDruidTest/url=jdbc:postgresql://127.0.0.1:5432/kettleReppgDruidTest/username=postgrespgDruidTest/password=postgrespgDruidTest/maxActive=50pgDruidTest/minIdle=10pgDruidTest/initialSize=5pgDruidTest/validationQuery=SELECT 1pgDruidTest/maxWait=10000pgDruidTest/removeabandoned=truepgDruidTest/removeabandonedtimeout=60pgDruidTest/logabandoned=falsepgDruidTest/filters=stat,config,log4jpgDruidTest/connectionProperties=druid.log.stmt.executableSql=true    * date: 2016年1月31日 下午12:54:10  * @author [email protected] */public class DruidDataSourceConverter implements Converter {private final static Log LOG = LogFactory.getLog(DruidDataSourceConverter.class);/** *  * @see org.osjava.sj.loader.convert.Converter#convert(java.util.Properties, java.lang.String) */@Overridepublic Object convert(Properties properties, String type) {try {DruidDataSource dataSource = new DruidDataSource();DruidDataSourceFactory.config(dataSource, properties);return dataSource;} catch (SQLException e) {LOG.error("properties:"+properties, e);}return null;}}

  我已将以上改进pull requests到官方了,并已经合并,官方新版应该直接支持作为kettle的数据源配置了。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有