Hi,
I have a task to check if some data is in a MySQL database and populate it in a Notes database. There is some existing code that searches the MySQL database (written as a Java Agent using JDBC) then displays it via a web page. I thought I could write a Java class to do something similar and use LS2J to connect and grab the returned data. Am coming across a brick wall in that I keep hitting
java.lang.ExceptionInInitializerErrorjava.lang.ExceptionInInitializerError at java.lang.J9VMInternals.initialize(J9VMInternals.java:222) at com.mysql.jdbc.Util.stackTraceToString(Util.java:350) at com.mysql.jdbc.Util.<clinit>(Util.java:115) at java.lang.J9VMInternals.initializeImpl(Native Method) at java.lang.J9VMInternals.initialize(J9VMInternals.java:200) at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:666) at com.mysql.
At the point where I connect to the MySQL database
conn = DriverManager.getConnection("jdbc:mysql://xx.xx.xx.xx/xxxx", "xxxxxx", "xxxxx");
The code above is in a Java Library and I'm including it in my LotusScript agent via a Use "XXX" as well as having the UseLSX "*javacon" . The java library contains the MySQL-connector-java-5.15.jar file. Just to confirm that the code was ok (instantiating the Java object in LotusScript) I created a method in the class to concatenate two strings and return the result, that works fine.
At first I though it may be a security issue for myself (since there is almost the same code running elsewhere but it is an agent not a script library) but am in all relevant groups with access to run restricted/unrestricted java code. Then I thought maybe because I'm running it manually (not on server) so wrote another agent to load the agent and runonserver, but same error. Am not a Java developer so not sure where to go next. I'll post more code below the message (up to the crash point). Am also going to try converting it to an agent, just to see what happens. Again, thanks for any assistance.
*Update* I copied the code (almost) to a new Notes Java Agent, and it worked fine, ran the query, returned the result and I could pull data out of the result set.
Thanks,
Cameron
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
public class LookupCowDB {
private String Animals_NationalID;
private String Animals_InternatID;
private String Cows_Shortname;
private String Cows_Longname;
private String Animals_Herdbook;
private String Animals_BreedS;
private String Animals_Birth;
private String TestThis="This is the java value";
private String SQLStatement;
public String findCow(String nationalID, String IntID) {
ResultSet resultSet = null;
Statement st = null;
Connection conn = null;
String query="";
String where="";
try {
if (nationalID.equals("") && IntID.equals("")) {
return "Parameters empty";
}
query = "SELECT * from table";
if (!nationalID.equals("") ) {
where = " AND animals_nationalID=\"" + nationalID + "\"";
}
if (!IntID.equals("")) {
if (where.equals("")) {
where = " AND Animals_InternatID=\"" + IntID + "\"";
} else {
where = where + " AND Animals_InternatID=\"" + IntID + "\"";
}
}
query = query + where;
SQLStatement=where;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://xx.xx.xx.xx/xxxxxxx", "xxxxxxx", "xxxxx"); // <---- crash point