You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class testdemo {
public static final String URL = "jdbc:mysql://localhost:8066/testdb?useCursorFetch=false&useServerPrepStmts=true";
public static final String USER_HOST = "xxxx";
public static final String PASSWORD = "xxxx";
public static void main(String[] args) throws SQLException {
Connection conn=null;
PreparedStatement ps;
ResultSet rs = null;
try {
//1.加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//2. 获得数据库连接
conn = DriverManager.getConnection(URL, USER_HOST, PASSWORD);
String sql = "select * from testjson;";
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
ps.close();
}catch (Exception e){
System.out.println(" jdbc error : "+e);
}finally {
conn.close();
System.out.println("task done");
}
}
}
step5. 执行程序
expect result:
返回查询结果
real result:
返回java.sql.SQLException: java.lang.IllegalArgumentException: Field type is not supported
supplements:
使用useCursorFetch=true或者useServerPrepStmts=true参数后,传输的数据会被转化为二进制格式,由于com/actiontech/dble/net/mysql/BinaryRowDataPacket.java类的covert(byte[] fv, FieldPacket fieldPk)方法中缺少对json字段类型的解析,因此返回了Field type is not supported的报错。
The text was updated successfully, but these errors were encountered:
dble version:2.19.03/lts
preconditions :
configs:
schema.xml
rule.xml
server.xml
steps:
step1. 创建表testjson
CREATE TABLE
testjson
(id
int NOT NULL,jsonvalue
json DEFAULT NULL,PRIMARY KEY (
id
))
step2. 更新配置文件
step3. 插入数据insert into testjson values(1,'{"type":"select"}');
step4. 编写程序(JDBC连接中配置useCursorFetch=true或者useServerPrepStmts=true)
import java.sql.*;
public class testdemo {
public static final String URL = "jdbc:mysql://localhost:8066/testdb?useCursorFetch=false&useServerPrepStmts=true";
public static final String USER_HOST = "xxxx";
public static final String PASSWORD = "xxxx";
public static void main(String[] args) throws SQLException {
Connection conn=null;
PreparedStatement ps;
ResultSet rs = null;
try {
//1.加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//2. 获得数据库连接
conn = DriverManager.getConnection(URL, USER_HOST, PASSWORD);
String sql = "select * from testjson;";
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
ps.close();
}catch (Exception e){
System.out.println(" jdbc error : "+e);
}finally {
conn.close();
System.out.println("task done");
}
}
}
step5. 执行程序
返回查询结果
返回java.sql.SQLException: java.lang.IllegalArgumentException: Field type is not supported
使用useCursorFetch=true或者useServerPrepStmts=true参数后,传输的数据会被转化为二进制格式,由于com/actiontech/dble/net/mysql/BinaryRowDataPacket.java类的covert(byte[] fv, FieldPacket fieldPk)方法中缺少对json字段类型的解析,因此返回了Field type is not supported的报错。
The text was updated successfully, but these errors were encountered: