I was playing with a test client both on C# and JAVA and wanted to execute a simple query: *select * from data;*
mysql 5.7, connector/j 5.1.39, connector/.net 6.9.9. The data table has ID and VAL columns - int and text respectively. The db schema, table and text column are using utf8 collation but strangely enough I could not make both clients to receive the query result in sync. Changing collation results in failure either in c# or java - tried utf8mb4, latin1 and more random choices.
if C# DataReader has records the JAVA ResultSet is empty or vice versa. When C# fails it throws: Fatal error encountered attempting to read the resultset and inner exception: Expected end of data packet. If java fails it just has an empty ResultSet
I tried to change different collation and charset/characterEncoding settings and trial and error leaded me to here:
If i use utf8 collation for the database and the following C# connection string:
server=x.x.x.x;user=mydbuser;database=mydb;port=3306;password=mypassword;Character Set=utf8
and this Java connection string
jdbc:mysql://x.x.x.x/mydb?user=mydbuser&password=mypassword&characterEncoding=ascii
both apps are showing result - even when the VAL column contains utf (Cyrillic) characters the java client shows them correctly regarding the ascii parameter. if characterEncoding is set to utf8 the ResultSet is again empty.
I could not wrap my head around why this works.