repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DefaultRolloutApprovalStrategy.java | DefaultRolloutApprovalStrategy.isApprovalNeeded | @Override
public boolean isApprovalNeeded(final Rollout rollout) {
final UserDetails userDetails = this.getActor(rollout);
final boolean approvalEnabled = this.tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, Boolean.class).getValue();
return approvalEnabled && userDetails.getAuthorities().stream()
.noneMatch(authority -> SpPermission.APPROVE_ROLLOUT.equals(authority.getAuthority()));
} | java | @Override
public boolean isApprovalNeeded(final Rollout rollout) {
final UserDetails userDetails = this.getActor(rollout);
final boolean approvalEnabled = this.tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, Boolean.class).getValue();
return approvalEnabled && userDetails.getAuthorities().stream()
.noneMatch(authority -> SpPermission.APPROVE_ROLLOUT.equals(authority.getAuthority()));
} | [
"@",
"Override",
"public",
"boolean",
"isApprovalNeeded",
"(",
"final",
"Rollout",
"rollout",
")",
"{",
"final",
"UserDetails",
"userDetails",
"=",
"this",
".",
"getActor",
"(",
"rollout",
")",
";",
"final",
"boolean",
"approvalEnabled",
"=",
"this",
".",
"ten... | Returns true, if rollout approval is enabled and rollout creator doesn't have
approval role. | [
"Returns",
"true",
"if",
"rollout",
"approval",
"is",
"enabled",
"and",
"rollout",
"creator",
"doesn",
"t",
"have",
"approval",
"role",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DefaultRolloutApprovalStrategy.java#L48-L55 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java | DurationField.handleUnparsableDateString | @Override
protected Date handleUnparsableDateString(final String value) throws ConversionException {
try {
return durationFormat.parse(value);
} catch (final ParseException e1) {
try {
return additionalFormat.parse("000000".substring(value.length() <= 6 ? value.length() : 6) + value);
} catch (final ParseException e2) {
// if Parsing is not possible ConversionException is thrown
}
}
throw new ConversionException("input is not in HH:MM:SS format.");
} | java | @Override
protected Date handleUnparsableDateString(final String value) throws ConversionException {
try {
return durationFormat.parse(value);
} catch (final ParseException e1) {
try {
return additionalFormat.parse("000000".substring(value.length() <= 6 ? value.length() : 6) + value);
} catch (final ParseException e2) {
// if Parsing is not possible ConversionException is thrown
}
}
throw new ConversionException("input is not in HH:MM:SS format.");
} | [
"@",
"Override",
"protected",
"Date",
"handleUnparsableDateString",
"(",
"final",
"String",
"value",
")",
"throws",
"ConversionException",
"{",
"try",
"{",
"return",
"durationFormat",
".",
"parse",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"final",
"ParseExcept... | This method is called to handle a non-empty date string from the client
if the client could not parse it as a Date. In the current case two
different parsing schemas are tried. If parsing is not possible a
ConversionException is thrown which marks the DurationField as invalid. | [
"This",
"method",
"is",
"called",
"to",
"handle",
"a",
"non",
"-",
"empty",
"date",
"string",
"from",
"the",
"client",
"if",
"the",
"client",
"could",
"not",
"parse",
"it",
"as",
"a",
"Date",
".",
"In",
"the",
"current",
"case",
"two",
"different",
"pa... | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java#L86-L101 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java | DurationField.setDuration | public void setDuration(@NotNull final Duration duration) {
if (duration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The duaration has to be smaller than 23:59:59.");
}
super.setValue(durationToDate(duration));
} | java | public void setDuration(@NotNull final Duration duration) {
if (duration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The duaration has to be smaller than 23:59:59.");
}
super.setValue(durationToDate(duration));
} | [
"public",
"void",
"setDuration",
"(",
"@",
"NotNull",
"final",
"Duration",
"duration",
")",
"{",
"if",
"(",
"duration",
".",
"compareTo",
"(",
"MAXIMUM_DURATION",
")",
">",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The duaration has to b... | Sets the duration value
@param duration
duration, only values less then 23:59:59 are excepted | [
"Sets",
"the",
"duration",
"value"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java#L148-L153 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java | DurationField.setMinimumDuration | public void setMinimumDuration(@NotNull final Duration minimumDuration) {
if (minimumDuration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The minimum duaration has to be smaller than 23:59:59.");
}
this.minimumDuration = durationToDate(minimumDuration);
} | java | public void setMinimumDuration(@NotNull final Duration minimumDuration) {
if (minimumDuration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The minimum duaration has to be smaller than 23:59:59.");
}
this.minimumDuration = durationToDate(minimumDuration);
} | [
"public",
"void",
"setMinimumDuration",
"(",
"@",
"NotNull",
"final",
"Duration",
"minimumDuration",
")",
"{",
"if",
"(",
"minimumDuration",
".",
"compareTo",
"(",
"MAXIMUM_DURATION",
")",
">",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"T... | Sets the minimal allowed duration value as a String
@param minimumDuration
minimum Duration, only values smaller 23:59:59 are excepted | [
"Sets",
"the",
"minimal",
"allowed",
"duration",
"value",
"as",
"a",
"String"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java#L173-L178 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java | DurationField.setMaximumDuration | public void setMaximumDuration(@NotNull final Duration maximumDuration) {
if (maximumDuration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The maximum duaration has to be smaller than 23:59:59.");
}
this.maximumDuration = durationToDate(maximumDuration);
} | java | public void setMaximumDuration(@NotNull final Duration maximumDuration) {
if (maximumDuration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The maximum duaration has to be smaller than 23:59:59.");
}
this.maximumDuration = durationToDate(maximumDuration);
} | [
"public",
"void",
"setMaximumDuration",
"(",
"@",
"NotNull",
"final",
"Duration",
"maximumDuration",
")",
"{",
"if",
"(",
"maximumDuration",
".",
"compareTo",
"(",
"MAXIMUM_DURATION",
")",
">",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"T... | Sets the maximum allowed duration value as a String
@param maximumDuration
maximumDuration, only values smaller 23:59:59 are excepted | [
"Sets",
"the",
"maximum",
"allowed",
"duration",
"value",
"as",
"a",
"String"
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java#L186-L191 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java | DurationField.compareTimeOfDates | private int compareTimeOfDates(final Date d1, final Date d2) {
final LocalTime lt1 = LocalDateTime.ofInstant(d1.toInstant(), ZONEID_UTC).toLocalTime();
final LocalTime lt2 = LocalDateTime.ofInstant(d2.toInstant(), ZONEID_UTC).toLocalTime();
return lt1.compareTo(lt2);
} | java | private int compareTimeOfDates(final Date d1, final Date d2) {
final LocalTime lt1 = LocalDateTime.ofInstant(d1.toInstant(), ZONEID_UTC).toLocalTime();
final LocalTime lt2 = LocalDateTime.ofInstant(d2.toInstant(), ZONEID_UTC).toLocalTime();
return lt1.compareTo(lt2);
} | [
"private",
"int",
"compareTimeOfDates",
"(",
"final",
"Date",
"d1",
",",
"final",
"Date",
"d2",
")",
"{",
"final",
"LocalTime",
"lt1",
"=",
"LocalDateTime",
".",
"ofInstant",
"(",
"d1",
".",
"toInstant",
"(",
")",
",",
"ZONEID_UTC",
")",
".",
"toLocalTime"... | Because parsing done by base class returns a different date than parsing
done by the user or converting duration to a date. But for the
DurationField comparison only the time is important. This function helps
comparing the time and ignores the values for day, month and year.
@param d1
date, which time will compared with the time of d2
@param d2
date, which time will compared with the time of d1
@return the value 0 if the time represented d1 is equal to the time
represented by d2; a value less than 0 if the time of d1 is
before the time of d2; and a value greater than 0 if the time of
d1 is after the time represented by d2. | [
"Because",
"parsing",
"done",
"by",
"base",
"class",
"returns",
"a",
"different",
"date",
"than",
"parsing",
"done",
"by",
"the",
"user",
"or",
"converting",
"duration",
"to",
"a",
"date",
".",
"But",
"for",
"the",
"DurationField",
"comparison",
"only",
"the... | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationField.java#L222-L227 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java | ArtifactDetailsLayout.maxArtifactDetails | private void maxArtifactDetails() {
final Boolean flag = (Boolean) maxMinButton.getData();
if (flag == null || Boolean.FALSE.equals(flag)) {
// Clicked on max Button
maximizedArtifactDetailsView();
} else {
minimizedArtifactDetailsView();
}
} | java | private void maxArtifactDetails() {
final Boolean flag = (Boolean) maxMinButton.getData();
if (flag == null || Boolean.FALSE.equals(flag)) {
// Clicked on max Button
maximizedArtifactDetailsView();
} else {
minimizedArtifactDetailsView();
}
} | [
"private",
"void",
"maxArtifactDetails",
"(",
")",
"{",
"final",
"Boolean",
"flag",
"=",
"(",
"Boolean",
")",
"maxMinButton",
".",
"getData",
"(",
")",
";",
"if",
"(",
"flag",
"==",
"null",
"||",
"Boolean",
".",
"FALSE",
".",
"equals",
"(",
"flag",
")"... | will be used by button click listener of action history expand icon. | [
"will",
"be",
"used",
"by",
"button",
"click",
"listener",
"of",
"action",
"history",
"expand",
"icon",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java#L356-L364 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java | ArtifactDetailsLayout.createMaxArtifactDetailsTable | public void createMaxArtifactDetailsTable() {
maxArtifactDetailsTable = createArtifactDetailsTable();
maxArtifactDetailsTable.setId(UIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX);
maxArtifactDetailsTable.setContainerDataSource(artifactDetailsTable.getContainerDataSource());
addGeneratedColumn(maxArtifactDetailsTable);
if (!readOnly) {
addGeneratedColumnButton(maxArtifactDetailsTable);
}
setTableColumnDetails(maxArtifactDetailsTable);
} | java | public void createMaxArtifactDetailsTable() {
maxArtifactDetailsTable = createArtifactDetailsTable();
maxArtifactDetailsTable.setId(UIComponentIdProvider.UPLOAD_ARTIFACT_DETAILS_TABLE_MAX);
maxArtifactDetailsTable.setContainerDataSource(artifactDetailsTable.getContainerDataSource());
addGeneratedColumn(maxArtifactDetailsTable);
if (!readOnly) {
addGeneratedColumnButton(maxArtifactDetailsTable);
}
setTableColumnDetails(maxArtifactDetailsTable);
} | [
"public",
"void",
"createMaxArtifactDetailsTable",
"(",
")",
"{",
"maxArtifactDetailsTable",
"=",
"createArtifactDetailsTable",
"(",
")",
";",
"maxArtifactDetailsTable",
".",
"setId",
"(",
"UIComponentIdProvider",
".",
"UPLOAD_ARTIFACT_DETAILS_TABLE_MAX",
")",
";",
"maxArti... | Create Max artifact details Table. | [
"Create",
"Max",
"artifact",
"details",
"Table",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java#L384-L393 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java | ArtifactDetailsLayout.populateArtifactDetails | public void populateArtifactDetails(final SoftwareModule softwareModule) {
if (softwareModule == null) {
populateArtifactDetails(null, null);
} else {
populateArtifactDetails(softwareModule.getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion()));
}
} | java | public void populateArtifactDetails(final SoftwareModule softwareModule) {
if (softwareModule == null) {
populateArtifactDetails(null, null);
} else {
populateArtifactDetails(softwareModule.getId(),
HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion()));
}
} | [
"public",
"void",
"populateArtifactDetails",
"(",
"final",
"SoftwareModule",
"softwareModule",
")",
"{",
"if",
"(",
"softwareModule",
"==",
"null",
")",
"{",
"populateArtifactDetails",
"(",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"populateArtifactDetails"... | Populate artifact details.
@param softwareModule
software module | [
"Populate",
"artifact",
"details",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java#L418-L425 | train |
eclipse/hawkbit | hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java | ArtifactDetailsLayout.setTitleOfLayoutHeader | private void setTitleOfLayoutHeader() {
titleOfArtifactDetails.setValue(HawkbitCommonUtil.getArtifactoryDetailsLabelId("", i18n));
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
} | java | private void setTitleOfLayoutHeader() {
titleOfArtifactDetails.setValue(HawkbitCommonUtil.getArtifactoryDetailsLabelId("", i18n));
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
} | [
"private",
"void",
"setTitleOfLayoutHeader",
"(",
")",
"{",
"titleOfArtifactDetails",
".",
"setValue",
"(",
"HawkbitCommonUtil",
".",
"getArtifactoryDetailsLabelId",
"(",
"\"\"",
",",
"i18n",
")",
")",
";",
"titleOfArtifactDetails",
".",
"setContentMode",
"(",
"Conten... | Set title of artifact details header layout. | [
"Set",
"title",
"of",
"artifact",
"details",
"header",
"layout",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java#L454-L457 | train |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java | RolloutGroupConditionBuilder.successCondition | public RolloutGroupConditionBuilder successCondition(final RolloutGroupSuccessCondition condition,
final String expression) {
conditions.setSuccessCondition(condition);
conditions.setSuccessConditionExp(expression);
return this;
} | java | public RolloutGroupConditionBuilder successCondition(final RolloutGroupSuccessCondition condition,
final String expression) {
conditions.setSuccessCondition(condition);
conditions.setSuccessConditionExp(expression);
return this;
} | [
"public",
"RolloutGroupConditionBuilder",
"successCondition",
"(",
"final",
"RolloutGroupSuccessCondition",
"condition",
",",
"final",
"String",
"expression",
")",
"{",
"conditions",
".",
"setSuccessCondition",
"(",
"condition",
")",
";",
"conditions",
".",
"setSuccessCon... | Sets the finish condition and expression on the builder.
@param condition
the finish condition
@param expression
the finish expression
@return the builder itself | [
"Sets",
"the",
"finish",
"condition",
"and",
"expression",
"on",
"the",
"builder",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java#L39-L44 | train |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java | RolloutGroupConditionBuilder.successAction | public RolloutGroupConditionBuilder successAction(final RolloutGroupSuccessAction action, final String expression) {
conditions.setSuccessAction(action);
conditions.setSuccessActionExp(expression);
return this;
} | java | public RolloutGroupConditionBuilder successAction(final RolloutGroupSuccessAction action, final String expression) {
conditions.setSuccessAction(action);
conditions.setSuccessActionExp(expression);
return this;
} | [
"public",
"RolloutGroupConditionBuilder",
"successAction",
"(",
"final",
"RolloutGroupSuccessAction",
"action",
",",
"final",
"String",
"expression",
")",
"{",
"conditions",
".",
"setSuccessAction",
"(",
"action",
")",
";",
"conditions",
".",
"setSuccessActionExp",
"(",... | Sets the success action and expression on the builder.
@param action
the success action
@param expression
the error expression
@return the builder itself | [
"Sets",
"the",
"success",
"action",
"and",
"expression",
"on",
"the",
"builder",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java#L55-L59 | train |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java | RolloutGroupConditionBuilder.errorCondition | public RolloutGroupConditionBuilder errorCondition(final RolloutGroupErrorCondition condition,
final String expression) {
conditions.setErrorCondition(condition);
conditions.setErrorConditionExp(expression);
return this;
} | java | public RolloutGroupConditionBuilder errorCondition(final RolloutGroupErrorCondition condition,
final String expression) {
conditions.setErrorCondition(condition);
conditions.setErrorConditionExp(expression);
return this;
} | [
"public",
"RolloutGroupConditionBuilder",
"errorCondition",
"(",
"final",
"RolloutGroupErrorCondition",
"condition",
",",
"final",
"String",
"expression",
")",
"{",
"conditions",
".",
"setErrorCondition",
"(",
"condition",
")",
";",
"conditions",
".",
"setErrorConditionEx... | Sets the error condition and expression on the builder.
@param condition
the error condition
@param expression
the error expression
@return the builder itself | [
"Sets",
"the",
"error",
"condition",
"and",
"expression",
"on",
"the",
"builder",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java#L70-L75 | train |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java | RolloutGroupConditionBuilder.errorAction | public RolloutGroupConditionBuilder errorAction(final RolloutGroupErrorAction action, final String expression) {
conditions.setErrorAction(action);
conditions.setErrorActionExp(expression);
return this;
} | java | public RolloutGroupConditionBuilder errorAction(final RolloutGroupErrorAction action, final String expression) {
conditions.setErrorAction(action);
conditions.setErrorActionExp(expression);
return this;
} | [
"public",
"RolloutGroupConditionBuilder",
"errorAction",
"(",
"final",
"RolloutGroupErrorAction",
"action",
",",
"final",
"String",
"expression",
")",
"{",
"conditions",
".",
"setErrorAction",
"(",
"action",
")",
";",
"conditions",
".",
"setErrorActionExp",
"(",
"expr... | Sets the error action and expression on the builder.
@param action
the error action
@param expression
the error expression
@return the builder itself | [
"Sets",
"the",
"error",
"action",
"and",
"expression",
"on",
"the",
"builder",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java#L86-L90 | train |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java | RolloutGroupConditionBuilder.withDefaults | public RolloutGroupConditionBuilder withDefaults() {
successCondition(RolloutGroupSuccessCondition.THRESHOLD, "50");
successAction(RolloutGroupSuccessAction.NEXTGROUP, "");
errorCondition(RolloutGroupErrorCondition.THRESHOLD, "50");
errorAction(RolloutGroupErrorAction.PAUSE, "");
return this;
} | java | public RolloutGroupConditionBuilder withDefaults() {
successCondition(RolloutGroupSuccessCondition.THRESHOLD, "50");
successAction(RolloutGroupSuccessAction.NEXTGROUP, "");
errorCondition(RolloutGroupErrorCondition.THRESHOLD, "50");
errorAction(RolloutGroupErrorAction.PAUSE, "");
return this;
} | [
"public",
"RolloutGroupConditionBuilder",
"withDefaults",
"(",
")",
"{",
"successCondition",
"(",
"RolloutGroupSuccessCondition",
".",
"THRESHOLD",
",",
"\"50\"",
")",
";",
"successAction",
"(",
"RolloutGroupSuccessAction",
".",
"NEXTGROUP",
",",
"\"\"",
")",
";",
"er... | Sets condition defaults.
@return the builder itself | [
"Sets",
"condition",
"defaults",
"."
] | 9884452ad42f3b4827461606d8a9215c8625a7fe | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroupConditionBuilder.java#L97-L103 | train |
maxmind/GeoIP2-java | src/main/java/com/maxmind/geoip2/DatabaseReader.java | DatabaseReader.anonymousIp | @Override
public AnonymousIpResponse anonymousIp(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, AnonymousIpResponse.class, "GeoIP2-Anonymous-IP");
} | java | @Override
public AnonymousIpResponse anonymousIp(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, AnonymousIpResponse.class, "GeoIP2-Anonymous-IP");
} | [
"@",
"Override",
"public",
"AnonymousIpResponse",
"anonymousIp",
"(",
"InetAddress",
"ipAddress",
")",
"throws",
"IOException",
",",
"GeoIp2Exception",
"{",
"return",
"this",
".",
"get",
"(",
"ipAddress",
",",
"AnonymousIpResponse",
".",
"class",
",",
"\"GeoIP2-Anon... | Look up an IP address in a GeoIP2 Anonymous IP.
@param ipAddress IPv4 or IPv6 address to lookup.
@return a AnonymousIpResponse for the requested IP address.
@throws GeoIp2Exception if there is an error looking up the IP
@throws IOException if there is an IO error | [
"Look",
"up",
"an",
"IP",
"address",
"in",
"a",
"GeoIP2",
"Anonymous",
"IP",
"."
] | ecd6f15216d2ee0efd4ffd156dd4dd0dda741411 | https://github.com/maxmind/GeoIP2-java/blob/ecd6f15216d2ee0efd4ffd156dd4dd0dda741411/src/main/java/com/maxmind/geoip2/DatabaseReader.java#L244-L248 | train |
maxmind/GeoIP2-java | src/main/java/com/maxmind/geoip2/DatabaseReader.java | DatabaseReader.asn | @Override
public AsnResponse asn(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, AsnResponse.class, "GeoLite2-ASN");
} | java | @Override
public AsnResponse asn(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, AsnResponse.class, "GeoLite2-ASN");
} | [
"@",
"Override",
"public",
"AsnResponse",
"asn",
"(",
"InetAddress",
"ipAddress",
")",
"throws",
"IOException",
",",
"GeoIp2Exception",
"{",
"return",
"this",
".",
"get",
"(",
"ipAddress",
",",
"AsnResponse",
".",
"class",
",",
"\"GeoLite2-ASN\"",
")",
";",
"}... | Look up an IP address in a GeoLite2 ASN database.
@param ipAddress IPv4 or IPv6 address to lookup.
@return an AsnResponse for the requested IP address.
@throws GeoIp2Exception if there is an error looking up the IP
@throws IOException if there is an IO error | [
"Look",
"up",
"an",
"IP",
"address",
"in",
"a",
"GeoLite2",
"ASN",
"database",
"."
] | ecd6f15216d2ee0efd4ffd156dd4dd0dda741411 | https://github.com/maxmind/GeoIP2-java/blob/ecd6f15216d2ee0efd4ffd156dd4dd0dda741411/src/main/java/com/maxmind/geoip2/DatabaseReader.java#L258-L262 | train |
maxmind/GeoIP2-java | src/main/java/com/maxmind/geoip2/DatabaseReader.java | DatabaseReader.connectionType | @Override
public ConnectionTypeResponse connectionType(InetAddress ipAddress)
throws IOException, GeoIp2Exception {
return this.get(ipAddress, ConnectionTypeResponse.class,
"GeoIP2-Connection-Type");
} | java | @Override
public ConnectionTypeResponse connectionType(InetAddress ipAddress)
throws IOException, GeoIp2Exception {
return this.get(ipAddress, ConnectionTypeResponse.class,
"GeoIP2-Connection-Type");
} | [
"@",
"Override",
"public",
"ConnectionTypeResponse",
"connectionType",
"(",
"InetAddress",
"ipAddress",
")",
"throws",
"IOException",
",",
"GeoIp2Exception",
"{",
"return",
"this",
".",
"get",
"(",
"ipAddress",
",",
"ConnectionTypeResponse",
".",
"class",
",",
"\"Ge... | Look up an IP address in a GeoIP2 Connection Type database.
@param ipAddress IPv4 or IPv6 address to lookup.
@return a ConnectTypeResponse for the requested IP address.
@throws GeoIp2Exception if there is an error looking up the IP
@throws IOException if there is an IO error | [
"Look",
"up",
"an",
"IP",
"address",
"in",
"a",
"GeoIP2",
"Connection",
"Type",
"database",
"."
] | ecd6f15216d2ee0efd4ffd156dd4dd0dda741411 | https://github.com/maxmind/GeoIP2-java/blob/ecd6f15216d2ee0efd4ffd156dd4dd0dda741411/src/main/java/com/maxmind/geoip2/DatabaseReader.java#L272-L277 | train |
maxmind/GeoIP2-java | src/main/java/com/maxmind/geoip2/DatabaseReader.java | DatabaseReader.domain | @Override
public DomainResponse domain(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this
.get(ipAddress, DomainResponse.class, "GeoIP2-Domain");
} | java | @Override
public DomainResponse domain(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this
.get(ipAddress, DomainResponse.class, "GeoIP2-Domain");
} | [
"@",
"Override",
"public",
"DomainResponse",
"domain",
"(",
"InetAddress",
"ipAddress",
")",
"throws",
"IOException",
",",
"GeoIp2Exception",
"{",
"return",
"this",
".",
"get",
"(",
"ipAddress",
",",
"DomainResponse",
".",
"class",
",",
"\"GeoIP2-Domain\"",
")",
... | Look up an IP address in a GeoIP2 Domain database.
@param ipAddress IPv4 or IPv6 address to lookup.
@return a DomainResponse for the requested IP address.
@throws GeoIp2Exception if there is an error looking up the IP
@throws IOException if there is an IO error | [
"Look",
"up",
"an",
"IP",
"address",
"in",
"a",
"GeoIP2",
"Domain",
"database",
"."
] | ecd6f15216d2ee0efd4ffd156dd4dd0dda741411 | https://github.com/maxmind/GeoIP2-java/blob/ecd6f15216d2ee0efd4ffd156dd4dd0dda741411/src/main/java/com/maxmind/geoip2/DatabaseReader.java#L287-L292 | train |
maxmind/GeoIP2-java | src/main/java/com/maxmind/geoip2/DatabaseReader.java | DatabaseReader.enterprise | @Override
public EnterpriseResponse enterprise(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, EnterpriseResponse.class, "Enterprise");
} | java | @Override
public EnterpriseResponse enterprise(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, EnterpriseResponse.class, "Enterprise");
} | [
"@",
"Override",
"public",
"EnterpriseResponse",
"enterprise",
"(",
"InetAddress",
"ipAddress",
")",
"throws",
"IOException",
",",
"GeoIp2Exception",
"{",
"return",
"this",
".",
"get",
"(",
"ipAddress",
",",
"EnterpriseResponse",
".",
"class",
",",
"\"Enterprise\"",... | Look up an IP address in a GeoIP2 Enterprise database.
@param ipAddress IPv4 or IPv6 address to lookup.
@return an EnterpriseResponse for the requested IP address.
@throws GeoIp2Exception if there is an error looking up the IP
@throws IOException if there is an IO error | [
"Look",
"up",
"an",
"IP",
"address",
"in",
"a",
"GeoIP2",
"Enterprise",
"database",
"."
] | ecd6f15216d2ee0efd4ffd156dd4dd0dda741411 | https://github.com/maxmind/GeoIP2-java/blob/ecd6f15216d2ee0efd4ffd156dd4dd0dda741411/src/main/java/com/maxmind/geoip2/DatabaseReader.java#L302-L306 | train |
maxmind/GeoIP2-java | src/main/java/com/maxmind/geoip2/DatabaseReader.java | DatabaseReader.isp | @Override
public IspResponse isp(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, IspResponse.class, "GeoIP2-ISP");
} | java | @Override
public IspResponse isp(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.get(ipAddress, IspResponse.class, "GeoIP2-ISP");
} | [
"@",
"Override",
"public",
"IspResponse",
"isp",
"(",
"InetAddress",
"ipAddress",
")",
"throws",
"IOException",
",",
"GeoIp2Exception",
"{",
"return",
"this",
".",
"get",
"(",
"ipAddress",
",",
"IspResponse",
".",
"class",
",",
"\"GeoIP2-ISP\"",
")",
";",
"}"
... | Look up an IP address in a GeoIP2 ISP database.
@param ipAddress IPv4 or IPv6 address to lookup.
@return an IspResponse for the requested IP address.
@throws GeoIp2Exception if there is an error looking up the IP
@throws IOException if there is an IO error | [
"Look",
"up",
"an",
"IP",
"address",
"in",
"a",
"GeoIP2",
"ISP",
"database",
"."
] | ecd6f15216d2ee0efd4ffd156dd4dd0dda741411 | https://github.com/maxmind/GeoIP2-java/blob/ecd6f15216d2ee0efd4ffd156dd4dd0dda741411/src/main/java/com/maxmind/geoip2/DatabaseReader.java#L317-L321 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/thread/ConnectionValidator.java | ConnectionValidator.addListener | public void addListener(Listener listener, long listenerCheckMillis) {
queue.add(listener);
long newFrequency = Math.min(MINIMUM_CHECK_DELAY_MILLIS, listenerCheckMillis);
//first listener
if (currentScheduledFrequency.get() == -1) {
if (currentScheduledFrequency.compareAndSet(-1, newFrequency)) {
fixedSizedScheduler.schedule(checker, listenerCheckMillis, TimeUnit.MILLISECONDS);
}
} else {
long frequency = currentScheduledFrequency.get();
if (frequency > newFrequency) {
currentScheduledFrequency.compareAndSet(frequency, newFrequency);
}
}
} | java | public void addListener(Listener listener, long listenerCheckMillis) {
queue.add(listener);
long newFrequency = Math.min(MINIMUM_CHECK_DELAY_MILLIS, listenerCheckMillis);
//first listener
if (currentScheduledFrequency.get() == -1) {
if (currentScheduledFrequency.compareAndSet(-1, newFrequency)) {
fixedSizedScheduler.schedule(checker, listenerCheckMillis, TimeUnit.MILLISECONDS);
}
} else {
long frequency = currentScheduledFrequency.get();
if (frequency > newFrequency) {
currentScheduledFrequency.compareAndSet(frequency, newFrequency);
}
}
} | [
"public",
"void",
"addListener",
"(",
"Listener",
"listener",
",",
"long",
"listenerCheckMillis",
")",
"{",
"queue",
".",
"add",
"(",
"listener",
")",
";",
"long",
"newFrequency",
"=",
"Math",
".",
"min",
"(",
"MINIMUM_CHECK_DELAY_MILLIS",
",",
"listenerCheckMil... | Add listener to validation list.
@param listener listener
@param listenerCheckMillis schedule time | [
"Add",
"listener",
"to",
"validation",
"list",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/thread/ConnectionValidator.java#L79-L96 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/thread/ConnectionValidator.java | ConnectionValidator.removeListener | public void removeListener(Listener listener) {
queue.remove(listener);
if (queue.isEmpty()) {
synchronized (queue) {
if (currentScheduledFrequency.get() > 0 && queue.isEmpty()) {
currentScheduledFrequency.set(-1);
}
}
}
} | java | public void removeListener(Listener listener) {
queue.remove(listener);
if (queue.isEmpty()) {
synchronized (queue) {
if (currentScheduledFrequency.get() > 0 && queue.isEmpty()) {
currentScheduledFrequency.set(-1);
}
}
}
} | [
"public",
"void",
"removeListener",
"(",
"Listener",
"listener",
")",
"{",
"queue",
".",
"remove",
"(",
"listener",
")",
";",
"if",
"(",
"queue",
".",
"isEmpty",
"(",
")",
")",
"{",
"synchronized",
"(",
"queue",
")",
"{",
"if",
"(",
"currentScheduledFreq... | Remove listener to validation list.
@param listener listener | [
"Remove",
"listener",
"to",
"validation",
"list",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/thread/ConnectionValidator.java#L103-L114 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/io/LruTraceCache.java | LruTraceCache.put | public TraceObject put(TraceObject value) {
String key =
increment.incrementAndGet() + "- " + DateTimeFormatter.ISO_INSTANT.format(Instant.now());
return put(key, value);
} | java | public TraceObject put(TraceObject value) {
String key =
increment.incrementAndGet() + "- " + DateTimeFormatter.ISO_INSTANT.format(Instant.now());
return put(key, value);
} | [
"public",
"TraceObject",
"put",
"(",
"TraceObject",
"value",
")",
"{",
"String",
"key",
"=",
"increment",
".",
"incrementAndGet",
"(",
")",
"+",
"\"- \"",
"+",
"DateTimeFormatter",
".",
"ISO_INSTANT",
".",
"format",
"(",
"Instant",
".",
"now",
"(",
")",
")... | Add value to map.
@param value value to add
@return added value | [
"Add",
"value",
"to",
"map",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/io/LruTraceCache.java#L78-L82 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/io/LruTraceCache.java | LruTraceCache.printStack | public synchronized String printStack() {
StringBuilder sb = new StringBuilder();
Set<Map.Entry<String, TraceObject>> set = entrySet();
for (Map.Entry<String, TraceObject> entry : set) {
TraceObject traceObj = entry.getValue();
String key = entry.getKey();
String indicator = "";
switch (traceObj.getIndicatorFlag()) {
case TraceObject.NOT_COMPRESSED:
break;
case TraceObject.COMPRESSED_PROTOCOL_NOT_COMPRESSED_PACKET:
indicator = " (compressed protocol - packet not compressed)";
break;
case TraceObject.COMPRESSED_PROTOCOL_COMPRESSED_PACKET:
indicator = " (compressed protocol - packet compressed)";
break;
default:
break;
}
if (traceObj.isSend()) {
sb.append("\nsend at -exchange:");
} else {
sb.append("\nread at -exchange:");
}
sb.append(key).append(indicator)
.append(Utils.hexdump(traceObj.getBuf()));
traceObj.remove();
}
this.clear();
return sb.toString();
} | java | public synchronized String printStack() {
StringBuilder sb = new StringBuilder();
Set<Map.Entry<String, TraceObject>> set = entrySet();
for (Map.Entry<String, TraceObject> entry : set) {
TraceObject traceObj = entry.getValue();
String key = entry.getKey();
String indicator = "";
switch (traceObj.getIndicatorFlag()) {
case TraceObject.NOT_COMPRESSED:
break;
case TraceObject.COMPRESSED_PROTOCOL_NOT_COMPRESSED_PACKET:
indicator = " (compressed protocol - packet not compressed)";
break;
case TraceObject.COMPRESSED_PROTOCOL_COMPRESSED_PACKET:
indicator = " (compressed protocol - packet compressed)";
break;
default:
break;
}
if (traceObj.isSend()) {
sb.append("\nsend at -exchange:");
} else {
sb.append("\nread at -exchange:");
}
sb.append(key).append(indicator)
.append(Utils.hexdump(traceObj.getBuf()));
traceObj.remove();
}
this.clear();
return sb.toString();
} | [
"public",
"synchronized",
"String",
"printStack",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Set",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"TraceObject",
">",
">",
"set",
"=",
"entrySet",
"(",
")",
";",
"fo... | Value of trace cache in a readable format.
@return trace cache value | [
"Value",
"of",
"trace",
"cache",
"in",
"a",
"readable",
"format",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/io/LruTraceCache.java#L94-L131 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/io/LruTraceCache.java | LruTraceCache.clearMemory | public synchronized void clearMemory() {
Collection<TraceObject> traceObjects = values();
for (TraceObject traceObject : traceObjects) {
traceObject.remove();
}
this.clear();
} | java | public synchronized void clearMemory() {
Collection<TraceObject> traceObjects = values();
for (TraceObject traceObject : traceObjects) {
traceObject.remove();
}
this.clear();
} | [
"public",
"synchronized",
"void",
"clearMemory",
"(",
")",
"{",
"Collection",
"<",
"TraceObject",
">",
"traceObjects",
"=",
"values",
"(",
")",
";",
"for",
"(",
"TraceObject",
"traceObject",
":",
"traceObjects",
")",
"{",
"traceObject",
".",
"remove",
"(",
"... | Permit to clear array's of array, to help garbage. | [
"Permit",
"to",
"clear",
"array",
"s",
"of",
"array",
"to",
"help",
"garbage",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/io/LruTraceCache.java#L136-L142 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/FailoverProxy.java | FailoverProxy.handleFailOver | private Object handleFailOver(SQLException qe, Method method, Object[] args, Protocol protocol)
throws Throwable {
HostAddress failHostAddress = null;
boolean failIsMaster = true;
if (protocol != null) {
failHostAddress = protocol.getHostAddress();
failIsMaster = protocol.isMasterConnection();
}
HandleErrorResult handleErrorResult = listener.handleFailover(qe, method, args, protocol);
if (handleErrorResult.mustThrowError) {
listener
.throwFailoverMessage(failHostAddress, failIsMaster, qe, handleErrorResult.isReconnected);
}
return handleErrorResult.resultObject;
} | java | private Object handleFailOver(SQLException qe, Method method, Object[] args, Protocol protocol)
throws Throwable {
HostAddress failHostAddress = null;
boolean failIsMaster = true;
if (protocol != null) {
failHostAddress = protocol.getHostAddress();
failIsMaster = protocol.isMasterConnection();
}
HandleErrorResult handleErrorResult = listener.handleFailover(qe, method, args, protocol);
if (handleErrorResult.mustThrowError) {
listener
.throwFailoverMessage(failHostAddress, failIsMaster, qe, handleErrorResult.isReconnected);
}
return handleErrorResult.resultObject;
} | [
"private",
"Object",
"handleFailOver",
"(",
"SQLException",
"qe",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
",",
"Protocol",
"protocol",
")",
"throws",
"Throwable",
"{",
"HostAddress",
"failHostAddress",
"=",
"null",
";",
"boolean",
"failIsMaster... | After a connection exception, launch failover.
@param qe the exception thrown
@param method the method to call if failover works well
@param args the arguments of the method
@return the object return from the method
@throws Throwable throwable | [
"After",
"a",
"connection",
"exception",
"launch",
"failover",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/FailoverProxy.java#L352-L367 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/FailoverProxy.java | FailoverProxy.hasToHandleFailover | public boolean hasToHandleFailover(SQLException exception) {
return exception.getSQLState() != null
&& (exception.getSQLState().startsWith("08")
|| (exception.getSQLState().equals("70100") && 1927 == exception.getErrorCode()));
} | java | public boolean hasToHandleFailover(SQLException exception) {
return exception.getSQLState() != null
&& (exception.getSQLState().startsWith("08")
|| (exception.getSQLState().equals("70100") && 1927 == exception.getErrorCode()));
} | [
"public",
"boolean",
"hasToHandleFailover",
"(",
"SQLException",
"exception",
")",
"{",
"return",
"exception",
".",
"getSQLState",
"(",
")",
"!=",
"null",
"&&",
"(",
"exception",
".",
"getSQLState",
"(",
")",
".",
"startsWith",
"(",
"\"08\"",
")",
"||",
"(",... | Check if this Sqlerror is a connection exception. if that's the case, must be handle by
failover
<p>error codes : 08000 : connection exception 08001 : SQL client unable to establish SQL
connection 08002 : connection name in use 08003 : connection does not exist 08004 : SQL server
rejected SQL connection 08006 : connection failure 08007 : transaction resolution unknown 70100
: connection was killed if error code is "1927"</p>
@param exception the Exception
@return true if there has been a connection error that must be handled by failover | [
"Check",
"if",
"this",
"Sqlerror",
"is",
"a",
"connection",
"exception",
".",
"if",
"that",
"s",
"the",
"case",
"must",
"be",
"handle",
"by",
"failover"
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/FailoverProxy.java#L381-L385 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/FailoverProxy.java | FailoverProxy.reconnect | public void reconnect() throws SQLException {
try {
listener.reconnect();
} catch (SQLException e) {
ExceptionMapper.throwException(e, null, null);
}
} | java | public void reconnect() throws SQLException {
try {
listener.reconnect();
} catch (SQLException e) {
ExceptionMapper.throwException(e, null, null);
}
} | [
"public",
"void",
"reconnect",
"(",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"listener",
".",
"reconnect",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"ExceptionMapper",
".",
"throwException",
"(",
"e",
",",
"null",
",",
"null... | Launch reconnect implementation.
@throws SQLException exception | [
"Launch",
"reconnect",
"implementation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/FailoverProxy.java#L392-L398 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.readStringNullEnd | public String readStringNullEnd(final Charset charset) {
int initialPosition = position;
int cnt = 0;
while (remaining() > 0 && (buf[position++] != 0)) {
cnt++;
}
return new String(buf, initialPosition, cnt, charset);
} | java | public String readStringNullEnd(final Charset charset) {
int initialPosition = position;
int cnt = 0;
while (remaining() > 0 && (buf[position++] != 0)) {
cnt++;
}
return new String(buf, initialPosition, cnt, charset);
} | [
"public",
"String",
"readStringNullEnd",
"(",
"final",
"Charset",
"charset",
")",
"{",
"int",
"initialPosition",
"=",
"position",
";",
"int",
"cnt",
"=",
"0",
";",
"while",
"(",
"remaining",
"(",
")",
">",
"0",
"&&",
"(",
"buf",
"[",
"position",
"++",
... | Reads a string from the buffer, looks for a 0 to end the string.
@param charset the charset to use, for example ASCII
@return the read string | [
"Reads",
"a",
"string",
"from",
"the",
"buffer",
"looks",
"for",
"a",
"0",
"to",
"end",
"the",
"string",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L90-L97 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.readBytesNullEnd | public byte[] readBytesNullEnd() {
int initialPosition = position;
int cnt = 0;
while (remaining() > 0 && (buf[position++] != 0)) {
cnt++;
}
final byte[] tmpArr = new byte[cnt];
System.arraycopy(buf, initialPosition, tmpArr, 0, cnt);
return tmpArr;
} | java | public byte[] readBytesNullEnd() {
int initialPosition = position;
int cnt = 0;
while (remaining() > 0 && (buf[position++] != 0)) {
cnt++;
}
final byte[] tmpArr = new byte[cnt];
System.arraycopy(buf, initialPosition, tmpArr, 0, cnt);
return tmpArr;
} | [
"public",
"byte",
"[",
"]",
"readBytesNullEnd",
"(",
")",
"{",
"int",
"initialPosition",
"=",
"position",
";",
"int",
"cnt",
"=",
"0",
";",
"while",
"(",
"remaining",
"(",
")",
">",
"0",
"&&",
"(",
"buf",
"[",
"position",
"++",
"]",
"!=",
"0",
")",... | Reads a byte array from the buffer, looks for a 0 to end the array.
@return the read array | [
"Reads",
"a",
"byte",
"array",
"from",
"the",
"buffer",
"looks",
"for",
"a",
"0",
"to",
"end",
"the",
"array",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L104-L113 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.readStringLengthEncoded | public String readStringLengthEncoded(final Charset charset) {
int length = (int) getLengthEncodedNumeric();
String string = new String(buf, position, length, charset);
position += length;
return string;
} | java | public String readStringLengthEncoded(final Charset charset) {
int length = (int) getLengthEncodedNumeric();
String string = new String(buf, position, length, charset);
position += length;
return string;
} | [
"public",
"String",
"readStringLengthEncoded",
"(",
"final",
"Charset",
"charset",
")",
"{",
"int",
"length",
"=",
"(",
"int",
")",
"getLengthEncodedNumeric",
"(",
")",
";",
"String",
"string",
"=",
"new",
"String",
"(",
"buf",
",",
"position",
",",
"length"... | Reads length-encoded string.
@param charset the charset to use, for example ASCII
@return the read string | [
"Reads",
"length",
"-",
"encoded",
"string",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L121-L126 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.readString | public String readString(final int numberOfBytes) {
position += numberOfBytes;
return new String(buf, position - numberOfBytes, numberOfBytes);
} | java | public String readString(final int numberOfBytes) {
position += numberOfBytes;
return new String(buf, position - numberOfBytes, numberOfBytes);
} | [
"public",
"String",
"readString",
"(",
"final",
"int",
"numberOfBytes",
")",
"{",
"position",
"+=",
"numberOfBytes",
";",
"return",
"new",
"String",
"(",
"buf",
",",
"position",
"-",
"numberOfBytes",
",",
"numberOfBytes",
")",
";",
"}"
] | Read String with defined length.
@param numberOfBytes raw data length.
@return String value | [
"Read",
"String",
"with",
"defined",
"length",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L134-L137 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.readRawBytes | public byte[] readRawBytes(final int numberOfBytes) {
final byte[] tmpArr = new byte[numberOfBytes];
System.arraycopy(buf, position, tmpArr, 0, numberOfBytes);
position += numberOfBytes;
return tmpArr;
} | java | public byte[] readRawBytes(final int numberOfBytes) {
final byte[] tmpArr = new byte[numberOfBytes];
System.arraycopy(buf, position, tmpArr, 0, numberOfBytes);
position += numberOfBytes;
return tmpArr;
} | [
"public",
"byte",
"[",
"]",
"readRawBytes",
"(",
"final",
"int",
"numberOfBytes",
")",
"{",
"final",
"byte",
"[",
"]",
"tmpArr",
"=",
"new",
"byte",
"[",
"numberOfBytes",
"]",
";",
"System",
".",
"arraycopy",
"(",
"buf",
",",
"position",
",",
"tmpArr",
... | Read raw data.
@param numberOfBytes raw data length.
@return raw data | [
"Read",
"raw",
"data",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L203-L208 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.skipLengthEncodedBytes | public void skipLengthEncodedBytes() {
int type = this.buf[this.position++] & 0xff;
switch (type) {
case 251:
break;
case 252:
position += 2 + (0xffff & (((buf[position] & 0xff) + ((buf[position + 1] & 0xff) << 8))));
break;
case 253:
position += 3 + (0xffffff & ((buf[position] & 0xff)
+ ((buf[position + 1] & 0xff) << 8)
+ ((buf[position + 2] & 0xff) << 16)));
break;
case 254:
position += 8 + ((buf[position] & 0xff)
+ ((long) (buf[position + 1] & 0xff) << 8)
+ ((long) (buf[position + 2] & 0xff) << 16)
+ ((long) (buf[position + 3] & 0xff) << 24)
+ ((long) (buf[position + 4] & 0xff) << 32)
+ ((long) (buf[position + 5] & 0xff) << 40)
+ ((long) (buf[position + 6] & 0xff) << 48)
+ ((long) (buf[position + 7] & 0xff) << 56));
break;
default:
position += type;
break;
}
} | java | public void skipLengthEncodedBytes() {
int type = this.buf[this.position++] & 0xff;
switch (type) {
case 251:
break;
case 252:
position += 2 + (0xffff & (((buf[position] & 0xff) + ((buf[position + 1] & 0xff) << 8))));
break;
case 253:
position += 3 + (0xffffff & ((buf[position] & 0xff)
+ ((buf[position + 1] & 0xff) << 8)
+ ((buf[position + 2] & 0xff) << 16)));
break;
case 254:
position += 8 + ((buf[position] & 0xff)
+ ((long) (buf[position + 1] & 0xff) << 8)
+ ((long) (buf[position + 2] & 0xff) << 16)
+ ((long) (buf[position + 3] & 0xff) << 24)
+ ((long) (buf[position + 4] & 0xff) << 32)
+ ((long) (buf[position + 5] & 0xff) << 40)
+ ((long) (buf[position + 6] & 0xff) << 48)
+ ((long) (buf[position + 7] & 0xff) << 56));
break;
default:
position += type;
break;
}
} | [
"public",
"void",
"skipLengthEncodedBytes",
"(",
")",
"{",
"int",
"type",
"=",
"this",
".",
"buf",
"[",
"this",
".",
"position",
"++",
"]",
"&",
"0xff",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"251",
":",
"break",
";",
"case",
"252",
":",
"po... | Skip next length encode binary data. | [
"Skip",
"next",
"length",
"encode",
"binary",
"data",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L221-L252 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.getLengthEncodedBytes | public byte[] getLengthEncodedBytes() {
int type = this.buf[this.position++] & 0xff;
int length;
switch (type) {
case 251:
return null;
case 252:
length = 0xffff & readShort();
break;
case 253:
length = 0xffffff & read24bitword();
break;
case 254:
length = (int) ((buf[position++] & 0xff)
+ ((long) (buf[position++] & 0xff) << 8)
+ ((long) (buf[position++] & 0xff) << 16)
+ ((long) (buf[position++] & 0xff) << 24)
+ ((long) (buf[position++] & 0xff) << 32)
+ ((long) (buf[position++] & 0xff) << 40)
+ ((long) (buf[position++] & 0xff) << 48)
+ ((long) (buf[position++] & 0xff) << 56));
break;
default:
length = type;
break;
}
byte[] tmpBuf = new byte[length];
System.arraycopy(buf, position, tmpBuf, 0, length);
position += length;
return tmpBuf;
} | java | public byte[] getLengthEncodedBytes() {
int type = this.buf[this.position++] & 0xff;
int length;
switch (type) {
case 251:
return null;
case 252:
length = 0xffff & readShort();
break;
case 253:
length = 0xffffff & read24bitword();
break;
case 254:
length = (int) ((buf[position++] & 0xff)
+ ((long) (buf[position++] & 0xff) << 8)
+ ((long) (buf[position++] & 0xff) << 16)
+ ((long) (buf[position++] & 0xff) << 24)
+ ((long) (buf[position++] & 0xff) << 32)
+ ((long) (buf[position++] & 0xff) << 40)
+ ((long) (buf[position++] & 0xff) << 48)
+ ((long) (buf[position++] & 0xff) << 56));
break;
default:
length = type;
break;
}
byte[] tmpBuf = new byte[length];
System.arraycopy(buf, position, tmpBuf, 0, length);
position += length;
return tmpBuf;
} | [
"public",
"byte",
"[",
"]",
"getLengthEncodedBytes",
"(",
")",
"{",
"int",
"type",
"=",
"this",
".",
"buf",
"[",
"this",
".",
"position",
"++",
"]",
"&",
"0xff",
";",
"int",
"length",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"251",
":",
"retur... | Get next data bytes with length encoded prefix.
@return the raw binary data | [
"Get",
"next",
"data",
"bytes",
"with",
"length",
"encoded",
"prefix",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L289-L320 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.writeStringSmallLength | public void writeStringSmallLength(byte[] value) {
int length = value.length;
while (remaining() < length + 1) {
grow();
}
buf[position++] = (byte) length;
System.arraycopy(value, 0, buf, position, length);
position += length;
} | java | public void writeStringSmallLength(byte[] value) {
int length = value.length;
while (remaining() < length + 1) {
grow();
}
buf[position++] = (byte) length;
System.arraycopy(value, 0, buf, position, length);
position += length;
} | [
"public",
"void",
"writeStringSmallLength",
"(",
"byte",
"[",
"]",
"value",
")",
"{",
"int",
"length",
"=",
"value",
".",
"length",
";",
"while",
"(",
"remaining",
"(",
")",
"<",
"length",
"+",
"1",
")",
"{",
"grow",
"(",
")",
";",
"}",
"buf",
"[",... | Write value with length encoded prefix. value length MUST be less than 251 char
@param value value to write | [
"Write",
"value",
"with",
"length",
"encoded",
"prefix",
".",
"value",
"length",
"MUST",
"be",
"less",
"than",
"251",
"char"
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L362-L370 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.writeBytes | public void writeBytes(byte header, byte[] bytes) {
int length = bytes.length;
while (remaining() < length + 10) {
grow();
}
writeLength(length + 1);
buf[position++] = header;
System.arraycopy(bytes, 0, buf, position, length);
position += length;
} | java | public void writeBytes(byte header, byte[] bytes) {
int length = bytes.length;
while (remaining() < length + 10) {
grow();
}
writeLength(length + 1);
buf[position++] = header;
System.arraycopy(bytes, 0, buf, position, length);
position += length;
} | [
"public",
"void",
"writeBytes",
"(",
"byte",
"header",
",",
"byte",
"[",
"]",
"bytes",
")",
"{",
"int",
"length",
"=",
"bytes",
".",
"length",
";",
"while",
"(",
"remaining",
"(",
")",
"<",
"length",
"+",
"10",
")",
"{",
"grow",
"(",
")",
";",
"}... | Write bytes.
@param header header byte
@param bytes command bytes | [
"Write",
"bytes",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L379-L388 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java | Buffer.writeLength | public void writeLength(long length) {
if (length < 251) {
buf[position++] = (byte) length;
} else if (length < 65536) {
buf[position++] = (byte) 0xfc;
buf[position++] = (byte) length;
buf[position++] = (byte) (length >>> 8);
} else if (length < 16777216) {
buf[position++] = (byte) 0xfd;
buf[position++] = (byte) length;
buf[position++] = (byte) (length >>> 8);
buf[position++] = (byte) (length >>> 16);
} else {
buf[position++] = (byte) 0xfe;
buf[position++] = (byte) length;
buf[position++] = (byte) (length >>> 8);
buf[position++] = (byte) (length >>> 16);
buf[position++] = (byte) (length >>> 24);
buf[position++] = (byte) (length >>> 32);
buf[position++] = (byte) (length >>> 40);
buf[position++] = (byte) (length >>> 48);
buf[position++] = (byte) (length >>> 54);
}
} | java | public void writeLength(long length) {
if (length < 251) {
buf[position++] = (byte) length;
} else if (length < 65536) {
buf[position++] = (byte) 0xfc;
buf[position++] = (byte) length;
buf[position++] = (byte) (length >>> 8);
} else if (length < 16777216) {
buf[position++] = (byte) 0xfd;
buf[position++] = (byte) length;
buf[position++] = (byte) (length >>> 8);
buf[position++] = (byte) (length >>> 16);
} else {
buf[position++] = (byte) 0xfe;
buf[position++] = (byte) length;
buf[position++] = (byte) (length >>> 8);
buf[position++] = (byte) (length >>> 16);
buf[position++] = (byte) (length >>> 24);
buf[position++] = (byte) (length >>> 32);
buf[position++] = (byte) (length >>> 40);
buf[position++] = (byte) (length >>> 48);
buf[position++] = (byte) (length >>> 54);
}
} | [
"public",
"void",
"writeLength",
"(",
"long",
"length",
")",
"{",
"if",
"(",
"length",
"<",
"251",
")",
"{",
"buf",
"[",
"position",
"++",
"]",
"=",
"(",
"byte",
")",
"length",
";",
"}",
"else",
"if",
"(",
"length",
"<",
"65536",
")",
"{",
"buf",... | Write length.
@param length length | [
"Write",
"length",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/Buffer.java#L395-L418 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/ComStmtExecute.java | ComStmtExecute.writeCmd | public static void writeCmd(final int statementId, final ParameterHolder[] parameters,
final int parameterCount,
ColumnType[] parameterTypeHeader, final PacketOutputStream pos,
final byte cursorFlag) throws IOException {
pos.write(Packet.COM_STMT_EXECUTE);
pos.writeInt(statementId);
pos.write(cursorFlag);
pos.writeInt(1); //Iteration pos
//create null bitmap
if (parameterCount > 0) {
int nullCount = (parameterCount + 7) / 8;
byte[] nullBitsBuffer = new byte[nullCount];
for (int i = 0; i < parameterCount; i++) {
if (parameters[i].isNullData()) {
nullBitsBuffer[i / 8] |= (1 << (i % 8));
}
}
pos.write(nullBitsBuffer, 0, nullCount);
//check if parameters type (using setXXX) have change since previous request, and resend new header type if so
boolean mustSendHeaderType = false;
if (parameterTypeHeader[0] == null) {
mustSendHeaderType = true;
} else {
for (int i = 0; i < parameterCount; i++) {
if (!parameterTypeHeader[i].equals(parameters[i].getColumnType())) {
mustSendHeaderType = true;
break;
}
}
}
if (mustSendHeaderType) {
pos.write((byte) 0x01);
//Store types of parameters in first in first package that is sent to the server.
for (int i = 0; i < parameterCount; i++) {
parameterTypeHeader[i] = parameters[i].getColumnType();
pos.writeShort(parameterTypeHeader[i].getType());
}
} else {
pos.write((byte) 0x00);
}
}
for (int i = 0; i < parameterCount; i++) {
ParameterHolder holder = parameters[i];
if (!holder.isNullData() && !holder.isLongData()) {
holder.writeBinary(pos);
}
}
} | java | public static void writeCmd(final int statementId, final ParameterHolder[] parameters,
final int parameterCount,
ColumnType[] parameterTypeHeader, final PacketOutputStream pos,
final byte cursorFlag) throws IOException {
pos.write(Packet.COM_STMT_EXECUTE);
pos.writeInt(statementId);
pos.write(cursorFlag);
pos.writeInt(1); //Iteration pos
//create null bitmap
if (parameterCount > 0) {
int nullCount = (parameterCount + 7) / 8;
byte[] nullBitsBuffer = new byte[nullCount];
for (int i = 0; i < parameterCount; i++) {
if (parameters[i].isNullData()) {
nullBitsBuffer[i / 8] |= (1 << (i % 8));
}
}
pos.write(nullBitsBuffer, 0, nullCount);
//check if parameters type (using setXXX) have change since previous request, and resend new header type if so
boolean mustSendHeaderType = false;
if (parameterTypeHeader[0] == null) {
mustSendHeaderType = true;
} else {
for (int i = 0; i < parameterCount; i++) {
if (!parameterTypeHeader[i].equals(parameters[i].getColumnType())) {
mustSendHeaderType = true;
break;
}
}
}
if (mustSendHeaderType) {
pos.write((byte) 0x01);
//Store types of parameters in first in first package that is sent to the server.
for (int i = 0; i < parameterCount; i++) {
parameterTypeHeader[i] = parameters[i].getColumnType();
pos.writeShort(parameterTypeHeader[i].getType());
}
} else {
pos.write((byte) 0x00);
}
}
for (int i = 0; i < parameterCount; i++) {
ParameterHolder holder = parameters[i];
if (!holder.isNullData() && !holder.isLongData()) {
holder.writeBinary(pos);
}
}
} | [
"public",
"static",
"void",
"writeCmd",
"(",
"final",
"int",
"statementId",
",",
"final",
"ParameterHolder",
"[",
"]",
"parameters",
",",
"final",
"int",
"parameterCount",
",",
"ColumnType",
"[",
"]",
"parameterTypeHeader",
",",
"final",
"PacketOutputStream",
"pos... | Write COM_STMT_EXECUTE sub-command to output buffer.
@param statementId prepareResult object received after preparation.
@param parameters parameters
@param parameterCount parameters number
@param parameterTypeHeader parameters header1
@param pos outputStream
@param cursorFlag cursor flag. Possible values : <ol>
<li>CURSOR_TYPE_NO_CURSOR = fetch all</li>
<li>CURSOR_TYPE_READ_ONLY = fetch by bunch</li>
<li>CURSOR_TYPE_FOR_UPDATE = fetch by bunch with lock ?</li>
<li>CURSOR_TYPE_SCROLLABLE = //reserved, but not working</li>
</ol>
@throws IOException if a connection error occur | [
"Write",
"COM_STMT_EXECUTE",
"sub",
"-",
"command",
"to",
"output",
"buffer",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/ComStmtExecute.java#L79-L131 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/ComStmtExecute.java | ComStmtExecute.send | public static void send(final PacketOutputStream pos, final int statementId, final ParameterHolder[] parameters,
final int parameterCount, ColumnType[] parameterTypeHeader, byte cursorFlag) throws IOException {
pos.startPacket(0);
writeCmd(statementId, parameters, parameterCount, parameterTypeHeader, pos, cursorFlag);
pos.flush();
} | java | public static void send(final PacketOutputStream pos, final int statementId, final ParameterHolder[] parameters,
final int parameterCount, ColumnType[] parameterTypeHeader, byte cursorFlag) throws IOException {
pos.startPacket(0);
writeCmd(statementId, parameters, parameterCount, parameterTypeHeader, pos, cursorFlag);
pos.flush();
} | [
"public",
"static",
"void",
"send",
"(",
"final",
"PacketOutputStream",
"pos",
",",
"final",
"int",
"statementId",
",",
"final",
"ParameterHolder",
"[",
"]",
"parameters",
",",
"final",
"int",
"parameterCount",
",",
"ColumnType",
"[",
"]",
"parameterTypeHeader",
... | Send a prepare statement binary stream.
@param pos database socket
@param statementId prepareResult object received after preparation.
@param parameters parameters
@param parameterCount parameters number
@param parameterTypeHeader parameters header
@param cursorFlag cursor flag. Possible values : <ol>
<li>CURSOR_TYPE_NO_CURSOR = fetch all</li>
<li>CURSOR_TYPE_READ_ONLY = fetch by bunch</li>
<li>CURSOR_TYPE_FOR_UPDATE = fetch by bunch with lock ?</li>
<li>CURSOR_TYPE_SCROLLABLE = //reserved, but not working</li>
</ol>
@throws IOException if a connection error occur | [
"Send",
"a",
"prepare",
"statement",
"binary",
"stream",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/ComStmtExecute.java#L149-L154 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaXaResource.java | MariaXaResource.execute | private void execute(String command) throws XAException {
try {
connection.createStatement().execute(command);
} catch (SQLException sqle) {
throw mapXaException(sqle);
}
} | java | private void execute(String command) throws XAException {
try {
connection.createStatement().execute(command);
} catch (SQLException sqle) {
throw mapXaException(sqle);
}
} | [
"private",
"void",
"execute",
"(",
"String",
"command",
")",
"throws",
"XAException",
"{",
"try",
"{",
"connection",
".",
"createStatement",
"(",
")",
".",
"execute",
"(",
"command",
")",
";",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
... | Execute a query.
@param command query to run.
@throws XAException exception | [
"Execute",
"a",
"query",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaXaResource.java#L132-L138 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/LogQueryTool.java | LogQueryTool.exWithQuery | private String exWithQuery(String message, PrepareResult serverPrepareResult,
ParameterHolder[] parameters) {
if (options.dumpQueriesOnException) {
StringBuilder sql = new StringBuilder(serverPrepareResult.getSql());
if (serverPrepareResult.getParamCount() > 0) {
sql.append(", parameters [");
if (parameters.length > 0) {
for (int i = 0; i < Math.min(parameters.length, serverPrepareResult.getParamCount());
i++) {
sql.append(parameters[i].toString()).append(",");
}
sql = new StringBuilder(sql.substring(0, sql.length() - 1));
}
sql.append("]");
}
if (options.maxQuerySizeToLog != 0 && sql.length() > options.maxQuerySizeToLog - 3) {
return message
+ "\nQuery is: " + sql.substring(0, options.maxQuerySizeToLog - 3) + "..."
+ "\njava thread: " + Thread.currentThread().getName();
} else {
return message
+ "\nQuery is: " + sql
+ "\njava thread: " + Thread.currentThread().getName();
}
}
return message;
} | java | private String exWithQuery(String message, PrepareResult serverPrepareResult,
ParameterHolder[] parameters) {
if (options.dumpQueriesOnException) {
StringBuilder sql = new StringBuilder(serverPrepareResult.getSql());
if (serverPrepareResult.getParamCount() > 0) {
sql.append(", parameters [");
if (parameters.length > 0) {
for (int i = 0; i < Math.min(parameters.length, serverPrepareResult.getParamCount());
i++) {
sql.append(parameters[i].toString()).append(",");
}
sql = new StringBuilder(sql.substring(0, sql.length() - 1));
}
sql.append("]");
}
if (options.maxQuerySizeToLog != 0 && sql.length() > options.maxQuerySizeToLog - 3) {
return message
+ "\nQuery is: " + sql.substring(0, options.maxQuerySizeToLog - 3) + "..."
+ "\njava thread: " + Thread.currentThread().getName();
} else {
return message
+ "\nQuery is: " + sql
+ "\njava thread: " + Thread.currentThread().getName();
}
}
return message;
} | [
"private",
"String",
"exWithQuery",
"(",
"String",
"message",
",",
"PrepareResult",
"serverPrepareResult",
",",
"ParameterHolder",
"[",
"]",
"parameters",
")",
"{",
"if",
"(",
"options",
".",
"dumpQueriesOnException",
")",
"{",
"StringBuilder",
"sql",
"=",
"new",
... | Return exception message with query.
@param message current exception message
@param serverPrepareResult prepare result
@param parameters query parameters
@return exception message with query | [
"Return",
"exception",
"message",
"with",
"query",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/LogQueryTool.java#L198-L225 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/io/input/DecompressPacketInputStream.java | DecompressPacketInputStream.getPacketArray | public byte[] getPacketArray(boolean reUsable) throws IOException {
byte[] cachePacket = getNextCachePacket();
if (cachePacket != null) {
return cachePacket;
}
//loop until having the whole packet
do {
//Read 7 byte header
readBlocking(header, 7);
int compressedLength =
(header[0] & 0xff) + ((header[1] & 0xff) << 8) + ((header[2] & 0xff) << 16);
compressPacketSeq = header[3] & 0xff;
int decompressedLength =
(header[4] & 0xff) + ((header[5] & 0xff) << 8) + ((header[6] & 0xff) << 16);
byte[] rawBytes;
if (reUsable && decompressedLength == 0 && compressedLength < REUSABLE_BUFFER_LENGTH) {
rawBytes = reusableArray;
} else {
rawBytes = new byte[decompressedLength != 0 ? decompressedLength : compressedLength];
}
readCompressBlocking(rawBytes, compressedLength, decompressedLength);
if (traceCache != null) {
int length = decompressedLength != 0 ? decompressedLength : compressedLength;
traceCache.put(new TraceObject(false,
decompressedLength == 0 ? COMPRESSED_PROTOCOL_NOT_COMPRESSED_PACKET
: COMPRESSED_PROTOCOL_COMPRESSED_PACKET,
Arrays.copyOfRange(header, 0, 7),
Arrays.copyOfRange(rawBytes, 0, length > 1000 ? 1000 : length)));
}
if (logger.isTraceEnabled()) {
int length = decompressedLength != 0 ? decompressedLength : compressedLength;
logger.trace("read {} {}{}",
(decompressedLength == 0 ? "uncompress" : "compress"),
serverThreadLog,
Utils.hexdump(maxQuerySizeToLog - 7, 0, length, header, rawBytes));
}
cache(rawBytes, decompressedLength == 0 ? compressedLength : decompressedLength);
byte[] packet = getNextCachePacket();
if (packet != null) {
return packet;
}
} while (true);
} | java | public byte[] getPacketArray(boolean reUsable) throws IOException {
byte[] cachePacket = getNextCachePacket();
if (cachePacket != null) {
return cachePacket;
}
//loop until having the whole packet
do {
//Read 7 byte header
readBlocking(header, 7);
int compressedLength =
(header[0] & 0xff) + ((header[1] & 0xff) << 8) + ((header[2] & 0xff) << 16);
compressPacketSeq = header[3] & 0xff;
int decompressedLength =
(header[4] & 0xff) + ((header[5] & 0xff) << 8) + ((header[6] & 0xff) << 16);
byte[] rawBytes;
if (reUsable && decompressedLength == 0 && compressedLength < REUSABLE_BUFFER_LENGTH) {
rawBytes = reusableArray;
} else {
rawBytes = new byte[decompressedLength != 0 ? decompressedLength : compressedLength];
}
readCompressBlocking(rawBytes, compressedLength, decompressedLength);
if (traceCache != null) {
int length = decompressedLength != 0 ? decompressedLength : compressedLength;
traceCache.put(new TraceObject(false,
decompressedLength == 0 ? COMPRESSED_PROTOCOL_NOT_COMPRESSED_PACKET
: COMPRESSED_PROTOCOL_COMPRESSED_PACKET,
Arrays.copyOfRange(header, 0, 7),
Arrays.copyOfRange(rawBytes, 0, length > 1000 ? 1000 : length)));
}
if (logger.isTraceEnabled()) {
int length = decompressedLength != 0 ? decompressedLength : compressedLength;
logger.trace("read {} {}{}",
(decompressedLength == 0 ? "uncompress" : "compress"),
serverThreadLog,
Utils.hexdump(maxQuerySizeToLog - 7, 0, length, header, rawBytes));
}
cache(rawBytes, decompressedLength == 0 ? compressedLength : decompressedLength);
byte[] packet = getNextCachePacket();
if (packet != null) {
return packet;
}
} while (true);
} | [
"public",
"byte",
"[",
"]",
"getPacketArray",
"(",
"boolean",
"reUsable",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"cachePacket",
"=",
"getNextCachePacket",
"(",
")",
";",
"if",
"(",
"cachePacket",
"!=",
"null",
")",
"{",
"return",
"cachePacket",... | Get next packet. Packet can be compressed, and if so, can contain many standard packet.
@param reUsable if can use existing reusable buffer to avoid creating array
@return array packet.
@throws IOException if socket exception occur. | [
"Get",
"next",
"packet",
".",
"Packet",
"can",
"be",
"compressed",
"and",
"if",
"so",
"can",
"contain",
"many",
"standard",
"packet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/io/input/DecompressPacketInputStream.java#L107-L158 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/exceptions/ExceptionMapper.java | ExceptionMapper.throwException | public static void throwException(SQLException exception, MariaDbConnection connection,
MariaDbStatement statement) throws SQLException {
throw getException(exception, connection, statement, false);
} | java | public static void throwException(SQLException exception, MariaDbConnection connection,
MariaDbStatement statement) throws SQLException {
throw getException(exception, connection, statement, false);
} | [
"public",
"static",
"void",
"throwException",
"(",
"SQLException",
"exception",
",",
"MariaDbConnection",
"connection",
",",
"MariaDbStatement",
"statement",
")",
"throws",
"SQLException",
"{",
"throw",
"getException",
"(",
"exception",
",",
"connection",
",",
"statem... | Helper to throw exception.
@param exception exception
@param connection current connection
@param statement current statement
@throws SQLException exception | [
"Helper",
"to",
"throw",
"exception",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/exceptions/ExceptionMapper.java#L91-L94 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/exceptions/ExceptionMapper.java | ExceptionMapper.checkConnectionException | public static void checkConnectionException(SQLException exception,
MariaDbConnection connection) {
if (exception.getSQLState() != null) {
SqlStates state = SqlStates.fromString(exception.getSQLState());
if (SqlStates.CONNECTION_EXCEPTION.equals(state)) {
connection.setHostFailed();
if (connection.pooledConnection != null) {
connection.pooledConnection.fireConnectionErrorOccured(exception);
}
}
}
} | java | public static void checkConnectionException(SQLException exception,
MariaDbConnection connection) {
if (exception.getSQLState() != null) {
SqlStates state = SqlStates.fromString(exception.getSQLState());
if (SqlStates.CONNECTION_EXCEPTION.equals(state)) {
connection.setHostFailed();
if (connection.pooledConnection != null) {
connection.pooledConnection.fireConnectionErrorOccured(exception);
}
}
}
} | [
"public",
"static",
"void",
"checkConnectionException",
"(",
"SQLException",
"exception",
",",
"MariaDbConnection",
"connection",
")",
"{",
"if",
"(",
"exception",
".",
"getSQLState",
"(",
")",
"!=",
"null",
")",
"{",
"SqlStates",
"state",
"=",
"SqlStates",
".",... | Check connection exception to report to poolConnection listeners.
@param exception current exception
@param connection current connection | [
"Check",
"connection",
"exception",
"to",
"report",
"to",
"poolConnection",
"listeners",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/exceptions/ExceptionMapper.java#L203-L214 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.newConnection | public static MariaDbConnection newConnection(UrlParser urlParser, GlobalStateInfo globalInfo)
throws SQLException {
if (urlParser.getOptions().pool) {
return Pools.retrievePool(urlParser).getConnection();
}
Protocol protocol = Utils.retrieveProxy(urlParser, globalInfo);
return new MariaDbConnection(protocol);
} | java | public static MariaDbConnection newConnection(UrlParser urlParser, GlobalStateInfo globalInfo)
throws SQLException {
if (urlParser.getOptions().pool) {
return Pools.retrievePool(urlParser).getConnection();
}
Protocol protocol = Utils.retrieveProxy(urlParser, globalInfo);
return new MariaDbConnection(protocol);
} | [
"public",
"static",
"MariaDbConnection",
"newConnection",
"(",
"UrlParser",
"urlParser",
",",
"GlobalStateInfo",
"globalInfo",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"urlParser",
".",
"getOptions",
"(",
")",
".",
"pool",
")",
"{",
"return",
"Pools",
".",... | Create new connection Object.
@param urlParser parser
@param globalInfo global info
@return connection object
@throws SQLException if any connection error occur | [
"Create",
"new",
"connection",
"Object",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L168-L176 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.unquoteIdentifier | @Deprecated
public static String unquoteIdentifier(String string) {
if (string != null && string.startsWith("`") && string.endsWith("`") && string.length() >= 2) {
return string.substring(1, string.length() - 1).replace("``", "`");
}
return string;
} | java | @Deprecated
public static String unquoteIdentifier(String string) {
if (string != null && string.startsWith("`") && string.endsWith("`") && string.length() >= 2) {
return string.substring(1, string.length() - 1).replace("``", "`");
}
return string;
} | [
"@",
"Deprecated",
"public",
"static",
"String",
"unquoteIdentifier",
"(",
"String",
"string",
")",
"{",
"if",
"(",
"string",
"!=",
"null",
"&&",
"string",
".",
"startsWith",
"(",
"\"`\"",
")",
"&&",
"string",
".",
"endsWith",
"(",
"\"`\"",
")",
"&&",
"s... | UnQuote string.
@param string value
@return unquote string
@deprecated since 1.3.0 | [
"UnQuote",
"string",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L189-L195 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.clientPrepareStatement | public ClientSidePreparedStatement clientPrepareStatement(final String sql)
throws SQLException {
return new ClientSidePreparedStatement(this,
sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
Statement.RETURN_GENERATED_KEYS);
} | java | public ClientSidePreparedStatement clientPrepareStatement(final String sql)
throws SQLException {
return new ClientSidePreparedStatement(this,
sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
Statement.RETURN_GENERATED_KEYS);
} | [
"public",
"ClientSidePreparedStatement",
"clientPrepareStatement",
"(",
"final",
"String",
"sql",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"ClientSidePreparedStatement",
"(",
"this",
",",
"sql",
",",
"ResultSet",
".",
"TYPE_FORWARD_ONLY",
",",
"ResultSet",
... | Create a new client prepared statement.
@param sql the query.
@return a client prepared statement.
@throws SQLException if there is a problem preparing the statement. | [
"Create",
"a",
"new",
"client",
"prepared",
"statement",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L277-L284 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.serverPrepareStatement | public ServerSidePreparedStatement serverPrepareStatement(final String sql)
throws SQLException {
return new ServerSidePreparedStatement(this,
sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
Statement.RETURN_GENERATED_KEYS);
} | java | public ServerSidePreparedStatement serverPrepareStatement(final String sql)
throws SQLException {
return new ServerSidePreparedStatement(this,
sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
Statement.RETURN_GENERATED_KEYS);
} | [
"public",
"ServerSidePreparedStatement",
"serverPrepareStatement",
"(",
"final",
"String",
"sql",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"ServerSidePreparedStatement",
"(",
"this",
",",
"sql",
",",
"ResultSet",
".",
"TYPE_FORWARD_ONLY",
",",
"ResultSet",
... | Create a new server prepared statement.
@param sql the query.
@return a server prepared statement.
@throws SQLException if there is a problem preparing the statement. | [
"Create",
"a",
"new",
"server",
"prepared",
"statement",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L293-L300 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.prepareStatement | public PreparedStatement prepareStatement(final String sql) throws SQLException {
return internalPrepareStatement(sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
Statement.NO_GENERATED_KEYS);
} | java | public PreparedStatement prepareStatement(final String sql) throws SQLException {
return internalPrepareStatement(sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
Statement.NO_GENERATED_KEYS);
} | [
"public",
"PreparedStatement",
"prepareStatement",
"(",
"final",
"String",
"sql",
")",
"throws",
"SQLException",
"{",
"return",
"internalPrepareStatement",
"(",
"sql",
",",
"ResultSet",
".",
"TYPE_FORWARD_ONLY",
",",
"ResultSet",
".",
"CONCUR_READ_ONLY",
",",
"Stateme... | creates a new prepared statement.
@param sql the query.
@return a prepared statement.
@throws SQLException if there is a problem preparing the statement. | [
"creates",
"a",
"new",
"prepared",
"statement",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L309-L314 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.internalPrepareStatement | private PreparedStatement internalPrepareStatement(final String sql,
final int resultSetScrollType,
final int resultSetConcurrency,
final int autoGeneratedKeys)
throws SQLException {
if (sql != null) {
String sqlQuery = Utils.nativeSql(sql, protocol.noBackslashEscapes());
if (options.useServerPrepStmts && PREPARABLE_STATEMENT_PATTERN.matcher(sqlQuery).find()) {
//prepare isn't delayed -> if prepare fail, fallback to client preparedStatement?
checkConnection();
try {
return new ServerSidePreparedStatement(this,
sqlQuery,
resultSetScrollType,
resultSetConcurrency,
autoGeneratedKeys);
} catch (SQLNonTransientConnectionException e) {
throw e;
} catch (SQLException e) {
//on some specific case, server cannot prepared data (CONJ-238)
//will use clientPreparedStatement
}
}
return new ClientSidePreparedStatement(this,
sqlQuery,
resultSetScrollType,
resultSetConcurrency,
autoGeneratedKeys);
} else {
throw new SQLException("SQL value can not be NULL");
}
} | java | private PreparedStatement internalPrepareStatement(final String sql,
final int resultSetScrollType,
final int resultSetConcurrency,
final int autoGeneratedKeys)
throws SQLException {
if (sql != null) {
String sqlQuery = Utils.nativeSql(sql, protocol.noBackslashEscapes());
if (options.useServerPrepStmts && PREPARABLE_STATEMENT_PATTERN.matcher(sqlQuery).find()) {
//prepare isn't delayed -> if prepare fail, fallback to client preparedStatement?
checkConnection();
try {
return new ServerSidePreparedStatement(this,
sqlQuery,
resultSetScrollType,
resultSetConcurrency,
autoGeneratedKeys);
} catch (SQLNonTransientConnectionException e) {
throw e;
} catch (SQLException e) {
//on some specific case, server cannot prepared data (CONJ-238)
//will use clientPreparedStatement
}
}
return new ClientSidePreparedStatement(this,
sqlQuery,
resultSetScrollType,
resultSetConcurrency,
autoGeneratedKeys);
} else {
throw new SQLException("SQL value can not be NULL");
}
} | [
"private",
"PreparedStatement",
"internalPrepareStatement",
"(",
"final",
"String",
"sql",
",",
"final",
"int",
"resultSetScrollType",
",",
"final",
"int",
"resultSetConcurrency",
",",
"final",
"int",
"autoGeneratedKeys",
")",
"throws",
"SQLException",
"{",
"if",
"(",... | Send ServerPrepareStatement or ClientPrepareStatement depending on SQL query and options If
server side and PREPARE can be delayed, a facade will be return, to have a fallback on client
prepareStatement.
@param sql sql query
@param resultSetScrollType one of the following <code>ResultSet</code> constants:
<code>ResultSet.TYPE_FORWARD_ONLY</code>,
<code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
<code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
@param resultSetConcurrency a concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code>
or
<code>ResultSet.CONCUR_UPDATABLE</code>
@param autoGeneratedKeys a flag indicating whether auto-generated keys should be returned;
one of
<code>Statement.RETURN_GENERATED_KEYS</code>
or <code>Statement.NO_GENERATED_KEYS</code>
@return PrepareStatement
@throws SQLException if a connection error occur during the server preparation. | [
"Send",
"ServerPrepareStatement",
"or",
"ClientPrepareStatement",
"depending",
"on",
"SQL",
"query",
"and",
"options",
"If",
"server",
"side",
"and",
"PREPARE",
"can",
"be",
"delayed",
"a",
"facade",
"will",
"be",
"return",
"to",
"have",
"a",
"fallback",
"on",
... | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L516-L550 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.commit | public void commit() throws SQLException {
lock.lock();
try {
if (protocol.inTransaction()) {
try (Statement st = createStatement()) {
st.execute("COMMIT");
}
}
} finally {
lock.unlock();
}
} | java | public void commit() throws SQLException {
lock.lock();
try {
if (protocol.inTransaction()) {
try (Statement st = createStatement()) {
st.execute("COMMIT");
}
}
} finally {
lock.unlock();
}
} | [
"public",
"void",
"commit",
"(",
")",
"throws",
"SQLException",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"protocol",
".",
"inTransaction",
"(",
")",
")",
"{",
"try",
"(",
"Statement",
"st",
"=",
"createStatement",
"(",
")",
")"... | Sends commit to the server.
@throws SQLException if there is an error commiting. | [
"Sends",
"commit",
"to",
"the",
"server",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L749-L760 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.setReadOnly | public void setReadOnly(final boolean readOnly) throws SQLException {
try {
logger.debug("conn={}({}) - set read-only to value {} {}",
protocol.getServerThreadId(),
protocol.isMasterConnection() ? "M" : "S",
readOnly);
stateFlag |= ConnectionState.STATE_READ_ONLY;
protocol.setReadonly(readOnly);
} catch (SQLException e) {
throw ExceptionMapper.getException(e, this, null, false);
}
} | java | public void setReadOnly(final boolean readOnly) throws SQLException {
try {
logger.debug("conn={}({}) - set read-only to value {} {}",
protocol.getServerThreadId(),
protocol.isMasterConnection() ? "M" : "S",
readOnly);
stateFlag |= ConnectionState.STATE_READ_ONLY;
protocol.setReadonly(readOnly);
} catch (SQLException e) {
throw ExceptionMapper.getException(e, this, null, false);
}
} | [
"public",
"void",
"setReadOnly",
"(",
"final",
"boolean",
"readOnly",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"logger",
".",
"debug",
"(",
"\"conn={}({}) - set read-only to value {} {}\"",
",",
"protocol",
".",
"getServerThreadId",
"(",
")",
",",
"protocol",... | Sets whether this connection is read only.
@param readOnly true if it should be read only.
@throws SQLException if there is a problem | [
"Sets",
"whether",
"this",
"connection",
"is",
"read",
"only",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L851-L862 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.getClientInfo | public Properties getClientInfo() throws SQLException {
checkConnection();
Properties properties = new Properties();
try (Statement statement = createStatement()) {
try (ResultSet rs = statement
.executeQuery("SELECT @ApplicationName, @ClientUser, @ClientHostname")) {
if (rs.next()) {
if (rs.getString(1) != null) {
properties.setProperty("ApplicationName", rs.getString(1));
}
if (rs.getString(2) != null) {
properties.setProperty("ClientUser", rs.getString(2));
}
if (rs.getString(3) != null) {
properties.setProperty("ClientHostname", rs.getString(3));
}
return properties;
}
}
}
properties.setProperty("ApplicationName", null);
properties.setProperty("ClientUser", null);
properties.setProperty("ClientHostname", null);
return properties;
} | java | public Properties getClientInfo() throws SQLException {
checkConnection();
Properties properties = new Properties();
try (Statement statement = createStatement()) {
try (ResultSet rs = statement
.executeQuery("SELECT @ApplicationName, @ClientUser, @ClientHostname")) {
if (rs.next()) {
if (rs.getString(1) != null) {
properties.setProperty("ApplicationName", rs.getString(1));
}
if (rs.getString(2) != null) {
properties.setProperty("ClientUser", rs.getString(2));
}
if (rs.getString(3) != null) {
properties.setProperty("ClientHostname", rs.getString(3));
}
return properties;
}
}
}
properties.setProperty("ApplicationName", null);
properties.setProperty("ClientUser", null);
properties.setProperty("ClientHostname", null);
return properties;
} | [
"public",
"Properties",
"getClientInfo",
"(",
")",
"throws",
"SQLException",
"{",
"checkConnection",
"(",
")",
";",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"try",
"(",
"Statement",
"statement",
"=",
"createStatement",
"(",
")",
")"... | Returns a list containing the name and current value of each client info property supported by
the driver. The value of a client info property may be null if the property has not been set
and does not have a default value.
@return A <code>Properties</code> object that contains the name and current value of each of
the client info properties supported by the driver.
@throws SQLException if the database server returns an error when fetching the client info
values from the database or this method is called on a closed connection | [
"Returns",
"a",
"list",
"containing",
"the",
"name",
"and",
"current",
"value",
"of",
"each",
"client",
"info",
"property",
"supported",
"by",
"the",
"driver",
".",
"The",
"value",
"of",
"a",
"client",
"info",
"property",
"may",
"be",
"null",
"if",
"the",
... | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L1432-L1456 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.setNetworkTimeout | public void setNetworkTimeout(Executor executor, final int milliseconds) throws SQLException {
if (this.isClosed()) {
throw ExceptionMapper
.getSqlException("Connection.setNetworkTimeout cannot be called on a closed connection");
}
if (milliseconds < 0) {
throw ExceptionMapper
.getSqlException("Connection.setNetworkTimeout cannot be called with a negative timeout");
}
SQLPermission sqlPermission = new SQLPermission("setNetworkTimeout");
SecurityManager securityManager = System.getSecurityManager();
if (securityManager != null) {
securityManager.checkPermission(sqlPermission);
}
try {
stateFlag |= ConnectionState.STATE_NETWORK_TIMEOUT;
protocol.setTimeout(milliseconds);
} catch (SocketException se) {
throw ExceptionMapper.getSqlException("Cannot set the network timeout", se);
}
} | java | public void setNetworkTimeout(Executor executor, final int milliseconds) throws SQLException {
if (this.isClosed()) {
throw ExceptionMapper
.getSqlException("Connection.setNetworkTimeout cannot be called on a closed connection");
}
if (milliseconds < 0) {
throw ExceptionMapper
.getSqlException("Connection.setNetworkTimeout cannot be called with a negative timeout");
}
SQLPermission sqlPermission = new SQLPermission("setNetworkTimeout");
SecurityManager securityManager = System.getSecurityManager();
if (securityManager != null) {
securityManager.checkPermission(sqlPermission);
}
try {
stateFlag |= ConnectionState.STATE_NETWORK_TIMEOUT;
protocol.setTimeout(milliseconds);
} catch (SocketException se) {
throw ExceptionMapper.getSqlException("Cannot set the network timeout", se);
}
} | [
"public",
"void",
"setNetworkTimeout",
"(",
"Executor",
"executor",
",",
"final",
"int",
"milliseconds",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"this",
".",
"isClosed",
"(",
")",
")",
"{",
"throw",
"ExceptionMapper",
".",
"getSqlException",
"(",
"\"Con... | Change network timeout.
@param executor executor (can be null)
@param milliseconds network timeout in milliseconds.
@throws SQLException if security manager doesn't permit it. | [
"Change",
"network",
"timeout",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L1700-L1720 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbConnection.java | MariaDbConnection.reset | public void reset() throws SQLException {
boolean useComReset = options.useResetConnection
&& ((protocol.isServerMariaDb() && protocol.versionGreaterOrEqual(10, 2, 4))
|| (!protocol.isServerMariaDb() && protocol.versionGreaterOrEqual(5, 7, 3)));
if (useComReset) {
protocol.reset();
}
if (stateFlag != 0) {
try {
if ((stateFlag & ConnectionState.STATE_NETWORK_TIMEOUT) != 0) {
setNetworkTimeout(null, options.socketTimeout);
}
if ((stateFlag & ConnectionState.STATE_AUTOCOMMIT) != 0) {
setAutoCommit(options.autocommit);
}
if ((stateFlag & ConnectionState.STATE_DATABASE) != 0) {
protocol.resetDatabase();
}
if ((stateFlag & ConnectionState.STATE_READ_ONLY) != 0) {
setReadOnly(false); //default to master connection
}
//COM_RESET_CONNECTION reset transaction isolation
if (!useComReset && (stateFlag & ConnectionState.STATE_TRANSACTION_ISOLATION) != 0) {
setTransactionIsolation(defaultTransactionIsolation);
}
stateFlag = 0;
} catch (SQLException sqle) {
throw ExceptionMapper.getSqlException("error resetting connection");
}
}
warningsCleared = true;
} | java | public void reset() throws SQLException {
boolean useComReset = options.useResetConnection
&& ((protocol.isServerMariaDb() && protocol.versionGreaterOrEqual(10, 2, 4))
|| (!protocol.isServerMariaDb() && protocol.versionGreaterOrEqual(5, 7, 3)));
if (useComReset) {
protocol.reset();
}
if (stateFlag != 0) {
try {
if ((stateFlag & ConnectionState.STATE_NETWORK_TIMEOUT) != 0) {
setNetworkTimeout(null, options.socketTimeout);
}
if ((stateFlag & ConnectionState.STATE_AUTOCOMMIT) != 0) {
setAutoCommit(options.autocommit);
}
if ((stateFlag & ConnectionState.STATE_DATABASE) != 0) {
protocol.resetDatabase();
}
if ((stateFlag & ConnectionState.STATE_READ_ONLY) != 0) {
setReadOnly(false); //default to master connection
}
//COM_RESET_CONNECTION reset transaction isolation
if (!useComReset && (stateFlag & ConnectionState.STATE_TRANSACTION_ISOLATION) != 0) {
setTransactionIsolation(defaultTransactionIsolation);
}
stateFlag = 0;
} catch (SQLException sqle) {
throw ExceptionMapper.getSqlException("error resetting connection");
}
}
warningsCleared = true;
} | [
"public",
"void",
"reset",
"(",
")",
"throws",
"SQLException",
"{",
"boolean",
"useComReset",
"=",
"options",
".",
"useResetConnection",
"&&",
"(",
"(",
"protocol",
".",
"isServerMariaDb",
"(",
")",
"&&",
"protocol",
".",
"versionGreaterOrEqual",
"(",
"10",
",... | Reset connection set has it was after creating a "fresh" new connection.
defaultTransactionIsolation must have been initialized.
<p>BUT : - session variable state are reset only if option useResetConnection is set and - if
using the option "useServerPrepStmts", PREPARE statement are still prepared</p>
@throws SQLException if resetting operation failed | [
"Reset",
"connection",
"set",
"has",
"it",
"was",
"after",
"creating",
"a",
"fresh",
"new",
"connection",
".",
"defaultTransactionIsolation",
"must",
"have",
"been",
"initialized",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbConnection.java#L1744-L1786 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/dao/ColumnNameMap.java | ColumnNameMap.getIndex | public int getIndex(String name) throws SQLException {
if (name == null) {
throw new SQLException("Column name cannot be null");
}
String lowerName = name.toLowerCase(Locale.ROOT);
// The specs in JDBC 4.0 specify that ResultSet.findColumn and
// ResultSet.getXXX(String name) should use column alias (AS in the query). If label is not found, we use
// original table name.
if (aliasMap == null) {
aliasMap = new HashMap<>();
int counter = 0;
for (ColumnInformation ci : columnInfo) {
String columnAlias = ci.getName();
if (columnAlias != null) {
columnAlias = columnAlias.toLowerCase(Locale.ROOT);
aliasMap.putIfAbsent(columnAlias, counter);
String tableName = ci.getTable();
if (tableName != null) {
aliasMap.putIfAbsent(tableName.toLowerCase(Locale.ROOT) + "." + columnAlias, counter);
}
}
counter++;
}
}
Integer res = aliasMap.get(lowerName);
if (res != null) {
return res;
}
if (originalMap == null) {
originalMap = new HashMap<>();
int counter = 0;
for (ColumnInformation ci : columnInfo) {
String columnRealName = ci.getOriginalName();
if (columnRealName != null) {
columnRealName = columnRealName.toLowerCase(Locale.ROOT);
originalMap.putIfAbsent(columnRealName, counter);
String tableName = ci.getOriginalTable();
if (tableName != null) {
originalMap
.putIfAbsent(tableName.toLowerCase(Locale.ROOT) + "." + columnRealName, counter);
}
}
counter++;
}
}
res = originalMap.get(lowerName);
if (res == null) {
throw ExceptionMapper.get("No such column: " + name, "42S22", 1054, null, false);
}
return res;
} | java | public int getIndex(String name) throws SQLException {
if (name == null) {
throw new SQLException("Column name cannot be null");
}
String lowerName = name.toLowerCase(Locale.ROOT);
// The specs in JDBC 4.0 specify that ResultSet.findColumn and
// ResultSet.getXXX(String name) should use column alias (AS in the query). If label is not found, we use
// original table name.
if (aliasMap == null) {
aliasMap = new HashMap<>();
int counter = 0;
for (ColumnInformation ci : columnInfo) {
String columnAlias = ci.getName();
if (columnAlias != null) {
columnAlias = columnAlias.toLowerCase(Locale.ROOT);
aliasMap.putIfAbsent(columnAlias, counter);
String tableName = ci.getTable();
if (tableName != null) {
aliasMap.putIfAbsent(tableName.toLowerCase(Locale.ROOT) + "." + columnAlias, counter);
}
}
counter++;
}
}
Integer res = aliasMap.get(lowerName);
if (res != null) {
return res;
}
if (originalMap == null) {
originalMap = new HashMap<>();
int counter = 0;
for (ColumnInformation ci : columnInfo) {
String columnRealName = ci.getOriginalName();
if (columnRealName != null) {
columnRealName = columnRealName.toLowerCase(Locale.ROOT);
originalMap.putIfAbsent(columnRealName, counter);
String tableName = ci.getOriginalTable();
if (tableName != null) {
originalMap
.putIfAbsent(tableName.toLowerCase(Locale.ROOT) + "." + columnRealName, counter);
}
}
counter++;
}
}
res = originalMap.get(lowerName);
if (res == null) {
throw ExceptionMapper.get("No such column: " + name, "42S22", 1054, null, false);
}
return res;
} | [
"public",
"int",
"getIndex",
"(",
"String",
"name",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"Column name cannot be null\"",
")",
";",
"}",
"String",
"lowerName",
"=",
"name",
".",
... | Get column index by name.
@param name column name
@return index.
@throws SQLException if no column info exists, or column is unknown | [
"Get",
"column",
"index",
"by",
"name",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/dao/ColumnNameMap.java#L80-L137 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/resultset/ColumnInformation.java | ColumnInformation.getPrecision | public long getPrecision() {
switch (type) {
case OLDDECIMAL:
case DECIMAL:
//DECIMAL and OLDDECIMAL are "exact" fixed-point number.
//so :
// - if can be signed, 1 byte is saved for sign
// - if decimal > 0, one byte more for dot
if (isSigned()) {
return length - ((decimals > 0) ? 2 : 1);
} else {
return length - ((decimals > 0) ? 1 : 0);
}
default:
return length;
}
} | java | public long getPrecision() {
switch (type) {
case OLDDECIMAL:
case DECIMAL:
//DECIMAL and OLDDECIMAL are "exact" fixed-point number.
//so :
// - if can be signed, 1 byte is saved for sign
// - if decimal > 0, one byte more for dot
if (isSigned()) {
return length - ((decimals > 0) ? 2 : 1);
} else {
return length - ((decimals > 0) ? 1 : 0);
}
default:
return length;
}
} | [
"public",
"long",
"getPrecision",
"(",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"OLDDECIMAL",
":",
"case",
"DECIMAL",
":",
"//DECIMAL and OLDDECIMAL are \"exact\" fixed-point number.",
"//so :",
"// - if can be signed, 1 byte is saved for sign",
"// - if decimal > ... | Return metadata precision.
@return precision | [
"Return",
"metadata",
"precision",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/resultset/ColumnInformation.java#L271-L287 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/resultset/ColumnInformation.java | ColumnInformation.getDisplaySize | public int getDisplaySize() {
int vtype = type.getSqlType();
if (vtype == Types.VARCHAR || vtype == Types.CHAR) {
int maxWidth = maxCharlen[charsetNumber & 0xff];
if (maxWidth == 0) {
maxWidth = 1;
}
return (int) length / maxWidth;
}
return (int) length;
} | java | public int getDisplaySize() {
int vtype = type.getSqlType();
if (vtype == Types.VARCHAR || vtype == Types.CHAR) {
int maxWidth = maxCharlen[charsetNumber & 0xff];
if (maxWidth == 0) {
maxWidth = 1;
}
return (int) length / maxWidth;
}
return (int) length;
} | [
"public",
"int",
"getDisplaySize",
"(",
")",
"{",
"int",
"vtype",
"=",
"type",
".",
"getSqlType",
"(",
")",
";",
"if",
"(",
"vtype",
"==",
"Types",
".",
"VARCHAR",
"||",
"vtype",
"==",
"Types",
".",
"CHAR",
")",
"{",
"int",
"maxWidth",
"=",
"maxCharl... | Get column size.
@return size | [
"Get",
"column",
"size",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/resultset/ColumnInformation.java#L294-L306 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java | Results.addStats | public void addStats(long updateCount, long insertId, boolean moreResultAvailable) {
if (cmdInformation == null) {
if (batch) {
cmdInformation = new CmdInformationBatch(expectedSize, autoIncrement);
} else if (moreResultAvailable) {
cmdInformation = new CmdInformationMultiple(expectedSize, autoIncrement);
} else {
cmdInformation = new CmdInformationSingle(insertId, updateCount, autoIncrement);
return;
}
}
cmdInformation.addSuccessStat(updateCount, insertId);
} | java | public void addStats(long updateCount, long insertId, boolean moreResultAvailable) {
if (cmdInformation == null) {
if (batch) {
cmdInformation = new CmdInformationBatch(expectedSize, autoIncrement);
} else if (moreResultAvailable) {
cmdInformation = new CmdInformationMultiple(expectedSize, autoIncrement);
} else {
cmdInformation = new CmdInformationSingle(insertId, updateCount, autoIncrement);
return;
}
}
cmdInformation.addSuccessStat(updateCount, insertId);
} | [
"public",
"void",
"addStats",
"(",
"long",
"updateCount",
",",
"long",
"insertId",
",",
"boolean",
"moreResultAvailable",
")",
"{",
"if",
"(",
"cmdInformation",
"==",
"null",
")",
"{",
"if",
"(",
"batch",
")",
"{",
"cmdInformation",
"=",
"new",
"CmdInformati... | Add execution statistics.
@param updateCount number of updated rows
@param insertId primary key
@param moreResultAvailable is there additional packet | [
"Add",
"execution",
"statistics",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java#L174-L186 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java | Results.addStatsError | public void addStatsError(boolean moreResultAvailable) {
if (cmdInformation == null) {
if (batch) {
cmdInformation = new CmdInformationBatch(expectedSize, autoIncrement);
} else if (moreResultAvailable) {
cmdInformation = new CmdInformationMultiple(expectedSize, autoIncrement);
} else {
cmdInformation = new CmdInformationSingle(0, Statement.EXECUTE_FAILED, autoIncrement);
return;
}
}
cmdInformation.addErrorStat();
} | java | public void addStatsError(boolean moreResultAvailable) {
if (cmdInformation == null) {
if (batch) {
cmdInformation = new CmdInformationBatch(expectedSize, autoIncrement);
} else if (moreResultAvailable) {
cmdInformation = new CmdInformationMultiple(expectedSize, autoIncrement);
} else {
cmdInformation = new CmdInformationSingle(0, Statement.EXECUTE_FAILED, autoIncrement);
return;
}
}
cmdInformation.addErrorStat();
} | [
"public",
"void",
"addStatsError",
"(",
"boolean",
"moreResultAvailable",
")",
"{",
"if",
"(",
"cmdInformation",
"==",
"null",
")",
"{",
"if",
"(",
"batch",
")",
"{",
"cmdInformation",
"=",
"new",
"CmdInformationBatch",
"(",
"expectedSize",
",",
"autoIncrement",... | Indicate that result is an Error, to set appropriate results.
@param moreResultAvailable indicate if other results (ResultSet or updateCount) are available. | [
"Indicate",
"that",
"result",
"is",
"an",
"Error",
"to",
"set",
"appropriate",
"results",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java#L193-L205 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java | Results.addResultSet | public void addResultSet(SelectResultSet resultSet, boolean moreResultAvailable) {
if (resultSet.isCallableResult()) {
callableResultSet = resultSet;
return;
}
if (executionResults == null) {
executionResults = new ArrayDeque<>();
}
executionResults.add(resultSet);
if (cmdInformation == null) {
if (batch) {
cmdInformation = new CmdInformationBatch(expectedSize, autoIncrement);
} else if (moreResultAvailable) {
cmdInformation = new CmdInformationMultiple(expectedSize, autoIncrement);
} else {
cmdInformation = new CmdInformationSingle(0, -1, autoIncrement);
return;
}
}
cmdInformation.addResultSetStat();
} | java | public void addResultSet(SelectResultSet resultSet, boolean moreResultAvailable) {
if (resultSet.isCallableResult()) {
callableResultSet = resultSet;
return;
}
if (executionResults == null) {
executionResults = new ArrayDeque<>();
}
executionResults.add(resultSet);
if (cmdInformation == null) {
if (batch) {
cmdInformation = new CmdInformationBatch(expectedSize, autoIncrement);
} else if (moreResultAvailable) {
cmdInformation = new CmdInformationMultiple(expectedSize, autoIncrement);
} else {
cmdInformation = new CmdInformationSingle(0, -1, autoIncrement);
return;
}
}
cmdInformation.addResultSetStat();
} | [
"public",
"void",
"addResultSet",
"(",
"SelectResultSet",
"resultSet",
",",
"boolean",
"moreResultAvailable",
")",
"{",
"if",
"(",
"resultSet",
".",
"isCallableResult",
"(",
")",
")",
"{",
"callableResultSet",
"=",
"resultSet",
";",
"return",
";",
"}",
"if",
"... | Add resultSet to results.
@param resultSet new resultSet.
@param moreResultAvailable indicate if other results (ResultSet or updateCount) are available. | [
"Add",
"resultSet",
"to",
"results",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java#L217-L237 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java | Results.isFullyLoaded | public boolean isFullyLoaded(Protocol protocol) {
if (fetchSize == 0 || resultSet == null) {
return true;
}
return resultSet.isFullyLoaded()
&& executionResults.isEmpty()
&& !protocol.hasMoreResults();
} | java | public boolean isFullyLoaded(Protocol protocol) {
if (fetchSize == 0 || resultSet == null) {
return true;
}
return resultSet.isFullyLoaded()
&& executionResults.isEmpty()
&& !protocol.hasMoreResults();
} | [
"public",
"boolean",
"isFullyLoaded",
"(",
"Protocol",
"protocol",
")",
"{",
"if",
"(",
"fetchSize",
"==",
"0",
"||",
"resultSet",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"resultSet",
".",
"isFullyLoaded",
"(",
")",
"&&",
"executionRe... | Indicate if result contain result-set that is still streaming from server.
@param protocol current protocol
@return true if streaming is finished | [
"Indicate",
"if",
"result",
"contain",
"result",
"-",
"set",
"that",
"is",
"still",
"streaming",
"from",
"server",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java#L332-L339 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java | Results.getMoreResults | public boolean getMoreResults(final int current, Protocol protocol) throws SQLException {
if (fetchSize != 0 && resultSet != null) {
protocol.getLock().lock();
try {
//load current resultSet
if (current == Statement.CLOSE_CURRENT_RESULT && resultSet != null) {
resultSet.close();
} else {
resultSet.fetchRemaining();
}
//load next data if there is
if (protocol.hasMoreResults()) {
protocol.getResult(this);
}
} catch (SQLException e) {
ExceptionMapper.throwException(e, null, statement);
} finally {
protocol.getLock().unlock();
}
}
if (cmdInformation.moreResults() && !batch) {
if (current == Statement.CLOSE_CURRENT_RESULT && resultSet != null) {
resultSet.close();
}
if (executionResults != null) {
resultSet = executionResults.poll();
}
return resultSet != null;
} else {
if (current == Statement.CLOSE_CURRENT_RESULT && resultSet != null) {
resultSet.close();
}
resultSet = null;
return false;
}
} | java | public boolean getMoreResults(final int current, Protocol protocol) throws SQLException {
if (fetchSize != 0 && resultSet != null) {
protocol.getLock().lock();
try {
//load current resultSet
if (current == Statement.CLOSE_CURRENT_RESULT && resultSet != null) {
resultSet.close();
} else {
resultSet.fetchRemaining();
}
//load next data if there is
if (protocol.hasMoreResults()) {
protocol.getResult(this);
}
} catch (SQLException e) {
ExceptionMapper.throwException(e, null, statement);
} finally {
protocol.getLock().unlock();
}
}
if (cmdInformation.moreResults() && !batch) {
if (current == Statement.CLOSE_CURRENT_RESULT && resultSet != null) {
resultSet.close();
}
if (executionResults != null) {
resultSet = executionResults.poll();
}
return resultSet != null;
} else {
if (current == Statement.CLOSE_CURRENT_RESULT && resultSet != null) {
resultSet.close();
}
resultSet = null;
return false;
}
} | [
"public",
"boolean",
"getMoreResults",
"(",
"final",
"int",
"current",
",",
"Protocol",
"protocol",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"fetchSize",
"!=",
"0",
"&&",
"resultSet",
"!=",
"null",
")",
"{",
"protocol",
".",
"getLock",
"(",
")",
".",... | Position to next resultSet.
@param current one of the following <code>Statement</code> constants indicating what should
happen to current
<code>ResultSet</code> objects obtained using the method
<code>getResultSet</code>:
<code>Statement.CLOSE_CURRENT_RESULT</code>, <code>Statement.KEEP_CURRENT_RESULT</code>,
or <code>Statement.CLOSE_ALL_RESULTS</code>
@param protocol current protocol
@return true if other resultSet exists.
@throws SQLException if any connection error occur. | [
"Position",
"to",
"next",
"resultSet",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/read/dao/Results.java#L354-L399 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java | MariaDbPoolDataSource.getDatabaseName | public String getDatabaseName() {
if (database != null) {
return database;
}
return (urlParser != null && urlParser.getDatabase() != null) ? urlParser.getDatabase() : "";
} | java | public String getDatabaseName() {
if (database != null) {
return database;
}
return (urlParser != null && urlParser.getDatabase() != null) ? urlParser.getDatabase() : "";
} | [
"public",
"String",
"getDatabaseName",
"(",
")",
"{",
"if",
"(",
"database",
"!=",
"null",
")",
"{",
"return",
"database",
";",
"}",
"return",
"(",
"urlParser",
"!=",
"null",
"&&",
"urlParser",
".",
"getDatabase",
"(",
")",
"!=",
"null",
")",
"?",
"url... | Gets the name of the database.
@return the name of the database for this data source | [
"Gets",
"the",
"name",
"of",
"the",
"database",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java#L94-L99 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java | MariaDbPoolDataSource.getUser | public String getUser() {
if (user != null) {
return user;
}
return urlParser != null ? urlParser.getUsername() : null;
} | java | public String getUser() {
if (user != null) {
return user;
}
return urlParser != null ? urlParser.getUsername() : null;
} | [
"public",
"String",
"getUser",
"(",
")",
"{",
"if",
"(",
"user",
"!=",
"null",
")",
"{",
"return",
"user",
";",
"}",
"return",
"urlParser",
"!=",
"null",
"?",
"urlParser",
".",
"getUsername",
"(",
")",
":",
"null",
";",
"}"
] | Gets the username.
@return the username to use when connecting to the database | [
"Gets",
"the",
"username",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java#L123-L128 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java | MariaDbPoolDataSource.getPort | public int getPort() {
if (port != null && port != 0) {
return port;
}
return urlParser != null ? urlParser.getHostAddresses().get(0).port : 3306;
} | java | public int getPort() {
if (port != null && port != 0) {
return port;
}
return urlParser != null ? urlParser.getHostAddresses().get(0).port : 3306;
} | [
"public",
"int",
"getPort",
"(",
")",
"{",
"if",
"(",
"port",
"!=",
"null",
"&&",
"port",
"!=",
"0",
")",
"{",
"return",
"port",
";",
"}",
"return",
"urlParser",
"!=",
"null",
"?",
"urlParser",
".",
"getHostAddresses",
"(",
")",
".",
"get",
"(",
"0... | Returns the port number.
@return the port number | [
"Returns",
"the",
"port",
"number",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java#L157-L162 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java | MariaDbPoolDataSource.getServerName | public String getServerName() {
if (hostname != null) {
return hostname;
}
boolean hasHost = urlParser != null && this.urlParser.getHostAddresses().get(0).host != null;
return (hasHost) ? this.urlParser.getHostAddresses().get(0).host : "localhost";
} | java | public String getServerName() {
if (hostname != null) {
return hostname;
}
boolean hasHost = urlParser != null && this.urlParser.getHostAddresses().get(0).host != null;
return (hasHost) ? this.urlParser.getHostAddresses().get(0).host : "localhost";
} | [
"public",
"String",
"getServerName",
"(",
")",
"{",
"if",
"(",
"hostname",
"!=",
"null",
")",
"{",
"return",
"hostname",
";",
"}",
"boolean",
"hasHost",
"=",
"urlParser",
"!=",
"null",
"&&",
"this",
".",
"urlParser",
".",
"getHostAddresses",
"(",
")",
".... | Returns the name of the database server.
@return the name of the database server | [
"Returns",
"the",
"name",
"of",
"the",
"database",
"server",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java#L214-L220 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/SendChangeDbPacket.java | SendChangeDbPacket.send | public static void send(final PacketOutputStream pos, final String database) throws IOException {
pos.startPacket(0);
pos.write(Packet.COM_INIT_DB);
pos.write(database.getBytes("UTF-8"));
pos.flush();
} | java | public static void send(final PacketOutputStream pos, final String database) throws IOException {
pos.startPacket(0);
pos.write(Packet.COM_INIT_DB);
pos.write(database.getBytes("UTF-8"));
pos.flush();
} | [
"public",
"static",
"void",
"send",
"(",
"final",
"PacketOutputStream",
"pos",
",",
"final",
"String",
"database",
")",
"throws",
"IOException",
"{",
"pos",
".",
"startPacket",
"(",
"0",
")",
";",
"pos",
".",
"write",
"(",
"Packet",
".",
"COM_INIT_DB",
")"... | Send a COM_INIT_DB request to specify the default schema for the connection.
@param pos Write outputStream
@param database database name
@throws IOException if connection problem occur | [
"Send",
"a",
"COM_INIT_DB",
"request",
"to",
"specify",
"the",
"default",
"schema",
"for",
"the",
"connection",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/SendChangeDbPacket.java#L69-L74 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java | GssUtility.getAuthenticationMethod | public static GssapiAuth getAuthenticationMethod() {
try {
//Waffle-jna has jna as dependency, so if not available on classpath, just use standard authentication
if (Platform.isWindows()) {
try {
Class.forName("waffle.windows.auth.impl.WindowsAuthProviderImpl");
return new WindowsNativeSspiAuthentication();
} catch (ClassNotFoundException cle) {
//waffle not in the classpath
}
}
} catch (Throwable cle) {
//jna jar's are not in classpath
}
return new StandardGssapiAuthentication();
} | java | public static GssapiAuth getAuthenticationMethod() {
try {
//Waffle-jna has jna as dependency, so if not available on classpath, just use standard authentication
if (Platform.isWindows()) {
try {
Class.forName("waffle.windows.auth.impl.WindowsAuthProviderImpl");
return new WindowsNativeSspiAuthentication();
} catch (ClassNotFoundException cle) {
//waffle not in the classpath
}
}
} catch (Throwable cle) {
//jna jar's are not in classpath
}
return new StandardGssapiAuthentication();
} | [
"public",
"static",
"GssapiAuth",
"getAuthenticationMethod",
"(",
")",
"{",
"try",
"{",
"//Waffle-jna has jna as dependency, so if not available on classpath, just use standard authentication",
"if",
"(",
"Platform",
".",
"isWindows",
"(",
")",
")",
"{",
"try",
"{",
"Class"... | Get authentication method according to classpath. Windows native authentication is using
Waffle-jna.
@return authentication method | [
"Get",
"authentication",
"method",
"according",
"to",
"classpath",
".",
"Windows",
"native",
"authentication",
"is",
"using",
"Waffle",
"-",
"jna",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java#L13-L28 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/parameters/StreamParameter.java | StreamParameter.writeTo | public void writeTo(final PacketOutputStream pos) throws IOException {
pos.write(BINARY_INTRODUCER);
if (length == Long.MAX_VALUE) {
pos.write(is, true, noBackslashEscapes);
} else {
pos.write(is, length, true, noBackslashEscapes);
}
pos.write(QUOTE);
} | java | public void writeTo(final PacketOutputStream pos) throws IOException {
pos.write(BINARY_INTRODUCER);
if (length == Long.MAX_VALUE) {
pos.write(is, true, noBackslashEscapes);
} else {
pos.write(is, length, true, noBackslashEscapes);
}
pos.write(QUOTE);
} | [
"public",
"void",
"writeTo",
"(",
"final",
"PacketOutputStream",
"pos",
")",
"throws",
"IOException",
"{",
"pos",
".",
"write",
"(",
"BINARY_INTRODUCER",
")",
";",
"if",
"(",
"length",
"==",
"Long",
".",
"MAX_VALUE",
")",
"{",
"pos",
".",
"write",
"(",
"... | Write stream in text format.
@param pos database outputStream
@throws IOException if any error occur when reader stream | [
"Write",
"stream",
"in",
"text",
"format",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/parameters/StreamParameter.java#L89-L98 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/parameters/ByteArrayParameter.java | ByteArrayParameter.writeTo | public void writeTo(final PacketOutputStream pos) throws IOException {
pos.write(BINARY_INTRODUCER);
pos.writeBytesEscaped(bytes, bytes.length, noBackslashEscapes);
pos.write(QUOTE);
} | java | public void writeTo(final PacketOutputStream pos) throws IOException {
pos.write(BINARY_INTRODUCER);
pos.writeBytesEscaped(bytes, bytes.length, noBackslashEscapes);
pos.write(QUOTE);
} | [
"public",
"void",
"writeTo",
"(",
"final",
"PacketOutputStream",
"pos",
")",
"throws",
"IOException",
"{",
"pos",
".",
"write",
"(",
"BINARY_INTRODUCER",
")",
";",
"pos",
".",
"writeBytesEscaped",
"(",
"bytes",
",",
"bytes",
".",
"length",
",",
"noBackslashEsc... | Write data to socket in text format.
@param pos socket output stream
@throws IOException if socket error occur | [
"Write",
"data",
"to",
"socket",
"in",
"text",
"format",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/parameters/ByteArrayParameter.java#L76-L80 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/logging/LoggerFactory.java | LoggerFactory.init | @SuppressWarnings("unchecked")
public static void init(boolean mustLog) {
if ((hasToLog == null || hasToLog != mustLog) && mustLog) {
synchronized (LoggerFactory.class) {
if (hasToLog == null || hasToLog != mustLog) {
try {
Class.forName("org.slf4j.LoggerFactory");
hasToLog = Boolean.TRUE;
} catch (ClassNotFoundException classNotFound) {
System.out.println("Logging cannot be activated, missing slf4j dependency");
hasToLog = Boolean.FALSE;
}
}
}
}
} | java | @SuppressWarnings("unchecked")
public static void init(boolean mustLog) {
if ((hasToLog == null || hasToLog != mustLog) && mustLog) {
synchronized (LoggerFactory.class) {
if (hasToLog == null || hasToLog != mustLog) {
try {
Class.forName("org.slf4j.LoggerFactory");
hasToLog = Boolean.TRUE;
} catch (ClassNotFoundException classNotFound) {
System.out.println("Logging cannot be activated, missing slf4j dependency");
hasToLog = Boolean.FALSE;
}
}
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"void",
"init",
"(",
"boolean",
"mustLog",
")",
"{",
"if",
"(",
"(",
"hasToLog",
"==",
"null",
"||",
"hasToLog",
"!=",
"mustLog",
")",
"&&",
"mustLog",
")",
"{",
"synchronized",
"(",
... | Initialize factory.
@param mustLog indicate if must initiate Slf4j log | [
"Initialize",
"factory",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/logging/LoggerFactory.java#L65-L81 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/logging/LoggerFactory.java | LoggerFactory.getLogger | public static Logger getLogger(Class<?> clazz) {
if (hasToLog != null && hasToLog) {
return new Slf4JLogger(org.slf4j.LoggerFactory.getLogger(clazz));
} else {
return NO_LOGGER;
}
} | java | public static Logger getLogger(Class<?> clazz) {
if (hasToLog != null && hasToLog) {
return new Slf4JLogger(org.slf4j.LoggerFactory.getLogger(clazz));
} else {
return NO_LOGGER;
}
} | [
"public",
"static",
"Logger",
"getLogger",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"hasToLog",
"!=",
"null",
"&&",
"hasToLog",
")",
"{",
"return",
"new",
"Slf4JLogger",
"(",
"org",
".",
"slf4j",
".",
"LoggerFactory",
".",
"getLogger",
... | Initialize logger.
@param clazz initiator class
@return logger | [
"Initialize",
"logger",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/logging/LoggerFactory.java#L89-L95 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.standardSocket | public static Socket standardSocket(UrlParser urlParser, String host) throws IOException {
SocketFactory socketFactory;
String socketFactoryName = urlParser.getOptions().socketFactory;
if (socketFactoryName != null) {
try {
@SuppressWarnings("unchecked")
Class<? extends SocketFactory> socketFactoryClass = (Class<? extends SocketFactory>) Class
.forName(socketFactoryName);
if (socketFactoryClass != null) {
Constructor<? extends SocketFactory> constructor = socketFactoryClass.getConstructor();
socketFactory = constructor.newInstance();
return socketFactory.createSocket();
}
} catch (Exception exp) {
throw new IOException(
"Socket factory failed to initialized with option \"socketFactory\" set to \""
+ urlParser.getOptions().socketFactory + "\"", exp);
}
}
socketFactory = SocketFactory.getDefault();
return socketFactory.createSocket();
} | java | public static Socket standardSocket(UrlParser urlParser, String host) throws IOException {
SocketFactory socketFactory;
String socketFactoryName = urlParser.getOptions().socketFactory;
if (socketFactoryName != null) {
try {
@SuppressWarnings("unchecked")
Class<? extends SocketFactory> socketFactoryClass = (Class<? extends SocketFactory>) Class
.forName(socketFactoryName);
if (socketFactoryClass != null) {
Constructor<? extends SocketFactory> constructor = socketFactoryClass.getConstructor();
socketFactory = constructor.newInstance();
return socketFactory.createSocket();
}
} catch (Exception exp) {
throw new IOException(
"Socket factory failed to initialized with option \"socketFactory\" set to \""
+ urlParser.getOptions().socketFactory + "\"", exp);
}
}
socketFactory = SocketFactory.getDefault();
return socketFactory.createSocket();
} | [
"public",
"static",
"Socket",
"standardSocket",
"(",
"UrlParser",
"urlParser",
",",
"String",
"host",
")",
"throws",
"IOException",
"{",
"SocketFactory",
"socketFactory",
";",
"String",
"socketFactoryName",
"=",
"urlParser",
".",
"getOptions",
"(",
")",
".",
"sock... | Use standard socket implementation.
@param urlParser url parser
@param host host to connect
@return socket
@throws IOException in case of error establishing socket. | [
"Use",
"standard",
"socket",
"implementation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L119-L140 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.escapeString | public static String escapeString(String value, boolean noBackslashEscapes) {
if (!value.contains("'")) {
if (noBackslashEscapes) {
return value;
}
if (!value.contains("\\")) {
return value;
}
}
String escaped = value.replace("'", "''");
if (noBackslashEscapes) {
return escaped;
}
return escaped.replace("\\", "\\\\");
} | java | public static String escapeString(String value, boolean noBackslashEscapes) {
if (!value.contains("'")) {
if (noBackslashEscapes) {
return value;
}
if (!value.contains("\\")) {
return value;
}
}
String escaped = value.replace("'", "''");
if (noBackslashEscapes) {
return escaped;
}
return escaped.replace("\\", "\\\\");
} | [
"public",
"static",
"String",
"escapeString",
"(",
"String",
"value",
",",
"boolean",
"noBackslashEscapes",
")",
"{",
"if",
"(",
"!",
"value",
".",
"contains",
"(",
"\"'\"",
")",
")",
"{",
"if",
"(",
"noBackslashEscapes",
")",
"{",
"return",
"value",
";",
... | Escape String.
@param value value to escape
@param noBackslashEscapes must backslash be escaped
@return escaped string. | [
"Escape",
"String",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L149-L163 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.encryptPassword | public static byte[] encryptPassword(final String password, final byte[] seed,
String passwordCharacterEncoding)
throws NoSuchAlgorithmException, UnsupportedEncodingException {
if (password == null || password.isEmpty()) {
return new byte[0];
}
final MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
byte[] bytePwd;
if (passwordCharacterEncoding != null && !passwordCharacterEncoding.isEmpty()) {
bytePwd = password.getBytes(passwordCharacterEncoding);
} else {
bytePwd = password.getBytes();
}
final byte[] stage1 = messageDigest.digest(bytePwd);
messageDigest.reset();
final byte[] stage2 = messageDigest.digest(stage1);
messageDigest.reset();
messageDigest.update(seed);
messageDigest.update(stage2);
final byte[] digest = messageDigest.digest();
final byte[] returnBytes = new byte[digest.length];
for (int i = 0; i < digest.length; i++) {
returnBytes[i] = (byte) (stage1[i] ^ digest[i]);
}
return returnBytes;
} | java | public static byte[] encryptPassword(final String password, final byte[] seed,
String passwordCharacterEncoding)
throws NoSuchAlgorithmException, UnsupportedEncodingException {
if (password == null || password.isEmpty()) {
return new byte[0];
}
final MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
byte[] bytePwd;
if (passwordCharacterEncoding != null && !passwordCharacterEncoding.isEmpty()) {
bytePwd = password.getBytes(passwordCharacterEncoding);
} else {
bytePwd = password.getBytes();
}
final byte[] stage1 = messageDigest.digest(bytePwd);
messageDigest.reset();
final byte[] stage2 = messageDigest.digest(stage1);
messageDigest.reset();
messageDigest.update(seed);
messageDigest.update(stage2);
final byte[] digest = messageDigest.digest();
final byte[] returnBytes = new byte[digest.length];
for (int i = 0; i < digest.length; i++) {
returnBytes[i] = (byte) (stage1[i] ^ digest[i]);
}
return returnBytes;
} | [
"public",
"static",
"byte",
"[",
"]",
"encryptPassword",
"(",
"final",
"String",
"password",
",",
"final",
"byte",
"[",
"]",
"seed",
",",
"String",
"passwordCharacterEncoding",
")",
"throws",
"NoSuchAlgorithmException",
",",
"UnsupportedEncodingException",
"{",
"if"... | Encrypts a password.
<p>protocol for authentication is like this: 1. Server sends a random array of bytes (the
seed) 2. client makes a sha1 digest of the password 3. client hashes the output of 2 4. client
digests the seed 5. client updates the digest with the output from 3 6. an xor of the output of
5 and 2 is sent to server 7. server does the same thing and verifies that the scrambled
passwords match</p>
@param password the password to encrypt
@param seed the seed to use
@param passwordCharacterEncoding password character encoding
@return a scrambled password
@throws NoSuchAlgorithmException if SHA1 is not available on the platform we are using
@throws UnsupportedEncodingException if passwordCharacterEncoding is not a valid charset name | [
"Encrypts",
"a",
"password",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L181-L212 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.copyWithLength | public static byte[] copyWithLength(byte[] orig, int length) {
// No need to initialize with zero bytes, because the bytes are already initialized with that
byte[] result = new byte[length];
int howMuchToCopy = length < orig.length ? length : orig.length;
System.arraycopy(orig, 0, result, 0, howMuchToCopy);
return result;
} | java | public static byte[] copyWithLength(byte[] orig, int length) {
// No need to initialize with zero bytes, because the bytes are already initialized with that
byte[] result = new byte[length];
int howMuchToCopy = length < orig.length ? length : orig.length;
System.arraycopy(orig, 0, result, 0, howMuchToCopy);
return result;
} | [
"public",
"static",
"byte",
"[",
"]",
"copyWithLength",
"(",
"byte",
"[",
"]",
"orig",
",",
"int",
"length",
")",
"{",
"// No need to initialize with zero bytes, because the bytes are already initialized with that",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",... | Copies the original byte array content to a new byte array. The resulting byte array is always
"length" size. If length is smaller than the original byte array, the resulting byte array is
truncated. If length is bigger than the original byte array, the resulting byte array is filled
with zero bytes.
@param orig the original byte array
@param length how big the resulting byte array will be
@return the copied byte array | [
"Copies",
"the",
"original",
"byte",
"array",
"content",
"to",
"a",
"new",
"byte",
"array",
".",
"The",
"resulting",
"byte",
"array",
"is",
"always",
"length",
"size",
".",
"If",
"length",
"is",
"smaller",
"than",
"the",
"original",
"byte",
"array",
"the",... | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L224-L230 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.copyRange | public static byte[] copyRange(byte[] orig, int from, int to) {
int length = to - from;
byte[] result = new byte[length];
int howMuchToCopy = orig.length - from < length ? orig.length - from : length;
System.arraycopy(orig, from, result, 0, howMuchToCopy);
return result;
} | java | public static byte[] copyRange(byte[] orig, int from, int to) {
int length = to - from;
byte[] result = new byte[length];
int howMuchToCopy = orig.length - from < length ? orig.length - from : length;
System.arraycopy(orig, from, result, 0, howMuchToCopy);
return result;
} | [
"public",
"static",
"byte",
"[",
"]",
"copyRange",
"(",
"byte",
"[",
"]",
"orig",
",",
"int",
"from",
",",
"int",
"to",
")",
"{",
"int",
"length",
"=",
"to",
"-",
"from",
";",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"length",
"]",
... | Copies from original byte array to a new byte array. The resulting byte array is always
"to-from" size.
@param orig the original byte array
@param from index of first byte in original byte array which will be copied
@param to index of last byte in original byte array which will be copied. This can be outside
of the original byte array
@return resulting array | [
"Copies",
"from",
"original",
"byte",
"array",
"to",
"a",
"new",
"byte",
"array",
".",
"The",
"resulting",
"byte",
"array",
"is",
"always",
"to",
"-",
"from",
"size",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L242-L248 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.retrieveProxy | public static Protocol retrieveProxy(final UrlParser urlParser, final GlobalStateInfo globalInfo)
throws SQLException {
final ReentrantLock lock = new ReentrantLock();
Protocol protocol;
switch (urlParser.getHaMode()) {
case AURORA:
return getProxyLoggingIfNeeded(urlParser, (Protocol) Proxy.newProxyInstance(
AuroraProtocol.class.getClassLoader(),
new Class[]{Protocol.class},
new FailoverProxy(new AuroraListener(urlParser, globalInfo), lock)));
case REPLICATION:
return getProxyLoggingIfNeeded(urlParser,
(Protocol) Proxy.newProxyInstance(
MastersSlavesProtocol.class.getClassLoader(),
new Class[]{Protocol.class},
new FailoverProxy(new MastersSlavesListener(urlParser, globalInfo), lock)));
case FAILOVER:
case SEQUENTIAL:
return getProxyLoggingIfNeeded(urlParser, (Protocol) Proxy.newProxyInstance(
MasterProtocol.class.getClassLoader(),
new Class[]{Protocol.class},
new FailoverProxy(new MastersFailoverListener(urlParser, globalInfo), lock)));
default:
protocol = getProxyLoggingIfNeeded(urlParser,
new MasterProtocol(urlParser, globalInfo, lock));
protocol.connectWithoutProxy();
return protocol;
}
} | java | public static Protocol retrieveProxy(final UrlParser urlParser, final GlobalStateInfo globalInfo)
throws SQLException {
final ReentrantLock lock = new ReentrantLock();
Protocol protocol;
switch (urlParser.getHaMode()) {
case AURORA:
return getProxyLoggingIfNeeded(urlParser, (Protocol) Proxy.newProxyInstance(
AuroraProtocol.class.getClassLoader(),
new Class[]{Protocol.class},
new FailoverProxy(new AuroraListener(urlParser, globalInfo), lock)));
case REPLICATION:
return getProxyLoggingIfNeeded(urlParser,
(Protocol) Proxy.newProxyInstance(
MastersSlavesProtocol.class.getClassLoader(),
new Class[]{Protocol.class},
new FailoverProxy(new MastersSlavesListener(urlParser, globalInfo), lock)));
case FAILOVER:
case SEQUENTIAL:
return getProxyLoggingIfNeeded(urlParser, (Protocol) Proxy.newProxyInstance(
MasterProtocol.class.getClassLoader(),
new Class[]{Protocol.class},
new FailoverProxy(new MastersFailoverListener(urlParser, globalInfo), lock)));
default:
protocol = getProxyLoggingIfNeeded(urlParser,
new MasterProtocol(urlParser, globalInfo, lock));
protocol.connectWithoutProxy();
return protocol;
}
} | [
"public",
"static",
"Protocol",
"retrieveProxy",
"(",
"final",
"UrlParser",
"urlParser",
",",
"final",
"GlobalStateInfo",
"globalInfo",
")",
"throws",
"SQLException",
"{",
"final",
"ReentrantLock",
"lock",
"=",
"new",
"ReentrantLock",
"(",
")",
";",
"Protocol",
"p... | Retrieve protocol corresponding to the failover options. if no failover option, protocol will
not be proxied. if a failover option is precised, protocol will be proxied so that any
connection error will be handle directly.
@param urlParser urlParser corresponding to connection url string.
@param globalInfo global variable information
@return protocol
@throws SQLException if any error occur during connection | [
"Retrieve",
"protocol",
"corresponding",
"to",
"the",
"failover",
"options",
".",
"if",
"no",
"failover",
"option",
"protocol",
"will",
"not",
"be",
"proxied",
".",
"if",
"a",
"failover",
"option",
"is",
"precised",
"protocol",
"will",
"be",
"proxied",
"so",
... | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L535-L563 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.createSocket | public static Socket createSocket(UrlParser urlParser, String host) throws IOException {
return socketHandler.apply(urlParser, host);
} | java | public static Socket createSocket(UrlParser urlParser, String host) throws IOException {
return socketHandler.apply(urlParser, host);
} | [
"public",
"static",
"Socket",
"createSocket",
"(",
"UrlParser",
"urlParser",
",",
"String",
"host",
")",
"throws",
"IOException",
"{",
"return",
"socketHandler",
".",
"apply",
"(",
"urlParser",
",",
"host",
")",
";",
"}"
] | Create socket accordingly to options.
@param urlParser urlParser
@param host hostName ( mandatory only for named pipe)
@return a nex socket
@throws IOException if connection error occur | [
"Create",
"socket",
"accordingly",
"to",
"options",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L602-L604 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.parseSessionVariables | public static String parseSessionVariables(String sessionVariable) {
StringBuilder out = new StringBuilder();
StringBuilder sb = new StringBuilder();
Parse state = Parse.Normal;
boolean iskey = true;
boolean singleQuotes = true;
boolean first = true;
String key = null;
char[] chars = sessionVariable.toCharArray();
for (char car : chars) {
if (state == Parse.Escape) {
sb.append(car);
state = singleQuotes ? Parse.Quote : Parse.String;
continue;
}
switch (car) {
case '"':
if (state == Parse.Normal) {
state = Parse.String;
singleQuotes = false;
} else if (state == Parse.String && !singleQuotes) {
state = Parse.Normal;
}
break;
case '\'':
if (state == Parse.Normal) {
state = Parse.String;
singleQuotes = true;
} else if (state == Parse.String && singleQuotes) {
state = Parse.Normal;
}
break;
case '\\':
if (state == Parse.String) {
state = Parse.Escape;
}
break;
case ';':
case ',':
if (state == Parse.Normal) {
if (!iskey) {
if (!first) {
out.append(",");
}
out.append(key);
out.append(sb.toString());
first = false;
} else {
key = sb.toString().trim();
if (!key.isEmpty()) {
if (!first) {
out.append(",");
}
out.append(key);
first = false;
}
}
iskey = true;
key = null;
sb = new StringBuilder();
continue;
}
break;
case '=':
if (state == Parse.Normal && iskey) {
key = sb.toString().trim();
iskey = false;
sb = new StringBuilder();
}
break;
default:
//nothing
}
sb.append(car);
}
if (!iskey) {
if (!first) {
out.append(",");
}
out.append(key);
out.append(sb.toString());
} else {
String tmpkey = sb.toString().trim();
if (!tmpkey.isEmpty() && !first) {
out.append(",");
}
out.append(tmpkey);
}
return out.toString();
} | java | public static String parseSessionVariables(String sessionVariable) {
StringBuilder out = new StringBuilder();
StringBuilder sb = new StringBuilder();
Parse state = Parse.Normal;
boolean iskey = true;
boolean singleQuotes = true;
boolean first = true;
String key = null;
char[] chars = sessionVariable.toCharArray();
for (char car : chars) {
if (state == Parse.Escape) {
sb.append(car);
state = singleQuotes ? Parse.Quote : Parse.String;
continue;
}
switch (car) {
case '"':
if (state == Parse.Normal) {
state = Parse.String;
singleQuotes = false;
} else if (state == Parse.String && !singleQuotes) {
state = Parse.Normal;
}
break;
case '\'':
if (state == Parse.Normal) {
state = Parse.String;
singleQuotes = true;
} else if (state == Parse.String && singleQuotes) {
state = Parse.Normal;
}
break;
case '\\':
if (state == Parse.String) {
state = Parse.Escape;
}
break;
case ';':
case ',':
if (state == Parse.Normal) {
if (!iskey) {
if (!first) {
out.append(",");
}
out.append(key);
out.append(sb.toString());
first = false;
} else {
key = sb.toString().trim();
if (!key.isEmpty()) {
if (!first) {
out.append(",");
}
out.append(key);
first = false;
}
}
iskey = true;
key = null;
sb = new StringBuilder();
continue;
}
break;
case '=':
if (state == Parse.Normal && iskey) {
key = sb.toString().trim();
iskey = false;
sb = new StringBuilder();
}
break;
default:
//nothing
}
sb.append(car);
}
if (!iskey) {
if (!first) {
out.append(",");
}
out.append(key);
out.append(sb.toString());
} else {
String tmpkey = sb.toString().trim();
if (!tmpkey.isEmpty() && !first) {
out.append(",");
}
out.append(tmpkey);
}
return out.toString();
} | [
"public",
"static",
"String",
"parseSessionVariables",
"(",
"String",
"sessionVariable",
")",
"{",
"StringBuilder",
"out",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Parse",
"state",
"=",
"Pa... | Parse the option "sessionVariable" to ensure having no injection. semi-column not in string
will be replaced by comma.
@param sessionVariable option value
@return parsed String | [
"Parse",
"the",
"option",
"sessionVariable",
"to",
"ensure",
"having",
"no",
"injection",
".",
"semi",
"-",
"column",
"not",
"in",
"string",
"will",
"be",
"replaced",
"by",
"comma",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L769-L869 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/util/Utils.java | Utils.transactionFromString | public static int transactionFromString(String txIsolation) throws SQLException {
switch (txIsolation) { //tx_isolation
case "READ-UNCOMMITTED":
return Connection.TRANSACTION_READ_UNCOMMITTED;
case "READ-COMMITTED":
return Connection.TRANSACTION_READ_COMMITTED;
case "REPEATABLE-READ":
return Connection.TRANSACTION_REPEATABLE_READ;
case "SERIALIZABLE":
return Connection.TRANSACTION_SERIALIZABLE;
default:
throw new SQLException("unknown transaction isolation level");
}
} | java | public static int transactionFromString(String txIsolation) throws SQLException {
switch (txIsolation) { //tx_isolation
case "READ-UNCOMMITTED":
return Connection.TRANSACTION_READ_UNCOMMITTED;
case "READ-COMMITTED":
return Connection.TRANSACTION_READ_COMMITTED;
case "REPEATABLE-READ":
return Connection.TRANSACTION_REPEATABLE_READ;
case "SERIALIZABLE":
return Connection.TRANSACTION_SERIALIZABLE;
default:
throw new SQLException("unknown transaction isolation level");
}
} | [
"public",
"static",
"int",
"transactionFromString",
"(",
"String",
"txIsolation",
")",
"throws",
"SQLException",
"{",
"switch",
"(",
"txIsolation",
")",
"{",
"//tx_isolation",
"case",
"\"READ-UNCOMMITTED\"",
":",
"return",
"Connection",
".",
"TRANSACTION_READ_UNCOMMITTE... | Traduce a String value of transaction isolation to corresponding java value.
@param txIsolation String value
@return java corresponding value (Connection.TRANSACTION_READ_UNCOMMITTED,
Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_REPEATABLE_READ or
Connection.TRANSACTION_SERIALIZABLE)
@throws SQLException if String value doesn't correspond to @@tx_isolation/@@transaction_isolation
possible value | [
"Traduce",
"a",
"String",
"value",
"of",
"transaction",
"isolation",
"to",
"corresponding",
"java",
"value",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/util/Utils.java#L889-L906 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbProcedureStatement.java | MariaDbProcedureStatement.validAllParameters | private void validAllParameters() throws SQLException {
setInputOutputParameterMap();
//Set value for OUT parameters
for (int index = 0; index < params.size(); index++) {
if (!params.get(index).isInput()) {
super.setParameter(index + 1, new NullParameter());
}
}
validParameters();
} | java | private void validAllParameters() throws SQLException {
setInputOutputParameterMap();
//Set value for OUT parameters
for (int index = 0; index < params.size(); index++) {
if (!params.get(index).isInput()) {
super.setParameter(index + 1, new NullParameter());
}
}
validParameters();
} | [
"private",
"void",
"validAllParameters",
"(",
")",
"throws",
"SQLException",
"{",
"setInputOutputParameterMap",
"(",
")",
";",
"//Set value for OUT parameters",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"params",
".",
"size",
"(",
")",
";",
"ind... | Valid that all parameters are set.
@throws SQLException if set parameters is not right | [
"Valid",
"that",
"all",
"parameters",
"are",
"set",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbProcedureStatement.java#L173-L183 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/Utils.java | Utils.equal | public static int equal(int b, int c) {
int result = 0;
int xor = b ^ c;
for (int i = 0; i < 8; i++) {
result |= xor >> i;
}
return (result ^ 0x01) & 0x01;
} | java | public static int equal(int b, int c) {
int result = 0;
int xor = b ^ c;
for (int i = 0; i < 8; i++) {
result |= xor >> i;
}
return (result ^ 0x01) & 0x01;
} | [
"public",
"static",
"int",
"equal",
"(",
"int",
"b",
",",
"int",
"c",
")",
"{",
"int",
"result",
"=",
"0",
";",
"int",
"xor",
"=",
"b",
"^",
"c",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"result... | Constant-time byte comparison.
@param b a byte
@param c a byte
@return 1 if b and c are equal, 0 otherwise. | [
"Constant",
"-",
"time",
"byte",
"comparison",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/Utils.java#L26-L33 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/Utils.java | Utils.bytesToHex | public static String bytesToHex(byte[] raw) {
if (raw == null) {
return null;
}
final StringBuilder hex = new StringBuilder(2 * raw.length);
for (final byte b : raw) {
hex.append(Character.forDigit((b & 0xF0) >> 4, 16))
.append(Character.forDigit((b & 0x0F), 16));
}
return hex.toString();
} | java | public static String bytesToHex(byte[] raw) {
if (raw == null) {
return null;
}
final StringBuilder hex = new StringBuilder(2 * raw.length);
for (final byte b : raw) {
hex.append(Character.forDigit((b & 0xF0) >> 4, 16))
.append(Character.forDigit((b & 0x0F), 16));
}
return hex.toString();
} | [
"public",
"static",
"String",
"bytesToHex",
"(",
"byte",
"[",
"]",
"raw",
")",
"{",
"if",
"(",
"raw",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StringBuilder",
"hex",
"=",
"new",
"StringBuilder",
"(",
"2",
"*",
"raw",
".",
"length... | Converts bytes to a hex string.
@param raw the byte[] to be converted.
@return the hex representation as a string. | [
"Converts",
"bytes",
"to",
"a",
"hex",
"string",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/Utils.java#L94-L104 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java | AuroraListener.findClusterHostAddress | private HostAddress findClusterHostAddress(UrlParser urlParser) throws SQLException {
List<HostAddress> hostAddresses = urlParser.getHostAddresses();
Matcher matcher;
for (HostAddress hostAddress : hostAddresses) {
matcher = auroraDnsPattern.matcher(hostAddress.host);
if (matcher.find()) {
if (clusterDnsSuffix != null) {
//ensure there is only one cluster
if (!clusterDnsSuffix.equalsIgnoreCase(matcher.group(3))) {
throw new SQLException("Connection string must contain only one aurora cluster. "
+ "'" + hostAddress.host + "' doesn't correspond to DNS prefix '" + clusterDnsSuffix
+ "'");
}
} else {
clusterDnsSuffix = matcher.group(3);
}
if (matcher.group(2) != null && !matcher.group(2).isEmpty()) {
//not just an instance entry-point, but cluster entrypoint.
return hostAddress;
}
} else {
if (clusterDnsSuffix == null
&& hostAddress.host.contains(".")
&& !Utils.isIPv4(hostAddress.host)
&& !Utils.isIPv6(hostAddress.host)) {
clusterDnsSuffix = hostAddress.host.substring(hostAddress.host.indexOf(".") + 1);
}
}
}
return null;
} | java | private HostAddress findClusterHostAddress(UrlParser urlParser) throws SQLException {
List<HostAddress> hostAddresses = urlParser.getHostAddresses();
Matcher matcher;
for (HostAddress hostAddress : hostAddresses) {
matcher = auroraDnsPattern.matcher(hostAddress.host);
if (matcher.find()) {
if (clusterDnsSuffix != null) {
//ensure there is only one cluster
if (!clusterDnsSuffix.equalsIgnoreCase(matcher.group(3))) {
throw new SQLException("Connection string must contain only one aurora cluster. "
+ "'" + hostAddress.host + "' doesn't correspond to DNS prefix '" + clusterDnsSuffix
+ "'");
}
} else {
clusterDnsSuffix = matcher.group(3);
}
if (matcher.group(2) != null && !matcher.group(2).isEmpty()) {
//not just an instance entry-point, but cluster entrypoint.
return hostAddress;
}
} else {
if (clusterDnsSuffix == null
&& hostAddress.host.contains(".")
&& !Utils.isIPv4(hostAddress.host)
&& !Utils.isIPv6(hostAddress.host)) {
clusterDnsSuffix = hostAddress.host.substring(hostAddress.host.indexOf(".") + 1);
}
}
}
return null;
} | [
"private",
"HostAddress",
"findClusterHostAddress",
"(",
"UrlParser",
"urlParser",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"HostAddress",
">",
"hostAddresses",
"=",
"urlParser",
".",
"getHostAddresses",
"(",
")",
";",
"Matcher",
"matcher",
";",
"for",
"("... | Retrieves the cluster host address from the UrlParser instance.
@param urlParser object that holds the connection information
@return cluster host address | [
"Retrieves",
"the",
"cluster",
"host",
"address",
"from",
"the",
"UrlParser",
"instance",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java#L105-L137 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java | AuroraListener.retrieveAllEndpointsAndSet | public void retrieveAllEndpointsAndSet(Protocol protocol) throws SQLException {
// For a given cluster, same port for all endpoints and same end host address
if (clusterDnsSuffix != null) {
List<String> endpoints = getCurrentEndpointIdentifiers(protocol);
setUrlParserFromEndpoints(endpoints, protocol.getPort());
}
} | java | public void retrieveAllEndpointsAndSet(Protocol protocol) throws SQLException {
// For a given cluster, same port for all endpoints and same end host address
if (clusterDnsSuffix != null) {
List<String> endpoints = getCurrentEndpointIdentifiers(protocol);
setUrlParserFromEndpoints(endpoints, protocol.getPort());
}
} | [
"public",
"void",
"retrieveAllEndpointsAndSet",
"(",
"Protocol",
"protocol",
")",
"throws",
"SQLException",
"{",
"// For a given cluster, same port for all endpoints and same end host address",
"if",
"(",
"clusterDnsSuffix",
"!=",
"null",
")",
"{",
"List",
"<",
"String",
">... | Retrieves the information necessary to add a new endpoint. Calls the methods that retrieves the
instance identifiers and sets urlParser accordingly.
@param protocol current protocol connected to
@throws SQLException if connection error occur | [
"Retrieves",
"the",
"information",
"necessary",
"to",
"add",
"a",
"new",
"endpoint",
".",
"Calls",
"the",
"methods",
"that",
"retrieves",
"the",
"instance",
"identifiers",
"and",
"sets",
"urlParser",
"accordingly",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java#L241-L248 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java | AuroraListener.getCurrentEndpointIdentifiers | private List<String> getCurrentEndpointIdentifiers(Protocol protocol) throws SQLException {
List<String> endpoints = new ArrayList<>();
try {
proxy.lock.lock();
try {
// Deleted instance may remain in db for 24 hours so ignoring instances that have had no change
// for 3 minutes
Results results = new Results();
protocol.executeQuery(false, results,
"select server_id, session_id from information_schema.replica_host_status "
+ "where last_update_timestamp > now() - INTERVAL 3 MINUTE");
results.commandEnd();
ResultSet resultSet = results.getResultSet();
while (resultSet.next()) {
endpoints.add(resultSet.getString(1) + "." + clusterDnsSuffix);
}
//randomize order for distributed load-balancing
Collections.shuffle(endpoints);
} finally {
proxy.lock.unlock();
}
} catch (SQLException qe) {
logger.warning("SQL exception occurred: " + qe.getMessage());
if (protocol.getProxy().hasToHandleFailover(qe)) {
if (masterProtocol == null || masterProtocol.equals(protocol)) {
setMasterHostFail();
} else if (secondaryProtocol.equals(protocol)) {
setSecondaryHostFail();
}
addToBlacklist(protocol.getHostAddress());
reconnectFailedConnection(new SearchFilter(isMasterHostFail(), isSecondaryHostFail()));
}
}
return endpoints;
} | java | private List<String> getCurrentEndpointIdentifiers(Protocol protocol) throws SQLException {
List<String> endpoints = new ArrayList<>();
try {
proxy.lock.lock();
try {
// Deleted instance may remain in db for 24 hours so ignoring instances that have had no change
// for 3 minutes
Results results = new Results();
protocol.executeQuery(false, results,
"select server_id, session_id from information_schema.replica_host_status "
+ "where last_update_timestamp > now() - INTERVAL 3 MINUTE");
results.commandEnd();
ResultSet resultSet = results.getResultSet();
while (resultSet.next()) {
endpoints.add(resultSet.getString(1) + "." + clusterDnsSuffix);
}
//randomize order for distributed load-balancing
Collections.shuffle(endpoints);
} finally {
proxy.lock.unlock();
}
} catch (SQLException qe) {
logger.warning("SQL exception occurred: " + qe.getMessage());
if (protocol.getProxy().hasToHandleFailover(qe)) {
if (masterProtocol == null || masterProtocol.equals(protocol)) {
setMasterHostFail();
} else if (secondaryProtocol.equals(protocol)) {
setSecondaryHostFail();
}
addToBlacklist(protocol.getHostAddress());
reconnectFailedConnection(new SearchFilter(isMasterHostFail(), isSecondaryHostFail()));
}
}
return endpoints;
} | [
"private",
"List",
"<",
"String",
">",
"getCurrentEndpointIdentifiers",
"(",
"Protocol",
"protocol",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"String",
">",
"endpoints",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"proxy",
".",
"lock",
... | Retrieves all endpoints of a cluster from the appropriate database table.
@param protocol current protocol connected to
@return instance endpoints of the cluster
@throws SQLException if connection error occur | [
"Retrieves",
"all",
"endpoints",
"of",
"a",
"cluster",
"from",
"the",
"appropriate",
"database",
"table",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java#L257-L295 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java | AuroraListener.setUrlParserFromEndpoints | private void setUrlParserFromEndpoints(List<String> endpoints, int port) {
List<HostAddress> addresses = new ArrayList<>();
for (String endpoint : endpoints) {
HostAddress newHostAddress = new HostAddress(endpoint, port, null);
addresses.add(newHostAddress);
}
synchronized (urlParser) {
urlParser.setHostAddresses(addresses);
}
} | java | private void setUrlParserFromEndpoints(List<String> endpoints, int port) {
List<HostAddress> addresses = new ArrayList<>();
for (String endpoint : endpoints) {
HostAddress newHostAddress = new HostAddress(endpoint, port, null);
addresses.add(newHostAddress);
}
synchronized (urlParser) {
urlParser.setHostAddresses(addresses);
}
} | [
"private",
"void",
"setUrlParserFromEndpoints",
"(",
"List",
"<",
"String",
">",
"endpoints",
",",
"int",
"port",
")",
"{",
"List",
"<",
"HostAddress",
">",
"addresses",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"endpoint",
":",
... | Sets urlParser accordingly to discovered hosts.
@param endpoints instance identifiers
@param port port that is common to all endpoints | [
"Sets",
"urlParser",
"accordingly",
"to",
"discovered",
"hosts",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/impl/AuroraListener.java#L303-L313 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.p2 | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement p2(
final Curve curve,
final FieldElement X,
final FieldElement Y,
final FieldElement Z) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.P2, X, Y, Z, null);
} | java | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement p2(
final Curve curve,
final FieldElement X,
final FieldElement Y,
final FieldElement Z) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.P2, X, Y, Z, null);
} | [
"public",
"static",
"org",
".",
"mariadb",
".",
"jdbc",
".",
"internal",
".",
"com",
".",
"send",
".",
"authentication",
".",
"ed25519",
".",
"math",
".",
"GroupElement",
"p2",
"(",
"final",
"Curve",
"curve",
",",
"final",
"FieldElement",
"X",
",",
"fina... | Creates a new group element in P2 representation.
@param curve The curve.
@param X The $X$ coordinate.
@param Y The $Y$ coordinate.
@param Z The $Z$ coordinate.
@return The group element in P2 representation. | [
"Creates",
"a",
"new",
"group",
"element",
"in",
"P2",
"representation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L170-L177 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.p1p1 | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement p1p1(
final Curve curve,
final FieldElement X,
final FieldElement Y,
final FieldElement Z,
final FieldElement T) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.P1P1, X, Y, Z, T);
} | java | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement p1p1(
final Curve curve,
final FieldElement X,
final FieldElement Y,
final FieldElement Z,
final FieldElement T) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.P1P1, X, Y, Z, T);
} | [
"public",
"static",
"org",
".",
"mariadb",
".",
"jdbc",
".",
"internal",
".",
"com",
".",
"send",
".",
"authentication",
".",
"ed25519",
".",
"math",
".",
"GroupElement",
"p1p1",
"(",
"final",
"Curve",
"curve",
",",
"final",
"FieldElement",
"X",
",",
"fi... | Creates a new group element in P1P1 representation.
@param curve The curve.
@param X The $X$ coordinate.
@param Y The $Y$ coordinate.
@param Z The $Z$ coordinate.
@param T The $T$ coordinate.
@return The group element in P1P1 representation. | [
"Creates",
"a",
"new",
"group",
"element",
"in",
"P1P1",
"representation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L209-L217 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.precomp | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement precomp(
final Curve curve,
final FieldElement ypx,
final FieldElement ymx,
final FieldElement xy2d) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.PRECOMP, ypx, ymx, xy2d, null);
} | java | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement precomp(
final Curve curve,
final FieldElement ypx,
final FieldElement ymx,
final FieldElement xy2d) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.PRECOMP, ypx, ymx, xy2d, null);
} | [
"public",
"static",
"org",
".",
"mariadb",
".",
"jdbc",
".",
"internal",
".",
"com",
".",
"send",
".",
"authentication",
".",
"ed25519",
".",
"math",
".",
"GroupElement",
"precomp",
"(",
"final",
"Curve",
"curve",
",",
"final",
"FieldElement",
"ypx",
",",
... | Creates a new group element in PRECOMP representation.
@param curve The curve.
@param ypx The $y + x$ value.
@param ymx The $y - x$ value.
@param xy2d The $2 * d * x * y$ value.
@return The group element in PRECOMP representation. | [
"Creates",
"a",
"new",
"group",
"element",
"in",
"PRECOMP",
"representation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L228-L235 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.cached | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement cached(
final Curve curve,
final FieldElement YpX,
final FieldElement YmX,
final FieldElement Z,
final FieldElement T2d) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.CACHED, YpX, YmX, Z, T2d);
} | java | public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement cached(
final Curve curve,
final FieldElement YpX,
final FieldElement YmX,
final FieldElement Z,
final FieldElement T2d) {
return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
Representation.CACHED, YpX, YmX, Z, T2d);
} | [
"public",
"static",
"org",
".",
"mariadb",
".",
"jdbc",
".",
"internal",
".",
"com",
".",
"send",
".",
"authentication",
".",
"ed25519",
".",
"math",
".",
"GroupElement",
"cached",
"(",
"final",
"Curve",
"curve",
",",
"final",
"FieldElement",
"YpX",
",",
... | Creates a new group element in CACHED representation.
@param curve The curve.
@param YpX The $Y + X$ value.
@param YmX The $Y - X$ value.
@param Z The $Z$ coordinate.
@param T2d The $2 * d * T$ value.
@return The group element in CACHED representation. | [
"Creates",
"a",
"new",
"group",
"element",
"in",
"CACHED",
"representation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L247-L255 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.toByteArray | public byte[] toByteArray() {
switch (this.repr) {
case P2:
case P3:
FieldElement recip = Z.invert();
FieldElement x = X.multiply(recip);
FieldElement y = Y.multiply(recip);
byte[] s = y.toByteArray();
s[s.length - 1] |= (x.isNegative() ? (byte) 0x80 : 0);
return s;
default:
return toP2().toByteArray();
}
} | java | public byte[] toByteArray() {
switch (this.repr) {
case P2:
case P3:
FieldElement recip = Z.invert();
FieldElement x = X.multiply(recip);
FieldElement y = Y.multiply(recip);
byte[] s = y.toByteArray();
s[s.length - 1] |= (x.isNegative() ? (byte) 0x80 : 0);
return s;
default:
return toP2().toByteArray();
}
} | [
"public",
"byte",
"[",
"]",
"toByteArray",
"(",
")",
"{",
"switch",
"(",
"this",
".",
"repr",
")",
"{",
"case",
"P2",
":",
"case",
"P3",
":",
"FieldElement",
"recip",
"=",
"Z",
".",
"invert",
"(",
")",
";",
"FieldElement",
"x",
"=",
"X",
".",
"mu... | Converts the group element to an encoded point on the curve.
@return The encoded point as byte array. | [
"Converts",
"the",
"group",
"element",
"to",
"an",
"encoded",
"point",
"on",
"the",
"curve",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L399-L412 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.toP2 | public org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement toP2() {
return toRep(Representation.P2);
} | java | public org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement toP2() {
return toRep(Representation.P2);
} | [
"public",
"org",
".",
"mariadb",
".",
"jdbc",
".",
"internal",
".",
"com",
".",
"send",
".",
"authentication",
".",
"ed25519",
".",
"math",
".",
"GroupElement",
"toP2",
"(",
")",
"{",
"return",
"toRep",
"(",
"Representation",
".",
"P2",
")",
";",
"}"
] | Converts the group element to the P2 representation.
@return The group element in the P2 representation. | [
"Converts",
"the",
"group",
"element",
"to",
"the",
"P2",
"representation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L419-L421 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.toP3 | public org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement toP3() {
return toRep(Representation.P3);
} | java | public org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement toP3() {
return toRep(Representation.P3);
} | [
"public",
"org",
".",
"mariadb",
".",
"jdbc",
".",
"internal",
".",
"com",
".",
"send",
".",
"authentication",
".",
"ed25519",
".",
"math",
".",
"GroupElement",
"toP3",
"(",
")",
"{",
"return",
"toRep",
"(",
"Representation",
".",
"P3",
")",
";",
"}"
] | Converts the group element to the P3 representation.
@return The group element in the P3 representation. | [
"Converts",
"the",
"group",
"element",
"to",
"the",
"P3",
"representation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L428-L430 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.toCached | public org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement toCached() {
return toRep(Representation.CACHED);
} | java | public org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement toCached() {
return toRep(Representation.CACHED);
} | [
"public",
"org",
".",
"mariadb",
".",
"jdbc",
".",
"internal",
".",
"com",
".",
"send",
".",
"authentication",
".",
"ed25519",
".",
"math",
".",
"GroupElement",
"toCached",
"(",
")",
"{",
"return",
"toRep",
"(",
"Representation",
".",
"CACHED",
")",
";",... | Converts the group element to the CACHED representation.
@return The group element in the CACHED representation. | [
"Converts",
"the",
"group",
"element",
"to",
"the",
"CACHED",
"representation",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L437-L439 | train |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java | GroupElement.isOnCurve | public boolean isOnCurve(Curve curve) {
switch (repr) {
case P2:
case P3:
FieldElement recip = Z.invert();
FieldElement x = X.multiply(recip);
FieldElement y = Y.multiply(recip);
FieldElement xx = x.square();
FieldElement yy = y.square();
FieldElement dxxyy = curve.getD().multiply(xx).multiply(yy);
return curve.getField().ONE.add(dxxyy).add(xx).equals(yy);
default:
return toP2().isOnCurve(curve);
}
} | java | public boolean isOnCurve(Curve curve) {
switch (repr) {
case P2:
case P3:
FieldElement recip = Z.invert();
FieldElement x = X.multiply(recip);
FieldElement y = Y.multiply(recip);
FieldElement xx = x.square();
FieldElement yy = y.square();
FieldElement dxxyy = curve.getD().multiply(xx).multiply(yy);
return curve.getField().ONE.add(dxxyy).add(xx).equals(yy);
default:
return toP2().isOnCurve(curve);
}
} | [
"public",
"boolean",
"isOnCurve",
"(",
"Curve",
"curve",
")",
"{",
"switch",
"(",
"repr",
")",
"{",
"case",
"P2",
":",
"case",
"P3",
":",
"FieldElement",
"recip",
"=",
"Z",
".",
"invert",
"(",
")",
";",
"FieldElement",
"x",
"=",
"X",
".",
"multiply",... | Verify that a point is on the curve.
@param curve The curve to check.
@return true if the point lies on the curve. | [
"Verify",
"that",
"a",
"point",
"is",
"on",
"the",
"curve",
"."
] | d148c7cd347c4680617be65d9e511b289d38a30b | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ed25519/math/GroupElement.java#L1021-L1036 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.