database mapping in web.xml

R

Rob

Hello,

I'd like to move my database into my web app's web directory,
into something like c:\myapp\web\mydb, so that I can archive it
all together, instead of having the db in c:\mysql\data\mydb .

Does anyone know where I could get these questions answered:
a) is that the proper place to put the db files?
b) what entries must i add into the web.xml file to reflect the
new db path?
c) how do i revise my db URL to establish the connection once
the move is made?

currently it's: "jdbc:mysql://localhost:3306/mydb";

I can't seem to find a lot of info on this issue.

Thanks,

-Rob
 
H

Herman Timmermans

Rob said:
Hello,

I'd like to move my database into my web app's web directory,
into something like c:\myapp\web\mydb, so that I can archive it
all together, instead of having the db in c:\mysql\data\mydb .

Does anyone know where I could get these questions answered:
a) is that the proper place to put the db files?
b) what entries must i add into the web.xml file to reflect the
new db path?
c) how do i revise my db URL to establish the connection once
the move is made?

currently it's: "jdbc:mysql://localhost:3306/mydb";

I can't seem to find a lot of info on this issue.

Thanks,

-Rob
Rob,
a) Basicly there is nothing that will stop you of putting your db elsewhere,
but I would not recommend it. One reason could be scalability, you may
want to move your database to separate hardware from your application
server. Nevertheless, if you would put them in your web application, I
would put it in the /WEB-INF directory, because this directory contains the
main files for your application that will not be provided by the container
to the client.
b) As far as I kown, nothing should be changed unless you move your
db-server to another computer, then of course you should modify localhost
into whateverhost
c) See b.
That is the beauty of separating different layers in your application. Your
web application doesn't need to be concerned where the actual db is
running, that is left up to the data access layer, just make sure that your
db url is ok, it is then up to the db server to locate your data.
Pleasecheck the mySQL manual how to move your database to another location.
Hope this helps, Brgds Herman
 
I

iksrazal

Rob said:
Hello,

I'd like to move my database into my web app's web directory,
into something like c:\myapp\web\mydb, so that I can archive it
all together, instead of having the db in c:\mysql\data\mydb .

Does anyone know where I could get these questions answered:
a) is that the proper place to put the db files?
b) what entries must i add into the web.xml file to reflect the
new db path?
c) how do i revise my db URL to establish the connection once
the move is made?

currently it's: "jdbc:mysql://localhost:3306/mydb";

I can't seem to find a lot of info on this issue.

Thanks,

-Rob

a) Your path of where your db resides should not - or even cannot -
matter at all. However - do not put your db in your webapp - anyplace
but that. DB access is done via an ip - localhost is fine - and a port
- for mysql the default port is indeed 3306 . Put it this way -
several linux and unix distros but mysql in different places - and
most db's resides on other hosts - and from java`s perspective that
doen't matter one bit.

b) This can be highly servlet container dependant. For tomcat and
using DataSource for you db connections, it could something like:

<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

You`d have to make some changes in conf/server.xml as well.

c) Try leaving it exactly as it is.

Outsource to an American programmer living in brazil!
http://www.braziloutsource.com/
iksrazal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top