Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accesing ODBC drivers via Lotus Notes agent

Status
Not open for further replies.

dwbh

Programmer
Oct 24, 2002
8
US
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 = "jdbc:eek:dbc: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 = &quot;</center></b></td><td><b><center>&quot;;
String tag = &quot;</center></td><td><center>&quot;;
String titleOpen = &quot;<tr><td colspan=&quot; + fldCt + &quot;><center><b>&quot;;
String titleClose = &quot;</b></center></td></tr>&quot;;
//ActiveXComponent xl = new ActiveXComponent(&quot;Excel.Application&quot;);
//Object xlo = xl.getObject();
pw.println(&quot;content-type: application/vnd.ms-excel&quot;);
pw.println(&quot;<html><head><style></style></head><body>&quot;);
pw.println(&quot;<table border=1><tr>&quot;);
String tmpFldList = fldList;
while (tmpFldList.indexOf(&quot;, &quot;) > -1) {
String tmpFld = tmpFldList.substring(0, tmpFldList.indexOf(&quot;, &quot;));
pw.println(&quot;<td><center><b>&quot; + tmpFld + &quot;</b></center></td>&quot;);
tmpFldList = tmpFldList.substring(tmpFldList.indexOf(&quot;, &quot;) + 2);
}
//Print last field (not delimited by &quot;, &quot;)
pw.println(&quot;<td><center><b>&quot; + tmpFldList + &quot;</b></center></td></tr>&quot;);
while (rs.next()) {
pw.println(&quot;<tr>&quot;);
for (x=0; x < fldCt; x++) {
pw.println(&quot;<td><center>&quot; + rs.getString(x+1) + &quot;</center></td>&quot;);
}
pw.println(&quot;</tr>&quot;);
}
pw.println(&quot;</table></body></html>&quot;);
} catch(Exception e) {
e.printStackTrace();
}
}
}
=========================

Any tips/advice would be greatly appreciated. Thanks in advance,
Sam
 
I can't help you with your problem, but I hope you could help me with mine.

I want to use the jdbc:eek:dbc bridge too, but at the instruction Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;) Notes gives the exception, and stack trace:

COM.ibm.JEmpower.applet.AppletSecurityException: Access of package 'sun.jdbc.odbc'

at COM.ibm.JEmpower.applet.AppletSecurity.maybeFailSecurity(AppletSecurity.java:321)

at COM.ibm.JEmpower.applet.AppletSecurity.maybeFailSecurity(AppletSecurity.java:282)

at COM.ibm.JEmpower.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:944)

at COM.ibm.JEmpower.applet.AppletClassLoader.loadClass(AppletClassLoader.java:185)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:304)

at ikta.ElsoApplet.notesAppletStart(ElsoApplet.java:35)

at lotus.domino.AppletBase.start(AppletBase.java:69)

at COM.ibm.JEmpower.applet.AppletFrame.run(AppletFrame.java:467)

at java.lang.Thread.run(Thread.java:466)

What should I set up to make my applet work?

If you give me any help, I appreciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top