You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Anton Veretennikov <an...@gmail.com> on 2008/12/03 07:37:23 UTC

Switch db connection when Local <> Remote

Hello Wicket users,

I test my app on local Tomcat and update it frequently on remote. They
have different MySQL DB connection params.
What is the easiest way to decide which params to choose depending on
where Tomcat is running without editing of xml-files?

I need to know it during init() of Application because I must run
upgrades of db tables / data when new version of app is uploaded.
Tomcat thinks it is running on "localhost" on remote server
(configured as Proxy Pass).

Thank you

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Switch db connection when Local <> Remote

Posted by Anton Veretennikov <an...@gmail.com>.
Thanks you for suggestions.

On Wed, Dec 3, 2008 at 5:55 PM, Ulf Gitschthaler <ul...@gitschthaler.de> wrote:
> Maybe you should have a look at:
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>
> It describes how to use JNDI for your database connection. In short: the
> tomcat itself holds the necessary connection data and connects via JNDI to
> the DB.
>
>
> Jeremy Thomerson wrote:
>>
>> There are a myriad of ways, but most are going to include something like:
>> - read them from a properties file
>> - configure them in web.xml or tomcat config
>>
>> It doesn't sound like you're using Spring or similar to configure your
>> database access, but since I do, I typically use a properties file for the
>> app that configures various server-or-deployment-specific settings, and
>> Spring has a mechanism for interpolating those into your Spring config.
>>
>> I know this is off-topic, but it sounds like you are possibly doing raw
>> JDBC?  If so, I'd highly recommend NOT doing that.
>>
>> Hope this helps.
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Switch db connection when Local <> Remote

Posted by Ulf Gitschthaler <ul...@gitschthaler.de>.
Maybe you should have a look at: 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

It describes how to use JNDI for your database connection. In short: the 
tomcat itself holds the necessary connection data and connects via JNDI 
to the DB.


Jeremy Thomerson wrote:
> There are a myriad of ways, but most are going to include something like:
> - read them from a properties file
> - configure them in web.xml or tomcat config
>
> It doesn't sound like you're using Spring or similar to configure your
> database access, but since I do, I typically use a properties file for the
> app that configures various server-or-deployment-specific settings, and
> Spring has a mechanism for interpolating those into your Spring config.
>
> I know this is off-topic, but it sounds like you are possibly doing raw
> JDBC?  If so, I'd highly recommend NOT doing that.
>
> Hope this helps.
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Switch db connection when Local <> Remote

Posted by Jeremy Thomerson <je...@wickettraining.com>.
There are a myriad of ways, but most are going to include something like:
- read them from a properties file
- configure them in web.xml or tomcat config

It doesn't sound like you're using Spring or similar to configure your
database access, but since I do, I typically use a properties file for the
app that configures various server-or-deployment-specific settings, and
Spring has a mechanism for interpolating those into your Spring config.

I know this is off-topic, but it sounds like you are possibly doing raw
JDBC?  If so, I'd highly recommend NOT doing that.

Hope this helps.


-- 
Jeremy Thomerson
http://www.wickettraining.com


On Wed, Dec 3, 2008 at 12:37 AM, Anton Veretennikov <
anton.veretennikov@gmail.com> wrote:

> Hello Wicket users,
>
> I test my app on local Tomcat and update it frequently on remote. They
> have different MySQL DB connection params.
> What is the easiest way to decide which params to choose depending on
> where Tomcat is running without editing of xml-files?
>
> I need to know it during init() of Application because I must run
> upgrades of db tables / data when new version of app is uploaded.
> Tomcat thinks it is running on "localhost" on remote server
> (configured as Proxy Pass).
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Switch db connection when Local <> Remote

Posted by James Carman <ja...@carmanconsulting.com>.
If you're using Hibernate, one thing we do with this, to make sure the
target database is up to snuff (all the right tables/columns, etc.) is to
run a test case that executes the verifier from Hibernate against the schema
(our test cases don't usually touch the real database; they run against an
in-memory HSQLDB database).

On Wed, Dec 3, 2008 at 11:25 AM, Anton Veretennikov <
anton.veretennikov@gmail.com> wrote:

> Thank you, James!
>
> On Wed, Dec 3, 2008 at 7:45 PM, James Carman <ja...@carmanconsulting.com>
> wrote:
> > We use "profiles" in Maven2 to decide which configuration parameters to
> > build with.  Take a look at the example project for Wicketopia for an
> > example of how we do that:
> > https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/
> >
> > Basically, we add in a special resources directory that's based on a
> > parameter (called "configuration") defined in the pom:
> >
> >        <resources>
> >            <resource>
> >                <directory>src/main/conf/${configuration}</directory>
> >            </resource>
> >            <resource>
> >                <directory>src/main/resources</directory>
> >            </resource>
> >            <resource>
> >                <directory>src/main/java</directory>
> >                <includes>
> >                    <include>**</include>
> >                </includes>
> >                <excludes>
> >                    <exclude>**/*.java</exclude>
> >                </excludes>
> >            </resource>
> >        </resources>
> >
> > Then, we use Spring to load a properties file (using
> > PropertyPlaceholderConfigurer) that's inside that directory.  So, all you
> > have to do to build a different version is:
> >
> > mvn -Pprod install
> >
> > and it'll run with the "production" profile.
> > On Wed, Dec 3, 2008 at 1:37 AM, Anton Veretennikov <
> > anton.veretennikov@gmail.com> wrote:
> >
> >> Hello Wicket users,
> >>
> >> I test my app on local Tomcat and update it frequently on remote. They
> >> have different MySQL DB connection params.
> >> What is the easiest way to decide which params to choose depending on
> >> where Tomcat is running without editing of xml-files?
> >>
> >> I need to know it during init() of Application because I must run
> >> upgrades of db tables / data when new version of app is uploaded.
> >> Tomcat thinks it is running on "localhost" on remote server
> >> (configured as Proxy Pass).
> >>
> >> Thank you
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Switch db connection when Local <> Remote

Posted by Anton Veretennikov <an...@gmail.com>.
Thank you, James!

On Wed, Dec 3, 2008 at 7:45 PM, James Carman <ja...@carmanconsulting.com> wrote:
> We use "profiles" in Maven2 to decide which configuration parameters to
> build with.  Take a look at the example project for Wicketopia for an
> example of how we do that:
> https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/
>
> Basically, we add in a special resources directory that's based on a
> parameter (called "configuration") defined in the pom:
>
>        <resources>
>            <resource>
>                <directory>src/main/conf/${configuration}</directory>
>            </resource>
>            <resource>
>                <directory>src/main/resources</directory>
>            </resource>
>            <resource>
>                <directory>src/main/java</directory>
>                <includes>
>                    <include>**</include>
>                </includes>
>                <excludes>
>                    <exclude>**/*.java</exclude>
>                </excludes>
>            </resource>
>        </resources>
>
> Then, we use Spring to load a properties file (using
> PropertyPlaceholderConfigurer) that's inside that directory.  So, all you
> have to do to build a different version is:
>
> mvn -Pprod install
>
> and it'll run with the "production" profile.
> On Wed, Dec 3, 2008 at 1:37 AM, Anton Veretennikov <
> anton.veretennikov@gmail.com> wrote:
>
>> Hello Wicket users,
>>
>> I test my app on local Tomcat and update it frequently on remote. They
>> have different MySQL DB connection params.
>> What is the easiest way to decide which params to choose depending on
>> where Tomcat is running without editing of xml-files?
>>
>> I need to know it during init() of Application because I must run
>> upgrades of db tables / data when new version of app is uploaded.
>> Tomcat thinks it is running on "localhost" on remote server
>> (configured as Proxy Pass).
>>
>> Thank you
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Switch db connection when Local <> Remote

Posted by James Carman <ja...@carmanconsulting.com>.
We use "profiles" in Maven2 to decide which configuration parameters to
build with.  Take a look at the example project for Wicketopia for an
example of how we do that:
https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/

Basically, we add in a special resources directory that's based on a
parameter (called "configuration") defined in the pom:

        <resources>
            <resource>
                <directory>src/main/conf/${configuration}</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**</include>
                </includes>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>

Then, we use Spring to load a properties file (using
PropertyPlaceholderConfigurer) that's inside that directory.  So, all you
have to do to build a different version is:

mvn -Pprod install

and it'll run with the "production" profile.
On Wed, Dec 3, 2008 at 1:37 AM, Anton Veretennikov <
anton.veretennikov@gmail.com> wrote:

> Hello Wicket users,
>
> I test my app on local Tomcat and update it frequently on remote. They
> have different MySQL DB connection params.
> What is the easiest way to decide which params to choose depending on
> where Tomcat is running without editing of xml-files?
>
> I need to know it during init() of Application because I must run
> upgrades of db tables / data when new version of app is uploaded.
> Tomcat thinks it is running on "localhost" on remote server
> (configured as Proxy Pass).
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>