外來鍵新增失敗:java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails
錯誤程式碼
java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails (
book.
t_order_item, CONSTRAINT
t_order_item_ibfk_1 FOREIGN KEY (
order_id) REFERENCES
t_order (
order_id)) Query: insert into t_order_item(
name,
count,
price,
total_price,
order_id)values(?,?,?,?,?) Parameters: [Java程式設計思想, 1, 100, 100, 1234511]
嘗試根據錯誤資訊排錯
a foreign key constraint fails
:外來鍵約束異常- 意思就是,設定的外來鍵和對應表的主鍵的值不匹配,即order_id的值在表t_order中沒有匹配上。
解決辦法
- 找出不匹配的值,修改成匹配的
相關推薦
外來鍵新增失敗:java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails
錯誤程式碼 java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails (book.t_order_item, CONSTRAINT t_order_item_ibfk_1 FOREIGN KEY (order_id) REFERENCES t_order (orde
c3p0 配置連線MySQL異常:java.sql.SQLException: Connections could not be acquired from the underlying database!
在Idea上配置c3p0連線MySQL時報如下錯誤: 警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@4e745ea8 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a n
MySQL報錯:java.sql.SQLException: Incorrect string value:‘\xF0\x9F\x92\xA9\x0D\x0A...’的完全解決
文章適合瞭解MySQL。文章在編寫過程中難免有疏漏和錯誤,歡迎大佬指出文章的不足之處;更多內容請點進
Mybatis-Plus報錯:java.sql.SQLException: The server time zone value ‘�й���ʱ��‘ is unrecognized or repr
java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serv
Idea資料庫引入異常:java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized
java.sql.SQLException: The server time zone value \'Öйú±ê׼ʱ¼ä\' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via t
JDBC連線報錯:java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized...解決方案
技術標籤:JavaBUG解決合集mysqljavajdbc資料庫mybatis JDBC連線報錯:java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼
從資料庫中取時間值,報錯:java.sql.Timestamp cannot be cast to java.lang.Long
從資料庫中取時間值,報錯:java.sql.Timestamp cannot be cast to java.lang.Long 1、問題描述
mysql刪除表時報錯:Cannot delete or update a parent row: a foreign key constraint fails 解決辦法
技術標籤:mysqlmysql資料庫 參考StackOverflow:https://stackoverflow.com/questions/2300396/force-drop-mysql-bypassing-foreign-key-constraint?rq=1
MyBatis新增資料報錯Cannot add or update a child row: a foreign key constraint fails
技術標籤:java後端資料庫javamysqlsqlmybatis 報錯資訊: org.springframework.dao.DataIntegrityViolationException:
Ranger升級版本初始化報錯:SQLException : SQL state: HY000 java.sql.SQLException: Operation CREATE USER failed
SQLException : SQL state: HY000 java.sql.SQLException: Operation CREATE USER failed for ‘ranger’@‘localhost’ ErrorCode: 1396
資料庫連結失敗 java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
資料庫連結失敗報錯 java.sql.SQLException: Access denied for user \'root\'@\'localhost\' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957) ~[mysql-connector-java-5.
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password
關於這個問題,我又找到了一個引發問題的新原因。 我將jar包放進了lib裡面然後build path了,可是就是一直出現問題,然後我檢視properties->java build path -> libraries裡面有多餘的錯誤的jar包。刪除之
JAVA | MYSQL | java.sql.SQLException: Invalid value for getInt() - ‘’
出錯提示如下: 檢查資料庫,發現該欄欄位為varchar型別,而我變成寫成了用Integer接收
解決IDEA錯誤 Cause: java.sql.SQLException: The server time zone value的問題
在我們配置檔案的時候 執行會報The server time zone的錯 Cause: java.sql.SQLException: The server time zone value
報錯如何看和解決Error updating database. Cause: java.sql.SQLException: Field 'course_id' doesn't have a default value
前端控制檯報錯資訊: 後端控制檯報錯資訊: org.springframework.dao.DataIntegrityViolationException:
解決java.sql.SQLException: Zero date value prohibited
點選第二頁的時候報錯java.sql.SQLException: Zero date value prohibited 前端頁面報錯如圖:
java.sql.SQLException: Column count doesn't match value count at row 1
1、異常提示: Cause: java.sql.SQLException: Column count doesn\'t match value count at row 1 ; bad SQL grammar []; nested exception is java.sql.SQLException: Column count doesn\'t match value count
java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä'...解決
在使用idea連線mysql測試時,報的錯: Cause: java.sql.SQLException: The server time zone value \'Öйú±ê׼ʱ¼ä\' is unrecognized o
mybatis批量插入oralce資料庫報錯java.sql.SQLException: ORA-00933: SQL 命令未正確結束
轉自:https://blog.csdn.net/csdn_ss1991/article/details/80439777 簡述:需要向oracle資料庫批量插入資料,然後一直報錯,”java.sql.SQLException: ORA-00933: SQL 命令未正確結束“,然後各種百度,最終得到解決
java.sql.SQLException: Unknown system variable 'tx_isolation'
問題原因:mysql版本:8.0.21,mysql-connector-java版本:mysql-connector-java-5.1.7-bin.jar,版本不對齊導致報錯。