This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Mar 11, 2015, 2:21 AM
15 Posts

Using LS2J to create Java Class to connect to MySQL

  • Category: Domino Designer
  • Platform: Linux
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 3

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

 

 

Mar 11, 2015, 7:07 PM
3 Posts
Maybe the URL is not correct.

The error message is pointing in the direction, that the Connection URL is not correct. Are you sure that your are using the correct URL?

Ralf M Petter www.everyhtingaboutit.eu

 

Mar 11, 2015, 7:19 PM
43 Posts
Thie may be off topic, but there was a regression introduced in Java 1.6 SR16FP3 that brok...
Are you running Notes 9.0.1 FP3 (or did you JVM patch an earlier release)?  This could be off topic but I did want to alert to an LS2J issue.

We included a JVM update (SR16FP3) in Notes 901FP3 that broke LS2J. The JVM team issued us an iFix and we included it in a
new JVM patch up to SR16FP3+iFix that was posted last Friday. The Patch actually covers the January round of Orace JVM security vulns and fixes the LS2J patch.

I'm asking that technote be published by end of week on the LS2J issue. It's in draft now. Technote #1696682 in case you want to look at it once published.
Mar 11, 2015, 9:43 PM
15 Posts
Re: Using LS2J to create Java Class to connect to MySQL

Hi Ralf and Scott,

 

Thanks for the replies. Ralf, yes the connection URL is the right one. I have used it in the Java agent and that works fine, can run a query, get data back and see values. Scott, they are running 9.01HF235.

 

Am going to try a different track. Will create a document and pass it to a Java agent, not use LS2J and a Java library see how that goes.

 

Thanks again.

 

Cameron


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal