backslashes and inserts

140 views
Skip to first unread message

SB

unread,
Aug 1, 2013, 11:36:10 AM8/1/13
to jooq...@googlegroups.com
Hello,

I have the following value that I need to insert:

car\

Note the backslash at the end. It seems like JOOQ is generating an insert statement for MySQL that looks like this:

insert into `database`.`TABLE` (`column1`) value ('car\')

This causes the following exception to be thrown. Do I need to escape backslashes before inserting using JOOQ?

Exception in thread "main" org.jooq.exception.DataAccessException: SQL [null]; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ....

Thanks,
-SB

Lukas Eder

unread,
Aug 1, 2013, 11:47:49 AM8/1/13
to jooq...@googlegroups.com
Hmm, that's surprising to me. I wasn't aware that MySQL uses backslashes for escaping. The same queries in MySQL and Oracle:


Thanks for reporting this. This needs to be fixed!

The other question here is why the value is inlined...? Did you explicitly use inlined bind values or did you set the relevant Settings flag? You wouldn't have this problem if you were using PreparedStatements

Cheers
Lukas


2013/8/1 SB <suhabe....@gmail.com>

--
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/groups/opt_out.
 
 

Lukas Eder

unread,
Aug 1, 2013, 11:50:41 AM8/1/13
to jooq...@googlegroups.com

Lukas Eder

unread,
Aug 1, 2013, 12:22:26 PM8/1/13
to jooq...@googlegroups.com
Huh, I've just noticed that the issue appears also for regular bind values. That's just how MySQL works. So jOOQ shouldn't fix this and you should either:

1. Escape string values yourself
2. (better in my opinion) turn off backslash escaping


Hope this helps
Lukas


2013/8/1 Lukas Eder <lukas...@gmail.com>

Suhabe Bugrara

unread,
Aug 1, 2013, 1:35:08 PM8/1/13
to jooq...@googlegroups.com
Great, thank you!

-SB


You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/JdU_Qaap94E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages