[MySQL] Database error set

1. Error list

1.1. Out of range value for column “xx” at row x

insert image description here

  1. Explanation: Column 'xx' at row 'x' is out of range
  2. Reason: When creating a table, the type is bigint and the length is 20, as follows字段的值超过其可输入的范围了
  3. Solution: Modify the value to the length set by the column

1.2. Incorrect datetime value:“for column 数据库名.表名.字段” at row 1

2

  1. Explanation: The xx column in the xx table of the xx database is an incorrect date value.
  2. Reason: The following settings default to NULL, then the default is '0000-00-00 00:00:00'
  3. Solution: The value filled in “0000-00-00 00:00:00”will not report an error
    insert image description here

1.3. Cannot deserialize value of type java.util.Date from String “2023-05-29T18:02:02.000Z”: expected format “yyyy-MM-dd HH:mm:ss”;

insert image description here

  1. Explanation: What is expected is yyyy-MM-dd HH:mm:ssthe format, and what is obtained isyyyy-MM-ddTHH:mm:ss.000Z
  2. Reason: the value passed from the front and back ends, and the parameter passed to the calling interface is incorrect
  3. Solution: The time can be transferred to the backend through the filter,见附录二的 2.1

1.4. Operand should contain 1 column

insert image description here

  1. Explanation: Two tables are jointly searched, and the query result in the operated data has no column value
  2. Reason: This part is not yet understood
  3. Reference: reason

1.5 Subquery returns more than 1 row

insert image description here

  1. Explanation: Two tables are jointly searched, and the subquery returns multiple pieces of data
  2. Reason: the sql can only return one piece of data
  3. Reference: A table (tree structure) joint query, returns the tree structure.附录二 2.2

1.6 Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘xxx.updata_time’ in ‘order clause’\r\n### The error may exist in file

insert image description here

  1. Elaboration: The column "borrow.updata_time" could not be found
  2. Reason: update_time is written wrong

1.7 class java.lang.String cannot be cast to class java.util.Date (java.lang.String and java.util.Date are in module java.base of loader ‘bootstrap’)

insert image description here

  1. Explanation: Converting String to Date type is not allowed
  2. Reason: The front end uses the component el-data-picker to implement the function of filtering time. The time type passed in when passing parameters is 'String', but it is converted to 'Date' when receiving in the back end
  3. Solution: Change the front and back ends to the same String type

1.8 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘[borrow_state] LIKE ‘%21%’)’ at line 1\r\n### The error may exist in org/springblade/modules/archiveAdvantage/mapper/ArchiveBorrowRelateMapper.java (best guess)\r\n### The error may involve defaultParameterMap\r\

insert image description here

  1. Explanation: SQL syntax error
  2. Reason: Type error when passing parameters
    insert image description here

1.9 Failed to process,Error SQL

insert image description here

  1. Explanation: SQL confusion
  2. Reason: More or less useless fields are written

1.10 nested exception is org.apache.ibatis.binding.BindingException: Parameter ‘param’ not found. Available parameters are [page, params, param1, param2]"

insert image description here

  1. Explanation: param not found
  2. Reason: When using sql statement, param.xxx is used. However undefined
    insert image description here
    insert image description here
  3. 解决:加上即可 @Param(“param”)
    nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2"

1.11 nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2

insert image description here

  1. Explanation: Expected one result, found two
  2. Reason: The method getOne to obtain the list in the later stage only allows one return value

1.12

insert image description here
insert image description here

2. Appendix

2.1. Date format conversion

// 1. 先放在js文件,路径为:@/utils/date.js
export function dateFormat(date, format) {
    
    
  format = format || 'yyyy-MM-dd hh:mm:ss'
  if (date !== 'Invalid Date') {
    
    
    let o = {
    
    
      'M+': date.getMonth() + 1, //month
      'd+': date.getDate(), //day
      'h+': date.getHours(), //hour
      'm+': date.getMinutes(), //minute
      's+': date.getSeconds(), //second
      'q+': Math.floor((date.getMonth() + 3) / 3), //quarter
      S: date.getMilliseconds(), //millisecond
    }
    if (/(y+)/.test(format))
      format = format.replace(
        RegExp.$1,
        (date.getFullYear() + '').substr(4 - RegExp.$1.length)
      )
    for (let k in o)
      if (new RegExp('(' + k + ')').test(format))
        format = format.replace(
          RegExp.$1,
          RegExp.$1.length === 1
            ? o[k]
            : ('00' + o[k]).substr(('' + o[k]).length)
        )
    return format
  }
  return ''
}

// 2. 在vue文件中使用
 import {
    
     dateFormat } from '@/utils/date'
 methods: {
    
    
	submit(){
    
    
	let time = dateFormat(要处理的时间)
 }

2.2 A table self-connected query, get the list of children and the name of the parent

– 1. SELECT
sort.*,( SELECT ca.catamanage_name FROM admin_archive_attach_sort ca WHERE ca.id = sort.parent_id ) AS parentName
FROM
admin_archive_attach_sort sort
WHERE
sort.id = '166134770833992499 4'

– 2. SELECT
sort
.*,
ca.catamanage_name parentName
FROM
admin_archive_attach_sort sort
LEFT JOIN admin_archive_attach_sort ca ON sort.parent_id = ca.id
WHERE
sort.id = '1661347708339924994'

Guess you like

Origin blog.csdn.net/weixin_47375144/article/details/130944025