|Title|Modification on JDBCProvider for using container defined DataSources
|Date|30-Apr-2006 12:53:02 EEST
|JSPWiki version|2.2.28
|Submitter|84.168.77.94
|[Idea Category]|ProviderIdea
|Reference|
|[Idea Status]|NewIdea

Hi,

I made some modification on the [JDBCProvider|JDBCProviders] (Wiki Version 2.2.28)
It's now possible to use a container defined JDBC DataSource. 

I think there are following advantages using a container def. DS:
* Connection-Pooling is managed by App-Server
* JDBC specific Data (Driver, User, ....) isn't defined in the Web-Application

I abstract the connection management part. So it's possible to use either the actual JDBC management and the container Data Source management. Please tell me if You are interested.

Btw.: The JDBCProvider supports Oracle too. ( Tested with OracleXE )


Greetings,

Matthias Peter



----

I made the following changes:

1. I create an interface ''DataSourceManager''.

2. The ''JDBCBaseProvider'' and the new class ''JDBCContainerManaged'' implement this interface.

3. The ''AttachmentProvider'' and ''PageProvider'' classes dont extend the ''JDBCBaseProvider'' anymore. They have an instance of ''DataSourceManager'' so it's possible to use both variants of JDBC connection management.






--[MatthiasPeter|mailto:matthias.peter@gmail.com], 30-Apr-2006


----

Here are the table definitions for Oracle (they work for me with JDBCProvider for JSPWiki 2.2.28):

{{{
CREATE TABLE WIKI_PAGE
    (
        PAGE_NAME          VARCHAR (100)  NOT NULL,
        PAGE_VERSION       INTEGER        NOT NULL,
        PAGE_MODIFIED      DATE,
        PAGE_MODIFIED_BY   VARCHAR (50),
        PAGE_TEXT          LONG VARCHAR,
        PRIMARY KEY (PAGE_NAME)
    );

CREATE INDEX IX_WP_MODIFIED ON WIKI_PAGE_2(PAGE_MODIFIED);

CREATE TABLE WIKI_PAGE_VERSIONS
    (
        VERSION_NAME          VARCHAR (100)  NOT NULL,
        VERSION_NUM           INTEGER        NOT NULL,
        VERSION_MODIFIED      DATE,
        VERSION_MODIFIED_BY   VARCHAR (50),
        VERSION_TEXT          LONG VARCHAR,
        PRIMARY KEY (VERSION_NAME, VERSION_NUM)
    );

CREATE TABLE WIKI_ATT (
  ATT_PAGENAME VARCHAR(100),
  ATT_FILENAME VARCHAR(100),
  ATT_VERSION INTEGER,
  ATT_MODIFIED DATE,
  ATT_MODIFIED_BY VARCHAR(50),
  ATT_DATA BLOB,
  PRIMARY KEY(ATT_PAGENAME, ATT_FILENAME, ATT_VERSION)
);

}}}

--Matthias Peter, 18-May-2006


----

I uploaded a version of the (DS)JDBCProvider port based on [JDBCProvider|JDBCProviders] project.

There are 2 new properties for jspwiki.properties:

{{{
jspwiki-s.JDBCAttachmentProvider.dsManager = container
jspwiki-s.JDBCAttachmentProvider.dataSource = java:/DefaultDS
}}}

Here is a complete definition for using container managed DS:

{{{
jspwiki.pageProvider = com.forthgo.jspwiki.jdbcprovider.JDBCPageProvider
jspwiki-s.JDBCPageProvider.dsManager = container
jspwiki-s.JDBCPageProvider.dataSource = java:/DefaultDS

jspwiki.attachmentProvider = com.forthgo.jspwiki.jdbcprovider.JDBCAttachmentProvider
jspwiki-s.JDBCAttachmentProvider.dsManager = container
jspwiki-s.JDBCAttachmentProvider.dataSource = java:/DefaultDS
}}}

A documentation about defining a DataSource in Tomcat can be found at the [tomcat homepage|http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html]



--Matthias Peter, 20-May-2006


----

Hi,

I'm one of the authors of the JDBCProvider, and I have done a lot of rewriting the last few days. It is still not released, but if you get a copy of the dbrewrite branch from SVN (svn checkout http://svn.berlios.de/svnroot/repos/jdbcprovider/dbrewrite). You should be able to roll your own, and if you do an oracle version please let me know. Start by reading the readme.txt file.

Best regards,
Søren



--[Søren Berg Glasius|mailto:sbglasius@users.berlios.de], 23-Aug-2006