如何正确地在JDBC URL中传递会话变量? [英] How to pass session variables in JDBC url properly?

查看:417
本文介绍了如何正确地在JDBC URL中传递会话变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须增加group_concat_max_len. 我不能通过preparestatement做到这一点,而且也无法在mysql my.conf文件中做到这一点.

I have to increase group_concat_max_len. I cannot do it by preparestatement, and also I cannot do it in mysql my.conf file.

我在mysql文档上发现,有一个选项可以在url中传递会话变量. 但是没有例子,我试图这样做:

I found on mysql docs that there is an option to pass session variables in url. But there is no example, I tried to do it like that:

jdbc.url=jdbc:mysql://xxxx.xx.xx.xx/dbName?sessionVariables=group_concat_max_len:204800

我有这个例外:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':204800' at line 1

我也这样尝试过:

jdbc.url=jdbc:mysql://xxxx.xx.xx.xx/dbName?sessionVariables=group_concat_max_len,204800

因为官方文档说:

sessionVariables

A comma-separated list of name/value pairs to be sent as SET SESSION ... to the server when the driver connects.

Since version: 3.1.8

任何想法?

推荐答案

尝试一下:

jdbc.url=jdbc:mysql://xxxx.xx.xx.xx/dbName?sessionVariables=group_concat_max_len=204800

这篇关于如何正确地在JDBC URL中传递会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆