LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-25-2009, 06:42 AM   #1
nbcohen
Member
 
Registered: Mar 2003
Location: Northern Virginia
Distribution: RH Enterprise, Fedora
Posts: 96

Rep: Reputation: 17
Locating a database at runtime


I have written a java application using Netbeans (and I'm also asking this question on the Netbeans mailing list...) The program uses a MySQL database and Hibernate. When I wrote the program, I configured it to find the database on 'localhost'. And it works fine. But now I am ready to deploy the application. In one instance the database really is on the same machine, and that works. But on a second machine, the database is located remotely. Can someone tell me how I can reconfigure the database connection on the fly? I can pass the host name or IP address in on the command line, but I'm not sure what to do with it when I get it. The information appears to be stored in the 'persistence.xml' file that Netbeans creates. For any instance of my program, once it connects, it will not have to be changed...

Much obliged,

nbc
 
Old 11-26-2009, 03:20 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Not a Java / netBeans expert, but it sounds like the easiest way is to use different connection pools / JNDI Datasources for the 2 installations,
through the usual WEB_INF/web.xml (web-application specific) or $CATALINA_HOME/conf/context.xml (server-level, so for all web-applications).
That is, if you're using the Tomcat engine.

http://netbeans.org/kb/docs/web/mysq...html#settingUp
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DBI Connect Failed:Access denied for user ''@'localhost' to database <database> error kaplan71 Linux - Software 3 06-05-2009 12:39 PM
Locating Grub Iaz Linux - Newbie 2 03-26-2009 05:55 PM
Database Programming (database to database transaction) johncsl82 Programming 7 02-02-2007 08:20 AM
Locating Kernel arimus25 Linux - Software 3 02-24-2004 05:22 PM
locating lilo seeker1 Linux - Newbie 12 01-11-2003 01:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration