The Answer to Life, the Universe, and Everything

Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Thursday, January 08, 2009

ERROR JDBCExceptionReporter - Duplicate entry

By using mysql, I faced the followin error and here is the solution
2009-01-08 22:55:18,454  WARN JDBCExceptionReporter - SQL Error: 1062, SQLState: 23000
2009-01-08 22:55:18,454 ERROR JDBCExceptionReporter - Duplicate entry '268731' for key 1
2009-01-08 22:55:18,454 ERROR AbstractFlushingEventListener - Could not synchronize database state with sessi
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update


Close the session after transaction.commit().
transaction.commit();
session.flush();
session.close();

Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost

I faced the following error and here is the solution.
  ** BEGIN NESTED EXCEPTION **

java.io.EOFException
MESSAGE: Can not read response from server. Expected to read 4 bytes, read 2
bytes before connection was unexpectedly lost.

STACKTRACE:

java.io.EOFException: Can not read response from server. Expected to read 4
bytes, read 2 bytes before connection was unexpectedly lost.


Comment the wait_timeout such as below.
#wait_timeout=30

Wednesday, December 10, 2008

Illegal mix of collations in MySQL

In case for having such a error in mysql using Hibernate or so.

java.sql.SQLException: General error message
from server: "Illegal mix of collations
(utf8_general_ci,COERCIBLE) and
(latin1_swedish_ci,IMPLICIT) for operation '='"


Add the following in my.cnf
[client]
default-character-set = utf8

[mysqld]
skip-character-set-client-handshake
default-character-set=utf8
character-set-server=utf8
init-connect=SET NAMES utf8

Thursday, November 29, 2007

MySQL Encoding

You need to change params for the server and the client.
# Change MySQL server encode
# By calling the following SQL you can see the current encoding.
# show create table xxx;
# show variables like 'char%';

mysql$ alter table xxx character set utf8;
mysql$ alter table xxx change sub1 sub1 varchar(256) character set utf8;
mysql$ set names utf8;
mysql$ set character_set_database=utf8
mysql$ set character_set_server=utf8

#On the client to connet to DB set the following param in URL
jdbc:mysql://localhost/blojsom?autoReconnect=true&useUnicode=true&characterEncoding=utf-8