1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
/*
========== licence begin GPL
Copyright (C) 2002-2003 SAP AG
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
========== licence end
*/
package com.sap.dbtech.rte.comm;
import java.sql.SQLException;
import java.util.Properties;
import com.sap.dbtech.util.*;
/**
*
*/
public class NativeComm
extends JdbcCommunication
{
private byte [] nativeStruct;
private String host;
private String dbname;
private String dbroot;
private String pgm;
public final static JdbcCommFactory factory = new JdbcCommFactory () {
public JdbcCommunication open(String host, String dbname, Properties property) throws RTEException {
return new NativeComm (host, dbname);
}
public JdbcCommunication xopen(String host,
String db,
String dbroot,
String pgm,
Properties properties)
throws RTEException
{
return new NativeComm (host, db, dbroot, pgm);
}
};
/**
* creates a new NativeComm
*/
public
NativeComm (
String host,
String dbname)
throws RTEException
{
this.host = host;
this.dbname = dbname;
this.connect ();
}
/**
* creates a new NativeComm
*/
public
NativeComm (
String host,
String dbname,
String dbroot,
String pgm)
throws RTEException
{
this.host = host;
this.dbname = dbname;
this.dbroot= dbroot;
this.pgm = pgm;
this.connectX ();
}
/**
*
*/
public native boolean isChallengeResponseSupportedNative() throws SQLException ;
public native void
connect ()
throws RTEException;
public native void
connectX ()
throws RTEException;
/**
* cancels a pending request.
*/
public native void cancel () throws java.sql.SQLException;
/**
* gets a new request packet.
* @return StructuredMem
*/
public native StructuredMem getRequestPacket ();
/**
* test whether the connection is still valid.
* @return boolean
*/
public native boolean isConnected ();
/**
* blocks while waiting for a reply
* @return StructuredMem
* @exception com.sap.dbtech.rte.comm.RTEException.
*/
public native StructuredMem receive () throws RTEException;
/**
* tries to reconnect after a timeout.
* @exception com.sap.dbtech.rte.comm.RTEException.
*/
public native void reconnect () throws RTEException;
/**
* closes the connection.
*/
public native void release ();
/**
* send a new request to the server.
* @param userPacket StructuredMem
* @param len int
* @exception com.sap.dbtech.rte.comm.RTEException.
*/
public void request (StructuredMem userPacket, int len)
throws RTEException
{
this.rawRequest (userPacket. getBytes (0, len), len);
}
/**
* send a new request to the server.
* @param userPacket byte []
* @param len int
* @exception com.sap.dbtech.rte.comm.RTEException.
*/
public native void rawRequest (byte [] userPacket, int len) throws RTEException;
/**
*
*/
public void
finalize ()
{
this.release ();
}
/* (non-Javadoc)
* @see com.sap.dbtech.rte.comm.JdbcCommunication#isChallengeResponseSupported()
*/
public boolean isChallengeResponseSupported() throws SQLException {
try {
return isChallengeResponseSupportedNative();
} catch (java.lang.UnsatisfiedLinkError e) {
return false;
}
}
}
|