The value of JDBCSpecs and JDBCDriver are as in the original email.

 

This is old IBM VAJ Persistence Builder technology used for object-relational 
mapping in this application (a 2000-01 application).

 

I include three methods:

 

(1) npmt.services.NpmtdbnpmtdbDataStore.getConnectionSpec():

     This is a callback method in a subclass of Persistence Builder (PB) 
SqlDataStore, which the PB uses to get the connection specification information 
(driver, URL)

 

(2)com.ibm.vap.RelationalPersistence.SqlDataStore.createConnectionWithAlias: 
The method that uses the information provided in (1) in order to perform the 
connection

 

(3) com.ibm.ivj.db.base.DatabaseConnection.connectToDataSource(): The method 
that actually invokes DriverManager.getConnection()

 

It is hard to provide a stack trace since the Persistence Builder framework 
"eats" the SQLException and returns a higher-level exception within the reason 
only but no stack trace. Even the highest level PB trace level does not return 
the exception. If this were not platform-specific I would get the stack trace 
by running in debug mode from within WSAD, but now on iSeries debugging is much 
harder and I've actually never done it.

 

Thanks!

 

Panagiotis.

 

====================================================

 

public com.ibm.ivj.db.base.DatabaseConnectionSpec getConnectionSpec() {

DatabaseConnectionSpec aConnectionSpec;

//get server name using the Utils method and don't let it be hardcoded 

String serverName = npmt.srv.common.Utils.getServer().trim();

int delimPosition = Environment.getJDBCSpecs().indexOf("|");

String driverName = Environment.getJDBCDriver();

String dataSourceName =

Environment.getJDBCSpecs().substring(0, delimPosition)

+ serverName

+ Environment.getJDBCSpecs().substring(delimPosition + 1);

System.out.println("DEBUG: driver name: " + driverName);

System.out.println("DEBUG: data source name: " + dataSourceName);

aConnectionSpec = 

new DatabaseConnectionSpec("VA1", driverName, dataSourceName);

return aConnectionSpec;

}

 

====================================================

protected Object createConnectionWithAlias(String anAlias, DatabaseLogonSpec 
aLogonSpec) {

DatabaseConnection conn = null;

DatabaseConnectionSpec aSpec = (DatabaseConnectionSpec) 
getStoredConnectionSpec(aLogonSpec).clone();

aSpec.setAlias(anAlias);

try {

conn = getConnectionPolicy().connect(aSpec);

conn.setMaxCacheSize(getMaxPreparedStatementCacheSizePerConnection());

} catch (SQLException ex1) {

Trace.showException(ex1, this, "createConnectionWithAlias()");

errorConnectionFailed(getConnectionSpec().getDriverName(), ex1.getMessage());

} catch (ClassNotFoundException ex2) {

Trace.showException(ex2, this, "createConnectionWithAlias()");

errorJDBCDriverNotFound(getConnectionSpec().getDriverName());

} catch (Exception ex3) {

Trace.showException(ex3, this, "createConnectionWithAlias()");

}

return conn;

}
 
====================================================
 

/**

* Attempt to connect using the supplied logon and connection specs

*/

public synchronized void connectToDataSource() throws SQLException {

DatabaseLogonSpec aLogonSpec = getConnectionSpec().getLogonSpec();

if (aLogonSpec == null)

throw (new SQLException(resobjectExtender.getString("incorrectLogon"),"08004"));

String anId = aLogonSpec.getId();

String aPassword = aLogonSpec.getPassword();

if (aLogonSpec.isValid()) {

try {

setJdbcConnection(DriverManager.getConnection(getConnectionUrl(), anId, 
aPassword));

} catch (SQLWarning warn) { 

warn.printStackTrace();

} 

initialize(); 

}

else { /* This never makes it to the driver, so return a meaningful exception */

throw (new 
SQLException(resobjectExtender.getString("incorrectLogon"),"08004"));//$NON-NLS-2$
 //$NON-NLS-1$

}

}

 

=======================================================

 


/**

* This method will return a connection object after successfully connecting

* using the supplied connection info.

*/

public DatabaseConnection connect () throws SQLException, 
ClassNotFoundException {

DatabaseConnection connection;

JDBCConnectionManager databaseManager;

databaseManager = JDBCConnectionManager.singleton();

databaseManager.registerDriver(getDriverName());

connection = databaseManager.getConnectionAtAlias(getAlias()); /* Check to see 
if a connection with this alias already exists */

if ( connection != null ) {

if (connection.getConnectionSpec().matches(this))

return connection;

};

connection = databaseManager.connectUsingSpec (this);

// If this connection has an alias, register it

if (getAlias()!= null)

databaseManager.registerConnection(connection);

return connection;

}



Rune Kaus <rune@xxxxxxx> wrote:
If you have a snippet of your code to share with us, and maybe a stack
trace, it would help the investigation.

Rune

PS. You are of course sure that the username and password is correct.
Panagiotis Varlagas wrote:

When attempting to use the native iSeries JDBC driver to access the local 
iSeries DB2 db, I get the following SQLException:

"The Username and/or password supplied is incorrect." (SQL1403N) 

The JDBC Driver used is:

com.ibm.db2.jdbc.app.DB2Driver

and the URL string is: 

jdbc:db2:MYDATABASE;errors=full;translate 
binary=true;naming=system;libraries=ICBSUATDB1 
ICBSSMS712;user=MYUSER;password=MYPASSWORD

The configuration is a Java application and a DB2 both on the _same_ iSeries 
(AS/400) machine.

I have tried different renditions of the URL string, in particular:
1) With *LOCAL instead of MYDATABASE and
2) Without the user and password properties
Four (4) combinations in all. In all four cases the above error ("The Username 
and/or password supplied is incorrect.") was gotten!

(Reminder: Both Java app and DB2 db live on the same iSeries box)

Any help as to (i) why this error occurs and (ii) how it can be eliminated 
would be _greatly_ appreciated!!!

Panagiotis Varlagas
Senior Software Developer, NovaBank S.A.
varlagpa@xxxxxxxxxxx
varlagas@xxxxxxxxx


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2022 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.