Result Set not updatable

本文探讨了在数据库操作中,由于表缺少主键而引发的`com.mysql.jdbc.NotUpdatable`异常。详细解释了该错误的具体原因及解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

com.mysql.jdbc.NotUpdatable: Result Set not updatable (referenced table has no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
at com.mysql.jdbc.UpdatableResultSet.generateStatements(UpdatableResultSet.java:628)
at com.mysql.jdbc.UpdatableResultSet.syncUpdate(UpdatableResultSet.java:1537)
at com.mysql.jdbc.UpdatableResultSet.updateString(UpdatableResultSet.java:2493)

at com.mysql.jdbc.UpdatableResultSet.updateString(UpdatableResultSet.java:2531)



表没有加主键导致。

这是数据区表结构:CREATE TABLE `t_framehead` ( `N_FRAMEHEAD_ID` int NOT NULL AUTO_INCREMENT COMMENT '帧结构ID,自增主键', `N_TYPE` tinyint NOT NULL COMMENT '类型,1=遥测,2=遥控,3=其他', `D_CREATE` datetime NOT NULL COMMENT '创建时间,不能为空,系统创建时的时间', `VC_DESC` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '简述,简单描述,如适用项目等,允许为空', PRIMARY KEY (`N_FRAMEHEAD_ID`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; // 封装请求函数 export const frameheadAPI = (data) => { return request({ url: '/edit/framehead', method: 'POST', data }) } data示例:{desc: “”,type: 2} 写一份后端接口,springboot3,rest风格 ,controller,entity,mapper,service(impl),xml全都要,结果封装:public class Result { private Integer code; private String msg; private Object data; public static Result success() { Result result = new Result(); result.setCode(200); result.setMsg("请求成功"); return result; } public static Result success(Object data) { Result result = new Result(); result.setCode(200); result.setMsg("请求成功"); result.setData(data); return result; } public static Result error() { Result result = new Result(); result.setCode(500); result.setMsg("系统错误"); return result; } public static Result error(Integer code,String msg) { Result result = new Result(); result.setCode(code); result.setMsg(msg); return result; } public static Result error(Integer code,String msg,Object data) { Result result = new Result(); result.setCode(code); result.setMsg(msg); result.setData(data); return result; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public Object getData() { return data; } public void setData(Object data) { this.data = data; } }
03-17
03-21 23:30:14.696 10057 29101 29101 I Perf : Connecting to perf service. 03-21 23:30:14.701 10057 29101 29101 V GraphicsEnvironment: Currently set values for: 03-21 23:30:14.701 10057 29101 29101 V GraphicsEnvironment: angle_gl_driver_selection_pkgs=[] 03-21 23:30:14.701 10057 29101 29101 V GraphicsEnvironment: angle_gl_driver_selection_values=[] 03-21 23:30:14.701 10057 29101 29101 V GraphicsEnvironment: Global.Settings values are invalid: number of packages: 0, number of values: 0 03-21 23:30:14.701 10057 29101 29101 V GraphicsEnvironment: Neither updatable production driver nor prerelease driver is supported. 03-21 23:30:14.714 10057 29101 29116 W ThemeOverlayManager: Skip enabled overlay package:com.google.android.overlay.modules.documentsui, user:UserHandle{0} 03-21 23:30:14.728 10112 29079 29115 D CompatChangeReporter: Compat change id reported: 263076149; UID 10112; state: ENABLED 03-21 23:30:14.735 1000 2675 4003 D CompatChangeReporter: Compat change id reported: 161145287; UID 10112; state: ENABLED 03-21 23:30:14.737 10057 29101 29101 E oid.documentsui: Invalid resource ID 0x00000000. 03-21 23:30:14.738 10057 29101 29101 D CompatChangeReporter: Compat change id reported: 279646685; UID 10057; state: ENABLED 03-21 23:30:14.751 1000 2675 4665 D ActivityManager: Async freezing 29079 com.google.android.apps.carrier.carrierwifi 03-21 23:30:14.752 1000 2675 4665 D ActivityManager: Cancel freezing 28526 com.google.android.apps.docs 03-21 23:30:14.761 1000 2675 4683 D ActivityManager: Cancel freezing 29079 com.google.android.apps.carrier.carrierwifi 03-21 23:30:14.765 10057 29101 29123 I ProvidersCache: Provider returned no roots. Possibly naughty: com.google.android.apps.docs.storage 03-21 23:30:14.766 1000 1242 1242 W ComposerExtn: DisplayExtnImpl::SetActiveConfig: HWC Display 0 is not registered! 03-21 23:30:14.766 1000 1242 1242 D DisplayModeController: setDesiredMode 4630946402628329601 {mode={fps=45.00 Hz, modePtr={id=4, vsyncRate=45
最新发布
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值