On Tue, Jul 7, 2009 at 2:08 AM, Igor Vaynberg <[email protected]>wrote:

> http://docs.codehaus.org/display/JETTY/JNDI
>
> -igor
>
> On Mon, Jul 6, 2009 at 1:22 PM, Petr Fejfar<[email protected]> wrote:
> > Hi all,
> >
> > When I've started learning Wicket, I followed configuration described
> > in the book Enjoy web dev ...
> >
> > Now I'm trying to migrate my project under Maven's management. I seem
> > to be almost
> > finished except data source configuration in the Tomcat's context file:
> >
> >  <Resource
> >    name="jdbc/trackerDataSource"
> >    auth="Container"
> >    type="javax.sql.DataSource"
> >    driverClassName="org.postgresql.Driver"
> >    url="jdbc:postgresql://localhost/tracker"
> >    username="xxx"
> >    password="xxx"
> >    maxActive="20"
> >    maxIdle="8"
> >    defaultAutoCommit="false"
> >    defaultTransactionIsolation="SERIALIZABLE"
> >    testOnBorrow="true"
> >    validationQuery="select 1"/>
> >
> > Please, could somebody show me how to achieve
> > the same effect in Jetty's configuration?
> >
>

A couple of tips to do the Jetty DataSource JNDI configuration the 'wicket
way' - in code, instead of xml.

Use a datasource implementation like org.apache.commons.dbcp.BasicDataSource

In the Start.java that you get after following the instructions here:
http://wicket.apache.org/quickstart.html

Add the following:

        BasicDataSource ds = new BasicDataSource();
        ds.setUrl("jdbc:hsqldb:.");
        ds.setDriverClassName("org.hsqldb.jdbcDriver");
        ds.setUsername("sa");
        ds.setPassword("");

        NamingEntry.setScope(NamingEntry.SCOPE_GLOBAL);
        // this line actually registers object in jetty jndi
        new Resource("java:/mydatasource", ds);

And you can refer the documentation of Apache DPCP to set properties like
this:

ds.setValidationQuery("SELECT 1");

Thanks,

Peter.

>
> >
> > Thanks, Peter
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to