Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

Creating MySQL table in Java with specific charset/collcation. Is it possible? (1 reply)

$
0
0
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?

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>