Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2013
    Posts
    3

    Unanswered: Need help making a connection to the DB

    Requirement: Copy a website/webapp, along with DB data under a different name and dB on the same hosting server.

    What's done:

    Website has been copied to another directory - and partially working (JSP)
    Database has been duplicated and renamed - (PostgreSQL)
    Host is Apache 2.2.3 - (Really old system) on
    "Linux version 2.4.26-1-386 (horms@tabatha) (gcc version 3.2.3 (Debian)) #1 Tue Aug 24 13:31:19 JST 2004"

    Ont the duplicated site the first page shows up fine but it fails to login. I cannot figure out where to go and make the change so that the website can pull the data from the newdb

    Any help will be appreciated.

  2. #2
    Join Date
    Apr 2011
    Posts
    34
    Did you check the logs in the DB and web server?
    If you renamed your database, what did you do with the connection string? Did you adapt anything? What about privileges?
    Can you connect to the new db from the psql prompt? I am curious to know how you duplicated the db.

  3. #3
    Join Date
    Sep 2013
    Posts
    3
    I am a very novice user to Linux/ PostgreSQL. I hope I am answering your questions correctly.

    Did you check the logs in the DB and web server?
    Web server logs shows just browser based info.

    Where would I see the PostgreSQL logs?

    If you renamed your database, what did you do with the connection string? Did you adapt anything?

    Here is what I have changed in /opt/tomcat5.5.20/conf/server.xml
    Code:
    <Host
              appBase="/var/www/mycompany/webapps/"
              name="www.mycompany.com">
            <Alias>mycompany.com</Alias>
            <Context
                path="/colormark"
                reloadable="true">
              <Manager className="org.apache.catalina.session.StandardManager"
                  expiredSessions="16"
                  maxActive="1"
                  maxInactiveInterval="900"
                  pathname="/tmp/COLORMARK.ses"
                  processingTime="33"
                  sessionAverageAliveTime="1191"
                  sessionCounter="16"
                  sessionMaxAliveTime="2226"/>
              <Resource
                auth="Container"
                name="jdbc/ColorMark"
                type="javax.sql.DataSource"
                password="xxx"
                driverClassName="org.postgresql.Driver"
                maxIdle="2"
                maxWait="10000"
                removeAbandoned="true"
                username="colormark"
                url="jdbc:postgresql://127.0.0.1:5433/colormark"
                maxActive="10"/>
            </Context>
    		<Context
                path="/mark2"
                reloadable="true">
              <Manager className="org.apache.catalina.session.StandardManager"
                  expiredSessions="16"
                  maxActive="1"
                  maxInactiveInterval="900"
                  pathname="/tmp/COLORMARK.ses"
                  processingTime="33"
                  sessionAverageAliveTime="1191"
                  sessionCounter="16"
                  sessionMaxAliveTime="2226"/>
              <Resource
                auth="Container"
                name="jdbc/Mark2"
                type="javax.sql.DataSource"
                password="xxx"
                driverClassName="org.postgresql.Driver"
                maxIdle="2"
                maxWait="10000"
                removeAbandoned="true"
                username="colormark"
                url="jdbc:postgresql://127.0.0.1:5433/colormark2"
                maxActive="10"/>
            </Context>
    		</Host>
    I have intentionally used 5433 as the port.

    What other place(s) should I be looking for to change the DB connection strings.

    I have created a new virtual host called mark2 and copied all the files from /var/www/mycomapny.com/ to /var/www/mark2/

    What about privileges?
    Privileges on the DB and the files are the same as the original source.

    For duplicating the DB this is what I did:
    Created a new db called colormark2. I created a dump file from the old DB and create a new db. Restored the data to newdb

    Can you connect to the new db from the psql prompt?
    Yes. I can.

    There is a .java/.class file and web.xml that references the DB in \WEB-INF folder of the website. But making any changes to it and restarting the server didnt make any difference.

    Even on the original site I changed the dbname in the \WEB-INF folder but it didn't make a change. Original site still works... so it may be pulling DB information from somewhere.

    I have verified that the DB is good and is working if I connect it from the prompt... I think I am missing the link between the db and website settings.

    I dont know where else to go to make the correction.


    Another question: In the code above - will it make a difference if I kept the resource name = "Colormark" the same or does it have to be different.

    I have tried changing it and also kept the same. Didn't see any difference.

  4. #4
    Join Date
    Apr 2011
    Posts
    34
    I don't know about Debian, but on Slackware, I have two log files for the webserver: access_log and error_log. It has been ages since I used Tomcat. If not mistaken, it also has logging facility. Did you check this?

    In my case, Postgresql logs is in /var/log.

    I take you used pg_dump tool to backup the db and created a new one from the backup script...
    I am not familiar with virtual system so I can't help from that point of view. It's only me but I prefer to use a second machine.

    When I referred to privileges I was not very clear, I meant granting connection permission through file pg_hba.conf. But if your run everything in a virtual environment, I guess there should be no changes...changes

    Not sure about your last question. But if you run two databases from the same server, they must have different names.

    One thing though. Maybe first start by just duplicating the application and see if it can connect to the original db? Maybe that would help to troubleshoot.

  5. #5
    Join Date
    Sep 2013
    Posts
    3
    I tried to duplicate the application and it doesn't connect to the original DB.
    I think it is tied to the location of the original app.

    Where should I be looking?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •