Problem connecting to MySQL JDBC connector

So, I'm trying to enter blog comments into the database for the NLP experiment, but I am having some problems: I use insert preparation instructions, but all single quotes turn into question marks.

I am testing OS X and do not know the character encoding: I assume that it isn_swedish, etc. by default, but after a few hours of scattered Google Googling, I could not figure out how to determine it. I present something like "I did not say this" as a parameter for

PreparedStatement statement = connect.prepareStatement("INSERT IGNORE INTO bwog.article (article_id, date, title, content, url) VALUES (?, ?, ?, ?, ?)"); ... ... String s = "I didn't say that"; //not literal string, but printlns like this statment.setString(4, s); 

and it turns into β€œI didn’t say this” in the database after doing all this.

I suppose this is some kind of assumption question in which I did not know or forgot to fulfill some precondition.

SOLUTION: This is a character encoding. The database and tables were in UTF-8, but the command line connection was in latin1 for all the "character_set%" variables, so even though the data was ok, it looked garbled.

+4
source share
1 answer

To remove this from the Unanswered filter ...

Prediction: Your problem is character encoding. I'm sure your database and tables are in UTF-8, but your command line connection is in latin1 for all the "character_set%" variables, so even though the data is ok, it looks garbled.

0
source

Source: https://habr.com/ru/post/1400146/


All Articles