× 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.



This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
[ Picked text/plain from multipart/alternative ]
Bruce,

I'm going to need the properties file anyway, for other information, but I
like your solution.

It has, however raised another question in my head. My software needs to be
deployable when WAS and the database are on separate machines (either
physically or via logical partitions). In this case do I use the Toolbox
driver for the AS/400 to AS/400 connection, or does the native driver handle
this? Which is faster?

Chris.

 -----Original Message-----
From:   Bruce Jin [mailto:JIN007M@hotmail.com]
Sent:   02 January 2002 16:39
To:     java400-l@midrange.com
Subject:        Re: Servlet Properties

 I use absolute location to tell servlet where to find a file.
File file = new File("/home/myfile.txt").

 To tell servlet which driver to use I use a few lines of code to detect if
the servlet is running on window or on A400. This way I don't have to use a
property file.

 class JDBCDataSource {

  private Connection conn;
  private String toolboxDriver = "com.ibm.as400.access.AS400JDBCDriver";
  private String db2Driver = "com.ibm.db2.jdbc.app.DB2Driver";
  private String toolboxURL = "jdbc:as400://myas400";
  private String db2URL = "jdbc:db2://*LOCAL";

   public JDBCDataSource() {

     String os   = System.getProperty("os.name");
     try  // load jdbc driver...
    {
      if (os.indexOf("Windows") >=0 )
      {
        System.out.println("This is a Window OS!");
        Class.forName(toolboxDriver);
      } else {
        System.out.println("This is an AS400!");
        Class.forName(db2Driver);
      }
    } catch(ClassNotFoundException exc) {
      System.out.println("no jdbc");
    }

    try  // Connect to database...
    {
      if (os.indexOf("Windows") >=0 )

       conn = DriverManager.getConnection(toolboxURL,"JIN","passwd");
      } else {
        conn = DriverManager.getConnection(db2URL);
      }
    } catch(SQLException exc) {

      System.out.println("connection failed");

    }

  }

----- Original Message -----
From: "Price, Chris" <chris_price@nsb.co.uk>
To: <java400-l@midrange.com>
Sent: Wednesday, January 02, 2002 5:19 AM
Subject: Servlet Properties


> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.
> --
> [ Picked text/plain from multipart/alternative ]
> All,
>
> I have a servlet which is using the Toolbox JDBC driver to access the
AS/400
> database. This is running fine, both in the WTE and when distributed to
WAS
> on the 400.
>
> However I believe (correct me if I'm wrong) that it will be more efficient

> to use the native driver when running on the 400. So rather than
recompiling
> the code, I want to use a properties file to tell my servlet which class
to
> use.
>
> So I add the following code to my servlet:
>
> File propPath = new File("mydir\\my.properties");
> myProperties = new Properties();
>
> file://Load Properties from File
> try {
> in = new FileInputStream(propPath);
> myProperties.load(in);
> in.close();
> } catch (IOException e) {
> }
>
> If I run this code in a "normal" java class, (i.e. with a main method), a
> properties file my.properties  is created, if one does not already exist,
in
> the specified directory. If I put the code in the servlet, I get a file
not
> found exception.
>
> How can I avoid the exception (why can't the servlet create the file?).
> Alternatively, where should I create the file manually, so the servlet
> engine finds it?
>
> Thanks,
> Chris.
>
>
> _______________________________________________
> This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
> To post a message email: JAVA400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
> or email: JAVA400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
>
_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.