idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
29,500
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 val . substring ( ( int ) ...
Get sub string .
29,501
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 ( ( int ) po...
Returns a Reader object that contains a partial Clob value starting with the character specified by pos which is length characters in length .
29,502
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 ) ; }
Set character stream .
29,503
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 ( ) ) ; } else if ( ...
Convert character position into byte position in UTF8 byte array .
29,504
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 ( ) ; }
Set String .
29,505
public long length ( ) { long len = 0 ; int pos = offset ; for ( ; len < length && data [ pos ] >= 0 ; ) { len ++ ; pos ++ ; } while ( pos < offset + length ) { byte firstByte = data [ pos ++ ] ; if ( firstByte < 0 ) { if ( firstByte >> 5 != - 2 || ( firstByte & 30 ) == 0 ) { if ( firstByte >> 4 == - 2 ) { if ( pos + 1...
Return character length of the Clob . Assume UTF8 encoding .
29,506
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 . en...
Search aliases corresponding to algorithms and issuers .
29,507
@ SuppressWarnings ( "unchecked" ) public static SocketHandlerFunction getSocketHandler ( ) { try { Platform . getOSType ( ) ; return ( urlParser , host ) -> { if ( urlParser . getOptions ( ) . pipe != null ) { return new NamedPipeSocket ( host , urlParser . getOptions ( ) . pipe ) ; } else if ( urlParser . getOptions ...
Create socket according to options . In case of compilation ahead of time will throw an error if dependencies found then use default socket implementation .
29,508
public void blockTillTerminated ( ) { while ( ! runState . compareAndSet ( State . IDLE , State . REMOVED ) ) { LockSupport . parkNanos ( TimeUnit . MILLISECONDS . toNanos ( 10 ) ) ; if ( Thread . currentThread ( ) . isInterrupted ( ) ) { runState . set ( State . REMOVED ) ; return ; } } }
Unschedule next launched and wait for the current task to complete before closing it .
29,509
public void unscheduleTask ( ) { if ( unschedule . compareAndSet ( false , true ) ) { scheduledFuture . cancel ( false ) ; scheduledFuture = null ; } }
Unschedule task if active and cancel thread to inform it must be interrupted in a proper way .
29,510
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 ; } return S...
Get generated Keys .
29,511
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 ) getInternalTinyInt ( co...
Get BigDecimal from raw binary format .
29,512
@ 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 timestamp = getInternalTimestamp...
Get date from raw binary format .
29,513
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 , timeZone ) ; return ( ...
Get time from raw binary format .
29,514
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 [ ] dataBit = new byte [ length ] ; Sy...
Get Object from raw binary format .
29,515
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 SMALLINT : case YEAR : return getI...
Get boolean from raw binary format .
29,516
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 ) ; break ; case SMALLINT : case YEAR : ...
Get byte from raw binary format .
29,517
public String getInternalTimeString ( ColumnInformation columnInfo ) { if ( lastValueWasNull ( ) ) { return null ; } if ( length == 0 ) { if ( columnInfo . getDecimals ( ) == 0 ) { return "00:00:00" ; } else { StringBuilder value = new StringBuilder ( "00:00:00." ) ; int decimal = columnInfo . getDecimals ( ) ; while (...
Get Time in string format from raw binary format .
29,518
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 ( ) . getSqlType ( ) ) { ca...
Get ZonedDateTime from raw binary format .
29,519
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 ( ) ) { case Types . TIME : int ...
Get LocalTime from raw binary format .
29,520
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 ( "MariaDbPool-maxTimeoutIdle-che...
Get existing pool for a configuration . Create it if doesn t exists .
29,521
public static void remove ( Pool pool ) { if ( poolMap . containsKey ( pool . getUrlParser ( ) ) ) { synchronized ( poolMap ) { if ( poolMap . containsKey ( pool . getUrlParser ( ) ) ) { poolMap . remove ( pool . getUrlParser ( ) ) ; shutdownExecutor ( ) ; } } } }
Remove pool .
29,522
public static void close ( ) { synchronized ( poolMap ) { for ( Pool pool : poolMap . values ( ) ) { try { pool . close ( ) ; } catch ( InterruptedException exception ) { } } shutdownExecutor ( ) ; poolMap . clear ( ) ; } }
Close all pools .
29,523
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 exception ) { } poolMap . r...
Closing a pool with name defined in url .
29,524
public synchronized int read ( byte [ ] externalBuf , int off , int len ) throws IOException { if ( len == 0 ) { return 0 ; } int totalReads = 0 ; while ( true ) { if ( end - pos <= 0 ) { if ( len - totalReads >= buf . length ) { int reads = super . read ( externalBuf , off + totalReads , len - totalReads ) ; if ( read...
Returing byte array from cache of reading socket if needed .
29,525
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 ; }
Fill buffer with required length or available bytes .
29,526
public void checkClientTrusted ( X509Certificate [ ] x509Certificates , String string ) throws CertificateException { if ( trustManager == null ) { return ; } trustManager . checkClientTrusted ( x509Certificates , string ) ; }
Check client trusted .
29,527
private void addConnectionRequest ( ) { if ( totalConnection . get ( ) < options . maxPoolSize && poolState . get ( ) == POOL_STATE_OK ) { connectionAppender . prestartCoreThread ( ) ; connectionAppenderQueue . offer ( ( ) -> { if ( ( totalConnection . get ( ) < options . minPoolSize || pendingRequestNumber . get ( ) >...
Add new connection if needed . Only one thread create new connection so new connection request will wait to newly created connection or for a released connection .
29,528
private void removeIdleTimeoutConnection ( ) { Iterator < MariaDbPooledConnection > iterator = idleConnections . descendingIterator ( ) ; MariaDbPooledConnection item ; while ( iterator . hasNext ( ) ) { item = iterator . next ( ) ; long idleTime = System . nanoTime ( ) - item . getLastUsed ( ) . get ( ) ; boolean time...
Removing idle connection . Close them and recreate connection to reach minimal number of connection .
29,529
private void addConnection ( ) throws SQLException { Protocol protocol = Utils . retrieveProxy ( urlParser , globalInfo ) ; MariaDbConnection connection = new MariaDbConnection ( protocol ) ; MariaDbPooledConnection pooledConnection = createPoolConnection ( connection ) ; if ( options . staticGlobal ) { if ( globalInfo...
Create new connection .
29,530
private MariaDbPooledConnection getIdleConnection ( long timeout , TimeUnit timeUnit ) throws InterruptedException { while ( true ) { MariaDbPooledConnection item = ( timeout == 0 ) ? idleConnections . pollFirst ( ) : idleConnections . pollFirst ( timeout , timeUnit ) ; if ( item != null ) { MariaDbConnection connectio...
Get an existing idle connection in pool .
29,531
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 ) : pass...
Get new connection from pool if user and password correspond to pool . If username and password are different from pool will return a dedicated connection .
29,532
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 , TimeUnit . SECONDS...
Close pool and underlying connections .
29,533
public void addToBlacklist ( HostAddress hostAddress ) { if ( hostAddress != null && ! isExplicitClosed ( ) ) { blacklist . putIfAbsent ( hostAddress , System . nanoTime ( ) ) ; } }
After a failover put the hostAddress in a static list so the other connection will not take this host in account for a time .
29,534
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 . NANOSECOND...
Permit to remove Host to blacklist after loadBalanceBlacklistTimeout seconds .
29,535
public boolean setMasterHostFail ( ) { if ( masterHostFail . compareAndSet ( false , true ) ) { masterHostFailNanos = System . nanoTime ( ) ; currentConnectionAttempts . set ( 0 ) ; return true ; } return false ; }
Set master fail variables .
29,536
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 ] instanceof Str...
After a failover that has bean done relaunch the operation that was in progress . In case of special operation that crash server doesn t relaunched it ;
29,537
public boolean isQueryRelaunchable ( Method method , Object [ ] args ) { if ( method != null ) { switch ( method . getName ( ) ) { case "executeQuery" : if ( ! ( ( Boolean ) args [ 0 ] ) ) { return true ; } if ( args [ 2 ] instanceof String ) { return ( ( String ) args [ 2 ] ) . toUpperCase ( Locale . ROOT ) . startsWi...
Check if query can be re - executed .
29,538
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 . lock . unlock ...
When switching between 2 connections report existing connection parameter to the new used connection .
29,539
public void throwFailoverMessage ( HostAddress failHostAddress , boolean wasMaster , SQLException queryException , boolean reconnected ) throws SQLException { String firstPart = "Communications link failure with " + ( wasMaster ? "primary" : "secondary" ) + ( ( failHostAddress != null ) ? " host " + failHostAddress . h...
Throw a human readable message after a failoverException .
29,540
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 : return zeroFillingIfNeeded ...
Get String from raw text format .
29,541
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 ; }
Get int from raw text format .
29,542
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 : case FLOAT : case DOUBLE : case DECIMAL ...
Get float from raw text format .
29,543
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 ) ) ; }
Get BigDecimal from raw text format .
29,544
@ 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 } ; int partIdx = 0 ...
Get date from raw text format .
29,545
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 timestamp = getIntern...
Get time from raw text format .
29,546
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" . equals ( ...
Get boolean from raw text format .
29,547
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 ; }
Get byte from raw text format .
29,548
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 ; }
Get short from raw text format .
29,549
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 . useLega...
Get Time in string format from raw text format .
29,550
public BigInteger getInternalBigInteger ( ColumnInformation columnInfo ) { if ( lastValueWasNull ( ) ) { return null ; } return new BigInteger ( new String ( buf , pos , length , StandardCharsets . UTF_8 ) ) ; }
Get BigInteger format from raw text format .
29,551
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 , length , StandardCharsets...
Get ZonedDateTime format from raw text format .
29,552
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 ( ) ; if ( zoneId instanceof Z...
Get OffsetTime format from raw text format .
29,553
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 , StandardCharsets . UTF_8 ) ; switch ( ...
Get LocalTime format from raw text format .
29,554
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 , StandardCharsets . UTF_8 ) ; switch ( ...
Get LocalDate format from raw text format .
29,555
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 ( "Could not connect to " + curren...
Connect to currentHost .
29,556
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 ( ) ; if ( options . localSocketAddress != null ) { InetSoc...
Connect the client and perform handshake .
29,557
private void sendPipelineCheckMaster ( ) throws IOException { if ( urlParser . getHaMode ( ) == HaMode . AURORA ) { writer . startPacket ( 0 ) ; writer . write ( COM_QUERY ) ; writer . write ( IS_MASTER_QUERY ) ; writer . flush ( ) ; } }
Send query to identify if server is master .
29,558
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...
Set ssl socket cipher according to options .
29,559
public boolean versionGreaterOrEqual ( int major , int minor , int patch ) { if ( this . majorVersion > major ) { return true ; } if ( this . majorVersion < major ) { return false ; } if ( this . minorVersion > minor ) { return true ; } if ( this . minorVersion < minor ) { return false ; } return this . patchVersion >=...
Utility method to check if database version is greater than parameters .
29,560
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 ( pa...
Send password in clear text to server .
29,561
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 ; } else if ( length < 65536 ) { totalLeng...
Create Buffer with Text protocol values .
29,562
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 =...
Parse url connection string with additional properties .
29,563
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 present in the url " + url ) ...
Parses the connection URL in order to set the UrlParser instance with all the information provided through the URL .
29,564
public UrlParser auroraPipelineQuirks ( ) { boolean disablePipeline = isAurora ( ) ; if ( options . useBatchMultiSend == null ) { options . useBatchMultiSend = disablePipeline ? Boolean . FALSE : Boolean . TRUE ; } if ( options . usePipelineAuth == null ) { options . usePipelineAuth = disablePipeline ? Boolean . FALSE ...
Permit to set parameters not forced . if options useBatchMultiSend and usePipelineAuth are not explicitly set in connection string value will default to true or false according if aurora detection .
29,565
public boolean removeEldestEntry ( Map . Entry eldest ) { boolean mustBeRemoved = this . size ( ) > maxSize ; if ( mustBeRemoved ) { ServerPrepareResult serverPrepareResult = ( ( ServerPrepareResult ) eldest . getValue ( ) ) ; serverPrepareResult . setRemoveFromCache ( ) ; if ( serverPrepareResult . canBeDeallocate ( )...
Remove eldestEntry .
29,566
public synchronized ServerPrepareResult put ( String key , ServerPrepareResult result ) { ServerPrepareResult cachedServerPrepareResult = super . get ( key ) ; if ( cachedServerPrepareResult != null && cachedServerPrepareResult . incrementShareCounter ( ) ) { return cachedServerPrepareResult ; } result . setAddToCache ...
Associates the specified value with the specified key in this map . If the map previously contained a mapping for the key the existing cached prepared result shared counter will be incremented .
29,567
public void authenticate ( final PacketOutputStream out , final PacketInputStream in , final AtomicInteger sequence , final String servicePrincipalName , final String mechanisms ) throws IOException { IWindowsSecurityContext clientContext = WindowsSecurityContextImpl . getCurrent ( mechanisms , servicePrincipalName ) ;...
Process native windows GSS plugin authentication .
29,568
public static void send ( final PacketOutputStream pos ) { try { pos . startPacket ( 0 ) ; pos . write ( Packet . COM_QUIT ) ; pos . flush ( ) ; } catch ( IOException ioe ) { } }
Send close stream to server .
29,569
public void flush ( ) throws IOException { flushBuffer ( true ) ; out . flush ( ) ; if ( buf . length > SMALL_BUFFER_SIZE && cmdLength * 2 < buf . length ) { buf = new byte [ SMALL_BUFFER_SIZE ] ; } if ( cmdLength >= maxAllowedPacket ) { throw new MaxAllowedPacketException ( "query size (" + cmdLength + ") is >= to max...
Send packet to socket .
29,570
public void checkMaxAllowedLength ( int length ) throws MaxAllowedPacketException { if ( cmdLength + length >= maxAllowedPacket && cmdLength == 0 ) { throw new MaxAllowedPacketException ( "query size (" + ( cmdLength + length ) + ") is >= to max_allowed_packet (" + maxAllowedPacket + ")" , false ) ; } }
Count query size . If query size is greater than max_allowed_packet and nothing has been already send throw an exception to avoid having the connection closed .
29,571
public void writeShort ( short value ) throws IOException { if ( 2 > buf . length - pos ) { 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 ) ( value >> 8 ) ; pos += 2 ; }
Write short value into buffer . flush buffer if too small .
29,572
public void writeInt ( int value ) throws IOException { if ( 4 > buf . length - pos ) { 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 ) ; return ; } buf [ pos ] = ( byte...
Write int value into buffer . flush buffer if too small .
29,573
public void writeLong ( long value ) throws IOException { if ( 8 > buf . length - pos ) { 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 ) ( value >> 32 ) ; arr [ 5 ] = ( ...
Write long value into buffer . flush buffer if too small .
29,574
public void writeBytes ( byte value , int len ) throws IOException { if ( len > buf . length - pos ) { 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 ; } pos += len ; }
Write byte value len times into buffer . flush buffer if too small .
29,575
public void write ( int value ) throws IOException { if ( pos >= buf . length ) { if ( pos >= getMaxPacketLength ( ) && ! bufferContainDataAfterMark ) { flushBuffer ( false ) ; } else { growBuffer ( 1 ) ; } } buf [ pos ++ ] = ( byte ) value ; }
Write byte into buffer flush buffer to socket if needed .
29,576
public void write ( byte [ ] arr , int off , int len ) throws IOException { if ( len > buf . length - pos ) { if ( buf . length != getMaxPacketLength ( ) ) { growBuffer ( len ) ; } if ( len > buf . length - pos ) { if ( mark != - 1 ) { growBuffer ( len ) ; if ( mark != - 1 ) { flushBufferStopAtMark ( ) ; } } else { int...
Write byte array to buffer . If buffer is full flush socket .
29,577
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 , d...
Write reader into socket .
29,578
public void writeBytesEscaped ( byte [ ] bytes , int len , boolean noBackslashEscapes ) throws IOException { if ( len * 2 > buf . length - pos ) { if ( buf . length != getMaxPacketLength ( ) ) { growBuffer ( len * 2 ) ; } if ( len * 2 > buf . length - pos ) { if ( mark != - 1 ) { growBuffer ( len * 2 ) ; if ( mark != -...
Write escape bytes to socket .
29,579
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 ; }
Flush to last mark .
29,580
public byte [ ] resetMark ( ) { mark = - 1 ; if ( bufferContainDataAfterMark ) { byte [ ] data = Arrays . copyOfRange ( buf , initialPacketPos ( ) , pos ) ; startPacket ( 0 ) ; bufferContainDataAfterMark = false ; return data ; } return null ; }
Reset mark flag and send bytes after mark flag .
29,581
public static DynamicSizedSchedulerInterface getScheduler ( int initialThreadCount , String poolName , int maximumPoolSize ) { return getSchedulerProvider ( ) . getScheduler ( initialThreadCount , poolName , maximumPoolSize ) ; }
Get a Dynamic sized scheduler directly with the current set provider .
29,582
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 ; } int usedTimeout = timeout == 0 ? 100 : timeout ; long initialNano = Sys...
Name pipe connection .
29,583
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 ) ; }
Write object to buffer for text protocol .
29,584
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 ; }
Update information after a failover .
29,585
public int isNullable ( final int column ) throws SQLException { if ( ( getColumnInformation ( column ) . getFlags ( ) & ColumnFlags . NOT_NULL ) == 0 ) { return ResultSetMetaData . columnNullable ; } else { return ResultSetMetaData . columnNoNulls ; } }
Indicates the nullability of values in the designated column .
29,586
public String getTableName ( final int column ) throws SQLException { if ( returnTableAlias ) { return getColumnInformation ( column ) . getTable ( ) ; } else { return getColumnInformation ( column ) . getOriginalTable ( ) ; } }
Gets the designated column s table name .
29,587
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 . getLength ( ) == 1 && options . tinyInt1...
Retrieves the designated column s SQL type .
29,588
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 ; }
Return new position or - 1 on error
29,589
private String catalogCond ( String columnName , String catalog ) { if ( catalog == null ) { if ( connection . nullCatalogMeansCurrent ) { return "(ISNULL(database()) OR (" + columnName + " = database()))" ; } return "(1 = 1)" ; } if ( catalog . isEmpty ( ) ) { return "(ISNULL(database()) OR (" + columnName + " = datab...
Generate part of the information schema query that restricts catalog names In the driver catalogs is the equivalent to MariaDB schemas .
29,590
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 COLUMN_SIZE, 0 DECIM...
Retrieves a description of the pseudo or hidden columns available in a given table within the specified catalog and schema . Pseudo or hidden columns may not always be stored within a table and are not visible in a ResultSet unless they are specified in the query s outermost SELECT list . Pseudo or hidden columns may n...
29,591
public String getDatabaseProductName ( ) throws SQLException { if ( urlParser . getOptions ( ) . useMysqlMetadata ) { return "MySQL" ; } if ( connection . getProtocol ( ) . isServerMariaDb ( ) && connection . getProtocol ( ) . getServerVersion ( ) . toLowerCase ( Locale . ROOT ) . contains ( "mariadb" ) ) { return "Mar...
Return Server type . MySQL or MariaDB . MySQL can be forced for compatibility with option useMysqlMetadata
29,592
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 DUAL WHERE 1 = 0" ; return executeQuery ( sql ) ; }
Retrieves a description of a table s columns that are automatically updated when any value in a row is updated . They are unordered .
29,593
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 X509TrustManager [ ] { ne...
Create an SSL factory according to connection string options .
29,594
public void clearBatch ( ) { parameterList . clear ( ) ; hasLongData = false ; this . parameters = new ParameterHolder [ prepareResult . getParamCount ( ) ] ; }
Clear batch .
29,595
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 . isMa...
Choose better way to execute queries according to query and options .
29,596
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 " + parameterIndex +...
Set parameter .
29,597
public void close ( ) throws SQLException { super . close ( ) ; if ( connection == null || connection . pooledConnection == null || connection . pooledConnection . noStmtEventListeners ( ) ) { return ; } connection . pooledConnection . fireStatementClosed ( this ) ; connection = null ; }
Close prepared statement maybe fire closed - statement events
29,598
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 ...
Write an empty packet .
29,599
public static AuthenticationPlugin processAuthPlugin ( String plugin , String password , byte [ ] authData , Options options ) throws SQLException { switch ( plugin ) { case MYSQL_NATIVE_PASSWORD : return new NativePasswordPlugin ( password , authData , options . passwordCharacterEncoding ) ; case MYSQL_OLD_PASSWORD : ...
Process AuthenticationSwitch .