Solved

Tomcat 5.0 Database Change

Posted on 2010-11-23
7
393 Views
Last Modified: 2012-08-14
Hi,

I need to change my database connection.  My current configuration is:

<Host name="www.website.com" appBase="webapps">
        <Alias>*.www.website.com</Alias>
        <Alias>website.com</Alias>
<Context path="" docBase="/home/www/www.website.com/web" debug="1" reloadable="true" crossContext="false">
            <Resource name="jdbc/trampoline" auth="Container" type="javax.sql.DataSource" />
                    <ResourceParams name="jdbc/trampoline">
                    <parameter>
                            <name>factory</name>
                            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                    </parameter>
                    <parameter>
                            <name>maxActive</name>
                            <value>100</value>
                    </parameter>
                    <parameter>
                            <name>maxIdle</name>
                            <value>30</value>
                    </parameter>
                    <parameter>
                            <name>maxWait</name>
                            <value>10000</value>
                    </parameter>
                    <parameter>
                            <name>username</name>
                            <value>invoke</value>
                    </parameter>
                    <parameter>
                            <name>password</name>
                            <value>$12_o</value>
                    </parameter>

                    <parameter>
                            <name>driverClassName</name>
                            <value>com.mysql.jdbc.Driver</value>
                    </parameter>
                    <parameter>
                            <name>url</name>
                            <value>jdbc:mysql://localhost:3306/databaseA?autoReconnect=true</value>
                    </parameter>

                    </ResourceParams>
        </Context>
</Host>


Can I simply change the line:
<value>jdbc:mysql://localhost:3306/databaseA?autoReconnect=true</value>

to:
<value>jdbc:mysql://localhost:3306/databaseB?autoReconnect=true</value>

Or do I need to edit additional file?

Thank you! ~Wendi
0
Comment
Question by:FrostyGirl
7 Comments
 
LVL 26

Expert Comment

by:mrcoffee365
Comment Utility
Yes, you can change the connection string to go to a different database.  Then all your code will go to the new database connection, and you will not be accessing the databaseA.

It's easy to try -- is there something else you're concerned about?  Or did you try it and it didn't work?
0
 

Author Comment

by:FrostyGirl
Comment Utility
Tried it and it didn't work.
0
 

Author Comment

by:FrostyGirl
Comment Utility
It's still using DB A
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Expert Comment

by:Hegemon
Comment Utility
It looks correct - make sure you have restarted the server.
0
 
LVL 26

Accepted Solution

by:
mrcoffee365 earned 500 total points
Comment Utility
After making sure that you have re-started your server --  changes to web.xml do not occur unless the webapp is reloaded -- then you need to post the exception you're getting.

If your code has the url for the database hard-coded somewhere, then it will use that regardless of what you write into this context parameter.  The parameters have to be used in the code -- nothing in the webapp makes any use of them.
0
 
LVL 13

Expert Comment

by:LinuxGuru
Comment Utility
As mentioned above you need to restart the tomcat. First stop the tomcat using the script "shutdown.sh" and start using the "startup.sh" in your tomcat's bin directory.

Cheers!
0
 
LVL 3

Expert Comment

by:eicheled
Comment Utility
And make sure that the username and password are correct for databaseB :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now