[opencms-dev] Separate database with OpenCms

Alexander Wallace aw at avatartechnology.com
Wed May 11 17:51:15 CEST 2005


I jsp gets compiled into a servlet..... sure you can... you can either create 
your own connection/pool or use opencms' ones (if you want to connect to the 
same db opencms connects to)...

On Wednesday 11 May 2005 10:16 am, philip lau wrote:
> hi All,
> 
> I am evaluating opencms for an intranet site I am implementing for a
> health care company. Does any know whether you can directly access a
> database from a .jsp page by using jdbc drivers. From what I observed
> with the modules included, servlets are mainly used to access the
> databases.
> 
> Thanks in advance,
> 
> Philip Lau
> 
> On 5/11/05, Alexander Wallace <aw at avatartechnology.com> wrote:
> > On Wednesday 11 May 2005 09:24 am, Enrico Ballarin Dolfin wrote:
> > 
> > > The definitions of the datasource and data pool for opencms seem not to 
be
> > in
> > > server.xml or web.xml. Do I have to define an additional database pool 
(e.g.
> > > application) in the file opencms.properties like this?
> > >
> > I would just create a datasource using my app server, in jboss, creating a
> > -ds.xml file and then setting the appropiate config in web.xml and
> > jboss-web.xml and web.xml
> > 
> > In tomcat you can do it in several places (server.xml, context.xml in 
META-INF
> > or use the admin app)...
> > 
> > then create a class or jsp code to get the connection from your new pool
> > 
> > >
> > >
> > 
---------------------------------------------------------------------------------------------------------------------------------------
> > > #
> > > # Declaration of database pools
> > >
> > 
#################################################################################
> > > db.pools=default, application
> > >
> > > #
> > > # Configuration of the default database pool
> > >
> > 
#################################################################################
> > > ...
> > > ...
> > >
> > > #
> > > # Configuration of the application specific database pool
> > >
> > 
#################################################################################
> > > # name of the JDBC driver
> > > db.pool.application.jdbcDriver=org.gjt.mm.mysql.Driver
> > >
> > > # URL of the JDBC driver
> > > db.pool.application.jdbcUrl=jdbc:mysql://localhost:3306/appdb
> > >
> > > # optional parameters for the URL of the JDBC driver
> > >
> > 
db.pool.application.jdbcUrl.params=?useUnicode\=true&characterEncoding\=UTF-8
> > >
> > > # user name to connect to the database
> > > db.pool.application.user=appuser
> > >
> > > # password to connect to the database
> > > db.pool.application.password=*********
> > >
> > > # the URL to make the JDBC DriverManager return connections from the 
DBCP
> > pool
> > > db.pool.application.poolUrl=opencms:application
> > > ...
> > > ...
> > >
> > 
---------------------------------------------------------------------------------------------------------------------------------------
> > >
> > > and then to try something like this?
> > >
> > > > <%@page import="java.sql.*,org.OpenCms.db.*,org.OpenCms.main.*"%>
> > > > <%
> > > >
> > > > java.sql.Connection con =
> > > > OpenCms.getSqlManager().getConnection(CmsDbPool.getDbPoolName(map,
> > > "application"));
> > > >
> > > > // do something
> > > >
> > > > con.close();
> > > >
> > > > %>
> > >
> > > Thanks
> > > Enrico
> > >
> > > >
> > > > On Wednesday 11 May 2005 07:49 am, Enrico Ballarin Dolfin wrote:
> > > > >
> > > > > We would like to migrate a Web application that uses an own mysql
> > > > > database to
> > > > > OpenCms. What we need is to access from OpenCms also this separate
> > > > > database using java in JSP templates (we are using Tomcat as servlet
> > > > > engine).
> > > > >
> > > > > To do this I have a few questions:
> > > > >
> > > > > OpenCms uses a special jdbc driver to access its own mysql database.
> > > > > In the configuration file opencms.property there is the 
configuration of
> > > > > the default database pool with jdbcDriver, jdbcUrl, jdbcUrl.params,
> > user,
> > > > > password etc. The tomcat configuration file server.xml seems not to 
be
> > > > > explicitly configured for opencms.
> > > > >
> > > > > 1) Can I use the same jdbc driver (with a second configuration) to
> > access
> > > >
> > > > the
> > > >
> > > > > separate database? Do I need a second driver (maybe the standard 
one)?
> > > > >
> > > > > 2) Where and how do I have to configure the driver to access the
> > separate
> > > > > database?
> > > > >
> > > > > 3) Do I have to configure a separate database pool? Where and how?
> > > > >
> > > > > Thanks a lot in advance
> > > > > Enrico
> > >
> > 
> > _______________________________________________
> > This mail is send to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please visit
> > http://mail.opencms.org/mailman/listinfo/opencms-dev
> >
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
> 



More information about the opencms-dev mailing list