[opencms-dev] need SQL connection example
Arash Kaffamanesh
arash.kaffamanesh at pomegranate.de
Fri Feb 29 11:05:26 CET 2008
Hello together,
This post was contributed by Enrico Ballarin Dolfin on the opencms
mailingslist some a days:
howto setup additional connection pool to access an external database:
http://www.pomegranate.de:9000/cms/forum/viewthread?thread=12#25
Best,
Arash
Jordi Martí schrieb:
> You can get the java.sql connection that opencms provides through this
> sentence:
>
> java.sql.Connection con =
> org.opencms.main.OpenCms.getSqlManager().getConnection(org.opencms.db.CmsDbP
> ool.getDefaultDbPoolName());
>
> You can use it directly in your jsp or in whatever servlet or class you
> would like to use.
>
> It's a good practice to create your jsp inside a module in opencms.
>
>
> JORDI MARTÍ
> Email: jmarti _at_ theinit *dot. com
>
>
> PRIVADO Y CONFIDENCIAL
> Este mensaje va dirigido a la persona(s) indicada(s). Puede contener
> información confidencial de carácter legal o personal de THE INIT SERVICES,
> La transmisión errónea del presente mensaje en ningún momento supone
> renuncia a su confidencialidad. Si el lector del mensaje no es el
> destinatario indicado, o el empleado encargado de su entrega a dicha
> persona, por favor, notifíquelo inmediatamente por teléfono y remita el
> mensaje original a la dirección de correo electrónico indicada. Cualquier
> copia o distribución de esta comunicación queda estrictamente prohibida.
>
>
>
>
>
>
>
> -----Mensaje original-----
> De: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org]
> En nombre de Christoph P. Kukulies
> Enviado el: viernes, 29 de febrero de 2008 9:25
> Para: Pere Torrodellas
> CC: The OpenCms mailing list
> Asunto: Re: [opencms-dev] need SQL connection example
>
> On Fri, Feb 29, 2008 at 09:03:12AM +0100, Pere Torrodellas wrote:
>
>> ----- Original Message -----
>> From: "Christoph P. Kukulies" <kuku at physik.rwth-aachen.de>
>> To: <opencms-dev at opencms.org>
>> Sent: Thursday, February 28, 2008 6:17 PM
>> Subject: [opencms-dev] need SQL connection example
>>
>>
>>
>>> How would one start with a database application in OpenCms?
>>>
>>>
>> You just have to build your application as an OpenCms module. See the
>> documentation that comes with OpenCms to learn how to create a module.
>> OpenCms has its own tables and definitions, and you build your own DB and
>> application.
>>
>
> Creating a module is not my problem. My problem is how I keep the
> connection state during the session.
>
>>> How is a database context kept during a session?
>>>
>>> Would one use a bean?
>>>
>>>
>> You can do the same as in any other Java application.
>>
>>
>>> Which API would one use?
>>>
>>>
>> Plain java.sql.*, unless you decide to use some framework (Ibatis,
>> Hibernate,...)
>>
>>
>>> I need a starting point and a bit of code. Advice welcome.
>>>
>
>
> I picked a snippet out of from the archive:
> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
> <sql:setDataSource
> driver="org.gjt.mm.mysql.Driver"
> url="jdbc:mysql://localhost:3306/steuer?autoReconnect=true"
> user="root"
> password="mysqlb3"
> scope="page"
> var="dir" />
>
> Or would I better use java.sql.* and code it in java?
> As said, I have no idea at the moment, what happens, when my code is
> in a jsp template and the page reloads. How would be the technique to
> store the fact that a connection is already made to the database?
>
> I'm not yet familar with that technique despite of oving done some
> java examples with a single jdbc request running in a self contained
> java application.
>
>
>
>> The included documentation provides information and examples.
>>
>
> Also on SQL programming? I saw very little on this also in the
> list archives.
>
> --
> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
More information about the opencms-dev
mailing list