[opencms-dev] Accessing mysql-dbms from opencms
Robert Petermeier
robert2.0 at gmx.de
Wed Nov 10 11:04:59 CET 2004
Andre Bernardini schrieb:
> Hello again,
>
> I'm trying to build a module and need to directly access the dbms to store
> information on customly created tables.
>
> So far I tried "Connection con =
> DriverManager.getConnection("URL","username","password");" in one of my JSPs.
OpenCms uses jakarta commons DBCP. Thus, you can fetch a connection from
the connection pool:
Connection con=
DriverManager.getConnection(
CmsDbPool.C_DBCP_JDBC_URL_PREFIX
+ CmsDbPool.C_OPENCMS_DEFAULT_POOL_URL);
Note: I don't know if this is *the* way to get a connection. I found
this out by reading the source plus try-and-error and so far it seems to
work fine.
I understand that creating additional DB tables is discouraged in favor
of creating XML content definitions (which is a great feature, by the
way) but I think in some cases you simply don't want to do without SQL.
Regards,
Robert
More information about the opencms-dev
mailing list