gpt4 book ai didi

java - 如何正确传递 JDBC url 中的 session 变量?

转载 作者:IT王子 更新时间:2023-10-29 00:38:53 26 4
gpt4 key购买 nike

我必须增加 group_concat_max_len。我不能通过preparestatement来做,我也不能在mysql my.conf文件中做。

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

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

我有这个异常(exception):

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

关于java - 如何正确传递 JDBC url 中的 session 变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26425045/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com