Twitter Text from Java to MySQL: utf8mb4 SQL error "reportcharsetnr ("

In context: trying to load Twitter text into MySQL database. Some tweets have characters utf8mb4

that throw java.SQL.Exception. I solved it thanks to this post too.

The Java code now runs without errors; however, I am unable to perform a simple one select * from test.tweet

on my table.

I am getting the following SQL error:

Error code: 0 45). Please report this (

SQL code:

create table test.tweet (
    text varchar(200) character set utf8mb4 collate utf8mb4_unicode_ci not null);

      

Java code: (I know this works)

// create a mysql database connection
        String myDriver = "com.mysql.jdbc.Driver";
        String myUrl = "jdbc:mysql://localhost:3306/test?";
        Class.forName(myDriver).newInstance();
        Connection conn = DriverManager.getConnection(myUrl, "root", "pass");
        PreparedStatement setNames = conn.prepareStatement("SET NAMES 'utf8mb4'");
        setNames.execute();

//Load the tweets into a mySQL DB
                    loadTweets(jsonObject, conn);

      

There is NOTHING on the internet about this error. Any thoughts why I am unable to request this error message:

Error code: 0 45). Please report this (
MySQL error message

+3


source to share


2 answers


In MySQL Workbench, I get this error when I run SET NAMES

without sorting.

I'll fix it doing it (change the sort order correctly):



SET NAMES 'utf8mb4' collate 'utf8mb4_spanish_ci';

      

You can execute it in your code after creating the connection.

+1


source


I was getting this error after I created and tried to work with the database in MySQL Workbench. After restarting the Workbench, my problem went away.



0


source







All Articles