use of com.mysql.cj.exceptions.FeatureNotAvailableException in project ABC by RuiPinto96274.
the class NativeProtocol method negotiateSSLConnection.
/**
* Negotiates the SSL communications channel used when connecting
* to a MySQL server that understands SSL.
*/
@Override
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), null);
}
long clientParam = this.serverSession.getClientParam();
NativePacketPayload packet = new NativePacketPayload(SSL_REQUEST_LENGTH);
packet.writeInteger(IntegerDataType.INT4, clientParam);
packet.writeInteger(IntegerDataType.INT4, NativeConstants.MAX_PACKET_SIZE);
packet.writeInteger(IntegerDataType.INT1, this.serverSession.getCharsetSettings().configurePreHandshake(false));
// Set of bytes reserved for future use.
packet.writeBytes(StringLengthDataType.STRING_FIXED, new byte[23]);
send(packet, packet.getPosition());
try {
this.socketConnection.performTlsHandshake(this.serverSession, this.log);
// i/o streams were replaced, build new packet sender/reader
this.packetSender = new SimplePacketSender(this.socketConnection.getMysqlOutput());
this.packetReader = new SimplePacketReader(this.socketConnection, this.maxAllowedPacket);
} catch (FeatureNotAvailableException nae) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), nae);
} catch (IOException ioEx) {
throw ExceptionFactory.createCommunicationsException(this.propertySet, this.serverSession, this.getPacketSentTimeHolder(), this.getPacketReceivedTimeHolder(), ioEx, getExceptionInterceptor());
}
}
use of com.mysql.cj.exceptions.FeatureNotAvailableException in project ABC by RuiPinto96274.
the class XProtocol method negotiateSSLConnection.
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException();
}
if (!((XServerCapabilities) this.serverSession.getCapabilities()).hasCapability(XServerCapabilities.KEY_TLS)) {
throw new CJCommunicationsException("A secure connection is required but the server is not configured with SSL.");
}
// the message reader is async and is always "reading". we need to stop it to use the socket for the TLS handshake
this.reader.stopAfterNextMessage();
Map<String, Object> tlsCapabilities = new HashMap<>();
tlsCapabilities.put(XServerCapabilities.KEY_TLS, true);
sendCapabilities(tlsCapabilities);
try {
this.socketConnection.performTlsHandshake(null, this.log);
} catch (SSLParamsException | FeatureNotAvailableException | IOException e) {
throw new CJCommunicationsException(e);
}
try {
this.sender = new SyncMessageSender(this.socketConnection.getMysqlOutput());
this.reader = new SyncMessageReader(this.socketConnection.getMysqlInput(), this);
} catch (IOException e) {
throw new XProtocolError(e.getMessage(), e);
}
}
use of com.mysql.cj.exceptions.FeatureNotAvailableException in project ABC by RuiPinto96274.
the class CallableStatement method registerOutParameter.
@Override
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
try {
MysqlType mt = MysqlType.getByJdbcType(sqlType);
registerOutParameter(parameterIndex, mt);
} catch (FeatureNotAvailableException nae) {
throw SQLError.createSQLFeatureNotSupportedException(Messages.getString("Statement.UnsupportedSQLType") + JDBCType.valueOf(sqlType), MysqlErrorNumbers.SQL_STATE_DRIVER_NOT_CAPABLE, getExceptionInterceptor());
}
}
use of com.mysql.cj.exceptions.FeatureNotAvailableException in project JavaSegundasQuintas by ecteruel.
the class NativeProtocol method negotiateSSLConnection.
/**
* Negotiates the SSL communications channel used when connecting
* to a MySQL server that understands SSL.
*/
@Override
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), null);
}
long clientParam = this.serverSession.getClientParam();
NativePacketPayload packet = new NativePacketPayload(SSL_REQUEST_LENGTH);
packet.writeInteger(IntegerDataType.INT4, clientParam);
packet.writeInteger(IntegerDataType.INT4, NativeConstants.MAX_PACKET_SIZE);
packet.writeInteger(IntegerDataType.INT1, this.serverSession.getCharsetSettings().configurePreHandshake(false));
// Set of bytes reserved for future use.
packet.writeBytes(StringLengthDataType.STRING_FIXED, new byte[23]);
send(packet, packet.getPosition());
try {
this.socketConnection.performTlsHandshake(this.serverSession, this.log);
// i/o streams were replaced, build new packet sender/reader
this.packetSender = new SimplePacketSender(this.socketConnection.getMysqlOutput());
this.packetReader = new SimplePacketReader(this.socketConnection, this.maxAllowedPacket);
} catch (FeatureNotAvailableException nae) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), nae);
} catch (IOException ioEx) {
throw ExceptionFactory.createCommunicationsException(this.propertySet, this.serverSession, this.getPacketSentTimeHolder(), this.getPacketReceivedTimeHolder(), ioEx, getExceptionInterceptor());
}
}
use of com.mysql.cj.exceptions.FeatureNotAvailableException in project JavaSegundasQuintas by ecteruel.
the class SessionTest method sqlUpdate.
@Test
public void sqlUpdate() {
SqlStatement stmt = this.session.sql("set @cjTestVar = 1");
SqlResult res = stmt.execute();
assertFalse(res.hasData());
assertEquals(0, res.getAffectedItemsCount());
assertEquals(null, res.getAutoIncrementValue());
assertEquals(0, res.getWarningsCount());
assertFalse(res.getWarnings().hasNext());
// TODO SqlUpdateResult throws FeatureNotAvailableException("Not a multi-result");
// res.nextResult();
assertThrows(FeatureNotAvailableException.class, "No data", new Callable<Void>() {
public Void call() throws Exception {
res.fetchAll();
return null;
}
});
assertThrows(FeatureNotAvailableException.class, "No data", new Callable<Void>() {
public Void call() throws Exception {
res.next();
return null;
}
});
assertThrows(FeatureNotAvailableException.class, "No data", new Callable<Void>() {
public Void call() throws Exception {
res.hasNext();
return null;
}
});
assertThrows(FeatureNotAvailableException.class, "No data", new Callable<Void>() {
public Void call() throws Exception {
res.getColumnCount();
return null;
}
});
assertThrows(FeatureNotAvailableException.class, "No data", new Callable<Void>() {
public Void call() throws Exception {
res.getColumns();
return null;
}
});
assertThrows(FeatureNotAvailableException.class, "No data", new Callable<Void>() {
public Void call() throws Exception {
res.getColumnNames();
return null;
}
});
assertThrows(FeatureNotAvailableException.class, "No data", new Callable<Void>() {
public Void call() throws Exception {
res.count();
return null;
}
});
}
Aggregations