|
10鱼币
报错代码:Data truncation: Cannot get geometry object from data you send to the GEOMETRY field
给我定位到了这一行代码:
- int result = statement.executeUpdate(sql);
复制代码
然后源码如下,也不多:
- public class Test {
- public static void main(String[] args) {
- //加载驱动
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- //获取连接
- String url = "jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=GMT%2B8";
- String user = "root";
- String password = "123456";
- try {
- Connection connection = DriverManager.getConnection(url,user,password);
- String sql = "insert into student_table(username,age) values('zhangSan','7')";
- Statement statement = connection.createStatement();
- int result = statement.executeUpdate(sql);
- System.out.println(result);
- } catch (SQLException throwables) {
- throwables.printStackTrace();
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
复制代码
我的数据库中test下只有一个表student_table,只有三项内容:id,username和age;username的数据类型是lineString,这样写sql语句应该没问题吧。 |
|