I'm trying to load the JDBC driver to make some SQL calls to my AS400. I've tried running the connection on a computer which has JDBC installed on it and the URL and SQL calls work fine.
I need to develop an app (currently for Android, though we're looking to expand to desktop application) which doesn't have the drivers installed. I am testing the code on an actual android device, not the emulator, so it has full internet permissions.
jt400 has drivers located in com.ibm.as400.access.AS400JDBCDriver as noted by IBM.
This is my code:
try {
Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();
Connection conn = DriverManager.getConnection(
url + schema + ";naming=sql;errors=full",
uname,
psswrd);
// do SQL query stuff
rs.close();
stmt.close();
conn.close();
}
catch (ClassNotFoundException e)
{
this.basicOutput.setText("Class not found: " + e.getMessage());
System.out.println(e.getStackTrace());
}
//catch (SQLException e)
catch (Exception e) //need generic to catch all errors thrown
{
this.basicOutput.setText(e.getMessage());
System.out.println(e.getStackTrace());
}
I get a "Class not found: com.ibm.as400.access.AS400JDBCDriver" when I run this.
I've done some research and it suggests that Class.forName isn't a good way to go. So I tried this as well:
DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
But this also yields the same error.
The class is there. The compiled code doesn't throw any syntax errors, but for some reason, runtime can't find it.
What am I missing?