I am trying to retrieve data from MySQL database table. To do that, I use following code on various platforms. My code works perfectly on Windows and Linux platforms. But when I use same code in AIX 6.1, it does not retrieve correct data.
The Main Function:
String storedstring = objDBUtil.lookup(0);
logger.info(storedstring);
The Database Util Function:
public String lookup(String number) throws Exception {
String sql = "SELECT info FROM records WHERE Snumber=?";
Connection dbConn = connect();
try {
PreparedStatement stmt = dbConn.prepareStatement(sql);
try {
stmt.setString(1, number);
ResultSet rs = stmt.executeQuery();
try {
if (!rs.next()) {
throw new TException("does not exist in the database");
}
return rs.getString(1);
} catch (Exception e) {
logger.info("Unexpected exception caught during auth: " + e.getClass().toString() + " " + e.getMessage());
return null;
}finally {
rs.close();
}
} finally {
stmt.close();
}
} finally {
dbConn.close();
}
}
Output of the main function on Windows, I get the entire string from the database. But exact code gives me encrypted value on AIX machine.
Output on AIX machine [B@62637268
I resolved the issue. Issue was with connector file. I was using older version of connector file.
MySQL version I was using:
mysql-5.5.2-m2-aix5.3-powerpc-64bit
Non working version of Mysql connector with above mysql:
mysql-connector-java-3.1.7-bin.jar
Working version of MySQL connctor with above mysql:
New version: mysql-connector-java-5.1.6-bin.jar
Thank you everyone for looking into my question and trying to help me. Really appreciated.