Solved

Changing a settings file in a Java program

Posted on 2002-04-26
6
181 Views
Last Modified: 2010-03-31
Hi,
When I install a Java application, it requires a connection to a database. The flaw in this program is that it has a default database name (DSN) to which it tries to connect. Unless you happen to have that data source on your machine, it will fail. When installing this application, it never gives you the option to edit the DSN name. Can anyone suggest how I might change this? I am not a java programmer, so be gentle!. I suppose i need to change one of the source files for this.
thanks for any assistance
Mike
0
Comment
Question by:mikeandbee
6 Comments
 
LVL 7

Expert Comment

by:yoren
ID: 6971895
I would first check the documentation of this application. If this application ignores all sensibility and does not give you the option to change the DSN, read on.

You'll have to change one of two things, depending on the application. It might be reading the DSN from a properties (settings) file, or it may be embedded in the application.

The easiest way to find the problem is to unpack the source files and use an editor that lets you search for the DSN string in multiple files. If you find it in a properties file, you won't have to recompile. If you find it in the source, you'll have to run "javac <file>" for the changed file.

Yuval
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 6972592
Two options:

1. Pass the DSN as a paramater on the program as a command line:

java -Ddsn=xyz mypackage.MyClass

2. Store the DSN in a properties files, and have your program read it from there.
0
 

Author Comment

by:mikeandbee
ID: 6977791
I can change the DSN in the properties file AFTER it has been installed, but what I want is for the program to give me the option to add/find a DSN on my system, and not hardcode the DSN into the settings file. Is it possible tochange this with little knowledge of Java? Do i need a Java programming environment to do this (which i don't have)?

thanks
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 92

Expert Comment

by:objects
ID: 6978707
> Is it possible tochange this with little knowledge of Java?

Define little.
Sounds like this would require a code change.

> Do i need a Java programming environment
to do this (which i don't have)?

Yes.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7992289
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: objects
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8048111
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 104
numbers ascending pyramid 101 191
jar file executable 12 51
Convert from a json string array to a Java object 3 28
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now