jdbc url
mysql jdbc url格式
jdbc:mysql://[host:port],[host:port].../[database][?参数名1][=参数值1][&参数名2][=参数值2]...
如果使用默认端口(3306) port可以省略
常用参数
参数名 | 说明 | 默认值 | 版本 |
---|---|---|---|
user | 数据库用户名 | 所有 | |
password | 数据库密码 | 所有 | |
useUnicode | 是否使用Unicode字符集 如果参数characterEncoding设置为gb2312或gbk,本参数必须设置为true | false | 1.1g |
chracteEncoding | 当useUnicode设置为true时,指定字符编码 | 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 | 和数据库建立连接的超时。单位:毫秒。0表示永不超时 | 0 | 3.0.1 |
socketTimeout | 读写操作超时时间。单位:毫秒。0表示永不超时 | 0 | 3.0.1 |
serverTimezone | 设置服务器时区 | ||
useServerPrepStmts | 是否使用预编译 | false | |
cachePrepStmts | 是否使用预编译缓存 | false |
当使用 LocalDateTime等api进行实际操作时需要设置时区