Solved

Tomcat 5.0 Database Change

Posted on 2010-11-23
7
396 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 27

Expert Comment

by:mrcoffee365
ID: 34199606
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
ID: 34200116
Tried it and it didn't work.
0
 

Author Comment

by:FrostyGirl
ID: 34200119
It's still using DB A
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 10

Expert Comment

by:Hegemon
ID: 34200527
It looks correct - make sure you have restarted the server.
0
 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 500 total points
ID: 34200853
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
ID: 34201656
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
ID: 34321940
And make sure that the username and password are correct for databaseB :-)
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

829 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