You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

设置maxFieldSize为1024报错,属JDBC还是CnosDB问题?

问题诊断:CnosDB JDBC setMaxFieldSize 报错分析

问题背景

测试代码如下:

@Test
public void test_Jdbc_field_size() throws SQLException {
    String url = "jdbc:arrow-flight-sql://localhost:8904";
    final Properties properties = new Properties();
    properties.put("user", "root"); //用户名
    properties.put("password", "");  //密码
    properties.put("tenant", "cnosdb");//租户
    properties.put("db", "public");// db
    properties.put("useEncryption", false);
    Connection conn = DriverManager.getConnection(url, properties);
    Statement stmt = conn.createStatement();
    int rs003 = stmt.getMaxFieldSize();
    assertTrue(rs003 == 0);
    stmt.setMaxFieldSize(1024);
    
    stmt.close();
    conn.close();
}

执行后报错:

SQL illegal maxField value: 1024

查阅JDBC官方文档说明:

The maxFieldSize limit (in bytes) is set to limit the size of data that can be returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. If the limit is exceeded, the excess data is silently discarded. For maximum portability use values greater than 256.

使用的驱动版本:flight-sql-jdbc-driver:12.0.1、arrow-jdbc:12.0.1

问题定位

这个报错属于CnosDB服务端的限制问题,而非JDBC驱动问题,原因如下:

  • 报错信息SQL illegal maxField value: 1024是服务端返回的SQL层面错误,JDBC驱动仅作为请求转发载体,不会自行生成这类错误提示。
  • JDBC规范中setMaxFieldSize允许设置大于256的值(官方文档也明确建议为兼容性使用大于256的值),你设置的1024符合规范要求。
  • 推测CnosDB目前可能不支持setMaxFieldSize参数的设置,或者对该参数的取值范围有特殊限制(比如仅允许0或特定区间值),导致服务端拒绝了1024这个值的设置请求。

验证建议

  • 尝试将值设置为0(即不限制),确认是否能正常执行,这是getMaxFieldSize返回的初始值,通常服务端会支持默认的无限制状态。
  • 查看CnosDB官方文档中关于JDBC驱动的特定参数说明,确认是否有对setMaxFieldSize的支持说明或特殊限制。

内容的提问来源于stack exchange,提问作者Baker X

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 08:12:36