MySQL JDBC Url参数说明

 

 

参数名称 参数说明 缺省值 最低版本要求
user 数据库用户名(用于连接数据库)   all
password 用户密码(用于连接数据库)   all
useUnicode 是否使用Unicode字符集,如果参数characterEncoding设置为gb2312、gbk或utf8,本参数的值必须设置为true false 1.1g
characterEncoding useUnicode为true时,指定字符编码,比如可以设置为gb2312、gbk或utf8 false 1.1g
autoReconnect 当数据库连接异常中断时,是否重新连接? false 1.1
autoReconnectForPools 是否使用针对数据库连接池的重连策略 false 3.1.3
failOverReadOnly 自动重连成功后,连接是否设置为只读? true 3.0.12
maxReconnects autoReconnect设置为true时,重试连接的次数 3 1.1
initialTimeout autoReconnect设置为true时,两次重连之间的时间间隔,单位:秒  2 1.1
connectTimeout 和数据库服务器建立socket连接时的超时,单位:毫秒。 0表示永不超时,适用于JDK 1.4及更高版本 0 3.0.1
scoketTimeout socket操作(读写)超时,单位:毫秒。 0表示永不超时 0 3.0.1

 对应中文环境,通常mysql连接URL可以设置为:
  jdbc:mysql://localhost:3306/test?user=root&password=&useUnicode=true&characterEncoding=gbk&autoReconnect=true&failOverReadOnly=false

 

c3p0连接池Mysql配置

        <property name="jdbcUrl">
            <![CDATA[
                jdbc:mysql://localhost:3306/goods?useUnicode=true&characterEncoding=UTF8&useServerPrepStmts=true&prepStmtCacheSqlLimit=256&cachePrepStmts=true&prepStmtCacheSize=256&rewriteBatchedStatements=true
            ]]>
        </property>
        <property name="driverClass">com.mysql.jdbc.Driver</property>
        <property name="user">root</property>
        <property name="password">123</property>

 

posted @ 2017-03-03 13:31  Jonnyxu  阅读(8410)  评论(0编辑  收藏  举报