code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public String getSubString(long pos, int length) throws SQLException {
if (pos < 1) {
throw ExceptionMapper.getSqlException("position must be >= 1");
}
if (length < 0) {
throw ExceptionMapper.getSqlException("length must be > 0");
}
try {
String val = toString();
return va... | java |
public Reader getCharacterStream(long pos, long length) throws SQLException {
String val = toString();
if (val.length() < (int) pos - 1 + length) {
throw ExceptionMapper
.getSqlException("pos + length is greater than the number of characters in the Clob");
}
String sub = val.substring((i... | java |
public Writer setCharacterStream(long pos) throws SQLException {
int bytePosition = utf8Position((int) pos - 1);
OutputStream stream = setBinaryStream(bytePosition + 1);
return new OutputStreamWriter(stream, StandardCharsets.UTF_8);
} | java |
private int utf8Position(int charPosition) {
int pos = offset;
for (int i = 0; i < charPosition; i++) {
int byteValue = data[pos] & 0xff;
if (byteValue < 0x80) {
pos += 1;
} else if (byteValue < 0xC2) {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException... | java |
public int setString(long pos, String str) throws SQLException {
int bytePosition = utf8Position((int) pos - 1);
super.setBytes(bytePosition + 1 - offset, str.getBytes(StandardCharsets.UTF_8));
return str.length();
} | java |
@Override
public long length() {
//The length of a character string is the number of UTF-16 units (not the number of characters)
long len = 0;
int pos = offset;
//set ASCII (<= 127 chars)
for (; len < length && data[pos] >= 0; ) {
len++;
pos++;
}
//multi-bytes UTF-8
while... | java |
private ArrayList<String> searchAccurateAliases(String[] keyTypes, Principal[] issuers) {
if (keyTypes == null || keyTypes.length == 0) {
return null;
}
ArrayList<String> accurateAliases = new ArrayList<>();
for (Map.Entry<String, KeyStore.PrivateKeyEntry> mapEntry : privateKeyHash.entrySet()) {
... | java |
@SuppressWarnings("unchecked")
public static SocketHandlerFunction getSocketHandler() {
try {
//forcing use of JNA to ensure AOT compilation
Platform.getOSType();
return (urlParser, host) -> {
if (urlParser.getOptions().pipe != null) {
return new NamedPipeSocket(host, urlParse... | java |
public void blockTillTerminated() {
while (!runState.compareAndSet(State.IDLE, State.REMOVED)) {
// wait and retry
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
if (Thread.currentThread().isInterrupted()) {
runState.set(State.REMOVED);
return;
}
}
} | java |
public void unscheduleTask() {
if (unschedule.compareAndSet(false, true)) {
scheduledFuture.cancel(false);
scheduledFuture = null;
}
} | java |
public ResultSet getGeneratedKeys(Protocol protocol) {
if (insertId == 0) {
return SelectResultSet.createEmptyResultSet();
}
if (updateCount > 1) {
long[] insertIds = new long[(int) updateCount];
for (int i = 0; i < updateCount; i++) {
insertIds[i] = insertId + i * autoIncrement;
... | java |
public BigDecimal getInternalBigDecimal(ColumnInformation columnInfo) throws SQLException {
if (lastValueWasNull()) {
return null;
}
switch (columnInfo.getColumnType()) {
case BIT:
return BigDecimal.valueOf(parseBit());
case TINYINT:
return BigDecimal.valueOf((long) getInt... | java |
@SuppressWarnings("deprecation")
public Date getInternalDate(ColumnInformation columnInfo, Calendar cal, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
switch (columnInfo.getColumnType()) {
case TIMESTAMP:
case DATETIME:
Timestamp timestam... | java |
public Time getInternalTime(ColumnInformation columnInfo, Calendar cal, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
switch (columnInfo.getColumnType()) {
case TIMESTAMP:
case DATETIME:
Timestamp ts = getInternalTimestamp(columnInfo, cal, ... | java |
public Object getInternalObject(ColumnInformation columnInfo, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
switch (columnInfo.getColumnType()) {
case BIT:
if (columnInfo.getLength() == 1) {
return buf[pos] != 0;
}
byte... | java |
public boolean getInternalBoolean(ColumnInformation columnInfo) throws SQLException {
if (lastValueWasNull()) {
return false;
}
switch (columnInfo.getColumnType()) {
case BIT:
return parseBit() != 0;
case TINYINT:
return getInternalTinyInt(columnInfo) != 0;
case SMALL... | java |
public byte getInternalByte(ColumnInformation columnInfo) throws SQLException {
if (lastValueWasNull()) {
return 0;
}
long value;
switch (columnInfo.getColumnType()) {
case BIT:
value = parseBit();
break;
case TINYINT:
value = getInternalTinyInt(columnInfo);
... | java |
public String getInternalTimeString(ColumnInformation columnInfo) {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
// binary send 00:00:00 as 0.
if (columnInfo.getDecimals() == 0) {
return "00:00:00";
} else {
StringBuilder value = new StringBuilder("00:0... | java |
public ZonedDateTime getInternalZonedDateTime(ColumnInformation columnInfo, Class clazz,
TimeZone timeZone) throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
switch (columnInfo.getColumnType... | java |
public LocalTime getInternalLocalTime(ColumnInformation columnInfo, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
switch (columnInfo.getColumnType().getSqlType()) {
... | java |
public static Pool retrievePool(UrlParser urlParser) {
if (!poolMap.containsKey(urlParser)) {
synchronized (poolMap) {
if (!poolMap.containsKey(urlParser)) {
if (poolExecutor == null) {
poolExecutor = new ScheduledThreadPoolExecutor(1,
new MariaDbThreadFactory("Ma... | java |
public static void remove(Pool pool) {
if (poolMap.containsKey(pool.getUrlParser())) {
synchronized (poolMap) {
if (poolMap.containsKey(pool.getUrlParser())) {
poolMap.remove(pool.getUrlParser());
shutdownExecutor();
}
}
}
} | java |
public static void close() {
synchronized (poolMap) {
for (Pool pool : poolMap.values()) {
try {
pool.close();
} catch (InterruptedException exception) {
//eat
}
}
shutdownExecutor();
poolMap.clear();
}
} | java |
public static void close(String poolName) {
if (poolName == null) {
return;
}
synchronized (poolMap) {
for (Pool pool : poolMap.values()) {
if (poolName.equals(pool.getUrlParser().getOptions().poolName)) {
try {
pool.close();
} catch (InterruptedException ... | java |
public synchronized int read(byte[] externalBuf, int off, int len) throws IOException {
if (len == 0) {
return 0;
}
int totalReads = 0;
while (true) {
//read
if (end - pos <= 0) {
if (len - totalReads >= buf.length) {
//buffer length is less than asked byte and buf... | java |
private void fillBuffer(int minNeededBytes) throws IOException {
int lengthToReallyRead = Math.min(BUF_SIZE, Math.max(super.available(), minNeededBytes));
end = super.read(buf, 0, lengthToReallyRead);
pos = 0;
} | java |
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String string)
throws CertificateException {
if (trustManager == null) {
return;
}
trustManager.checkClientTrusted(x509Certificates, string);
} | java |
private void addConnectionRequest() {
if (totalConnection.get() < options.maxPoolSize && poolState.get() == POOL_STATE_OK) {
//ensure to have one worker if was timeout
connectionAppender.prestartCoreThread();
connectionAppenderQueue.offer(() -> {
if ((totalConnection.get() < options.minP... | java |
private void removeIdleTimeoutConnection() {
//descending iterator since first from queue are the first to be used
Iterator<MariaDbPooledConnection> iterator = idleConnections.descendingIterator();
MariaDbPooledConnection item;
while (iterator.hasNext()) {
item = iterator.next();
long id... | java |
private void addConnection() throws SQLException {
//create new connection
Protocol protocol = Utils.retrieveProxy(urlParser, globalInfo);
MariaDbConnection connection = new MariaDbConnection(protocol);
MariaDbPooledConnection pooledConnection = createPoolConnection(connection);
if (options.static... | java |
private MariaDbPooledConnection getIdleConnection(long timeout, TimeUnit timeUnit)
throws InterruptedException {
while (true) {
MariaDbPooledConnection item =
(timeout == 0) ? idleConnections.pollFirst() : idleConnections.pollFirst(timeout, timeUnit);
if (item != null) {
Ma... | java |
public MariaDbConnection getConnection(String username, String password) throws SQLException {
try {
if ((urlParser.getUsername() != null ? urlParser.getUsername().equals(username)
: username == null)
&& (urlParser.getPassword() != null ? urlParser.getPassword().equals(password)
... | java |
public void close() throws InterruptedException {
synchronized (this) {
Pools.remove(this);
poolState.set(POOL_STATE_CLOSING);
pendingRequestNumber.set(0);
scheduledFuture.cancel(false);
connectionAppender.shutdown();
try {
connectionAppender.awaitTermination(10, TimeUn... | java |
public void addToBlacklist(HostAddress hostAddress) {
if (hostAddress != null && !isExplicitClosed()) {
blacklist.putIfAbsent(hostAddress, System.nanoTime());
}
} | java |
public void resetOldsBlackListHosts() {
long currentTimeNanos = System.nanoTime();
Set<Map.Entry<HostAddress, Long>> entries = blacklist.entrySet();
for (Map.Entry<HostAddress, Long> blEntry : entries) {
long entryNanos = blEntry.getValue();
long durationSeconds = TimeUnit.NANOSECONDS.toSeconds(... | java |
public boolean setMasterHostFail() {
if (masterHostFail.compareAndSet(false, true)) {
masterHostFailNanos = System.nanoTime();
currentConnectionAttempts.set(0);
return true;
}
return false;
} | java |
public HandleErrorResult relaunchOperation(Method method, Object[] args)
throws IllegalAccessException, InvocationTargetException {
HandleErrorResult handleErrorResult = new HandleErrorResult(true);
if (method != null) {
switch (method.getName()) {
case "executeQuery":
if (args[2]... | java |
public boolean isQueryRelaunchable(Method method, Object[] args) {
if (method != null) {
switch (method.getName()) {
case "executeQuery":
if (!((Boolean) args[0])) {
return true; //launched on slave connection
}
if (args[2] instanceof String) {
ret... | java |
public void syncConnection(Protocol from, Protocol to) throws SQLException {
if (from != null) {
proxy.lock.lock();
try {
to.resetStateAfterFailover(from.getMaxRows(), from.getTransactionIsolationLevel(),
from.getDatabase(), from.getAutocommit());
} finally {
proxy.lo... | java |
@Override
public void throwFailoverMessage(HostAddress failHostAddress, boolean wasMaster,
SQLException queryException,
boolean reconnected) throws SQLException {
String firstPart = "Communications link failure with "
+ (wasMaster ? "primary" : "secondary")
+ ((failHostAddress != null)... | java |
public String getInternalString(ColumnInformation columnInfo, Calendar cal, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
switch (columnInfo.getColumnType()) {
case BIT:
return String.valueOf(parseBit());
case DOUBLE:
case FLOAT:
... | java |
public int getInternalInt(ColumnInformation columnInfo) throws SQLException {
if (lastValueWasNull()) {
return 0;
}
long value = getInternalLong(columnInfo);
rangeCheck(Integer.class, Integer.MIN_VALUE, Integer.MAX_VALUE, value, columnInfo);
return (int) value;
} | java |
public float getInternalFloat(ColumnInformation columnInfo) throws SQLException {
if (lastValueWasNull()) {
return 0;
}
switch (columnInfo.getColumnType()) {
case BIT:
return parseBit();
case TINYINT:
case SMALLINT:
case YEAR:
case INTEGER:
case MEDIUMINT:
... | java |
public BigDecimal getInternalBigDecimal(ColumnInformation columnInfo) {
if (lastValueWasNull()) {
return null;
}
if (columnInfo.getColumnType() == ColumnType.BIT) {
return BigDecimal.valueOf(parseBit());
}
return new BigDecimal(new String(buf, pos, length, StandardCharsets.UTF_8));
} | java |
@SuppressWarnings("deprecation")
public Date getInternalDate(ColumnInformation columnInfo, Calendar cal, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
switch (columnInfo.getColumnType()) {
case DATE:
int[] datePart = new int[]{0,0,0};
... | java |
public Time getInternalTime(ColumnInformation columnInfo, Calendar cal, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (columnInfo.getColumnType() == ColumnType.TIMESTAMP
|| columnInfo.getColumnType() == ColumnType.DATETIME) {
Timestamp timest... | java |
public boolean getInternalBoolean(ColumnInformation columnInfo) {
if (lastValueWasNull()) {
return false;
}
if (columnInfo.getColumnType() == ColumnType.BIT) {
return parseBit() != 0;
}
final String rawVal = new String(buf, pos, length, StandardCharsets.UTF_8);
return !("false".equa... | java |
public byte getInternalByte(ColumnInformation columnInfo) throws SQLException {
if (lastValueWasNull()) {
return 0;
}
long value = getInternalLong(columnInfo);
rangeCheck(Byte.class, Byte.MIN_VALUE, Byte.MAX_VALUE, value, columnInfo);
return (byte) value;
} | java |
public short getInternalShort(ColumnInformation columnInfo) throws SQLException {
if (lastValueWasNull()) {
return 0;
}
long value = getInternalLong(columnInfo);
rangeCheck(Short.class, Short.MIN_VALUE, Short.MAX_VALUE, value, columnInfo);
return (short) value;
} | java |
public String getInternalTimeString(ColumnInformation columnInfo) {
if (lastValueWasNull()) {
return null;
}
String rawValue = new String(buf, pos, length, StandardCharsets.UTF_8);
if ("0000-00-00".equals(rawValue)) {
return null;
}
if (options.maximizeMysqlCompatibility && options... | java |
public BigInteger getInternalBigInteger(ColumnInformation columnInfo) {
if (lastValueWasNull()) {
return null;
}
return new BigInteger(new String(buf, pos, length, StandardCharsets.UTF_8));
} | java |
public ZonedDateTime getInternalZonedDateTime(ColumnInformation columnInfo, Class clazz,
TimeZone timeZone) throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
String raw = new String(buf, pos... | java |
public OffsetTime getInternalOffsetTime(ColumnInformation columnInfo, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
ZoneId zoneId = timeZone.toZoneId().normalized();
... | java |
public LocalTime getInternalLocalTime(ColumnInformation columnInfo, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
String raw = new String(buf, pos, length, StandardCha... | java |
public LocalDate getInternalLocalDate(ColumnInformation columnInfo, TimeZone timeZone)
throws SQLException {
if (lastValueWasNull()) {
return null;
}
if (length == 0) {
lastValueNull |= BIT_LAST_FIELD_NULL;
return null;
}
String raw = new String(buf, pos, length, StandardCha... | java |
public void connect() throws SQLException {
if (!isClosed()) {
close();
}
try {
connect((currentHost != null) ? currentHost.host : null,
(currentHost != null) ? currentHost.port : 3306);
} catch (IOException ioException) {
throw ExceptionMapper.connException(
"Coul... | java |
private void connect(String host, int port) throws SQLException, IOException {
try {
socket = Utils.createSocket(urlParser, host);
if (options.socketTimeout != null) {
socket.setSoTimeout(options.socketTimeout);
}
initializeSocketOption();
// Bind the socket to a particular i... | java |
private void sendPipelineCheckMaster() throws IOException {
if (urlParser.getHaMode() == HaMode.AURORA) {
writer.startPacket(0);
writer.write(COM_QUERY);
writer.write(IS_MASTER_QUERY);
writer.flush();
}
} | java |
private void enabledSslCipherSuites(SSLSocket sslSocket) throws SQLException {
if (options.enabledSslCipherSuites != null) {
List<String> possibleCiphers = Arrays.asList(sslSocket.getSupportedCipherSuites());
String[] ciphers = options.enabledSslCipherSuites.split("[,;\\s]+");
for (String cipher :... | java |
public boolean versionGreaterOrEqual(int major, int minor, int patch) {
if (this.majorVersion > major) {
return true;
}
if (this.majorVersion < major) {
return false;
}
/*
* Major versions are equal, compare minor versions
*/
if (this.minorVersion > minor) {
return ... | java |
public Buffer process(PacketOutputStream out, PacketInputStream in, AtomicInteger sequence) throws IOException {
if (password == null || password.isEmpty()) {
out.writeEmptyPacket(sequence.incrementAndGet());
} else {
out.startPacket(sequence.incrementAndGet());
byte[] bytePwd;
if (passw... | java |
public static byte[] create(byte[][] rowDatas, ColumnType[] columnTypes) {
int totalLength = 0;
for (byte[] rowData : rowDatas) {
if (rowData == null) {
totalLength++;
} else {
int length = rowData.length;
if (length < 251) {
totalLength += length + 1;
} el... | java |
public static UrlParser parse(final String url, Properties prop) throws SQLException {
if (url != null
&& (url.startsWith("jdbc:mariadb:") || url.startsWith("jdbc:mysql:") && !url
.contains(DISABLE_MYSQL_URL))) {
UrlParser urlParser = new UrlParser();
parseInternal(urlParser, url, (prop ... | java |
private static void parseInternal(UrlParser urlParser, String url, Properties properties)
throws SQLException {
try {
urlParser.initialUrl = url;
int separator = url.indexOf("//");
if (separator == -1) {
throw new IllegalArgumentException(
"url parsing error : '//' is not... | java |
public UrlParser auroraPipelineQuirks() {
//Aurora has issue with pipelining, depending on network speed.
//Driver must rely on information provided by user : hostname if dns, and HA mode.</p>
boolean disablePipeline = isAurora();
if (options.useBatchMultiSend == null) {
options.useBatchMultiSen... | java |
@Override
public boolean removeEldestEntry(Map.Entry eldest) {
boolean mustBeRemoved = this.size() > maxSize;
if (mustBeRemoved) {
ServerPrepareResult serverPrepareResult = ((ServerPrepareResult) eldest.getValue());
serverPrepareResult.setRemoveFromCache();
if (serverPrepareResult.canBeDeal... | java |
public synchronized ServerPrepareResult put(String key, ServerPrepareResult result) {
ServerPrepareResult cachedServerPrepareResult = super.get(key);
//if there is already some cached data (and not been deallocate), return existing cached data
if (cachedServerPrepareResult != null && cachedServerPrepareResu... | java |
public void authenticate(final PacketOutputStream out, final PacketInputStream in, final AtomicInteger sequence,
final String servicePrincipalName, final String mechanisms) throws IOException {
// initialize a security context on the client
IWindowsSecurityContext clientContext = Win... | java |
public static void send(final PacketOutputStream pos) {
try {
pos.startPacket(0);
pos.write(Packet.COM_QUIT);
pos.flush();
} catch (IOException ioe) {
//eat
}
} | java |
public void flush() throws IOException {
flushBuffer(true);
out.flush();
// if buffer is big, and last query doesn't use at least half of it, resize buffer to default value
if (buf.length > SMALL_BUFFER_SIZE && cmdLength * 2 < buf.length) {
buf = new byte[SMALL_BUFFER_SIZE];
}
if (cmdLen... | java |
public void checkMaxAllowedLength(int length) throws MaxAllowedPacketException {
if (cmdLength + length >= maxAllowedPacket && cmdLength == 0) {
//launch exception only if no packet has been send.
throw new MaxAllowedPacketException("query size (" + (cmdLength + length)
+ ") is >= to max_allow... | java |
public void writeShort(short value) throws IOException {
if (2 > buf.length - pos) {
//not enough space remaining
byte[] arr = new byte[2];
arr[0] = (byte) value;
arr[1] = (byte) (value >> 8);
write(arr, 0, 2);
return;
}
buf[pos] = (byte) value;
buf[pos + 1] = (byte)... | java |
public void writeInt(int value) throws IOException {
if (4 > buf.length - pos) {
//not enough space remaining
byte[] arr = new byte[4];
arr[0] = (byte) value;
arr[1] = (byte) (value >> 8);
arr[2] = (byte) (value >> 16);
arr[3] = (byte) (value >> 24);
write(arr, 0, 4);
... | java |
public void writeLong(long value) throws IOException {
if (8 > buf.length - pos) {
//not enough space remaining
byte[] arr = new byte[8];
arr[0] = (byte) value;
arr[1] = (byte) (value >> 8);
arr[2] = (byte) (value >> 16);
arr[3] = (byte) (value >> 24);
arr[4] = (byte) (valu... | java |
public void writeBytes(byte value, int len) throws IOException {
if (len > buf.length - pos) {
//not enough space remaining
byte[] arr = new byte[len];
Arrays.fill(arr, value);
write(arr, 0, len);
return;
}
for (int i = pos; i < pos + len; i++) {
buf[i] = value;
}
... | java |
public void write(int value) throws IOException {
if (pos >= buf.length) {
if (pos >= getMaxPacketLength() && !bufferContainDataAfterMark) {
//buffer is more than a Packet, must flushBuffer()
flushBuffer(false);
} else {
growBuffer(1);
}
}
buf[pos++] = (byte) value;... | java |
public void write(byte[] arr, int off, int len) throws IOException {
if (len > buf.length - pos) {
if (buf.length != getMaxPacketLength()) {
growBuffer(len);
}
//max buffer size
if (len > buf.length - pos) {
if (mark != -1) {
growBuffer(len);
if (mark !=... | java |
public void write(Reader reader, boolean escape, boolean noBackslashEscapes) throws IOException {
char[] buffer = new char[4096];
int len;
while ((len = reader.read(buffer)) >= 0) {
byte[] data = new String(buffer, 0, len).getBytes("UTF-8");
if (escape) {
writeBytesEscaped(data, data.len... | java |
public void writeBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes)
throws IOException {
if (len * 2 > buf.length - pos) {
//makes buffer bigger (up to 16M)
if (buf.length != getMaxPacketLength()) {
growBuffer(len * 2);
}
//data may be bigger than buffer.
/... | java |
@Override
public void flushBufferStopAtMark() throws IOException {
final int end = pos;
pos = mark;
flushBuffer(true);
out.flush();
startPacket(0);
System.arraycopy(buf, mark, buf, pos, end - mark);
pos += end - mark;
mark = -1;
bufferContainDataAfterMark = true;
} | java |
public byte[] resetMark() {
mark = -1;
if (bufferContainDataAfterMark) {
byte[] data = Arrays.copyOfRange(buf, initialPacketPos(), pos);
startPacket(0);
bufferContainDataAfterMark = false;
return data;
}
return null;
} | java |
public static DynamicSizedSchedulerInterface getScheduler(int initialThreadCount, String poolName,
int maximumPoolSize) {
return getSchedulerProvider().getScheduler(initialThreadCount, poolName, maximumPoolSize);
} | java |
public void connect(SocketAddress endpoint, int timeout) throws IOException {
String filename;
if (host == null || host.equals("localhost")) {
filename = "\\\\.\\pipe\\" + name;
} else {
filename = "\\\\" + host + "\\pipe\\" + name;
}
//use a default timeout of 100ms if no timeout set.
... | java |
public void writeTo(final PacketOutputStream pos) throws IOException {
if (loadedStream == null) {
writeObjectToBytes();
}
pos.write(BINARY_INTRODUCER);
pos.writeBytesEscaped(loadedStream, loadedStream.length, noBackSlashEscapes);
pos.write(QUOTE);
} | java |
public void failover(int statementId, Protocol unProxiedProtocol) {
this.statementId = statementId;
this.unProxiedProtocol = unProxiedProtocol;
this.parameterTypeHeader = new ColumnType[parameters.length];
this.shareCounter = 1;
this.isBeingDeallocate = false;
} | java |
public int isNullable(final int column) throws SQLException {
if ((getColumnInformation(column).getFlags() & ColumnFlags.NOT_NULL) == 0) {
return ResultSetMetaData.columnNullable;
} else {
return ResultSetMetaData.columnNoNulls;
}
} | java |
public String getTableName(final int column) throws SQLException {
if (returnTableAlias) {
return getColumnInformation(column).getTable();
} else {
return getColumnInformation(column).getOriginalTable();
}
} | java |
public int getColumnType(final int column) throws SQLException {
ColumnInformation ci = getColumnInformation(column);
switch (ci.getColumnType()) {
case BIT:
if (ci.getLength() == 1) {
return Types.BIT;
}
return Types.VARBINARY;
case TINYINT:
if (ci.getLengt... | java |
private static int skipWhite(char[] part, int startPos) {
for (int i = startPos; i < part.length; i++) {
if (!Character.isWhitespace(part[i])) {
return i;
}
}
return part.length;
} | java |
private String catalogCond(String columnName, String catalog) {
if (catalog == null) {
/* Treat null catalog as current */
if (connection.nullCatalogMeansCurrent) {
return "(ISNULL(database()) OR (" + columnName + " = database()))";
}
return "(1 = 1)";
}
if (catalog.isEmpty()... | java |
public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern,
String columnNamePattern) throws SQLException {
return connection.createStatement().executeQuery(
"SELECT ' ' TABLE_CAT, ' ' TABLE_SCHEM,"
+ "' ' TABLE_NAME, ' ' COLUMN_NAME, 0 DATA_TYPE, 0 COL... | java |
public String getDatabaseProductName() throws SQLException {
if (urlParser.getOptions().useMysqlMetadata) {
return "MySQL";
}
if (connection.getProtocol().isServerMariaDb()
&& connection.getProtocol().getServerVersion().toLowerCase(Locale.ROOT).contains("mariadb")) {
return "MariaDB"... | java |
public ResultSet getVersionColumns(String catalog, String schema, String table)
throws SQLException {
String sql =
"SELECT 0 SCOPE, ' ' COLUMN_NAME, 0 DATA_TYPE,"
+ " ' ' TYPE_NAME, 0 COLUMN_SIZE, 0 BUFFER_LENGTH,"
+ " 0 DECIMAL_DIGITS, 0 PSEUDO_COLUMN "
+ " FROM DU... | java |
public static SSLSocketFactory getSslSocketFactory(Options options) throws SQLException {
TrustManager[] trustManager = null;
KeyManager[] keyManager = null;
if (options.trustServerCertificate || options.serverSslCert != null
|| options.trustStore != null) {
trustManager = new X509TrustManag... | java |
@Override
public void clearBatch() {
parameterList.clear();
hasLongData = false;
this.parameters = new ParameterHolder[prepareResult.getParamCount()];
} | java |
private void executeInternalBatch(int size) throws SQLException {
executeQueryPrologue(true);
results = new Results(this, 0, true, size, false, resultSetScrollType,
resultSetConcurrency, autoGeneratedKeys, protocol.getAutoIncrementIncrement());
if (protocol
.executeBatchClient(protocol.i... | java |
public void setParameter(final int parameterIndex, final ParameterHolder holder)
throws SQLException {
if (parameterIndex >= 1 && parameterIndex < prepareResult.getParamCount() + 1) {
parameters[parameterIndex - 1] = holder;
} else {
String error = "Could not set parameter at position " + para... | java |
@Override
public void close() throws SQLException {
super.close();
if (connection == null || connection.pooledConnection == null
|| connection.pooledConnection.noStmtEventListeners()) {
return;
}
connection.pooledConnection.fireStatementClosed(this);
connection = null;
} | java |
public void writeEmptyPacket() throws IOException {
buf[0] = (byte) 4;
buf[1] = (byte) 0x00;
buf[2] = (byte) 0x00;
buf[3] = (byte) this.compressSeqNo++;
buf[4] = (byte) 0x00;
buf[5] = (byte) 0x00;
buf[6] = (byte) 0x00;
buf[7] = (byte) 0x00;
buf[8] = (byte) 0x00;
buf[9] = (byte) 0... | java |
public static AuthenticationPlugin processAuthPlugin(String plugin,
String password,
byte[] authData,
Options options)
throws SQLException {
swit... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.