SDP(2):ScalikeJDBC-Connection Pool Configuration

  scalikeJDBC可以通过配置文件来设置连接池及全局系统参数。对配置文件的解析是通过TypesafeConfig工具库实现的。默认加载classpath下的application.conf,application.json和application.properties文件。作为尝试,我们可以在resource/application.conf文件里进行h2和mysql数据库的JDBC驱动参数定义:

# JDBC settings db { h2 { driver="org.h2.Driver" url="jdbc:h2:tcp://localhost/~/slickdemo" user="" password="" poolInitialSize=5 poolMaxSize=7 poolConnectionTimeoutMillis=1000 poolValidationQuery="select 1 as one" poolFactoryName="commons-dbcp" } } db.mysql.driver="com.mysql.jdbc.Driver" db.mysql.url="jdbc:mysql://localhost:3306/testdb" db.mysql.user="root" db.mysql.password="123" db.mysql.poolInitialSize=5 db.mysql.poolMaxSize=7 db.mysql.poolConnectionTimeoutMillis=1000 db.mysql.poolValidationQuery="select 1 as one" db.mysql.poolFactoryName="commons-dbcp" # scallikejdbc Global settings scalikejdbc.global.loggingSQLAndTime.enabled=true scalikejdbc.global.loggingSQLAndTime.logLevel=info scalikejdbc.global.loggingSQLAndTime.warningEnabled=true scalikejdbc.global.loggingSQLAndTime.warningThresholdMillis=1000 scalikejdbc.global.loggingSQLAndTime.warningLogLevel=warn scalikejdbc.global.loggingSQLAndTime.singleLineMode=false scalikejdbc.global.loggingSQLAndTime.printUnprocessedStackTrace=false scalikejdbc.global.loggingSQLAndTime.stackTraceDepth=10

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyfzgp.html