0

Using JDBI 3, I would like to execute unmodified SQL from a file (created by mysqldump, for what it's worth). Unfortunately, JDBI is very opinionated when it comes to what it considers legal SQL, because it's default use case is doing stuff with SQL, not just blindly executing it.

I have already turned off the TemplatingEngine through jdbi.setTemplateEngine(TemplateEngine.NOP);, but the internal lexer is still running over the SQL, causing issues with statements such as INSERT INTO folders (path) VALUES ('c:\\') and, for a reason I haven't managed to track down, // (trying to insert a URL as a value).

Is there any way to disable or restrict the lexer ? Any other good advice on executing arbitrary, multi-line SQL through JDBI or, if I have to, JDBC ?

Torque
  • 3,319
  • 2
  • 27
  • 39
  • Sounds like you're trying to use it for a case that it is specifically designed to disallow / not support. Why can't you use plain JDBC instead (for this task)? – Jiri Tousek Feb 01 '19 at 10:55
  • Because it isn't a task that JDBC supports either. There are various classes out there that promise to run scripts such as https://stackoverflow.com/questions/1497569/how-to-execute-sql-script-file-using-jdbc but as you can see from the comments these are all very buggy and only support small subsets of valid SQL. – Torque Feb 01 '19 at 10:58

0 Answers0