Search code examples
dbeaver

How to copy SQL in Java and paste it in Dbeaver


Dbeaver is a great tool for accessing database. But in ver.23, 24 (23.1.1 in my PC), something goes wrong.

Before upgrading it, I'm using ver.20~21. There's a admirable function makes you be able to copy SQL in java code with some String processing function, but when it be paste to DBeaver, it'll be pure SQL.

As an example :

StringBuilder sb = new StringBuilder();
sb.append(" select * from myTable ");
sb.append(" where name is null or lastName = 'Jake' ");

You can copy from the first quote to the last one, including "sb.append()"

" select * from myTable ");
sb.append(" where name is null or lastName = 'Jake' "

And it will be :

select * from myTable 
where name is null or lastName = 'Jake'

Is there any way to achieve this in the latest version? I hope this function isn't removed by purpose, it really hepls when writing huge sql.


Solution

  • Had the same problem, this helped me.

    Go to Window -> Preferences -> Editors -> SQL Editor -> Code Editor

    Check the option 'Extract SQL from Source'

    https://github.com/dbeaver/dbeaver/issues/240#issuecomment-198987695