dari
dari copied to clipboard
SqlDatabase usage
Hi to all,
I wish to know how com.psddev.dari.db.SqlDatabase
is intended to use. Currently I use one h2 database as dari/defaultDatabase
and I need to connect to another external Mysql database which is used by other system (not Dari). So I configure other datasource and add as a second dari/database
in context.xml.default. Now can I perform sql queries on SqlDatabase
:
SqlDatabase d = (SqlDatabase) Database.Static.getInstance("some-name/delegate/sql");
Connection c = d.openConnection();
PreparedStatement p = c.prepareStatement("SELECT * FROM ... WHERE id = ?");
...
This works fine, but Dari creates its own tables (Metric, Record etc.) in external database. Is there some way how to disable this behaviour? Or is my use case not intended and supported by Dari and I should connect to external database other way? Currently I need only a few selects...
Of course, I can use some ORM framework to connect to external database or I can simply lookup DataSource
from Context
, get Connection
and use database this way - but I like to have second database in debug -> sql tool for simple testing and developing.
Thanks for clarification.
O.