Hello all,
I'm trying to integrate the Shell tool (org.h2.tools.Shell) into another
application (namely Apache Felix, using H2 shell as a Gogo command).
The problem is that I already have my own way of creating JDBC connections,
which is not the one used by the H2 shell.
So I would like to provide the shell with my connection object, rather than
providing driver/url/user/password settings.
The only way I found so far is to use some Java Reflection black magic I'm
really not proud of.
So I wonder, is there a better way to do it? If not, I guess I'll have to
fill a new issue.
---
To be clear, here is the black magic I'm speaking about:
Connection conn = <the connection I want to use>
Field connField = Shell.class.getDeclaredField("conn");
connField.setAccessible(true);
Field statField = Shell.class.getDeclaredField("stat");
statField.setAccessible(true);
Shell shell = new Shell();
connField.set(shell, conn);
statField.set(shell, conn.createStatement());
shell.runTool();
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.