9

Can anyone help me out? I have small utility application that uses the Jt400-6.7.jar to connect to an AS400 server.

Please see the following code

private Connection buildConnection(String url, String userName, String password) throws ClassNotFoundException,
            SQLException {
        Connection connection = null;

        Class.forName("com.ibm.as400.access.AS400JDBCDriver");

        DriverManager.setLoginTimeout(10000);

        //OVER HERE!!! 
        connection = DriverManager.getConnection(url, userName, password);

        return connection;
    }

The code above works but if the the username or the password is wrong the application creates the following login screen. It happens when DriverManager.getConnection() is executed.

Cant post a picture but it looks something like this

Signon to the system           X

System:         AS400Server
User ID:        User ID
Password:       ********

       O Default User ID
       O Save Password

    OK            Cancel  

Can anyone tell me how to disable this feature??

Jefrey Valencia
  • 713
  • 3
  • 13
  • 30

4 Answers4

14

One way to disable this feature is to set the JVM property, com.ibm.as400.access.AS400.guiAvailable=false.

From a java command line, you would set this using java -Dcom.ibm.as400.access.AS400.guiAvailable=false ...

Here is an example using the jdbc client included in jt400.jar

C:\>java -cp jt400.jar -Dcom.ibm.as400.access.AS400.guiAvailable=false com.ibm.as400.access.jdbcClient.Main jdbc:as400:/SYSTEM
Warning:  Unable to connect to jdbc:as400:/SYSTEM using null
CON is not defined

The second way to disable this feature is to use the prompt=false connection property. For example.

C:\jtopen_build\dist6>java -cp jt400.jar com.ibm.as400.access.jdbcClient.Main jdbc:as400:/SYSTEM;prompt=false
Warning:  Unable to connect to jdbc:as400:/SYSTEM;prompt=false using null
CON is not defined
jweberhard
  • 576
  • 3
  • 7
  • Hi sorry for the late reply was a weekend on my end. Anyway I am calling the driver with my sample code above. I there anyway for me to pass these parameters using my code above. Sorry for my ignorance... – Jefrey Valencia Sep 29 '14 at 05:57
  • 1
    Just add the line ... url += ";prompt=false"; ... before ... connection = DriverManager.getConnection – jweberhard Oct 01 '14 at 01:50
1

Another method for preventing the GUI password prompt.

AS400.setPasswordExpirationWarningDays(-1);
Properties properties = new Properties();
properties.put("extended metadata", "true");
properties.put("user", userProfile);
properties.put("password", password);
properties.put("driver", "native");
properties.put("prompt", "false");
DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
Connection connection = DriverManager.getConnection("jdbc:as400://somedomain.com", properties);
PLA
  • 351
  • 7
  • 15
1

Just to add, when calling a RPG program from java, same Sign-on pop up arrives.You can turn it off by setting com.ibm.as400.access.AS400 object's setGuiAvailable(false);

Ani
  • 123
  • 1
  • 1
  • 14
0

You can also set it when defining the DataSource:

final AS400JDBCDataSource dataSourceISeries = new AS400JDBCDataSource();
dataSourceISeries.setDatabaseName(...);
dataSourceISeries.setUser(...);
...
dataSourceISeries.setPrompt(false);
Sergio Gabari
  • 663
  • 6
  • 12