having problems writing Russian characters into db

128 views
Skip to first unread message

bry...@indeed.com

unread,
May 11, 2015, 12:55:03 PM5/11/15
to jooq...@googlegroups.com
hello,

so I'm trying to write russian characters ("Здравствуйте") into the db, but somewhere jooq it gets replaced with all question marks ("??????? ?????"). I figured it has something to do with specifying the character encoding in jooq, but I'm not sure where that would take place or how that would be done.

thanks

Lukas Eder

unread,
May 11, 2015, 12:59:26 PM5/11/15
to jooq...@googlegroups.com
Hello Bryan,

Thanks for your enquiry. In order to best help you track down this issue:

- What database are you using?
- What jOOQ version are you using?
- What do the table/columns look like (CREATE TABLE...)?
- How do you insert data with jOOQ?

Depending on your SQLDialect, I'm thinking that jOOQ might be casting your bind variables to VARCHAR (instead of NVARCHAR). Also, jOOQ internally uses PreparedStatement.setString() (not setNString()), which might be causeing trouble here.

Best Regards,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bry...@indeed.com

unread,
May 11, 2015, 2:46:40 PM5/11/15
to jooq...@googlegroups.com
Hi Lukas

- What database are you using?
     - MySQL 5.6
- What jOOQ version are you using?
     - 3.6
- What do the table/columns look like (CREATE TABLE...)?
     - CREATE TABLE `tblLogAdcentral` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `account_id` int(10) unsigned NOT NULL DEFAULT '0',
  `account_type` enum('publisher','advertiser','general','prospect') NOT NULL DEFAULT 'general',
  `salesrep_id` int(10) unsigned NOT NULL DEFAULT '0',
  `note` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `note_type` enum('BILLING','EMAIL','NOTE','SYSTEM','ZENDESK') NOT NULL DEFAULT 'NOTE',
  `date_action` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `followup_date` date DEFAULT NULL,
  `followup_time` time DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `followup_date` (`followup_date`),
  KEY `account_id` (`account_id`,`account_type`),
  KEY `date_action` (`date_action`)
) ENGINE=InnoDB AUTO_INCREMENT=38508492 DEFAULT CHARSET=latin1

- How do you insert data with jOOQ?
        final TbllogadcentralRecord noteRecord = note.getInternalRecord();
        noteRecord.attach(adcentraldb.configuration());
        noteRecord.store();

Lukas Eder

unread,
May 14, 2015, 10:09:11 AM5/14/15
to jooq...@googlegroups.com
Hello Bryan,

Thanks for the additional info. I can reproduce the issue when running the same kind of query against a similar table, but I think that it might be a JDBC driver problem. Everything seems to work fine when I set the JDBC conneciton URL to this:

jdbc:mysql://localhost/test?characterEncoding=UTF-8&characterSetResults=utf8&connectionCollation=utf8_general_ci

Could that be the issue? Of course, you should be careful with such a change - that might cause issues otherwise, given that you default to using the CHARSET=latin1 in the rest of your data.

Hope this helps,
Lukas
Reply all
Reply to author
Forward
0 new messages