× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Source Evaluation?
  • From: "Joe Teff" <JoeTeff@xxxxxxxxxxxxx>
  • Date: Fri, 9 Feb 2001 17:45:12 -0600
  • Importance: Normal

I was trying to keep things simple for now. I didn't
clutter my example up with Connection Pools, etc.
I usually keep things like UI properties in different
files, but I think your idea is fine. I was just pointing
out the helper class Properties and hoew easy it is
to use.

Joe

-----Original Message-----
From: owner-java400-l@midrange.com
[mailto:owner-java400-l@midrange.com]On Behalf Of Joe Pluta
Sent: Friday, February 09, 2001 4:15 PM
To: JAVA400-L@midrange.com
Subject: RE: Source Evaluation?


Joe, this technique of using properties files is really great.  I'm
thinking, however, of extending it a little bit.  Let me know what you
think:

I'd like to create a "Categories" object that has, basically, a hashtable of
Properties objects.  The key to the hashtable would be a category ID.  The
category ID would then allow something like this:

    [UIProperties]

    font=Arial
    size=12pt
    color=blue

    [Database]

    driver=com.ibm.as400.access.AS400JDBCDriver
    url=jdbc:as400://web400
    user=jdbc
    password=jdbc

The load method would be the same:

    Categories cat = new Categories();
    cat.load(new FileInputStream("system.properties"));

But the access would one of two forms:

    cat.getProperties("Database").getProperty("url")
        -or-
    cat.getProperties("Database", "url")

What does everyone think?  And if you like it, is Categories a good class
name, or can someone think of something better?


> -----Original Message-----
> From: owner-java400-l@midrange.com
> [mailto:owner-java400-l@midrange.com]On Behalf Of Joe Teff
> Sent: Friday, February 09, 2001 2:04 PM
> To: JAVA400-L@midrange.com
> Subject: RE: Source Evaluation?
>
>
> You can use instance variable as long as you don't update
> them. That's the thread exposure. The init() is the proper
> place to initialize them as it is called prior to servicing
> any requests.
>
> One comment I was going to make about Brad's code is to
> place your jdbc values in a file and then load them into
> a Properties object. Very easy to do. I do that because
> I'll test on my home PC using Access and switch to the
> AS/400 for production. I have a database.properties file
> on both machines, so I don't have to change my code to
> switch.
>
> The file is plain ascii text that has key=value pairs.
> So I would have entries in my file like:
>
>    driver=com.ibm.as400.access.AS400JDBCDriver
>    url=jdbc:as400://web400
>    user=jdbc
>    password=jdbc
>
> The Properties class extends Hashtable. To create my
> Properties object from my file I use:
>
>    Properties prop = new Properties();
>    prop.load(new FileInputStream("database.properties"));
>
> I then use the getProperty() method that takes the key
> as a String and returns the value as a String.
>
>    Class.forName(prop.getProprty("driver"));
>    con  = DriverManager.getConnection(prop.getProperty("url"),
>           prop.getProperty("user"), prop.getProperty("password"));
>
> Joe

+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.