Using the simplest possible Java program to connect to a remote DB2 database, I get the following error, connecting from client 9.245.63.34 to server 9.244.43.32:
[email protected] # java -classpath /software/jars/IBM/db2jcc.jar:/software/jars/IBM/db2jcc_license_cu.jar:. DatabaseConnector
com.ibm.db2.jcc.c.SqlException: [ibm][db2][jcc][t4][2017][11253] Connection authorization failure occurred. Reason: User ID revoked.
at com.ibm.db2.jcc.a.b.m(b.java:2010)
at com.ibm.db2.jcc.a.b.c(b.java:1655)
at com.ibm.db2.jcc.a.bb.r(bb.java:792)
at com.ibm.db2.jcc.a.bb.k(bb.java:349)
at com.ibm.db2.jcc.a.bb.c(bb.java:133)
at com.ibm.db2.jcc.a.b.zc(b.java:1279)
at com.ibm.db2.jcc.a.b.b(b.java:1200)
at com.ibm.db2.jcc.a.b.y(b.java:4597)
at com.ibm.db2.jcc.a.b.b(b.java:754)
at com.ibm.db2.jcc.a.b.a(b.java:697)
at com.ibm.db2.jcc.a.b.a(b.java:378)
at com.ibm.db2.jcc.a.b.<init>(b.java:316)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:675)
at java.sql.DriverManager.getConnection(DriverManager.java:219)
at DatabaseConnector.main(DatabaseConnector.java:29)
The Java program looks like this:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class DatabaseConnector {
public static void main(String[] args) {
// Load the DB2 JDBC driver
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
return;
}
// Define database properties
Properties properties = new Properties();
properties.put("user", "dbuser");
properties.put("password", "SecretPa55word!");
// JDBC URL for Mediator_Control_DB
String jdbcUrl = "jdbc:db2://9.244.43.32:50010/MYDB";
// Establish the database connection
try (Connection connection = DriverManager.getConnection(jdbcUrl, properties)) {
System.out.println("Connected to the database.");
// Execute a sample query
try (Statement statement = connection.createStatement()) {
ResultSet resultSet = statement.executeQuery("SELECT CURRENT_DATE FROM SYSIBM.SYSDUMMY1");
if (resultSet.next()) {
String currentDate = resultSet.getString(1);
System.out.println("Current date from the database: " + currentDate);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
The error seems related to the DB2 user on the host AIX system being used to connect, dbuser, whose password expired. The password was reset on the host through:
[email protected] # passwd dbuser
But the error persists.
On the host system, the user also has the following attributes that seem relevant to the error:
[email protected] # lsuser -f dbuser
loginretries=5
account_locked=false
unsuccessful_login_count=0
Please advise.
I tried reseting the password multiple times, as well as clearing the unsuccessful_login_count attribute of the user on AIX through:
[email protected] # chsec -f /etc/security/lastlog -a unsuccessful_login_count=0 -s dbuser