以下java程序的主要目的是使用jtopen(9.6版)中的AS400FileRecordDescription类来检索iseries上物理文件的记录格式。它通过调用此类中的 retrieveRecordFormat() 方法来实现。
如果连接是不安全的连接(连接 url 不包含 secure=true 参数),则此程序可以正常工作。但是在安全连接下(连接 url 包含 secure=true 参数),它失败并出现以下错误:“javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake”。知道我在这里做错了什么吗?
import java.sql.Connection;
import java.sql.DriverManager;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400FileRecordDescription;
import com.ibm.as400.access.AS400JDBCConnection;
import com.ibm.as400.access.RecordFormat;
public class TestIseriesSecureConnection {
public static void main(String[] args) {
Connection conn = null;
AS400 system = null;
try {
// get standard jdbc connection
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
// notice the secure=true parameter, if that is removed, the program works fine.
conn = DriverManager.getConnection("jdbc:as400://myiseries;secure=true;naming=system;errors=full;prompt=false;libraries=*LIBL;timeFormat=iso;dateFormat=iso;dateSeparator=-", "myuser", "mypassword");
// cast connection into AS400 jdbc connection class to get the AS400 object
AS400JDBCConnection as400Conn = (AS400JDBCConnection) conn;
system = as400Conn.getSystem();
// get the record format of a file on iseries
RecordFormat recordFormats[] = null;
AS400FileRecordDescription fileRecordDescription = new AS400FileRecordDescription(system, "/QSYS.LIB/%LIBL%.LIB/MYFILE.FILE");
// This is where it error out if the connection is a secure connection
recordFormats = fileRecordDescription.retrieveRecordFormat();
for (int myIx = 0; myIx < recordFormats.length; myIx++) {
System.out.println(recordFormats[myIx].toString());
}
conn.close();
}
catch(Exception ex) {
ex.printStackTrace();
}
finally {
try {
if (conn != null) {
conn.close();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
System.exit(0);
}
}