Solved

Tomcat 5.0 Database Change

Posted on 2010-11-23
7
397 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
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…

756 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