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



Xu,

Don was correct, once a connection is established it will use it for the URL
also. If you have your properties set to use it. There is something about
cached passwords and signon.
Here is a test for you. See if this solves your problem. I am editing on the
fly but you get the idea and it works for me <grin>.

import java.io.File;
import java.sql.*;

import com.ibm.as400.access.*;

public class ConnectTest {

  public static void main(String args[]) {

    AS400 myAS400 = new AS400("MYSYSTEM");

    String jdbcURL = null;
    String systemName  = myAS400.getSystemName();
    String userID = myAS400.getUserId();
    Connection c;

    try {
            Class.forName("com.ibm.as400.access.AS400JDBCDriver");
    } catch(ClassNotFoundException e) {
            System.out.println(e.toString());
    }

    try {
      if (userID.equals("John")) {
          jdbcURL = "jdbc:as400://" + systemName + "databaseJohn";
        }
      else
        if (userID.equals("Tom")) {
          jdbcURL = "jdbc:as400://mysystem/databaseTom";
          }

      c = DriverManager.getConnection(jdbcURL);
      System.out.println("Driver connected -- Success");
      c.close();
    }

    catch (Exception e) {
      System.out.println("Driver failed - null Connection returned.");
    }

    System.out.println("\nConnection Test Done.");
    System.exit(0);
  } // end main
}

-----Original Message-----
From: java400-l-admin@midrange.com
[mailto:java400-l-admin@midrange.com]On Behalf Of Xu, Weining
Sent: Thursday, September 20, 2001 6:24 AM
To: 'java400-l@midrange.com'
Subject: RE: How to get the current user ID after sign on to AS400


Thanks, Don,

The getUserId() method could be called for a AS400 object.  But in my case,
I have the code like this:

String URL = "jdbc:as400://mysystem/databaseXYZ";
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
con = DriverManager.getConnection(URL);

How do I get the AS400 object here.  The AS400 sign on screen was invoked at
the line of code:  con = DriverManager.getConnection(URL); After this line
was executed, con has an implicit object as400_ which contains the userId I
just signed on.
So I assume that I should have something like this after con =
DriverManager.getConnection(URL);

String user = aAS400.getUserID();

How could I get this implicit aAS400 object from con?  If I create a AS400
object as: AS400 aAS400 = new AS400(); that would not be the same object
(as400_) after the connection.

Any suggestions?

Wayne

-----Original Message-----
From: Donald Whittaker [mailto:donald_whittaker@yahoo.com]
Sent: Wednesday, September 19, 2001 4:16 PM
To: java400-l@midrange.com
Subject: Re: How to get the current user ID after sign on to AS400


   The AS400 (connection) object has a .getUserID()
method that returns a String.
URL = "jdbc:as400://mysystem/database" +
myAS400.getUserID();

Hope this helps,
Don Whittaker

--- "Xu, Weining" <Weining.Xu@AIG.com> wrote:
> Hi, all,
>
> I have a program using JDBC driver to access DB2 on
> AS400.  I will let the
> different users to use different testing
> databases(libraries) on AS400.  So
> after the program connected to AS400, I need to know
> the user ID who just
> signed on AS400 in order to set up a URL as
> "jdbc:as400://mysystem/databaseXYZ".  Then use this
> URL to make a
> connection, such as:  con =
> DriverManager.getConnection(URL);
>
> Is there anyway I could get the current userID,
> something like:
>
> if (userID.equals("John")){
>       URL = "jdbc:as400://mysystem/databaseJohn";
> }
> else if (userID.equals("Tom")){
>       URL = "jdbc:as400://mysystem/databaseTom";
> }
>
> con = DriverManager.getConnection(URL);
>
> Thanks for any helps.
>
> Wayne
>
>
>
> _______________________________________________
> 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.
>


__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/
_______________________________________________
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:
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.