今天搞了一下午。 主表A:主键ID 字表B:字段main_id main_id即是ID两者关联 保存B时main_id来自A的ID,像这种情况最好不用jdbc连接数据库,有困难,用hibernate吧!