Spark中访问mysql连接池的封装
package com.lg.blgdata.utils import java.util.Properties import com.alibaba.druid.pool.DruidDataSourceFactory import javax.sql.DataSource import java.sql.Connection //mysql连接池 object DruidConnectionPool{ private val props=new Properties(); props.put("username","root") props.put("password","lgg123") props.put("driverClassName","com.mysql.cj.jdbc.Driver") props.put("url","jdbc:mysql://192.168.x.xxx:3306/jzwdata?useUnicode=true&characterEncoding=utf8") private val source:DataSource=DruidDataSourceFactory.createDataSource(props) def getConnection : Connection={ source.getConnection } }
作者:皓月无边*半步青莲
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。