鱼C论坛

 找回密码
 立即注册
查看: 3520|回复: 1

IDEA连接数据库报错

[复制链接]
发表于 2021-10-4 22:40:02 | 显示全部楼层 |阅读模式
10鱼币
报错代码:Data truncation: Cannot get geometry object from data you send to the GEOMETRY field
给我定位到了这一行代码:
  1. int result = statement.executeUpdate(sql);
复制代码


然后源码如下,也不多:
  1. public class Test {
  2.     public static void main(String[] args) {
  3.         //加载驱动
  4.         try {
  5.             Class.forName("com.mysql.cj.jdbc.Driver");
  6.             //获取连接
  7.             String url = "jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=GMT%2B8";

  8.             String user = "root";
  9.             String password = "123456";
  10.             try {
  11.                 Connection connection = DriverManager.getConnection(url,user,password);
  12.                 String sql = "insert into student_table(username,age) values('zhangSan','7')";
  13.                 Statement statement = connection.createStatement();
  14.                 int result = statement.executeUpdate(sql);
  15.                 System.out.println(result);
  16.             } catch (SQLException throwables) {
  17.                 throwables.printStackTrace();
  18.             }

  19.         } catch (ClassNotFoundException e) {
  20.             e.printStackTrace();
  21.         }
  22.     }
  23. }
复制代码


我的数据库中test下只有一个表student_table,只有三项内容:id,username和age;username的数据类型是lineString,这样写sql语句应该没问题吧。

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-6 16:54:01 | 显示全部楼层
数据截断:无法从发送到“几何体”字段的数据中获取几何体对象
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-27 16:29

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表