Creating MySQL table in Java with specific charset/collcation. Is it possible?
Posted by: Gonçalo Cardoso
Date: July 02, 2015 02:47AM

I'm trying to create a database in latin1/latin1_general_cs but whatever I try I always get a database created in utf8/default collation.

This is my current code:

MysqlDataSource mysqlDataSource = new MysqlDataSource();

mysqlDataSource.setServerName(jdbcInstance.getServer());
mysqlDataSource.setPortNumber(jdbcInstance.getPort());
mysqlDataSource.setDatabaseName(jdbcInstance.getDbName());
mysqlDataSource.setUser(jdbcInstance.getUser());
mysqlDataSource.setPassword(jdbcInstance.getPassword());

mysqlDataSource.setCreateDatabaseIfNotExist(true);
mysqlDataSource.setUseUnicode(false);
mysqlDataSource.setCharacterEncoding("latin1");
mysqlDataSource.setConnectionCollation("latin1_general_cs");

connection = mysqlDataSource.getConnection();

Am I doing something wrong? Or is it just impossible to do what I want?

Options: ReplyQuote


Subject
Written By
Posted
Creating MySQL table in Java with specific charset/collcation. Is it possible?
July 02, 2015 02:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.