I am using version 3.8.2 and having some issues with utf8 string appears as question mark (?) in the database when inserting new record, but it’s display old record correctly (inserted using phpmyadmin).
here how i init MySQLPool
fun init(vertx: Vertx): MySQLPool {
val connectOptions = MySQLConnectOptions()
.setPort(Config.mysqlPort)
.setHost(Config.mysqlHost)
.setDatabase(Config.mysqlDatabase)
.setUser(Config.mysqlUsername)
.setPassword(Config.mysqlPassword)
.setCharset("utf8") // tried utf8mb4 also same result
.setCollation("utf8_general_ci") // also tried utf8mb4_general_ci
val poolOptions = PoolOptions().setMaxSize(Config.maxPoolSize)
return MySQLPool.pool(vertx, connectOptions, poolOptions)
}
mysql variables
character_set_client = utf8
character_set_connection = utf8
character_set_database = utf8
character_set_filesystem = binary
character_set_results = utf8
character_set_server = utf8mb4
character_set_system = utf8
table collation
utf8_general_ci
mysql create table
CREATE TABLE `news` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Title` text NOT NULL,
`Image` text NOT NULL,
`Link` mediumtext NOT NULL,
`Summery` mediumtext NOT NULL,
`Story` mediumtext NOT NULL,
`Time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
Thank you
2
Answers
it's seems the default charset in jvm is set to windows-1252 changing it to UTF-8 solved it
the setCharset("utf8") and setCollation("utf8_general_ci") options are configured at the connection level, but not really have an effects on charset for encoding, that why the encoding value is encoded in the default jvm charset
I think this is the answer of your question Arabic language in php/mysql appears "????" question marks in html
you must set charset in first connect .