<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h" -->

---
title: How to Fix MySQL java.sql.SQLException: Incorrect string...
description: The java.sql.SQLException: Incorrect string value error in MySQL occurs because MySQL's default utf8 character set only supports up to 3 bytes per character,...
canonical: https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Fix MySQL java.sql.SQLException: Incorrect string value | daily.dev
og:description: The java.sql.SQLException: Incorrect string value error in MySQL occurs because MySQL's default utf8 character set only supports up to 3 bytes per character,...
og:url: https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h
og:image: https://api.daily.dev/og/posts/gp6Lqry7h.png
og:image:alt: How to Fix MySQL java.sql.SQLException: Incorrect string value
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Fix MySQL java.sql.SQLException: Incorrect string value

**[Baeldung](https://daily.dev/sources/baeldung)** · 5 min read · 2 upvotes · 0 comments

## Summary

The java.sql.SQLException: Incorrect string value error in MySQL occurs because MySQL's default utf8 character set only supports up to 3 bytes per character, while Java uses full UTF-8 encoding that can require 4 bytes (e.g., for emojis). The fix involves switching MySQL to utf8mb4 at the database, table, and column levels, configuring the JDBC connection URL with useUnicode=true and characterEncoding=utf8, updating server-level my.cnf settings, and upgrading to the latest MySQL Connector/J driver (com.mysql:mysql-connector-j). Partial configuration at any layer can still trigger the error, so all components must consistently use utf8mb4.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://feeds.feedblitz.com/~/961624316/0/baeldung~How-to-Fix-MySQL-javasqlSQLException-Incorrect-string-value>

## Questions this post answers

### How do I fix java.sql.SQLException: Incorrect string value when inserting emojis into MySQL from a Java application?

Convert the database, affected tables, and columns from the default utf8 character set to utf8mb4, which supports 4-byte Unicode characters like emojis. Use ALTER DATABASE, ALTER TABLE CONVERT TO CHARACTER SET, and ALTER TABLE MODIFY column statements, then confirm the JDBC URL uses useUnicode=true and characterEncoding=utf8, and check server variables with SHOW VARIABLES LIKE 'character_set%'.

_daily.dev surfaces practical fixes like this for developers debugging MySQL encoding errors in Java apps._

### Why does MySQL reject a string value containing an emoji when the column uses utf8 encoding?

MySQL's default utf8 character set only supports up to 3 bytes per character, but Java's UTF-8 encoding can produce 4-byte characters such as emojis, causing MySQL to reject the insert with Incorrect string value. Switching the column, table, and database to utf8mb4 resolves this because it supports the full Unicode range including 4-byte characters.

_Developers hitting character encoding mismatches between Java and MySQL can track fixes like this on daily.dev._

### What is the correct Maven dependency to use for the modern MySQL JDBC driver instead of mysql-connector-java?

Use groupId com.mysql and artifactId mysql-connector-j, for example version 9.7.0, rather than the outdated mysql:mysql-connector-java artifact such as version 8.0.33. The renamed artifact reflects the current, actively maintained driver, and keeping it updated helps avoid encoding and compatibility issues with newer MySQL versions.

_Teams upgrading JDBC drivers can follow dependency changes like this via daily.dev._

## Similar posts on daily.dev

- [Avoiding truncation errors in Microsoft Fabric Data Warehouse: Understanding UTF‑8, collations, and column lengths](https://daily.dev/posts/avoiding-truncation-errors-in-microsoft-fabric-data-warehouse-understanding-utf-8-collations-and--jlppyqsuz) · The Art of Simplicity · 0 upvotes · 0 comments
- [Fix the Java-MySQL Connection Exception: Public Key Retrieval is not allowed](https://daily.dev/posts/fix-the-java-mysql-connection-exception-public-key-retrieval-is-not-allowed-irph6xfla) · Baeldung · 1 upvotes · 0 comments
- [Taming Text in MySQL: How a Simple Emoji Uncovered a Complex Collation Problem](https://daily.dev/posts/taming-text-in-mysql-how-a-simple-emoji-uncovered-a-complex-collation-problem-fzvjgbqmz) · Wix Engineering · 0 upvotes · 0 comments
- [How to Fix the Communications link failure Error in Java Applications With MySQL](https://daily.dev/posts/how-to-fix-the-communications-link-failure-error-in-java-applications-with-mysql-yfmzc4hrp) · Baeldung · 3 upvotes · 0 comments
- [COSCUP 2026: Planning your upgrade to MySQL 9.7](https://daily.dev/posts/coscup-2026-planning-your-upgrade-to-mysql-9-7-ephf70afu) · Planet MySQL · 0 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#mysql](https://daily.dev/tags/mysql)

[View this post on daily.dev](https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Fix MySQL java.sql.SQLException: Incorrect string value","url":"https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h"},"datePublished":"2026-07-22T11:32:22.776Z","dateModified":"2026-09-14T08:46:07.558Z","description":"The java.sql.SQLException: Incorrect string value error in MySQL occurs because MySQL's default utf8 character set only supports up to 3 bytes per character,...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/cce8a7dedded714690313c0919f6c8da?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/cce8a7dedded714690313c0919f6c8da?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Baeldung","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Baeldung","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/52cccfb454d946c4b7dfa5e816f9e576","url":"https://daily.dev/sources/baeldung"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,mysql","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Baeldung","item":"https://daily.dev/sources/baeldung"},{"@type":"ListItem","position":3,"name":"How to Fix MySQL java.sql.SQLException: Incorrect string value"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-fix-mysql-java-sql-sqlexception-incorrect-string-value-gp6lqry7h#faq","mainEntity":[{"@type":"Question","name":"How do I fix java.sql.SQLException: Incorrect string value when inserting emojis into MySQL from a Java application?","acceptedAnswer":{"@type":"Answer","text":"Convert the database, affected tables, and columns from the default utf8 character set to utf8mb4, which supports 4-byte Unicode characters like emojis. Use ALTER DATABASE, ALTER TABLE CONVERT TO CHARACTER SET, and ALTER TABLE MODIFY column statements, then confirm the JDBC URL uses useUnicode=true and characterEncoding=utf8, and check server variables with SHOW VARIABLES LIKE 'character_set%'. daily.dev surfaces practical fixes like this for developers debugging MySQL encoding errors in Java apps."}},{"@type":"Question","name":"Why does MySQL reject a string value containing an emoji when the column uses utf8 encoding?","acceptedAnswer":{"@type":"Answer","text":"MySQL's default utf8 character set only supports up to 3 bytes per character, but Java's UTF-8 encoding can produce 4-byte characters such as emojis, causing MySQL to reject the insert with Incorrect string value. Switching the column, table, and database to utf8mb4 resolves this because it supports the full Unicode range including 4-byte characters. Developers hitting character encoding mismatches between Java and MySQL can track fixes like this on daily.dev."}},{"@type":"Question","name":"What is the correct Maven dependency to use for the modern MySQL JDBC driver instead of mysql-connector-java?","acceptedAnswer":{"@type":"Answer","text":"Use groupId com.mysql and artifactId mysql-connector-j, for example version 9.7.0, rather than the outdated mysql:mysql-connector-java artifact such as version 8.0.33. The renamed artifact reflects the current, actively maintained driver, and keeping it updated helps avoid encoding and compatibility issues with newer MySQL versions. Teams upgrading JDBC drivers can follow dependency changes like this via daily.dev."}}]}
```

