[opencms-dev] jdbc and mysql connection

Manfred Pruntsch manfred.pruntsch at ifcos.com
Mon Sep 16 18:29:55 CEST 2002


INFLIBNETHi Mayur,

You can find an example for mysql database access in the newsmodul on the
opencms website. Download the sources. Go to NewsContentDefinition.java.
Here you can find methods like write(); or delete(); Here you can study how
a jdbc connection is established.
The connection over the connection pool itself is established with c_pool.
Make sure your module has a property called poolname with the value
jdbc:opencmspool:mysql (if you have problems to get it run --> compare it
with the entry in opencms registry).
The variable c_pool can be filled in over event mechanism like:

  // static event handler that is automatically called when the module
parameters are modified
  static {
    try {
      // try to update the moduleparameters
      moduleParameterWasUpdated(null);
    } catch(CmsException  exc) {
      if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING &&
A_OpenCms.isLogging() ) {
        A_OpenCms.log(C_MODULE_CRITICAL, "[FeeCD]" + ": Error while updating
module parameters : " + exc.toString());
      }
    }
  }

  /**
   * This event-method is invoked if a user changes a parameter for a module
in the module-administration.
   * @param CmsObject The current CmsObject.
   */
  public static void moduleParameterWasUpdated(CmsObject cms) throws
CmsException {
     c_pool =
OpenCms.getRegistry().getModuleParameterString("<your.package.modulename>",
"poolname");
  }

good luck and best regards
Manfred


----------------------------------------------
IFCOS Institut für Zell- und Organsimulation GmbH
Friedrich-Barnewitz-Strasse 3
18119 Rostock
phone: +49 (0)381.5196-190
fax: +49 (0)381.5196-137
email: manfred.pruntsch at ifcos.com

  -----Original Message-----
  From: owner-opencms-dev at www.opencms.org
[mailto:owner-opencms-dev at www.opencms.org]On Behalf Of Mayur Solanki
  Sent: Thursday, September 12, 2002 1:34 PM
  To: opencms-dev at www.opencms.org
  Subject: [opencms-dev] jdbc and mysql connection


  Hello,

      I have only knowledge about core java, I don't know Advanced.
      Please give me idea about connectivity mysql to jdbc.
      I have alrealy jdbc driver.

      If anybody can give short sample code for connecting mysql to jdbc,
      it will be really appreciated.
      Advanced thanks.


  Mayur.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20020916/f867229f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image1.gif
Type: image/gif
Size: 3610 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20020916/f867229f/attachment.gif>


More information about the opencms-dev mailing list