Hi,
I'm hoping someone here has experience writing Java agents in Lotus Notes, b/c I'm trying to write a Java agent that makes use of the JDBC-ODBC bridge driver to access an Oracle database, configured as an ODBC data source. However, I have two problems with the agent:
(1) The bridge driver loads, but the ODBC driver won't load. I wrote this agent locally, set up the DSN locally, and tested it locally, and it works fine from there. I set up the data source with the name "CSSPROD9" locally, and set it up exactly the same way on my server, with the same name and same parameters. However, I can't get my code to work when run from my server. The error message I get from the Java console is:
"java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:3661)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:3814)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:1029)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:145)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:165)
at java.sql.DriverManager.getConnection(DriverManager.java:83)
at java.sql.DriverManager.getConnection(DriverManager.java:126)
at JavaAgent.NotesMain(JavaAgent.java:59)
at lotus.domino.AgentBase.runNotes(AgentBase.java:160)
at lotus.domino.NotesThread.run(NotesThread.java:203)"
(2) I'd like to use the last() method for the ResultSet object, and I'm being told that the method does not exist for the object. This is a fairly common method for ResultSet, and I later discovered that other cursor positioning methods, such as first(), afterLast(), and beforeFirst() are also not available. Why are they not available, and how can I make them available?
My code is below:
============================
import lotus.domino.*;
import java.sql.*;
import java.io.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
Document docContext = agentContext.getDocumentContext();
PrintWriter pw = getAgentOutput();
String qString = "";
String fldList = "";
String KEYFIELD = "EMPLID";
int fldCt = 0;
int numRecs = 0;
int x = 0;
fldList = "EMPLID, NAME, WORK_PHONE";
fldCt = 3;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"
String url = "jdbcdbc:CSSPROD9";
Connection con = DriverManager.getConnection(url, "myUserId", "myPassword"
Statement stmt = con.createStatement();
String sqlstring = "SELECT " + fldList + " FROM BX_PDR.SNAP$_PS_BX_COMMON_DATA";
sqlstring = sqlstring + " WHERE EMPL_STATUS='A' OR EMPL_STATUS='L' OR EMPL_STATUS='P'";
sqlstring = sqlstring + " AND NOT EMPL_CLASS='L'";
ResultSet rs = stmt.executeQuery(sqlstring);
//rs.Last();
//numRecs = rs.getRow();
String tagB = "</center></b></td><td><b><center>";
String tag = "</center></td><td><center>";
String titleOpen = "<tr><td colspan=" + fldCt + "><center><b>";
String titleClose = "</b></center></td></tr>";
//ActiveXComponent xl = new ActiveXComponent("Excel.Application"
//Object xlo = xl.getObject();
pw.println("content-type: application/vnd.ms-excel"
pw.println("<html><head><style></style></head><body>"
pw.println("<table border=1><tr>"
String tmpFldList = fldList;
while (tmpFldList.indexOf(", " > -1) {
String tmpFld = tmpFldList.substring(0, tmpFldList.indexOf(", ");
pw.println("<td><center><b>" + tmpFld + "</b></center></td>"
tmpFldList = tmpFldList.substring(tmpFldList.indexOf(", " + 2);
}
//Print last field (not delimited by ", "
pw.println("<td><center><b>" + tmpFldList + "</b></center></td></tr>"
while (rs.next()) {
pw.println("<tr>"
for (x=0; x < fldCt; x++) {
pw.println("<td><center>" + rs.getString(x+1) + "</center></td>"
}
pw.println("</tr>"
}
pw.println("</table></body></html>"
} catch(Exception e) {
e.printStackTrace();
}
}
}
=========================
Any tips/advice would be greatly appreciated. Thanks in advance,
Sam
I'm hoping someone here has experience writing Java agents in Lotus Notes, b/c I'm trying to write a Java agent that makes use of the JDBC-ODBC bridge driver to access an Oracle database, configured as an ODBC data source. However, I have two problems with the agent:
(1) The bridge driver loads, but the ODBC driver won't load. I wrote this agent locally, set up the DSN locally, and tested it locally, and it works fine from there. I set up the data source with the name "CSSPROD9" locally, and set it up exactly the same way on my server, with the same name and same parameters. However, I can't get my code to work when run from my server. The error message I get from the Java console is:
"java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:3661)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:3814)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:1029)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:145)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:165)
at java.sql.DriverManager.getConnection(DriverManager.java:83)
at java.sql.DriverManager.getConnection(DriverManager.java:126)
at JavaAgent.NotesMain(JavaAgent.java:59)
at lotus.domino.AgentBase.runNotes(AgentBase.java:160)
at lotus.domino.NotesThread.run(NotesThread.java:203)"
(2) I'd like to use the last() method for the ResultSet object, and I'm being told that the method does not exist for the object. This is a fairly common method for ResultSet, and I later discovered that other cursor positioning methods, such as first(), afterLast(), and beforeFirst() are also not available. Why are they not available, and how can I make them available?
My code is below:
============================
import lotus.domino.*;
import java.sql.*;
import java.io.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
Document docContext = agentContext.getDocumentContext();
PrintWriter pw = getAgentOutput();
String qString = "";
String fldList = "";
String KEYFIELD = "EMPLID";
int fldCt = 0;
int numRecs = 0;
int x = 0;
fldList = "EMPLID, NAME, WORK_PHONE";
fldCt = 3;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"
String url = "jdbcdbc:CSSPROD9";
Connection con = DriverManager.getConnection(url, "myUserId", "myPassword"
Statement stmt = con.createStatement();
String sqlstring = "SELECT " + fldList + " FROM BX_PDR.SNAP$_PS_BX_COMMON_DATA";
sqlstring = sqlstring + " WHERE EMPL_STATUS='A' OR EMPL_STATUS='L' OR EMPL_STATUS='P'";
sqlstring = sqlstring + " AND NOT EMPL_CLASS='L'";
ResultSet rs = stmt.executeQuery(sqlstring);
//rs.Last();
//numRecs = rs.getRow();
String tagB = "</center></b></td><td><b><center>";
String tag = "</center></td><td><center>";
String titleOpen = "<tr><td colspan=" + fldCt + "><center><b>";
String titleClose = "</b></center></td></tr>";
//ActiveXComponent xl = new ActiveXComponent("Excel.Application"
//Object xlo = xl.getObject();
pw.println("content-type: application/vnd.ms-excel"
pw.println("<html><head><style></style></head><body>"
pw.println("<table border=1><tr>"
String tmpFldList = fldList;
while (tmpFldList.indexOf(", " > -1) {
String tmpFld = tmpFldList.substring(0, tmpFldList.indexOf(", ");
pw.println("<td><center><b>" + tmpFld + "</b></center></td>"
tmpFldList = tmpFldList.substring(tmpFldList.indexOf(", " + 2);
}
//Print last field (not delimited by ", "
pw.println("<td><center><b>" + tmpFldList + "</b></center></td></tr>"
while (rs.next()) {
pw.println("<tr>"
for (x=0; x < fldCt; x++) {
pw.println("<td><center>" + rs.getString(x+1) + "</center></td>"
}
pw.println("</tr>"
}
pw.println("</table></body></html>"
} catch(Exception e) {
e.printStackTrace();
}
}
}
=========================
Any tips/advice would be greatly appreciated. Thanks in advance,
Sam