witlili witlili - 1 year ago 95
Java Question

NotesException:Older version on server does not support this method

Lotusscript calling Java class get this error.
Product Area: Domino Designer on Eclipse (DDE)

Technical Area: Application Development

Platform: Windows 2008 R2 64bit

Release: 8.5.3

Reproducible: Always

1 create SqlTest script libray(Java) in Notes database.

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import java.sql.Statement;

import lotus.domino.*;

public class Model{


Get database connection

public static Connection getConn(){

Connection conn = null;

String SqlDriverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";

String SqlDBUrl = "jdbc:sqlserver://;DatabaseName=TMSTEST";

String SqlUserName = "sa";

String Sqlpwd = "1q2w3e4r!";

try {


conn = DriverManager.getConnection(SqlDBUrl, SqlUserName, Sqlpwd);

System.out.println("database connection sucess");

} catch (Exception e) {


System.out.println("database connection failure");


return conn;


public static boolean test1(String id){


Connection conn = getConn();

Statement stmt = null;

String sql;

// Open the current Notes db

try {

Session s = NotesFactory.createSession("", "admin test/testeam", "testtest");

System.out.println("session is OK");

Database db = s.getCurrentDatabase();

// System.out.println("Title of URL database: \"" + db.getTitle() + "\"");

if (db.isOpen())

System.out.println("Is open");


System.out.println("Not open");
Document doc = null;

//through the id para get the Notesdocument

doc = db.getDocumentByUNID(id);


//insert the Notesdocument data to sql

if (doc != null) {

sql = "insert into TEST_USER(userID, userName,xqbh) values('123456','"+doc.getItemValueString("fld_xqbh")+"', '"+doc.getItemValueString("fld_xqmc")+"')";

System.out.println("SQL :"+sql);

stmt = conn.createStatement();


System.out.println("excute finish");

return true;


return false;


} catch (NotesException e) {

// TODO auto generate catch block


return false;

}catch(SQLException se){


return false;



if(stmt != null) stmt.close();

if(conn != null) conn.close();

}catch(Exception e1){






2 in the Notes form:

Uselsx "*javacon"
Use "SqlTest"

Function jTest(id As String) As Boolean

Dim jSession As New JAVASESSION


Dim jObj As JavaObject

Set jClass = jSession.GetClass("Model")

'Msgbox jClass.className

Call jClass.test1(id)
End Function

3 use the java class through Lotusscript:

'call java class

Call jTest(doc.UniversalID)

4 debug the program find the error in java console log through IDE(Lotus Domino Designer).use some print sentences and find the error line(Java):

Database db = s.getCurrentDatabase();

5 I have had seen follow posts.

Invoking method on a Java class from lotus script (LS2J)

passing LotusScript parameter to Java

google Nothing,trouble for days.
thanks everyone,thanks in advance.First Posts in stackoverflow.

Answer Source

The problem is in the way you get your session: you open a complete new one that has nothing to do with the currently open session. That new session does not have a current database as it is not connected to you frontend session.

Just initialize your session with this line:

Session session = getSession();

Then getCurrentDatabase will work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download