java.sql.SQLException : Incorrect string value: ‘\xF0\x9F\x98\x82\xF0\x9F…’
Problem:
because the emoticons stored in MySQL database string are not compatible with 4-byte Unicode.
Solution:
use the third-party jar to import and store after transformation.
POM introduction:
<!-- Expression Switching -->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>java-emoji-converter</artifactId>
<version>0.1.1</version>
</dependency>
Specific conversion method:
String content = "\xF0\x9F\x98\x82\xF0\x9F";
EmojiConverter emojiConverter = EmojiConverter.getInstance();
content= emojiConverter.toAlias(content);//Escaping chat content
System.out.println(content);
Read More:
- java: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x590
- [Solved] Error updating database. Cause: java.sql.SQLException: Incorrect integer value: ‘**‘ for column
- [Solved] Mybatis insert Error: Cause: java.sql.SQLException: SQL String cannot be empty
- [Solved] Flink1.12 integrate Hadoop 3.X error: java.lang.RuntimeException…
- [Solved] Hbase-shell 2.x Error: Unhandled Java exception: java.lang.IncompatibleClassChangeError: Found class jline.Terminal…
- keytool error: java.lang.Exception: Input not an X.509 certificate
- Mongodb java version 3.X, prompt “XXX (an encryption algorithm) is not available” when there is a user name and password
- Springboot2.6.X configurate swagger error [How to Solve]
- Springboot2.6X version integrate knife4j error [How to Solve]
- Error querying database.Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource.
- [Solved] java.sql.SQLException: Unknown system variable cache query size
- [Solved] Springboot2.x ElasticSearch Error: availableProcessors is already set to [4], rejecting [4]
- [Solved] java.sql.SQLException: Unsupported character encoding ‘utf-8
- [Solved] mybatis Error querying database. Cause: java.sql.SQLException: The server time zone value
- [Solved] Error updating database. Cause: java.sql.SQLException: Unknown initial character set index ‘255‘ re
- Java.sql.sqlexception: unable to read more data from socket
- [Solved] redis-server.exe Flashback Error: QForkMasterInit: system error caught. error code=0x000005af, message=Virtual
- [Solved] java.sql.SQLException: Table ‘xxx.hibernate_sequence’ doesn’t exist
- API Failed to Connect phoenix Error: java.sql.SQLException: ERROR 726 (43M10): Inconsistent namespace mapping properties
- [Solved] IDEA jdbc Connect Database Error: java.sql.SQLException: Undefined Error