Solved

Changing a settings file in a Java program

Posted on 2002-04-26
6
183 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

713 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