Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the error of batch inserting index out of range into Mybatis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

The main content of this article is to explain "how to solve the Mybatis batch insertion index out of range error", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to solve Mybatis bulk insertion index out of range errors".

Mybatis bulk insert index out of range error

Often we see that all kinds of online articles about this kind of error about batch insertion report are null, or the parameters are not obtained correctly, etc., but my colleagues encountered this type of error during development. I always thought it was caused by those blogs on the Internet, so the two eyes kept staring at the code for a long time without finding any problem. So what's the problem?

Reason

This is because sharding-jdbc is used to connect to the database in the project, and sharding-jdbc does not support bulk insertion of SQL statements.

Improve

1. Modify the statements inserted in bulk, this kind of comparison may go against the development habits of many programmers.

two。 Replace the connected data source, change sharding-jdbc to com.alibaba.druid.pool.DruidDataSource

String index out of range: 100A bizarre error report, error situation

After debug here, you can see that the exception is in substring:

That is, an error is reported when judging a string: the specific reason is that the value of the string string indexof itself is only 5, and then take the 100th character as the cutoff here, so this error will be reported.

Knowledge point

The main reason is that the concept of String is not clear. The following is a brief introduction to string-related concepts (String, char, char []).

Solutions to the above problems

At this point, I believe you have a deeper understanding of "how to solve Mybatis bulk insertion index out of range errors". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report