diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf
deleted file mode 100644
index 314254ba9..000000000
--- a/.bzr-mysql/default.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-[MYSQL]
-tree_location = bzr+ssh://mmatthews@bk-internal.mysql.com/bzrroot/connector-j/branches/branch_5_1/
-# This line would send on every local branch commit.
-# post_commit_to = dev-merlin@mysql.com
-post_push_to = commits@lists.mysql.com
-post_commit_url = bzr+ssh://mmatthews@bk-internal.mysql.com/bzrroot/connector-j/branches/branch_5_1/
-tree_name = connector-j/branches/branch_5_1
diff --git a/.classpath b/.classpath
index 7c02730ec..74e927b25 100644
--- a/.classpath
+++ b/.classpath
@@ -1,24 +1,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index 67b544a3d..000000000
--- a/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin
-build
-dist
diff --git a/.eclipse-format-settings b/.eclipse-format-settings
deleted file mode 100644
index d8dd75e5f..000000000
--- a/.eclipse-format-settings
+++ /dev/null
@@ -1,246 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.externalToolBuilders/Ant_Builder (for JDBC-4.0 Implementation).launch b/.externalToolBuilders/Ant_Builder (for JDBC-4.0 Implementation).launch
deleted file mode 100644
index 2b4f57072..000000000
--- a/.externalToolBuilders/Ant_Builder (for JDBC-4.0 Implementation).launch
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.externalToolBuilders/Ant_Builder.launch b/.externalToolBuilders/Ant_Builder.launch
new file mode 100644
index 000000000..14939cd16
--- /dev/null
+++ b/.externalToolBuilders/Ant_Builder.launch
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.externalToolBuilders/New_Builder.launch b/.externalToolBuilders/New_Builder.launch
deleted file mode 100644
index 2138dd414..000000000
--- a/.externalToolBuilders/New_Builder.launch
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.fbprefs b/.fbprefs
index d1745f1f3..eb885fa97 100644
--- a/.fbprefs
+++ b/.fbprefs
@@ -1,98 +1,137 @@
-#FindBugs User Preferences
-#Tue Dec 19 15:23:45 CST 2006
-detector73=InefficientToArray|true
-detector72=FindDeadLocalStores|true
-detector71=FindNonSerializableValuePassedToWriteObject|true
-detector70=UncallableMethodOfAnonymousClass|true
-detector9=FindOpenStream|true
-detector8=FindUnsyncGet|true
-detector7=InefficientMemberAccess|false
-detector6=FindDoubleCheck|true
-detector5=FindNonSerializableStoreIntoSession|true
-detector4=IteratorIdioms|true
-detector69=LoadOfKnownNullValue|true
-detector3=DontCatchIllegalMonitorStateException|true
-detector68=DumbMethodInvocations|true
-detector2=SuspiciousThreadInterrupted|true
-detector67=SuperfluousInstanceOf|true
-detector1=FindNakedNotify|true
-detector66=FindSleepWithLockHeld|true
-detector0=BadSyntaxForRegularExpression|true
-detector65=ConfusedInheritance|true
-detector64=SerializableIdiom|true
-detector63=FindUnreleasedLock|true
-detector62=PreferZeroLengthArrays|true
-detector61=UnnecessaryMath|true
-detector60=FindNonShortCircuit|true
-detector59=StartInConstructor|true
-detector58=WrongMapIterator|true
-detector57=FindTwoLockWait|true
-detector56=FindReturnRef|true
-detector55=DuplicateBranches|true
-detector54=FindCircularDependencies|false
-detector53=UnreadFields|true
-detector52=QuestionableBooleanAssignment|true
-detector51=UselessSubclassMethod|false
-detector50=FindUninitializedGet|true
-detector49=FindFloatEquality|true
-detector48=LazyInit|true
-detector47=FindSpinLoop|true
-detector46=FindBadCast2|true
-detector45=FindLocalSelfAssignment2|true
-detector44=BadAppletConstructor|false
-detector43=FindFieldSelfAssignment|true
-detector42=IDivResultCastToDouble|true
-filter_settings=Medium|CORRECTNESS,PERFORMANCE,I18N,MT_CORRECTNESS,STYLE,MALICIOUS_CODE|false
-detector41=FindUselessControlFlow|true
-detector40=FindNullDeref|true
-detector39=CloneIdiom|true
-detector38=FindEmptySynchronizedBlock|true
-detector37=XMLFactoryBypass|true
-detector36=FindRefComparison|true
-detector35=WaitInLoop|true
-detector34=InstantiateStaticClass|true
-detector33=ComparatorIdiom|true
-detector32=BadlyOverriddenAdapter|true
-detector31=VolatileUsage|true
-detector30=ReadReturnShouldBeChecked|true
-detector92=InfiniteRecursiveLoop|true
-detector91=RuntimeExceptionCapture|true
-detector90=ConfusionBetweenInheritedAndOuterMethod|true
-default_directory=C\:\\ides\\eclipse-SDK-3.2RC7-win32
-detector29=FindUnconditionalWait|true
-detector28=FindJSR166LockMonitorenter|true
-detector27=InvalidJUnitTest|true
-detector26=FindRunInvocations|true
-detector25=MultithreadedInstanceAccess|true
-detector89=BadResultSetAccess|true
-detector24=MutableLock|true
-detector88=MutableStaticFields|true
-detector23=UseObjectEquals|false
-detector87=CheckImmutableAnnotation|true
-detector22=DumbMethods|true
-detector86=DroppedException|true
-detector21=VarArgsProblems|true
-detector85=FindHEmismatch|true
-detector20=FindUncalledPrivateMethods|true
-detector84=MethodReturnCheck|true
-detector_threshold=2
-detector83=BadUseOfReturnValue|true
-detector82=FindSqlInjection|true
-detector81=Naming|true
-detector80=EmptyZipFileEntry|true
-detector19=FindMaskedFields|true
-detector18=InfiniteLoop|false
-detector17=DoInsideDoPriviledged|true
-detector16=FindPuzzlers|true
-detector15=RedundantInterfaces|true
-detector79=InitializationChain|true
-detector14=IncompatMask|true
-detector78=InfiniteRecursiveLoop2|false
-detector13=FindMismatchedWaitOrNotify|true
-detector77=PublicSemaphores|true
-detector12=FindFinalizeInvocations|true
-detector76=SwitchFallthrough|true
-detector11=StringConcatenation|true
-detector75=InheritanceUnsafeGetResource|true
-detector10=FindBadForLoop|true
-detector74=FindInconsistentSync2|true
+#FindBugs User Preferences
+#Fri Aug 01 12:18:53 WEST 2014
+cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud
+detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
+detectorAtomicityProblem=AtomicityProblem|true
+detectorBadAppletConstructor=BadAppletConstructor|true
+detectorBadResultSetAccess=BadResultSetAccess|true
+detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
+detectorBadUseOfReturnValue=BadUseOfReturnValue|true
+detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
+detectorBooleanReturnNull=BooleanReturnNull|true
+detectorCallToUnsupportedMethod=CallToUnsupportedMethod|true
+detectorCheckExpectedWarnings=CheckExpectedWarnings|false
+detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
+detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true
+detectorCheckTypeQualifiers=CheckTypeQualifiers|true
+detectorCloneIdiom=CloneIdiom|true
+detectorComparatorIdiom=ComparatorIdiom|true
+detectorConfusedInheritance=ConfusedInheritance|true
+detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
+detectorCrossSiteScripting=CrossSiteScripting|true
+detectorDefaultEncodingDetector=DefaultEncodingDetector|true
+detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
+detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
+detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
+detectorDontUseEnum=DontUseEnum|true
+detectorDroppedException=DroppedException|true
+detectorDumbMethodInvocations=DumbMethodInvocations|true
+detectorDumbMethods=DumbMethods|true
+detectorDuplicateBranches=DuplicateBranches|true
+detectorEmptyZipFileEntry=EmptyZipFileEntry|true
+detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
+detectorExplicitSerialization=ExplicitSerialization|true
+detectorFinalizerNullsFields=FinalizerNullsFields|true
+detectorFindBadCast2=FindBadCast2|true
+detectorFindBadForLoop=FindBadForLoop|true
+detectorFindCircularDependencies=FindCircularDependencies|true
+detectorFindDeadLocalStores=FindDeadLocalStores|true
+detectorFindDoubleCheck=FindDoubleCheck|true
+detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
+detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
+detectorFindFinalizeInvocations=FindFinalizeInvocations|true
+detectorFindFloatEquality=FindFloatEquality|true
+detectorFindHEmismatch=FindHEmismatch|true
+detectorFindInconsistentSync2=FindInconsistentSync2|true
+detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
+detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
+detectorFindMaskedFields=FindMaskedFields|true
+detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
+detectorFindNakedNotify=FindNakedNotify|true
+detectorFindNonShortCircuit=FindNonShortCircuit|true
+detectorFindNullDeref=FindNullDeref|true
+detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
+detectorFindOpenStream=FindOpenStream|true
+detectorFindPuzzlers=FindPuzzlers|true
+detectorFindRefComparison=FindRefComparison|true
+detectorFindReturnRef=FindReturnRef|true
+detectorFindRoughConstants=FindRoughConstants|true
+detectorFindRunInvocations=FindRunInvocations|true
+detectorFindSelfComparison=FindSelfComparison|true
+detectorFindSelfComparison2=FindSelfComparison2|true
+detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
+detectorFindSpinLoop=FindSpinLoop|true
+detectorFindSqlInjection=FindSqlInjection|true
+detectorFindTwoLockWait=FindTwoLockWait|true
+detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
+detectorFindUnconditionalWait=FindUnconditionalWait|true
+detectorFindUninitializedGet=FindUninitializedGet|true
+detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
+detectorFindUnreleasedLock=FindUnreleasedLock|true
+detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
+detectorFindUnsyncGet=FindUnsyncGet|true
+detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
+detectorFindUselessControlFlow=FindUselessControlFlow|true
+detectorFormatStringChecker=FormatStringChecker|true
+detectorHugeSharedStringConstants=HugeSharedStringConstants|true
+detectorIDivResultCastToDouble=IDivResultCastToDouble|true
+detectorIncompatMask=IncompatMask|true
+detectorInconsistentAnnotations=InconsistentAnnotations|true
+detectorInefficientIndexOf=InefficientIndexOf|true
+detectorInefficientMemberAccess=InefficientMemberAccess|true
+detectorInefficientToArray=InefficientToArray|true
+detectorInfiniteLoop=InfiniteLoop|true
+detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
+detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
+detectorInitializationChain=InitializationChain|true
+detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
+detectorInstantiateStaticClass=InstantiateStaticClass|true
+detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
+detectorInvalidJUnitTest=InvalidJUnitTest|true
+detectorIteratorIdioms=IteratorIdioms|true
+detectorLazyInit=LazyInit|true
+detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
+detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
+detectorMethodReturnCheck=MethodReturnCheck|true
+detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
+detectorMutableLock=MutableLock|true
+detectorMutableStaticFields=MutableStaticFields|true
+detectorNaming=Naming|true
+detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
+detectorNumberConstructor=NumberConstructor|true
+detectorOptionalReturnNull=OptionalReturnNull|true
+detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
+detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
+detectorPublicSemaphores=PublicSemaphores|true
+detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
+detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
+detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
+detectorRedundantInterfaces=RedundantInterfaces|true
+detectorRepeatedConditionals=RepeatedConditionals|true
+detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
+detectorSerializableIdiom=SerializableIdiom|true
+detectorStartInConstructor=StartInConstructor|true
+detectorStaticCalendarDetector=StaticCalendarDetector|true
+detectorStringConcatenation=StringConcatenation|true
+detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
+detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
+detectorSwitchFallthrough=SwitchFallthrough|true
+detectorSynchronizationOnSharedBuiltinConstant=SynchronizationOnSharedBuiltinConstant|true
+detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
+detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
+detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
+detectorURLProblems=URLProblems|true
+detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
+detectorUnnecessaryMath=UnnecessaryMath|true
+detectorUnreadFields=UnreadFields|true
+detectorUselessSubclassMethod=UselessSubclassMethod|true
+detectorVarArgsProblems=VarArgsProblems|true
+detectorVolatileUsage=VolatileUsage|true
+detectorWaitInLoop=WaitInLoop|true
+detectorWrongMapIterator=WrongMapIterator|true
+detectorXMLFactoryBypass=XMLFactoryBypass|true
+detector_threshold=2
+effort=default
+filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false|15
+filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL|
+run_at_full_build=false
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..0662ee8f3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,20 @@
+/bin/
+/build/
+/buildtest/
+/dist/
+/docs/
+/nbproject/
+/patches/
+/*.properties
+*~
+*.lock
+*.swp
+*.DS_Store
+*.diff
+*.dot
+*.dot.png
+*.class
+.project.el
+.attach_pid*
+hs_err_pid*.log
+*.sh
diff --git a/.project b/.project
index 2723a90a8..d437fa76a 100644
--- a/.project
+++ b/.project
@@ -1,29 +1,65 @@
-
-
- connector-j-5-1
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.ui.externaltools.ExternalToolBuilder
- full,incremental,
-
-
- LaunchConfigHandle
- <project>/.externalToolBuilders/Ant_Builder (for JDBC-4.0 Implementation).launch
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.team.cvs.core.cvsnature
- com.telesynthesis.tools.eclipse.checkstyle.CheckStyleNature
-
-
+
+
+ ConnectorJ 80
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.ui.externaltools.ExternalToolBuilder
+ clean,full,incremental,
+
+
+ LaunchConfigHandle
+ <project>/.externalToolBuilders/Ant_Builder.launch
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
+
+ 0
+
+ 26
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-projectRelativePath-matches-false-false-build
+
+
+
+ 0
+
+ 26
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-projectRelativePath-matches-false-false-dist
+
+
+
+ 0
+
+ 26
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-projectRelativePath-matches-false-false-patches
+
+
+
+ 0
+
+ 26
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-projectRelativePath-matches-false-false-buildtest
+
+
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 351272cdb..70f2b2d1d 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,62 +1,451 @@
-#Mon Apr 16 13:40:22 CDT 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.source=1.3
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.incompleteClasspath=error
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
+org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
+org.eclipse.jdt.core.formatter.align_with_spaces=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=1
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false
+org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=false
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=160
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=false
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_if_empty
+org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
+org.eclipse.jdt.core.formatter.lineSplit=160
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=true
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
+org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
diff --git a/.settings/org.eclipse.jdt.launching.prefs b/.settings/org.eclipse.jdt.launching.prefs
new file mode 100644
index 000000000..d211d3263
--- /dev/null
+++ b/.settings/org.eclipse.jdt.launching.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index d68d860d1..783c90450 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -1,3 +1,132 @@
-#Tue Dec 19 15:23:45 CST 2006
-eclipse.preferences.version=1
-internal.default.compliance=default
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_methods=false
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_missing_override_annotations_interface_methods=false
+cleanup.add_serial_version_id=false
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=true
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_functional_interfaces=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.correct_indentation=false
+cleanup.format_source_code=false
+cleanup.format_source_code_changes_only=false
+cleanup.insert_inferred_type_arguments=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=true
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_redundant_type_arguments=true
+cleanup.remove_trailing_whitespaces=false
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_anonymous_class_creation=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_lambda=true
+cleanup.use_parentheses_in_expressions=false
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=false
+cleanup.use_this_for_non_static_method_access=false
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup.use_type_arguments=false
+cleanup_profile=_ConnectorJ Team
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_ConnectorJ Team
+formatter_settings_version=15
+internal.default.compliance=default
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=java;javax;org;com;testsuite;
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.staticondemandthreshold=99
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=true
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.push_down_negation=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_modifiers=false
+sp_cleanup.remove_redundant_semicolons=false
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_type_arguments=false
+sp_cleanup.use_unboxing=false
diff --git a/CHANGES b/CHANGES
index e36d33b19..45cc8c2a1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,1945 @@
# Changelog
-# $Id$
+# https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/
+
+Version 8.0.28
+
+ - Fix for Bug#99260 (31189960), statement.setQueryTimeout,creates a database connection and does not close.
+
+ - Fix for Bug#103324 (32770013), X DevAPI Collection.replaceOne() missing matching _id check.
+
+ - Fix for Bug#105197 (33461744), Statement.executeQuery() may return non-navigable ResultSet.
+
+ - Fix for Bug#105323 (33507321), README.md contains broken links.
+
+ - Fix for Bug#96900 (30355150), STATEMENT.CANCEL()CREATE A DATABASE CONNECTION BUT DOES NOT CLOSE THE CONNECTION.
+
+ - Fix for Bug#104067 (33054827), No reset autoCommit after unknown issue occurs.
+ Thanks to Tingyu Wei for his contribution.
+
+ - Fix for Bug#85223 (25656020), MYSQLSQLXML SETSTRING CRASH.
+
+ - Fix for Bug#84365 (33425867), INSERT..VALUE with VALUES function lead to a StringIndexOutOfBoundsException.
+
+ - Fix for Bug#105211 (33468860), class java.time.LocalDate cannot be cast to class java.sql.Date.
+
+ - Fix for Bug#101389 (32089018), GETWARNINGS SHOULD CHECK WARNING COUNT BEFORE SENDING SHOW.
+
+ - Fix for Bug#33488091, Remove all references to xdevapi.useAsyncProtocol from properties and code.
+
+ - WL#14805, Remove support for TLS 1.0 and 1.1.
+
+ - WL#14650, Support for MFA (multi factor authentication) authentication.
+
+Version 8.0.27
+
+ - Fix for Bug#103612 (32902019), Incorrectly identified WITH...SELECT as unsafe for read-only connections.
+
+ - Fix for Bug#71929 (18346501), Prefixing query with double comments cancels query DML validation.
+
+ - Fix for Bug#23204652, CURSOR POSITIONING API'S DOESNOT CHECK THE VALIDITY OF RESULTSET.
+
+ - Fix for Bug#28725534, MULTI HOST CONNECTION WOULD BLOCK IN CONNECTION POOLING.
+
+ - Fix for Bug#95139 (29807572), CACHESERVERCONFIGURATION APPEARS TO THWART CHARSET DETECTION.
+
+ - Fix for Bug#104641 (33237255), DatabaseMetaData.getImportedKeys can return duplicated foreign keys.
+
+ - Fix for Bug#33185116, Have method ResultSet.getBoolean() supporting conversion of 'T' and 'F' in a VARCHAR to True/False (boolean).
+
+ - Fix for Bug#31117686, PROTOCOL ALLOWLIST NOT COMPATIBLE WITH IBM JAVA.
+
+ - Fix for Bug#104559 (33232419), ResultSet.getObject(i, java.util.Date.class) throws NPE when the value is null.
+
+ - WL#14707, Support OCI IAM authentication.
+
+ - WL#14660, Testsuite with support for single MySQL server instance.
+
+ - Fix for Bug#103878 (32954449), CONNECTOR/J 8 : QUERY WITH 'SHOW XXX' WILL GET EXCEPTION WHEN USE CURSOR.
+
+ - Fix for Bug#103796 (32922715), CONNECTOR/J 8 STMT SETQUERYTIMEOUT CAN NOT WORK.
+ Thanks to Hong Wang for his contribution.
+
+ - Fix for Bug#104170 (33064455), CONTRIBUTION: CLIENTPREPAREDSTMT: LEAVE CALENDAR UNTOUCHED.
+ Thanks to Björn Michael for his contribution.
+
+ - Fix for Bug#95564 (29894324), createDatabaseIfNotExist is not working for databases with hyphen in name.
+ Thanks to Lukasz Sanek for his contribution.
+
+Version 8.0.26
+
+ - Fix for Bug#32954396, EXECUTEQUERY HANGS WITH USECURSORFETCH=TRUE & SETFETCHSIZE.
+
+ - Fix for Bug#102372 (32459408), v8.0.23 unusable in OSGi.
+
+ - Fix for Bug#25554464, CONNECT FAILS WITH NPE WHEN THE SERVER STARTED WITH CUSTOM COLLATION.
+
+ - Fix for Bug#100606 (31818423), UNECESARY CALL TO "SET NAMES 'UTF8' COLLATE 'UTF8_GENERAL_CI'".
+ Thanks to Marc Fletcher for his contribution.
+
+ - Fix for Bug#102404 (32435618), CONTRIBUTION: ADD TRACK SESSION STATE CHANGE.
+ Thanks to William Lee for his contribution.
+
+ - Fix for Bug#95280 (29757140), DATABASEMETADATA.GETIMPORTEDKEYS RETURNS DOUBLE THE ROWS.
+ Thanks to Miron Balcerzak for his contribution.
+
+ - Fix for Bug#97269 (30438500), POSSIBLE BUG IN COM.MYSQL.CJ.XDEVAPI.STREAMINGDOCRESULTBUILDER.
+
+ - Fix for Bug#103303 (32766143), JAVA.LANG.CLASSCASTEXCEPTION WHEN INSERTING BLOB WITH SERVER PREPARED STATEMENT.
+
+ - WL#14205, Support query attributes.
+
+ - WL#14411, Support for authentication_kerberos_client authentication plugin.
+
+ - WL#14559, Deprecate TLS 1.0 and 1.1.
+
+ - WL#14391, Migrate QA tests to main repo.
+
+Version 8.0.25
+
+ - This release contains no functional changes and is published to align the version number with the MySQL Server 8.0.25 release.
+
+Version 8.0.24
+
+ - Fix for Bug#102188 (32526663), AccessControlException with AuthenticationLdapSaslClientPlugin.
+
+ - Fix for Bug#22508715, SETSESSIONMAXROWS() CALL ON CLOSED CONNECTION RESULTS IN NPE.
+
+ - Fix for Bug#102131 (32338451), UPDATABLERESULTSET NPE WHEN USING DERIVED QUERIES OR VIEWS.
+
+ - Fix for Bug#101596 (32151143), GET THE 'HOST' PROPERTY ERROR AFTER CALLING TRANSFORMPROPERTIES() METHOD.
+
+ - Fix for Bug#20391832, SETOBJECT() FOR TYPES.TIME RESULTS IN EXCEPTION WHEN VALUE HAS FRACTIONAL PART.
+
+ - Fix for Bug#97730 (31699993), xdev api: ConcurrentModificationException at Session.close.
+
+ - Fix for Bug#99708 (31510398), mysql-connector-java 8.0.20 ASSERTION FAILED: Unknown message type: 57 s.close.
+
+ - Fix for Bug#32122553, EXTRA BYTE IN COM_STMT_EXECUTE.
+
+ - Fix for Bug#101558 (32141210), NULLPOINTEREXCEPTION WHEN EXECUTING INVALID QUERY WITH USEUSAGEADVISOR ENABLED.
+
+ - Fix for Bug#102076 (32329915), CONTRIBUTION: MYSQL JDBC DRIVER RESULTSET.GETLONG() THROWS NUMBEROUTOFRANGE.
+
+ - Fix for Bug#31747910, BUG 30474158 FIX IMPROVES JDBC COMPLIANCE BUT CHANGES DEFAULT RESULTSETTYPE HANDLING.
+
+ - Fix for Bug#102321 (32405590), CALLING RESULTSETMETADATA.GETCOLUMNCLASSNAME RETURNS WRONG VALUE FOR DATETIME.
+
+ - WL#14453, Pluggable authentication: new default behavior & user-less authentications.
+
+ - WL#14392, Improve timeout error messages [classic].
+
+ - WL#14202, XProtocol: Support connection close notification.
+
+Version 8.0.23
+
+ - Fix for Bug#21789378, FORCED TO SET SERVER TIMEZONE IN CONNECT STRING.
+
+ - Fix for Bug#95644 (30573281), JDBC GETDATE/GETTIME/GETTIMESTAMP INTERFACE BEHAVIOR CHANGE AFTER UPGRADE 8.0.
+
+ - Fix for Bug#94457 (29402209), CONNECTOR/J RESULTSET.GETOBJECT( ..., OFFSETDATETIME.CLASS ) THROWS.
+
+ - Fix for Bug#76775 (20959249), FRACTIONAL SECONDS IN TIME VALUES ARE NOT AVAILABLE VIA JDBC.
+
+ - Fix for Bug#99013 (31074051), AN EXTRA HOUR GETS ADDED TO THE TIMESTAMP WHEN SUBTRACTING INTERVAL 'N' DAYS.
+
+ - Fix for Bug#98695 (30962953), EXECUTION OF "LOAD DATA LOCAL INFILE" COMMAND THROUGH JDBC FOR DATETIME COLUMN.
+
+ - Fix for Bug#101413 (32099505), JAVA.TIME.LOCALDATETIME CANNOT BE CAST TO JAVA.SQL.TIMESTAMP.
+
+ - Fix for Bug#101242 (32046007), CANNOT USE BYTEARRAYINPUTSTREAM AS ARGUMENTS IN PREPARED STATEMENTS ANYMORE.
+ Thanks to Martynas Puronas for his contribution.
+
+ - WL#14274, Support for authentication_ldap_sasl_client(SCRAM-SHA-256) authentication plugin.
+
+ - WL#14206, Support for authentication_ldap_sasl_client(GSSAPI) authentication plugin.
+
+ - WL#14207, Replace language in APIs and source code/docs.
+
+Version 8.0.22
+
+ - Fix for Bug#98667 (31711961), "All pipe instances are busy" exception on multiple connections to named Pipe.
+
+ - Fix for Bug#96309 (31699357), MultiHost in loadbalance may lead to a TPS reduction during a quick switch.
+
+ - Fix for Bug#99076 (31083755), Unclear exception/error when connecting with jdbc:mysql to a mysqlx port.
+
+ - Fix for Bug#96870 (30304764), Contribution: Allow to disable AbandonedConnectionCleanupThread completely.
+ Thanks to Andrey Turbanov for his contribution.
+
+ - WL#14115, Support for authentication_ldap_sasl_client(SCRAM-SHA-1) authentication plugin.
+
+ - WL#14096, Add option to specify LOAD DATA LOCAL allow list folder.
+
+ - WL#13780, Skip system-wide trust and key stores (incl. X DevAPI client certs).
+
+ - WL#14017, XProtocol -- support for configurable compression algorithms.
+
+ - Fix for Bug#92903 (28834903), MySQL Connector/j should support wildcard names or alternative names.
+
+ - Fix for Bug#99767 (31443178), Contribution: Check SubjectAlternativeName for TLS instead of commonName.
+ Thanks to Daniël van Eeden for his contribution.
+
+ - Fix for Bug#93444 (29015453), LOCALDATETIME PARAMETER VALUES ALTERED WHEN CLIENT AND SERVER TIMEZONES DIFFER.
+ Thanks to Iwao Abe for his contribution.
+
+ - WL#14052, Remove asynchronous variant of X Protocol.
+
+ - Fix for Bug#99713 (31418928), NPE DURING COM.MYSQL.CJ.SERVERPREPAREDQUERYBINDVALUE.STOREDATE().
+
+ - WL#14068, Remove legacy integration with JBoss.
+
+Version 8.0.21
+
+ - WL#14051, Upgrade Protocol Buffers dependency to protobuf-java-3.11.4.
+
+ - WL#14042, Upgrade testsuite to JUnit 5.
+
+ - Fix for Bug#98237 (30911870), PREPAREDSTATEMENT.SETOBJECT(I, "FALSE", TYPES.BOOLEAN) ALWAYS SETS TRUE OR 1.
+
+ - WL#13008, DevAPI: Add schema validation to create collection.
+
+Version 8.0.20
+
+ - Fix for Bug#30805426, IN CASE OF ISAUTHMETHODSWITCHREQUESTPACKET , TOSERVERS > 1 ARE IGNORED.
+
+ - Fix for Bug#97714 (30570249), Contribution: Expose elapsed time for query interceptor to avoid hacky thread local implementations.
+ Thanks to Matti Sillanpää and Johnathan Crawford for their contribution.
+
+ - Fix for Bug#97724 (30570721), Contribution: Allow \'3.\' formatted numbers.
+ Thanks to Nick Pollett for his contribution.
+
+ - Fix for Bug#98536 (30877755), SIMPLEDATEFORMAT COULD CACHE A WRONG CALENDAR.
+
+ - Fix for Bug#91112 (28125069), AGAIN WRONG JAVA.SQL.DATE.
+
+ - Fix for Bug#30474158, CONNECTOR/J 8 DOES NOT HONOR THE REQUESTED RESULTSETTYPE SCROLL_INSENSITIVE ETC.
+
+ - Fix for Bug#98445 (30832513), Connection option clientInfoProvider=ClientInfoProviderSP causes NPE.
+
+ - WL#12248, DevAPI: Connection compression.
+
+ - Fix for Bug#30636056, ResultSetUtil.resultSetToMap() can be unsafe to use.
+
+ - Fix for Bug#97757 (30584907), NULLPOINTEREXCEPTION WITH CACHERESULTSETMETADATA=TRUE AND EXECUTEQUERY OF "SET".
+
+Version 8.0.19
+
+ - WL#13346, Support for mult-host and failover.
+
+ - Fix for Bug#97413 (30477722), DATABASEMETADATA IS BROKEN AFTER SERVER WL#13528.
+
+ - WL#13367, DNS SRV support.
+
+ - WL#12736, DevAPI: Specify TLS ciphers to be used by a client or session.
+
+ - Fix for regression tests broken by Bug#97079 fix.
+
+ - Fix for Bug#96383 (30119545) RS.GETTIMESTAMP() HAS DIFFERENT RESULTS FOR TIME FIELDS WITH USECURSORFETCH=TRUE.
+
+ - Fix for Bug#96059 (29999318), ERROR STREAMING MULTI RESULTSETS WITH MYSQL-CONNECTOR-JAVA 8.0.X.
+
+ - Fix for Bug#96442 (30151808), INCORRECT DATE ERROR WHEN CALLING GETMETADATA ON PREPARED STATEMENT.
+
+Version 8.0.18
+
+ - WL#13347, Connectors should handle expired password sandbox without SET operations.
+
+ - Fix for Bug#84098 (25223123), endless loop in LoadBalancedAutoCommitInterceptor.
+
+ - Fix for Bug#23721537, MULTI-SELECT WITH EXECUTEASYNC() GIVES IMPROPER ERROR.
+
+ - Fix for Bug#95741 (29898567), METADATA QUERY USES UPPER() AROUND NUMERIC EXPRESSION.
+
+ - Fix for Bug#20913289, PSTMT.EXECUTEUPDATE() FAILS WHEN SQL MODE IS NO_BACKSLASH_ESCAPES.
+
+ - Fix for Bug#80441 (22850444), SYNTAX ERROR ON RESULTSET.UPDATEROW() WITH SQL_MODE NO_BACKSLASH_ESCAPES.
+
+Version 8.0.17
+
+ - WL#13210, Generate Javadocs via ant.
+
+ - WL#12247, DevAPI: indexing array fields.
+
+ - WL#12726, DevAPI: Add overlaps and not_overlaps as operator.
+
+ - Fix for Bug#95503 (29821029), Operator IN not mapping consistently to the right X Plugin operation.
+
+ - WL#12942, Update README.md and add new CONTRIBUTING.md.
+
+ - WL#13125, Support fully qualified hostnames longer than 60 characters.
+
+ - Fix for Bug#95210 (29807741), ClassCastException in BlobFromLocator when connecting as jdbc:mysql:replication.
+
+ - Fix for Bug#29591275, THE JAR FILE NEEDS TO CONTAIN A README AND LICENSE FILE.
+
+ - WL#13124, Support new utf8mb4 bin collation.
+
+ - WL#13009, DevAPI: Deprecate methods.
+
+ - WL#11101, Remove de-cache and close of SSPSs on double call to close().
+
+ - Fix for Bug#89133 (27356869) CONTRIBUTION: UPDATE DATABASEMETADATA.JAVA.
+ Thanks to Harald Aamot for his contribution.
+
+ - Fix for Bug#11891000, DABATASEMETADATA.GETTABLES() IGNORES THE SCHEMA_PATTERN ARGUMENT.
+
+ - Fix for Bug#94101 (29277648), SETTING LOGSLOWQUERIES SHOULD NOT AUTOMATICALLY ENABLE PROFILESQL FOR QUERIES.
+ Thanks to Florian Agsteiner for the contribution.
+
+ - Fix for Bug#74690 (20010454), PROFILEREVENT HOSTNAME HAS NO GETTER().
+
+ - Fix for Bug#70677 (17640628), CONNECTOR J WITH PROFILESQL - LOG CONTAINS LOTS OF STACKTRACE DATA.
+
+ - Fix for Bug#41172 (11750577), PROFILEREVENT.PACK() THROWS ARRAYINDEXOUTOFBOUNDSEXCEPTION.
+
+ - Fix for Bug#27453692, CHARACTERS GET GARBLED IN CONCAT() IN PS WHEN USECURSORFETCH=TRUE.
+
+ - Fix for Bug#94585 (29452669), GETTABLENAME() RETURNS NULL FOR A QUERY HAVING COUNT(*) WITH JDBC DRIVER V8.0.12.
+
+ - Fix for Bug#94533 (29446100), GETOBJECT FOR BOXED PRIMITIVE TYPES DOESN'T RETURN NULL FOR NULL COLUMNS.
+
+ - Fix for Bug#94442 (29446059), RESULTSETIMPL.GETDOUBLE IS INEFFICIENT BECAUSE OF BIGDECIMAL (RE)CONSTRUCTIONS.
+
+Version 8.0.16
+
+ - WL#12825, Remove third-party libraries from sources and bundles.
+
+ - Fix for Bug#93590 (29054329), javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify.
+
+ - Fix for Bug#94414 (29384853), Connector/J RPM package have version number in path.
+
+ - Fix for Bug#27786499, REDUNDANT FILES IN DEBIAN PACKAGE FOR DEBIAN9(COMMUNITY PACKAGE) FOR CJAVA.
+
+ - WL#12246, DevAPI: Prepared statement support.
+
+ - WL#10839, Adjust c/J tests to the new "ON" default for explicit_defaults_for_timestamp.
+
+ - Fix for Bug#29329326, PLEASE AVOID SHOW PROCESSLIST IF POSSIBLE.
+
+ - WL#12460, DevAPI: Support new session reset functionality.
+
+ - WL#12459, DevAPI: Support connection-attributes.
+
+ - Fix for Bug#25650385, GETBYTE() RETURNS ERROR FOR BINARY() FLD.
+
+ - Fix for Bug#27784363, MYSQL 8.0 JDBC DRIVER THROWS NUMBERFORMATEXCEPTION FOR TEXT DATA
+
+ - Fix for Bug#93007 (28860051), LoadBalancedConnectionProxy.getGlobalBlacklist bug.
+
+ - Fix for Bug#29186870, CONNECTOR/J REGRESSION: NOT RETURNING PRECISION GETPROCEDURECOLUMNS.
+
+ - Fix for Bug#22038729, X DEVAPI: ANY API CALL AFTER A FAILED CALL PROC() RESULTS IN HANG.
+
+ - Fix for Bug#29244101, ADD MAPPING FOR UTF8MB4_ZH_0900_AS_CS COLLATION.
+
+ - Fix for Bug#92819 (28834959), EXPRPARSER THROWS WRONGARGUMENTEXCEPTION WHEN PARSING EMPTY JSON ARRAY.
+
+ - Fix for Bug#21921956, X DEVAPI: EXPRESSION PARSE ERROR WITH UNARY OPERATOR.
+
+ - Fix for Bug#94031 (29257922), WRONG JSON_UNQUOTE WORKAROUND.
+
+ - Fix for Bug#22931700, BINDINGS.GETBOOLEAN() ALWAYS RETURNS FALSE.
+
+ - Fix for Bug#25650912, ERROR MESSAGE NOT CLEAR WHEN WE PASS A CHAR DATA TO ANY TABLE API.
+
+ - Fix for Bug#25642021, CHANGEUSER() FAILS WHEN ENABLEPACKETDEBUG=TRUE.
+
+Version 8.0.15
+
+ - Fix for Bug#94051 (29261254), Not recommended default for 'allowLoadLocalInfile'.
+
+Version 8.0.14
+
+ - WL#12298, Connectors: Expose metadata about source and binaries in unified way.
+
+ - Fix for Bug#93111 (28894344), ConnectionUrl.java contains char U+00A7 (section sign).
+
+ - WL#12621, DevAPI: Handling of Default Schema.
+
+ - Fix for Bug#93340 (28970166), C/J BUILD SCRIPT IS TOO VERBOSE
+
+ - WL#12462, DevAPI: Be prepared for initial notice on connection.
+
+ - Fix for Bug#28924137, WL#12463:IF COLLECTION DOESN'T EXIST, COLL.COUNT() IS GIVING A WRONG ERROR MESSAGE.
+
+ - WL#12463, DevAPI: Standardize count method.
+
+ - Fix for Bug#92508 (28747636), mysql-connector in bootclasspath causing memory leak.
+
+ - Fix for Bug#25650514, UPDATEROW() CALL FAILS WITH NPE WHEN SSPS=TRUE AND TABLE HAS MULTI-FLD KEY.
+
+ - Fix for Bug#25650482, REFRESHROW() CALL AFTER UPDATEROW() API FAILS WHEN USESERVERPREPSTMTS=TRUE.
+
+ - Fix for Bug#92536 (28692243), UPDATEING SERVER SIDE PREPSTMTS RESULTSET FAIL.
+
+ - Fix for Bug#92625 (28731795), CONTRIBUTION: FIX OBSERVED NPE IN CLEARINPUTSTREAM.
+ Thanks to Henning Schmiedehausen for his contribution.
+
+ - Fix for Bug#23045642, ADDING NO-DOC (MYSQLCONNJ-696) RESULTS IN EXCEPTION.
+
+ - Fix for Bug#91065 (28101003), ZERODATETIMEBEHAVIOR=CONVERT_TO_NULL SHOULD NOT APPLY TO 00:00:00 TIME COLUMNS.
+
+ - Fix for Bug#92574 (28706219), WHEN CONVERTING FROM VARCHAR TO JAVA BOOLEAN, 'N' IS NOT SUPPORTED.
+
+ - Fix for Bug#25642226, CHANGEUSER() NOT SETTING THE DATABASE PROPERLY WITH SHA USER.
+
+ - Fix for Bug#28606708, NAMED PIPE CONNECTION FOR X PROTOCOL RETURNS NPE, EXPECTED PROPER ERROR MESSAGE.
+
+Version 8.0.13
+
+ - Fix for Bug#91317 (28207422), Wrong defaults on collation mappings.
+
+ - WL#12245, DevAPI: Implement connect timeout.
+
+ - Fix for Bug#21774249, UNIT TEST FAILS WITH ERROR " 'CEST' IS UNRECOGNIZED TIME ZONE".
+
+ - WL#11857, DevAPI: Implement connection pooling for xprotocol.
+
+ - Fix for Bug#91873 (28444461), REMOVE USEOLDUTF8BEHAVIOR CONNECTION PROPERTY.
+
+ - Fix for Bug#92264 (28594434), JSONPARSER PUTS UNNECESSARY MAXIMUM LIMIT ON JSONNUMBER TO 10 DIGITS.
+
+ - WL#12110, Extend PropertyDefinitions.PropertyKey usage.
+
+ - Fix for Bug#81063 (23098159), w/ rewriteBatchedStatements, when 2 tables involved, the rewriting not correct.
+
+ - Fix for Bug#84813 (25501750), rewriteBatchedStatements fails in INSERT.
+
+ - Fix for Bug#81196 (23227334), CONNECTOR/J NOT FOLLOWING DATABASE CHARACTER SET.
+
+ - Fix for Bug#72609 (18749544), SETDATE() NOT USING A PROLEPTIC GREGORIAN CALENDAR.
+
+ - Fix for Bug#87534 (26730196), UNION ALL query fails when useServerPrepStmts=true on database connection.
+ Test case only. Base bug fixed in MySQL 5.7.22.
+
+ - Fix for Bug#89948 (27658489), Batched statements are not committed for useLocalTransactionState=true.
+
+ - Fix for BUG#22305979, WRONG RECORD UPDATED IF SENDFRACTIONALSECONDS=FALSE AND SMT IS SCROLLABLE.
+
+ - Fix for Bug#27102307, CHANGE USESSL AND VERIFYSERVERCERTIFICATE TO SSLMODE OPTION.
+
+ - Fix for Bug#28150662, CONNECTOR/J 8 MALFORMED DATABASE URL EXCEPTION WHIT CORRECT URL STRING.
+
+ - Fix for Bug#91421 (28246270), ALLOWED VALUES FOR ZERODATETIMEBEHAVIOR ARE INCOMPATIBLE WITH NETBEANS.
+
+ - Fix for Bug#23045604, XSESSION.GETURI() RETURNS NPE.
+
+ - Fix for Bug#21914769, NPE WHEN TRY TO EXECUTE INVALID JSON STRING.
+
+ - Fix for Bug#BUG#90887 (28034570), DATABASEMETADATAUSINGINFOSCHEMA#GETTABLES FAILS IF METHOD ARGUMENTS ARE NULL.
+
+ - Fix for Bug#28207088, C/JAVA: UPDATECLOB(INT COLUMNLABEL, JAVA.SQL.CLOB CLOB) IS FAILING.
+
+ - Fix for Bug#27629553, NPE FROM GETSESSION() FOR SSL CONNECTION WHEN NO PASSWORD PASSED.
+
+Version 8.0.12
+
+ - Fix for Bug#28208000, MASTER : HANG IN ASYNCHRONOUS SELECT TEST.
+
+ - WL#10544, Update MySQL 8.0 keywords list.
+
+ - WL#11858, DevAPI: Core API v1 alignment.
+
+ - Fix for Bug#27652379, NPE FROM GETSESSION(PROPERTIES) WHEN HOST PARAMETER IS GIVEN IN SMALL LETTER.
+
+ - Fix for BUG#87600 (26724154), CONNECTOR THROWS 'MALFORMED DATABASE URL' ON NON MYSQL CONNECTION-URLS.
+
+ - Fix for BUG#26089880, GETCONNECTION("MYSQLX://..") RETURNS NON-X PROTOCOL CONNECTION.
+
+ - WL#11876, Improve connection properties design.
+
+ - WL#11933, Connector/J 8.0 X DevAPI reference documentation update.
+
+ - WL#11860, Ensure >= 75% code coverage.
+
+ - Fix for Bug#90753 (27977617), WAIT_TIMEOUT EXCEEDED MESSAGE NOT TRIGGERED.
+
+ - Fix for Bug#85941 (25924324), WASNULL NOT SET AFTER GETBYTES IS CALLED.
+
+ - Fix for Bug#28066709, COLLECTION.CREATEINDEX() TEST IS BROKEN AFTER WL#11808 IMPLEMENTATION.
+
+ - Fix for Bug#90872 (28027459), FILTERPARAMS CLASS IS NOT NEEDED.
+
+ - Fix for Bug#27522054, POSSIBLE ASYNC XPROTOCOL MESSAGE HANDLING PERF ISSUE.
+ The "xdevapi.useAsyncProtocol" connection property default value is changed to "false".
+
+Version 8.0.11
+
+ - WL#11293, DevAPI: Support new locking modes : NOWAIT and SKIP LOCKED.
+
+ - Fix for Bug#90029 (27678308), FAILURE WHEN GETTING GEOMCOLLECTION COLUMN TYPE.
+
+ - Fix for BUG#90024 (27677574), SOME TESTS FAILED AGAINST MYSQL 8.0.5 BECAUSE OF DEPRECATED FEATURES REMOVAL.
+
+ - Fix for Bug#86741 (26314325), Multi-Host connection with autocommit=0 getAutoCommit maybe wrong.
+
+ - Fix for Bug#27231383, PROVIDE MAVEN-FRIENDLY COMMERCIAL PACKAGES WITHOUT "-BIN".
+
+ - Fix for Bug#26819691, SETTING PACKETDEBUGBUFFERSIZE=0 RESULTS IN CONNECTION FAILURE.
+
+ - Fix for Bug#88227 (27029657), Connector/J 5.1.44 cannot be used against MySQL 5.7.20 without warnings.
+
+ - Fix for Bug#27374581, CONNECTION FAILS WHEN GPL SERVER STARTED WITH TLS-VERSION=TLSV1.2.
+
+ - WL#11419, DevAPI: New document _id generation support.
+
+ - WL#11620, Change caching_sha2_password padding.
+
+ - WL#11604, DevAPI: Add SHA256_MEMORY support.
+
+ - Fix for BUG#86278 (26092824), SUPPORT CUSTOM CONSTRUCTION OF SSLSOCKET DURING CONNECTION ESTABLISHMENT.
+
+ - Fix for BUG#27226293, JSONNUMBER.GETINTEGER() & NUMBERFORMATEXCEPTION.
+
+ - WL#10527, Clean up Protocol and Session interfaces.
+
+Version 8.0.10
+
+ - (Skipped version number to align versions between components and server)
+
+Version 8.0.9
+
+ - WL#11469, Update license header in GPL packages.
+
+ - Fix for BUG#27247349, WL#11208 : UNIQUE DOES NOT GIVE ERROR EVEN THOUGH IT IS NOT SUPPORTED.
+
+ - WL#11208, DevAPI: Collection.createIndex.
+
+ - WL#10156, Add setters/getters for connection properties to MysqlDataSource, MysqlXADataSource and MysqlConnectionPoolDataSource.
+
+ - WL#11401, DevAPI: Remove configuration API.
+ Partial revert of "WL#9868, DevAPI: Configuration handling interface."
+
+ - WL#10619, Ensure compatibility with new data dictionary.
+
+ - Fix for BUG#27217264, WL#10937: NULL POINTER EXCEPTION WHEN NULL IS PASSED AS _ID IN COLL.REPLACEONE.
+
+ - WL#10937, DevAPI: ReplaceOne, AddOrReplaceOne, GetOne, RemoveOne.
+
+ - Fix for Bug#26723646, JSON_MERGE() FUNCTION IS DEPRECATED IN MYSQL 8.0.
+
+ - Fix for Bug#27185332, WL#11210:ERROR IS THROWN WHEN NESTED EMPTY DOCUMENTS ARE INSERTED TO COLLECTION.
+
+ - Fix for Bug#27151601, WL#11210: DOCUMENT PATCH EXPRESSIONS ARE NOT SUPPORTED.
+
+ - WL#11210, DevAPI: Modify/MergePatch.
+
+ - Fix for Bug#79612 (22362474), CONNECTION ATTRIBUTES LOST WHEN CONNECTING WITHOUT DEFAULT DATABASE.
+
+ - WL#10152, Enable TLSv1.2 on mysqlx.
+
+ - Fix for Bug#27131768, NULL POINTER EXCEPTION IN CONNECTION.
+
+ - Fix for Bug#88232 (27047676), c/J does not rollback transaction when autoReconnect=true.
+
+ - Fix for Bug#88242 (27040063), autoReconnect and socketTimeout JDBC option makes wrong order of client packet.
+
+ - Fix for Bug#88021 (26939943), High GC pressure when driver configured with serversideprepared statements.
+ Thanks to Johnathan Crawford for his contribution.
+
+ - Fix for Bug#26724085, CHARSET MAPPING TO BE UPDATED FOR MYSQL 8.0.3.
+
+ - Fix for Bug#87704 (26771560), THE STREAM GETS THE RESULT SET ?THE DRIVER SIDE GET WRONG ABOUT GETLONG().
+
+ - Fix for Bug#24924097, SERVER GREETING ERROR ISN'T RECOGNIZED DURING HANDSHAKE.
+
+ - Fix for Bug#26748909, MASTER : ERROR - NO OPERATIONS ALLOWED AFTER STATEMENT CLOSED FOR TOSTRING().
+
+ - Fix for Bug#26266731, CONCUR_UPDATABLE RESULTSET OPERATIONS FAIL AGAINST 8.0 FOR BOOLEAN COLUMN.
+
+ - WL#11239, DevAPI: Remove create table implementation.
+
+ - Fix for Bug#27131100, WL#11212 : SAVEPOINT CREATING WITH EMPTY STRING AND SPACE AS NAME.
+
+ - WL#11212, DevAPI: transaction save-points.
+
+ - WL#11060, Support new SHA-256 authentication system.
+
+ - Fix for Bug#87826 (26846249), MYSQL JDBC CONNECTOR/J DATABASEMETADATA NULL PATTERN HANDLING IS NON-COMPLIANT.
+
+ - WL#11163, Extract parameter setters, serverPrepare() and serverExecute() to core classes.
+
+ - Fix for BUG#26995710, WL#11161 : NULL POINTER EXCEPTION IN EXECUTEBATCH() AND CLOSE().
+
+ - WL#11161, Unify query bindings.
+
+ - WL#8469, Don't extract query text from packets when possible.
+
+Version 8.0.8
+
+ - Fix for BUG#26722030, TEST FAILING DUE TO BINARY LOGGING ENABLED BY DEFAULT IN MYSQL 8.0.3.
+
+ - Fix for BUG#26722018, TESTS FAILING DUE TO CHANGE IN INFORMATION_SCHEMA.INNODB_SYS_* NAMING.
+
+ - Fix for BUG#26750807, MASTER : NULL POINTER EXCEPTION IN SCHEMA.DROPVIEW(NULL).
+
+ - Fix for BUG#26750705, MASTER : ERROR - UNSUPPORTED CONVERSION FROM TIME TO JAVA.SQL.DATE.
+
+ - WL#10620, DevAPI: SHA256 Authentication support.
+
+ - WL#10936, DevAPI: Row locking for Crud.Find.
+
+ - WL#9868, DevAPI: Configuration handling interface.
+
+ - WL#10935, DevAPI: Array or Object "contains" operator.
+
+ - WL#9875, Prepare c/J 8.0 for DEB and RPM builds.
+
+ - Fix for BUG#26259384, CALLABLE STATEMENT GIVES ERROR IN C/JAVA WHEN RUN AGAINST MYSQL 8.0.
+
+ - Fix for Bug#26393132, NULLPOINTEREXCEPTION IS THROWN WHEN TRIED TO DROP A NULL COLLECTION.
+
+ - WL#10532, DevAPI: Cleanup Drop APIs.
+
+ - Fix for Bug#87429 (26633984), repeated close of ServerPreparedStatement causes memory leak.
+ Thanks to Eduard Gurskiy for his contribution.
+
+ - Fix for Bug#87379 (26646676), Perform actual TLS capabilities check when restricting TLSv1.2.
+ Thanks to Todd Farmer for his contribution.
+
+ - Fix for Bug#85601 (25777822), Unit notation is missing in the description of the property involved in the time.
+
+ - Fix for Bug#87153 (26501245), INCORRECT RESULT OF DBMD.GETVERSIONCOLUMNS() AGAINST MYSQL 8.0.2+.
+
+ - Fix for Bug#78313 (21931572), proxies not handling Object.equals(Object) calls correctly.
+
+ - Fix for Bug#85885 (25874048), resultSetConcurrency and resultSetType are swapped in call to prepareStatement.
+
+ - Fix for Bug#74932 (20066806), ConnectionImp Doesn't Close Server Prepared Statement (PreparedStatement Leak).
+
+ - WL#10536, Deprecating COM_SHUTDOWN.
+
+ - Fix for Bug#25946965, UPDATE THE TIME ZONE MAPPINGS WITH LATEST TZ DATABASES.
+
+ - Fix for Bug#20182108, INCLUDE CUSTOM LOAD BALANCING STRATEGY USING PLUGIN API.
+ New load-balancing strategy "serverAffinity" and new connection property "serverAffinityOrder" added.
+
+ - Fix for Bug#26440544, CONNECTOR/J SHOULD NOT USE TX_{READ_ONLY,ISOLATION} WHICH IS PLANNED FOR REMOVAL.
+
+ - Fix for Bug#26399958, UNABLE TO CONNECT TO MYSQL 8.0.3.
+
+ - Fix for Bug#25650305, GETDATE(),GETTIME() AND GETTIMESTAMP() CALL WITH NULL CALENDAR RETURNS NPE.
+
+Version 8.0.7
+
+ - Fix for Bug#26227653, WL#10528 DIFF BEHAVIOUR WHEN SYSTEM PROP JAVAX.NET.SSL.TRUSTSTORETYPE IS SET.
+
+ - WL#10528, DevAPI: Ensure all connectors are secure by default.
+
+ - WL#8305, Remove internal dependency on connection objects.
+
+ - Fix for Bug#22972057, X DEVAPI: CLIENT HANGS AFTER CONNECTION FAILURE.
+
+ - Fix for Bug#26140577, GIS TESTS ARE FAILING WITH MYSQL 8.0.1.
+
+ - WL#10765, DevAPI: Forbid modify() and remove() with no condition.
+
+ - Fix for Bug#26090721, CONNECTION FAILING WHEN SERVER STARTED WITH COLLATION UTF8MB4_DE_PB_0900_AI_CI.
+
+ - WL#10781, enum-based connection properties.
+
+ - Fix for Bug#73775 (19531384), DBMD.getProcedureColumns()/.getFunctionColumns() fail to filter by columnPattern.
+
+ - Fix for Bug#84324 (25321524), CallableStatement.extractProcedureName() not work when catalog name with dash.
+
+ - Fix for Bug#79561 (22333996), NullPointerException when calling a fully qualified stored procedure.
+
+ - Fix for Bug#84783 (25490163), query timeout is not working(thread hang).
+
+ - Fix for Bug#70704 (17653733), Deadlock using UpdatableResultSet.
+
+ - Fix for Bug#66430 (16714868), setCatalog on connection leaves ServerPreparedStatement cache for old catalog.
+
+ - Fix for Bug#70808 (17757070), Set sessionVariables in a single query.
+
+ - Fix for Bug#77192 (21170603), Description for the Property replicationConnetionGroup Missing from the Manual.
+
+ - Fix for Bug#83834 (25101890), Typo in Connector/J error message.
+
+ - WL#10531, Support utf8mb4 as default charset.
+
+ - Fix for Bug#85555 (25757019), useConfigs Can't find configuration template named, in mysql-connector-java 6.x
+
+ - WL#10529, Move version number to 8.0.
+
+ - WL#10530, DevAPI: Remove XSession, rename NodeSession to Session.
+
+ - Fix for Bug#23510958, CONCURRENT ASYNC OPERATIONS RESULT IN HANG.
+
+ - Fix for Bug#23597281, GETNODESESSION() CALL WITH SSL PARAMETERS RETURNS CJCOMMUNICATIONSEXCEPTION.
+
+ - Fix for Bug#25207784, C/J DOESN'T FOLLOW THE FINAL X DEVAPI MY-193 SPECIFICATION.
+
+ - Fix for Bug#25494338, ENABLEDSSLCIPHERSUITES PARAMETER NOT WORKING AS EXPECTED WITH X-PLUGIN.
+
+ - Fix for Bug#84084 (25215008), JAVA.LANG.ARRAYINDEXOUTOFBOUNDSEXCEPTION ON ATTEMPT TO GET VALUE FROM RESULTSET.
+
+ - WL#10553, Add mapping for Japanese utf8mb4 collation.
+
+ - Fix for Bug#25575103, NPE FROM CREATETABLE() WHEN SOME OF THE INPUTS ARE NULL.
+
+ - Fix for Bug#25575156, NPE FROM CREATEVIEW() WHEN SOME OF THE INPUTS ARE NULL.
+
+ - Fix for Bug#25636947, CONNECTION USING MYSQL CLIENT FAILS IF WE USE THE SSL CERTIFICATES FROM C/J SRC.
+
+ - Fix for Bug#25687718, INCORRECT TIME ZONE IDENTIFIER IN STATEMENTREGRESSIONTEST.
+
+ - Fix for Bug#25556597, RESULTSETTEST.TESTPADDING UNIT TEST IS FAILING IN 5.1.41 RELEASE PACKAGE.
+
+ - Fix for Bug#25517837, CONNECT PERFORMNACE DEGRADED BY 10% IN 5.1.41.
+
+ - Fix for Bug#25504578, CONNECT FAILS WHEN CONNECTIONCOLLATION=ISO-8859-13.
+
+ - Fix for Bug#25438355, Improper automatic deserialization of binary data.
+
+ - Fix for Bug#70785 (17756825), MySQL Connector/J inconsistent init state for autocommit.
+ Property 'elideSetAutoCommits' is temporarily disabled due to Bug#66884. Defaults to 'false' until this bug is fixed.
+
+ - Fix for Bug#75615 (21181249), Incorrect implementation of Connection.setNetworkTimeout().
+
+ - Fix for Bug#81706 (23535001), NullPointerException in driver.
+
+ - Fix for Bug#83052 (25048543), static method in com.mysql.jdbc.Util relies on null object.
+
+ - Fix for Bug#69526 (17035755), 'Abandoned connection cleanup thread' at mysql-connector-java-5.1.25.
+
+ - Fix for Bug#82826 (24942672), Unneeded version requirement for javax.net.ssl Import-Package on OSGi MANIFEST.MF.
+
+Version 6.0.6
+
+ - Added Core TLS/SSL options for the mysqlx URI scheme.
+
+ - Updated collations map.
+
+ - Fix for Bug#24350526, UNEXPECTED BEHAVIOUR OF IS_NUMBER_SIGNED API IN C/JAVA.
+
+ - Fix for Bug#82707 (24512766), WRONG MILLI SECOND VALUE RETURNED FROM TIMESTAMP COLUMN.
+
+ - Fix for Bug#82005 (23702040), JDBCDATEVALUEFACTORY FAILS TO PARSE SOME DATES.
+
+ - Fix for Bug#83725 (25056803), NPE IN XPROTOCOL.GETPLUGINVERSION() WITH MYSQL 5.7.17.
+
+ - Fix for Bug#24525461, UPDATABLE RESULTSET FEATURE FAILS WHEN USESERVERPREPSTMTS=TRUE.
+
+ - Fix for Bug#24527173, QUERY EXECUTION USING PREPARED STMT FAILS WHEN USECURSORFETCH=TRUE.
+
+ - Fix for Bug#82964 (24658016), JSR-310 DATA TYPES CREATED THROUGH JAVA.SQL TYPES.
+
+ - Fix for Bug#81202 (23188159), RESULTSETIMPL.GETOBJECT THROWS NULLPOINTEREXCEPTION WHEN FIELD IS NULL.
+
+ - Fix for Bug#22931277, COLUMN.GETTYPE() RETURNS ERROR FOR VALID DATATYPES.
+
+ - Fix for BUG#24471057, UPDATE FAILS WHEN THE NEW VALUE IS OF TYPE DBDOC WHICH HAS ARRAY IN IT.
+
+ - Fix for Bug#81691 (23519211), GETLASTDOCUMENTIDS() DOESN'T REPORT IDS PROVIDED BY USER.
+
+ - Fix for Bug#82826 (24942672), Unneeded version requirement for javax.net.ssl Import-Package on OSGi MANIFEST.MF.
+
+10-21-16 - Version 6.0.5
+
+ - Fix for BUG#82896 (24613062), Unexpected behavior on attempt to connect to JDBC driver with unsupported URL.
+
+ - Added client-side failover during XSession initialization for multi-router configuration.
+
+ - Removed Extension interface. All extension classes now implement their specific interfaces.
+
+ - Fix for Bug#22988922, GETLENGTH() RETURNS -1 FOR LONGBLOB AND LONGTEXT FIELDS.
+
+ - Fix for Bug#24619829, NEW FAILURES IN C/JAVA UNITTESTS AGAINST MYSQL 8.0.
+
+ - Fix for Bug#75209 (20212882), Set useLocalTransactionState may result in partially committed transaction.
+
+ - Fix for Bug#48346 (11756431), Communications link failure when reading compressed data with compressed=true.
+ Thanks to Ryosuke Yamazaki for his contribution.
+
+ - Fix for Bug#80631 (22891845), ResultSet.getString return garbled result with json type data.
+ Thanks to Dong SongLing for his contribution.
+
+ - Fix for Bug#64188 (13702433), MysqlXAConnection.MYSQL_ERROR_CODES_TO_XA_ERROR_CODES is missing XA error codes.
+
+ - Fix for Bug#72632 (18759269), NullPointerException for invalid JDBC URL.
+
+ - Fix for Bug#82115 (23743956), Some exceptions are intercepted twice or fail to set the init cause.
+
+ - Fix for Bug#78685 (21938551), Wrong results when retrieving the value of a BIT column as an integer.
+
+ - Fix for Bug#80615 (22954007), prepared statement leak when rewriteBatchedStatements=true and useServerPrepStmt.
+
+ - Extended X DevAPI with flexible parameter lists.
+
+ - Added a virtual NodeSession to X DevAPI.
+
+09-05-16 - Version 6.0.4
+
+ - X DevAPI URL prefix changed from "mysql:x:" to "mysqlx:".
+
+ - Fix for Bug#24301468 X DEVAPI SSL CONNECTION FAILS ON WINDOWS
+
+ - The X DevAPI Table object now represents both database tables and views.
+
+ - Added support for matching against pattern for X DevAPI list_objects calls.
+ Added Schema.getCollections(String pattern) and Schema.getTables(String pattern) interface methods.
+
+ - Switched to "mysqlx" namespace for X DevAPI StmtExecute messages. This change is incompatible to MySQL server versions < 5.7.14.
+
+ - Fix for Bug#82046 (23743947), MYSQL CONNECTOR JAVA OSGI METADATA BROKEN.
+
+ - Fix for Bug#21690043, CONNECT FAILS WHEN PASSWORD IS BLANK.
+
+ - Fix for Bug#22931433, GETTING VALUE OF BIT COLUMN RESULTS IN EXCEPTION.
+
+06-17-16 - Version 6.0.3
+
+ - Fix for Bug#23535571, EXCESSIVE MEMORY USAGE WHEN ENABLEPACKETDEBUG=TRUE.
+
+ - Fix for Bug#23212347, ALL API CALLS ON RESULTSET METADATA RESULTS IN NPE WHEN USESERVERPREPSTMTS=TRUE.
+
+ - Fix for Bug#23201930, CLIENT HANG WHEN RSLT CUNCURRENCY=CONCUR_UPDATABLE AND RSLTSET TYPE=FORWARD_ONLY.
+
+ - Fix for Bug#23188498, CLIENT HANG WHILE USING SERVERPREPSTMT WHEN PROFILESQL=TRUE AND USEIS=TRUE.
+
+ - Fix for Bug#22678872, NPE DURING UPDATE WITH FABRIC.
+ New property 'loadBalanceHostRemovalGracePeriod' sets the grace period when removing hosts from a load-balanced connection.
+
+ - Fix for Bug#71131 (18068303), Poor error message in CallableStatement.java.
+
+ - Fix for Bug#59462 (16736619), ConcurrentModificationException inside ConnectionImpl.closeAllOpenStatements().
+
+ - Fix for Bug#22848249, LOADBALANCECONNECTIONGROUPMANAGER.REMOVEHOST() NOT WORKING AS EXPECTED.
+
+ - Fix for Bug#22730682, ARRAYINDEXOUTOFBOUNDSEXCEPTION FROM CONNECTIONGROUPMANAGER.REMOVEHOST().
+
+ - Fix for Bug#77171 (21181466), On every connect getting sql_mode from server creates unnecessary exception.
+
+ - Fix for Bug#79343 (22353759), NPE in TimeUtil.loadTimeZoneMappings causing server time zone value unrecognized.
+
+ - Fix for Bug#22038729, X DevAPI: Any API call after a failed CALL PROC() results in hang
+
+ - Remove Schema.drop(), Collection.drop() and replaced with X DevAPI's session.dropSchema() and session.dropCollection().
+ Also added session.dropTable().
+
+ - Fix for Bug#22932078, GETTIMESTAMP() RETURNS WRONG VALUE FOR FRACTIONAL PART
+
+ - Extracted packet readers from MysqlaProtocol.
+
+ - Fix for Bug#22972057, X protocol CLIENT HANGS AFTER CONNECTION FAILURE
+
+ - Fix for Bug#23044312, NullPointerException in X protocol AsyncMessageReader due to race condition
+
+ - Returned support for MySQL 5.5 and 5.6.
+
+04-05-16 - Version 6.0.2
+
+ - Deprecate the EOF packet.
+
+ - Fix for Bug#75956, Inserting timestamps using a server PreparedStatement and useLegacyDatetimeCode=false
+
+ - Fix for Bug#22385172, CONNECTOR/J MANIFEST DOES NOT EXPOSE FABRIC (OSGi).
+
+ - Fix for Bug#22598938, FABRICMYSQLDATASOURCE.GETCONNECTION() NPE AFTER SWITCHOVER.
+
+ - Merged version 5.1.38.
+
+ - Fix for Bug#21286268, CONNECTOR/J REPLICATION USE MASTER IF SLAVE IS UNAVAILABLE.
+
+ - Fix for Bug#21296840 & Bug#17910835, Server information in a group from Fabric is not refreshed after expired TTL.
+
+ - Fix for Bug#56122 (11763419), JDBC4 functionality failure when using replication connections.
+
+ - Added support for TLSv1.1 and TLSv1.2
+
+ - Fix for Bug#78961 (22096981), Can't call MySQL procedure with InOut parameters in Fabric environment.
+
+ - Fix for Bug#56100 (11763401), Replication driver routes DML statements to read-only slaves.
+
+ - StandardSSLSocketFactory implements SocketMetadata.
+
+ - Fix for Bug#21978216, GETTYPEINFO REPORT MAXIMUM PRECISION OF 255 FOR VARBINARY.
+
+ - Fix for Bug#78706 (21947042), Prefer TLS where supported by MySQL Server.
+
+ - Fix for Bug#21934573, FABRIC CODE INVOLVED IN THREAD DEADLOCK.
+ Duplicate: Bug#78710 (21966391), Deadlock on ReplicationConnection and ReplicationConnectionGroup when failover.
+
+ - Merged version 5.1.37.
+
+ - Fix for Bug#21876798, CONNECTOR/J WITH MYSQL FABRIC AND SPRING PRODUCES PROXY ERROR.
+
+10-19-15 - Version 6.0.1
+
+ - Removed useJvmCharsetConverters connection property. JVM charset converters are now used in all cases.
+
+ - Refactored value decoding and removed all date/time connection properties
+
+ - Refactored connection properties
+
+ - Assume existence of INFORMATION_SCHEMA.PARAMETERS (and thus MySQL 5.5) when preparing stored procedure calls.
+
+ - Removed retainStatementAfterResultSetClose connection property.
+
+ - Null-merge of Bug#54095 (11761585) fix.
+
+ - Removed support code for MySQL server versions < 5.7.
+
+ - Merged version 5.1.37.
+
+ - Fix for Bug#76859 (20969312), DBMD getColumns using I_S doesn't have column IS_GENERATEDCOLUMN as per JDBC 4.1.
+ Added support for GENERATED COLUMNS.
+
+ - Update Time Zone mappings with IANA Time Zone database tsdata2015f and Unicode CLDR v.28.
+
+ - Update DatabaseMetaData SQL keywords.
+
+ - Added tests for Optimizer hints syntax introduced in MySQL 5.7.7.
+
+ - Fix for Bug#21860833, JSON DATA TYPE DOESN'T WORK WITH SSPS.
+ Added support for JSON data type.
+
+ - Added support for JDBC 4.2 new features.
+ New property 'enableEscapeProcessing' sets the default escape processing behavior for Statement objects.
+
+ - Fix for Bug#16634180, LOCK WAIT TIMEOUT EXCEEDED CAUSES SQLEXCEPTION, SHOULD CAUSE SQLTRANSIENTEXCEPTION
+
+ - Fix for Bug#75849 (20536592), NPE in abortInternal() method on line 1358 of ConnectionImpl.
+
+ - Fix for Bug#78106 (21648826), Potential memory leak with inflater.
+
+ - Fix for Bug#78225 (21697684), DEFAULT NO_AUTO_CREATE_USER SQL_MODE BEHAVIOR BROKE SOME TESTS
+
+ - Fix for Bug#77665 (21415165), JDBC fails to connect with MySQL 5.0.
+
+ - Fix for Bug#77681 (21429909), rewrite replace sql like insert when rewriteBatchedStatements=true (contribution).
+ Thanks to Jie Han for his contribution.
+
+ - Fix for Bug#77449 (21304726) Add 'truncateFractionalSeconds=true|false' property (contribution).
+ The property 'sendFractionalSeconds' was added instead of the proposed 'truncateFractionalSeconds'.
+ Thanks to KwonNam for his contribution.
+
+ - Fix for Bug#50348 (11758179), mysql connector/j 5.1.10 render the wrong value for dateTime column in GMT DB.
+
+ - Fix for Bug#75670 (20433047), Connection fails with "Public Key Retrieval is not allowed" for native auth.
+
+ - Fix for Bug#76187 (20675539), getTypeInfo report maximum precision of 255 for varchar.
+
+ - Merged version 5.1.36.
+
+ - Add test for new syntax 'ALTER TABLE ... DISCARD|IMPORT PARTITION ...' introduced in MySQL 5.7.4.
+
+ - Fix for Bug#20727196, GETPROCEDURECOLUMNS() RETURNS EXCEPTION FOR FUNCTION WHICH RETURNS ENUM/SET TYPE.
+
+ - Fix for Bug#19803348, GETPROCEDURES() RETURNS INCORRECT OUTPUT WHEN USEINFORMATIONSCHEMA=FALSE.
+
+ - Fix for Bug#21215151, DATABASEMETADATA.GETCATALOGS() FAILS TO SORT RESULTS.
+
+ - Fix for Bug#72630 (18758686), NullPointerException during handshake in some situations
+
+ - Fix for Bug#20825727, CONNECT FAILURE WHEN TRY TO CONNECT SHA USER WITH DIFFERENT CHARSET.
+
+ - Flag RowDataDynamic.isInterrupted removed as it isn't needed.
+
+ - Fix for Bug#20518653, XSL FILES IN PACKAGES
+
+ - Fix for Bug#20804635, GETTIME() AND GETDATE() FUNCTIONS FAILS WHEN FRACTIONAL PART EXISTS
+
+ - Fix for Bug#62452 (16444069), NPE thrown in JDBC4MySQLPooledException when statement is closed.
+
+ - Fix for BUG#70927 (17810800), Connector/J COM_CHANGE_USER handling is broken
+
+ - Fix for Bug#75335 (20283655), Maven artifact for Connector/J is missing source jar.
+
+ - Fix for BUG#75592 (20408891), "SHOW VARIABLES WHERE" is expensive.
+
+ - Fix for Bug#75113 (20821888), Fail in failover of the connection in MySQL fabric
+
+ - Fix for Bug#72077 (18425861), Fabric connection with username to a server with disabled auth throws NPE
+
+ - Add test for already fixed Bug#72546 (18719760), C/J Fabric createGroup() throws ClassCastException
+
+ - Fix for Bug#77217 (21184949), ClassCastException when executing a streaming PreparedStatement with Fabric
+
+ - Merged version 5.1.35.
+
+ - Fix for Bug#19536760, GETSTRING() CALL AFTER RS.RELATIVE() RETURNS NULLPOINTEREXCEPTION
+
+ - Fix for BUG#20453712, CLOB.SETSTRING() WITH VALID INPUT RETURNS EXCEPTION
+
+ - Fix for BUG#20453671, CLOB.POSITION() API CALL WITH CLOB INPUT RETURNS EXCEPTION
+
+ - Fix for Bug#20685022, SSL CONNECTION TO MYSQL 5.7.6 COMMUNITY SERVER FAILS.
+
+ - Fix for Bug#20606107, TEST FAILURES WHEN RUNNING AGAINST 5.7.6 SERVER VERSION
+
+ - Fix for Bug#20533907, BUG#20204783 FIX EXPOSES WRONG BEAHAVIORS IN FAILOVER CONNECTIONS.
+ This fix is a refactoring of the default failover feature which is no longer attached to load-balancing support.
+
+ - Fix for Bug#20504139, GETFUNCTIONCOLUMNS() AND GETPROCEDURECOLUMNS() RETURNS ERROR FOR VALID INPUTS.
+
+ - Expose PreparedStatment.ParseInfo for external usage, with no capture of the connection, which allows for global, highly-concurrent parse caches to be
+ implemented.
+
+ - Fix for Bug#75309 (20272931), mysql connector/J driver in streaming mode will in the blocking state.
+
+ - New property 'readOnlyPropagatesToServer' controls the implicit propagation of read only transaction access mode to server.
+
+ - Fix for Bug#54095 (11761585), Unnecessary call in newSetTimestampInternal.
+ Test case only. The bug was fixed as a consequence of the patch for Bug#71084.
+
+ - Fix for Bug#67760 (15936413), Deadlock when concurrently executing prepared statements with Timestamp objects.
+
+ - Fix for Bug#71084 (18028319), Wrong java.sql.Date stored if client and server time zones differ.
+ Two connection properties added, "noTimezoneConversionForDateType" and "cacheDefaultTimezone", to define if and how time zone conversions are available to
+ DATE data type values.
+
+ - Fix for Bug#75080 (20217686), NullPointerException during setTimestamp on Fabric connection.
+
+ - Fix for Bug#75168 (20204783), loadBalanceExceptionChecker interface cannot work using JDBC4/JDK7.
+
+ - Fix for Bug#73595 (19465516), Replace usage of StringBuffer in JDBC driver.
+
+ - Fix for Bug#18925727, SQL INJECTION IN MYSQL JDBC DRIVER.
+
+ - Fix for Bug#74998 (20112694), readRemainingMultiPackets not computed correctly for rows larger than 16 MB.
+
+ - Merged version 5.1.34.
+
+ - Fix for Bug#73012 (19219158), Precedence between timezone options is unclear.
+
+ - Implement support for connecting through SOCKS proxies (WL#8105). Connection properties supporting this are socksProxyHost, socksProxyPort.
+
+ - Ant buildfile reworked to fix incompatibilities with latest Eclipse, to remove dependency from ant-contrib and to improve structure and documentation.
+
+ - Fix for Bug#18474141, TESTSUITE.FABRIC TEST CASES FAIL IF NO FABRIC.TESTSUITE PROPERTIES PROVIDED
+
+ - Fix for Bug#19383371, CONNECT USING MYSQL_OLD_PASSWORD USER FAILS WHEN PWD IS BLANK
+
+ - Merged version 5.1.33.
+
+ - Fix for Bug#17441747, C/J DOESN'T SUPPORT XA RECOVER OUTPUT FORMAT CHANGED IN MYSQL 5.7.
+ Test case was disabled for affected server versions 5.7.0 - 5.7.4.
+
+ - Fix for Bug#19145408, Error messages may not be interpreted according to the proper character set
+
+ - Fix for Bug#19505524, UNIT TEST SUITE DOES NOT CONSIDER ALL THE PARAMETERS PASSED TO BUILD.XML.
+
+ - Fix for Bug#73474 (19365473), Invalid empty line in MANIFEST.MF
+
+ - Fix for Bug#70436 (17527948), Incorrect mapping of windows timezone to Olson timezone.
+ TimeZone mappings were revised in order to use latest data from IANA Time Zone Database and Unicode CLDR.
+
+ - Fix for Bug73163 (19171665), IndexOutOfBoundsException thrown preparing statement.
+ Regression test added. Fix was included in patch from 5.1.32: "Fix for failing tests when running test suite with Java 6+".
+
+ - Added support for gb18030 character set
+
+ - Fix for Bug#73663 (19479242), utf8mb4 does not work for connector/j >=5.1.13
+
+ - Fix for Bug#73594 (19450418), ClassCastException in MysqlXADataSource if pinGlobalTxToPhysicalConnection=true
+
+ - Fix for Bug#19354014, changeUser() call results in "packets out of order" error when useCompression=true.
+
+ - Fix for Bug#73577 (19443777), CHANGEUSER() CALL WITH USECOMPRESSION=TRUE COULD LEAD TO IO FREEZE
+
+ - Fix for Bug#19172037, TEST FAILURES WHEN RUNNING AGAINST 5.6.20 SERVER VERSION
+
+ - Merged version 5.1.32
+
+ - Fix for Bug#71923 (18344403), Incorrect generated keys if ON DUPLICATE KEY UPDATE not exact.
+ Additionally several methods in StringUtils were fixed/upgraded.
+
+ - Fix for Bug#72502 (18691866), NullPointerException in isInterfaceJdbc() when using DynaTrace
+
+ - Fix for Bug#72890 (18970520), Java jdbc driver returns incorrect return code when it's part of XA transaction.
+
+ - Fabric client now supports Fabric 1.5. Older versions are no longer supported.
+
+ - Fix for Bug#71672 (18232840), Every SQL statement is checked if it contains "ON DUPLICATE KEY UPDATE" or not.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#73070 (19034681), Preparing a stored procedure call with Fabric results in an exception
+
+ - Fix for Bug#73053 (19022745), Endless loop in MysqlIO.clearInputStream due to Linux kernel bug.
+ In the source of this issue is a Linux kernel bug described in the patch "tcp: fix FIONREAD/SIOCINQ"
+ (https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=a3374c4).
+
+ - Fix for Bug#18869381, CHANGEUSER() FOR SHA USER RESULTS IN NULLPOINTEREXCEPTION
+
+ - Fix for Bug#62577 (16722757), XA connection fails with ClassCastException
+
+ - Fix for Bug#18852587, CONNECT WITH A USER CREATED USING SHA256_PASSWORD PLUGIN FAILS WHEN PWD IS BLANK
+
+ - Fix for Bug#18852682, TEST TESTSHA256PASSWORDPLUGIN FAILS WHEN EXECUTE AGAINST COMMERCIAL SERVER
+
+ - Fix for failing tests when running test suite with Java 6+.
+ Includes fix for Bug#35829 (11748301), build.xml check for java6 should use or instead of and.
+
+ - Charset mappings refactored.
+
+ - Fix for Bug#72712 (18836319), No way to configure Connector JDBC to not do extra queries on connection
+
+06-09-14 - Version 5.1.31
+
+ - Fix for Bug#66947 (16004987), Calling ServerPreparedStatement.close() twice corrupts cached statements.
+
+ - Fix for Bug#61213 (18009254), ON DUPLICATE KEY UPDATE breaks generated key list when extended INSERT is used
+
+ - Test cases updated to comply with MySQL 5.7.4 new STRICT_MODE behavior and no longer supported IGNORE clause in
+ ALTER TABLE statement.
+
+ - Added support for sha256_password authentication with RSA encryption.
+
+ - Fix for Bug#71753 (18260918), Bad SSL socket transform.
+
+ - Added tests for changes in GET DIAGNOSTIC syntax introduced in MySQL 5.7.0.
+
+ - Fix for Bug#67803 (16708231), XA commands sent twice to MySQL server.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#55680 (16737192), MySQL Connector/J memory leak
+
+ - Fix for Bug#72326 (18598665), Typo in fullDebug.properties - gatherPerMetrics should be gatherPerfMetrics
+
+ - Fix for Bug#72023 (18403456), Avoid byte array creation in MysqlIO#unpackBinaryResultSetRow.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#72000 (18402873), java.lang.ArrayIndexOutOfBoundsException on java.sql.ResultSet.getInt(String).
+
+ - Fix for Bug#71850 (18318197), init() is called twice on exception interceptors
+
+ - Fix for Bug#72008 (18389973), Avoid useless object creation in StringUtils#getBytes-methods.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#72006 (18403199), Avoid creation of a character array in PreparedStatement$ParseInfo.
+ Thanks to Andrej Golovnin for his contribution.
+ Additionally, unneeded StringBuffer replaced by StringBuilder instances in StringUtils.
+
+ - Fix for Bug#72301 (18549472), Fabric driver swallows exceptions thrown during connection creation using JDBC4
+
+03-28-14 - Version 5.1.30
+
+ - Fix for Bug#71679 (18236388), Avoid iterator creation when invoking statement interceptors in MysqlIO.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#70944 (17831255), community and commercial builds should have the same line number tables
+
+ - Fix for Bug#71861 (18327245), Avoid manual array copy in MysqlIO and LoadBalancingConnectionProxy.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#71623 (18228668), Field#getStringFromBytes() creates useless byte array when using JVM converter.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#71621 (18228302), MysqlXAConnection#xidToString(Xid xid) produces too much garbage.
+ Thanks to Andrej Golovnin for his contribution.
+
+ - Fix for Bug#67318 (16722637), SQLException thrown on already closed ResultSet. Thanks to Thomas Manville and Andrej Golovnin for their contribution.
+
+ - Fix for Bug#71396 (18110320), setMaxRows (SQL_SELECT_LIMIT) from one query used in later queries (sometimes).
+ Additionally, SQL_SELECT_LIMIT is no longer sent unnecessarily between consecutive queries.
+
+ - Fix for Bug#71432 (18107621), Key store files not closed when making SSL connection
+
+ - Reserved words lists updated from latest official SQL:92 and SQL:2003 specifications.
+
+ - Fix for Bug#18091639, STRINGINDEXOUTOFBOUNDSEXCEPTION IN PREPAREDSTATEMENT.SETTIMESTAMP WITH 5.6.15
+
+ - Added Fabric support
+
+02-10-14 - Version 5.1.29
+
+ - Fix for Bug#70701 (17647584), DatabaseMetaData.getSQLKeywords() doesn't match MySQL 5.6 reserved words.
+
+ - Fix for Bug#17435879, REMOVE SRC/LIB-NODIST DIRECTORY FROM LAUNCHPAD DISTRIBUTION.
+ Additional "com.mysql.jdbc.extra.libs" parameter must be used for ant build.
+
+ - Fix for Bug#71038, Add an option for custom collations detection.
+ Added new connection property detectCustomCollations=[true|false], with default false.
+ Please be aware that these changed the previous default behavior and if you use custom charsets or collations
+ you need to set detectCustomCollations=true.
+
+ - Added tests for new index renaming syntax introduced in 5.7.1.
+
+12-23-13 - Version 5.1.28
+
+ - Fix for Bug#69579, DriverManager.setLoginTimeout not honored.
+
+ - Fix for Bug#51313, Escape processing is confused by multiple backslashes.
+
+ - Fix for Bug#55340, initializeResultsMetadataFromCache fails on second call to stored proc.
+
+ - Fix for Bug#70969, Shadow declaration of OperationNotSupportedException in RowDataDynamic.
+
+ - Fix for Bug#70835 (17750877), SQLExceptions thrown because of query interruption (KILL QUERY, query timeout, etc.)
+ didn't extend java.sql.SQLNonTransientException for JDBC4+ deployments.
+
+ - Fix for Bug#24344 test case, test fails if it's run with UTC timezone settings.
+
+ - Fix for Bug#69777, Setting maxAllowedPacket below 8203 makes blobSendChunkSize negative.
+
+ - Fix for Bug#35115, yearIsDateType=false has no effect on result's column type and class.
+
+ - Fix for Bug#68916 (16691047), closeOnCompletion doesn't work.
+
+ - Fix for Bug #69746 (17164058), ResultSet closed after Statement.close() when dontTrackOpenResources=true
+
+ - Fix for Bug#70842 (17753369), Adding live management of replication host topographies.
+
+11-04-13 - Version 5.1.27
+
+ - Fix for Bug#17248345, getFunctionColumns() method returns columns of procedure.
+
+ - Fix for Bug#69290 (16879239), JDBC Table type "SYSTEM TABLE" is used inconsistently.
+
+ - Fix for Bug#68562, Combination rewriteBatchedStatements and useAffectedRows not working as expected.
+
+ - Fix for Bug#69452 (17015673), memory size connection property doesn't support large values well.
+
+ - Added tests for InnoDB full-text search support introduced in 5.6GA.
+
+ - Extended slow query warning with query execution plan for INSERT, REPLACE, UPDATE and DELETE.
+
+ - Added tests for IPv6 functions introduced in 5.6GA.
+
+ - Added support of authentication data up to 2^64-1 bytes.
+
+ - Fix for Bug#38252, ResultSet.absolute(0) is not behaving according to JDBC specification.
+
+ - Fix for Bug#62469, JDBC Authentication Fails with Null Byte in Scramble
+
+ - Fix for Bug#69506, XAER_DUPID error code is not returned when a duplicate XID is offered in Java.
+
+ - Added support for multi-master replication topographies in ReplicationDriver. ReplicationDriver now uses two discrete load-balanced
+ connections, one each for master and slave connections. The same load-balancing options which apply to load-balanced connections
+ now also apply to ReplicationConnections. By default, this means that when a ReplicationConnection uses master connections
+ (because the read-only property of the Connection is false), work may be re-balanced between configured master hosts at transaction
+ boundaries. As with load-balanced connections, the ReplicationConnection host list may be managed within the JVM (see
+ com.mysql.jdbc.ReplicationConnectionGroupManager) or optionally via JMX (using replicationEnableJMX configuration option; see
+ com.mysql.jdbc.jmx.ReplicationGroupManagerMBean). To specify multi-master replication topographies, define each host "type"
+ property using the following format:
+
+ address=(host=hostname)(port=3306)(type=[master|slave])
+
+ In the absense of explicit type definitions, the driver will assume a single master listed first, with all subsequently-listed
+ hosts configured as slaves.
+
+ - Fix for Bug#63354 (16443992), JDBC cannot make new connections if master is down.
+
+ - Fix for Bug#17003626, REGRESSION TEST FAILURE WITH SERVER VERSION 5.7.1
+
+ - Removed ant-contrib.jar from C/J distribution.
+
+ - Added tests for GIS precise spatial operations introduced in 5.6GA.
+
+ - Fixed META-INF information
+
+ - Fix for Bug#17251955, ARRAYINDEXOUTOFBOUNDSEXCEPTION ON LONG MULTI-BYTE DB/USER NAMES
+
+ - Fix for Bug#50538, DatabaseMetaData.getDriverVersion() contains unexpanded ${bzr.revision-id}
+
+08-05-13 - Version 5.1.26
+
+ - Fix for Bug#69298 (16845965), Methods DatabaseMetaData.getProcedures() and DatabaseMetaData.getProcedureColumns(), in JDBC4,
+ return stored procedure only or both stored procedures and functions metadata information, depending on the value set in the
+ connection property "getProceduresReturnsFunctions", having default value 'true'. Several fixes in Functions and
+ Procedures metadata so that consulting I__S and MySQL/DDL returns the same info.
+
+ - Fix for Bug#69308 (16879267), Avoid calling batchedStatement.close() twice, and thus raising and ignoring an undercover SQLException, in methods
+ PreparedStatement.executeBatchedInserts and PreparedStatement.executePreparedBatchAsMultiStatement.
+
+ - Fix for Bug#68400, useCompression=true and connect to server, zip native method cause out of memory.
+ CompressedInputStream now does not keep reference to connection.
+ Thank Dominic Tootell for his investigation, proposed solution and all the help he provided.
+
+ - Fix for Bug#65871, DatabaseMetaData.getColumns() throws an MySQLSyntaxErrorException.
+ Delimited names of databases and tables are handled correctly now. The edge case is ANSI quoted
+ identifiers with leading and trailing "`" symbols, for example CREATE DATABASE "`dbname`". Methods
+ like DatabaseMetaData.getColumns() allow parameters passed both in unquoted and quoted form,
+ quoted form is not JDBC-compliant but used by third party tools. So when you pass the indentifier
+ "`dbname`" in unquoted form (`dbname`) driver handles it as quoted by "`" symbol. To handle such
+ identifiers correctly a new behavior was added to pedantic mode (connection property pedantic=true),
+ now if it set to true methods like DatabaseMetaData.getColumns() treat all parameters as unquoted.
+
+ - Fix for Bug#45757 (11754192), Don't allow updateRow() to be called when updatable cursor is positioned on insert row.
+
+ - Fix for Bug#68098 (16224299), Return indexes sorted by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION in DatabaseMetaData.getIndexInfo.
+
+ - Fix for Bug#68307 (16707803), Return correct COLUMN_TYPE from both getProcedureColumns() and getFunctionColumns().
+
+ - Fix for Bug#42267, PreparedStatementWrapper doesn't have a toString() implementation
+
+ - Fix for Bug#44451 (11753081), Added missing fields in methods getColumns(), getProcedureColumns(), getTables() and getUDTs().
+ Methods getClientInfoProperties() and getFunctions() were made available in all *DatabaseMetaDataUsingInfoSchema implementations.
+
+05-06-13 - Version 5.1.25
+
+ - Fix for Bug#68801, java webstart mysql-connector-java lib calls -bin library.
+
+ - Fix for Bug#16426462, SyntaxRegressionTest failing on C/J 5.1.24 against MySQL 5.6.10
+
+ - Fix for Bug#60816, Cannot pass NULL to an INOUT procedure parameter.
+
+ - Added support for Connection Attributes when used with MySQL Server versions (5.6+) which support this feature.
+ By default, the following standard attributes are sent to the server, where they can be seen in the
+ performance_schema.session_connect_attrs table:
+ * _client_version : the version of MySQL Connector Java in use
+ * _client_name : "MySQL Connector Java"
+ * _runtime_version : the version of the Java runtime environment in which the driver is running
+ * _runtime_vendor : the name of company which produced the Java runtime environment
+ Additionally, users may supply their own key/value attributes to be exposed by providing them in
+ "key1:value1,key2:value2" format in the connectionAttributes connection property.
+ To avoid sending any connection attributes to the server, set connectionAttributes property to "none".
+
+ - Fix for Bug#68763 (16545334), ReplicationConnection.isMasterConnection() returns false always.
+
+ - Fix for Bug#68733 (16526938), ReplicationConnection doesn't ping all slaves.
+
+ - Fix for Bug#68556, Tomcat can't stop a cleanup thread by clearReferencesStopThreads.
+
+ - Fix for Bug#16436511, getDriverName() returns a string with company name "MySQL-AB". Driver name changed to "MySQL Connector Java".
+
+ - Fix for Bug#68664 (16486957), Enable packaging of .JAR file from Eclipse.
+
+03-05-13 - Version 5.1.24
+
+ - Fix for Bug#64204, ResultSet.close hangs if streaming query is killed.
+
+ - Fix for Bug#16224249, Deadlock on concurrently used LoadBalancedMySQLConnection:
+ 1) abortInternal() method was moved from com.mysql.jdbc.MySQLConnection to com.mysql.jdbc.Connection interface;
+ 2) load-balanced/failover proxy now broadcasts abortInternal() to all underlying physical connections;
+ 3) load-balanced/failover proxy now prevents picking of new physical connection after close() or abortInternal() were called explicitly on proxy;
+ 4) connection synchronization mutex was refactored, now mutex is proxy instance for proxied connection or connection instance itself if there is no proxy.
+
+ - Fix for Bug#64805, StatementImpl$CancelTask occasionally throws NullPointerExceptions.
+
+ - Fixed typos in descriptions of properties.
+
+ - Fix for Bug#68011, Invalid error message noDatetimeSync property instead of noDatetimeStringSync.
+
+02-04-13 - Version 5.1.23
+
+ - Fix for Bug#35653, executeQuery() in Statement.java let "TRUNCATE" queries being executed. "TRUNCATE" and "RENAME" are now filtered for executeQuery().
+
+ - Fix for Bug#65909, referenceThread causes memory leak in Tomcat.
+ Abandoned connection cleanup thread was refactored to have static shutdown method.
+ If you encountered this leak problem, your application should implement context listener with
+ AbandonedConnectionCleanupThread.shutdown() call in contextDestroyed method.
+
+ For example:
+ @WebListener
+ public class YourThreadsListener implements ServletContextListener {
+ public void contextDestroyed(ServletContextEvent arg0) {
+ try {
+ AbandonedConnectionCleanupThread.shutdown();
+ } catch (InterruptedException e) {
+ }
+ }
+ ...
+ }
+
+ Note that if container does not support annotations you should add description to web.xml:
+
+ user.package.YourThreadsListener
+
+
+ - Added tests for explicit partition selection syntax introduced in 5.6GA.
+
+ - Added support of password expiration protocol. This introduces new boolean connection property disconnectOnExpiredPasswords.
+ If disconnectOnExpiredPasswords = true and password expired then connection will be rejected by server with ErrorCode == 1820 (ER_MUST_CHANGE_PASSWORD).
+ If disconnectOnExpiredPasswords = false then connection will enter to "sandbox" mode,
+ all commands except SET PASSWORD = ... and SET PASSWORD FOR CURRRENT_USER() = ... will cause an error to be thrown.
+
+ - Added tests for EXCHANGE PARTITION syntax introduced in 5.6GA.
+
+ - Added tests for transportable tablespaces syntax introduced in 5.6GA.
+
+ - Added tests for CREATE TABLE syntax changed in 5.6GA: CREATE TABLE ... DATA DIRECTORY = 'absolute/path/to/directory/'
+
+ - Added tests for ALTER TABLE syntax changed in 5.6GA: ALGORITHM and LOCK keywords.
+
+ - Fix for Bug#67954, stack trace used for point-of-origin in log and exception messages
+ causes permgen leak with webapp classloader on application redeploy. We no longer store the entire
+ stack trace, only the calling class and method, and even then, that only when using the usage advisor
+ or when profiling.
+
+ - Fix for Bug#11237, useCompression=true and LOAD DATA LOCAL INFILE SQL Command.
+
+ - Static charset/collation maps were updated.
+
+ - Fix for Bug#14260352, difference in Timestamp value returned with rewriteBatchedStatements=true.
+
+ - Fix for Bug#60598, nativeSQL() truncates fractional seconds.
+
+ - Fix for Bug#40279, Timestamp values get truncated when passed as prepared statement parameters.
+ This was partly fixed in 5.1.19 but that fix did not cover useLegacyDatetimeCode=true case.
+
+ - Fix for Bug#14665141, Diff results returned from ResultSet and CachedRowSet with new password hashing.
+ Test suite modified to don't perform comparison of PASSWORD() results if old_passwords=2
+ because with SHA-256 password hashing enabled they are nondeterministic.
+
+ - The driver now allows the mechanism for caching MySQL server configuration values replaceable at runtime,
+ via the "serverConfigCacheFactory" property. The default is an implementation that is a per-VM concurrent
+ map, keyed by URL. The driver will invalidate cache entries when SQLExceptions that indicate communications
+ errors are thrown (on the assumption that the server has been or is restarting), or if the server version
+ that is being connected to, differs from the one that was present when the cached values were populated.
+
+ To replace the default implementation, implement CacheAdapterFactory>, and
+ use the fully-qualified class name of this implementation for "serverConfigCacheFactory".
+
+ - Connection.setReadOnly() will take advantage of server-side support for read-only transactions
+ present in MySQL-5.6 and newer. Calling .isReadOnly() will incur a round-trip if useLocalSessionState
+ is not enabled.
+
+09-06-12 - Version 5.1.22
+ - Fix for Bug#57662, Incorrect Query Duration When useNanosForElapsedTime Enabled.
+
+ - Fix for Bug#65503, ResultSets created by PreparedStatement.getGeneratedKeys() are not close()d.
+
+ - Fix for Bug#63800, getVersionColumns() does not return timestamp fields; always empty.
+ Added support of ON UPDATE CURRENT_TIMESTAMP for TIMESTAMP and DATETIME fields.
+
+ - Fix for Bug#41752, Can't connect mysqld which character_set_server=ucs2.
+
+ - Fix for Bug#65508, getCharsetNameForIndex() should be faster.
+
+ - Fix for Bug#14563127, Load-balanced connection fails to select valid host, closes connection
+ on re-balance.
+
+07-05-12 - Version 5.1.21
+ - Added new built-in authentication plugin com.mysql.jdbc.authentication.Sha256PasswordPlugin
+ ("sha256_password").
+
+ - Fix for Bug#64731, StringUtils.getBytesWrapped throws StringIndexOutOfBoundsException.
+
+ - Added new built-in authentication plugin com.mysql.jdbc.authentication.MysqlClearPasswordPlugin
+ ("mysql_clear_password"). It allows C/J based clients to connect to MySQL accounts which use
+ PAM authentication for example. SSL connection required for this authentication method.
+ If SSL is not enabled then authentication which requires "mysql_clear_password" will lead to an error.
+
+ - Fix for Bug#13980303, Auth plugin's confidentiality requirements are not checked after Auth Switch Request.
+
+ - Fix for Bug#64205, Connected through Connector/J 5.1 to MySQL 5.5, the error message is garbled.
+
+ - Fix for Bug#37931, Null Pointer Exception Thrown When specifying invalid character_set_results enc.
+
+ - Fix for Bug#36662, TimeUtil.java: MEST mapping n/a.
+
+ - Fix a scalability/memory footprint issue where Object.finalize() was being used on
+ ConnectionImpl to clean up the low-level network connection to MySQL should a
+ connection be abandoned by the application before being cleanly close()d. We now
+ track connections in a phantom reference queue, and have a single thread per-vm
+ clean these up when the VM notices the connection is no longer referenced by
+ anything else.
+
+ - Added the ability to add new client-side prepared statement parse info caches by
+ implementing com.mysql.jdbc.CacheAdapterFactory and telling the driver to use it
+ when "cachePrepStmts=true" via the "parseInfoCacheFactory" configuration property.
+
+ - Implemented JDBC-4.1 methods from Java-7:
+
+ - Connection.setSchema(String) - no-op, until we support database==schema in the driver
+ - Connection.getSchema() - see above
+ - Connection.abort(Executor executor)
+ - Connection.setNetworkTimeout(Executor, int)
+ - Connection.getNetworkTimeout() throws SQLException;
+ - CallableStatement.getObject(int, Class)
+ - CallableStatement.getObject(String, Class)
+ - DBMD.getPseudoColumns() - returns an empty result set
+ - DBMD.generatedKeyAlwaysReturned() - always true for MySQL
+ - ResultSet.getObject(int, Class)
+ - ResultSet.getObject(String, Class)
+ - Statement.closeOnCompletion()
+ - Statement.isCloseOnCompletion()
+
+05-02-12 - Version 5.1.20
+ - Fix for Bug#64983, 5.1.19 not working with JBoss AS 4.2.3.GA.
+
+ - Fix for Bug#13960556, java.lang.StringIndexOutOfBoundsException in com.mysql.jdbc.PreparedStatement.formatNanos(int nanos).
+
+ - Fix for pluggable authentication tests to run on Windows.
+
+ - Fix for Bug#13897714, NPE in testsuite.regression.StatementRegressionTest.testBug1933() with 5.6.5_m8 server.
+
+ - Fix for Bug#55962, Savepoint identifier is occasionally considered as floating point numbers.
+
+ - Fix for Bug#13955027, SET OPTION syntax was removed starting from 5.6.5 server version.
+
+ - Fix for Bug#13958793, ClassCastException in ConnectionImpl.buildCollationMapping() with 4.1 server.
+
+ - Fix for Bug#36478, Client prepared statement bugged if word 'limit' included in the query.
+
+04-02-12 - Version 5.1.19
+ - Fix for Bug#64621, setMaxRows was not correctly processed during CS PS metadata
+ collection causing entire resultset to be fetched and possibly leading to OOM.
+
+ - Fix for Bug#63456, MetaData precision is different when using UTF8 or Latin1 tables.
+ The problem was in finding maxBytesPerChar through versioned mapping from Java charset to MySQL charset.
+ That map returns "utf8mb4" instead "utf8" for server versions starting with 5.5.2.
+ CharsetMapping, ConnectionImpl and Field have been reorganized to use static maps INDEX_TO_MYSQL_CHARSET,
+ STATIC_CHARSET_TO_NUM_BYTES_MAP instead. Also dynamic maps ConnectionImpl.indexToCustomMysqlCharset
+ and ConnectionImpl.mysqlCharsetToCustomMblen have been added for custom charsets.
+
+ - Added support for pluggable authentication via the com.mysql.jdbc.AuthenticationPlugin
+ interface (which extends standard "extension" interface). Examples are in
+ com/mysql/jdbc/authentication and in testsuite.regression.ConnectionRegressionTest.
+ This introduces three new properties:
+
+ authenticationPlugins defines comma-delimited list of classes that implement
+ com.mysql.jdbc.AuthenticationPlugin and which will be used for authentication
+ unless disabled by "disabledAuthenticationPlugins" property.
+
+ disabledAuthenticationPlugins defines comma-delimited list of classes implementing
+ com.mysql.jdbc.AuthenticationPlugin or mechanisms, i.e. "mysql_native_password".
+ The authentication plugins or mechanisms listed will not be used for authentication
+ which will fail if it requires one of them. It is an error to disable the default
+ authentication plugin (either the one named by "defaultAuthenticationPlugin" property
+ or the hard-coded one if "defaultAuthenticationPlugin" propery is not set).
+
+ defaultAuthenticationPlugin defines name of a class implementing
+ com.mysql.jdbc.AuthenticationPlugin which will be used as the default authentication
+ plugin. It is an error to use a class which is not listed in "authenticationPlugins"
+ nor it is one of the built-in plugins. It is an error to set as default a plugin
+ which was disabled with "disabledAuthenticationPlugins" property. It is an error
+ to set this value to null or the empty string (i.e. there must be at least a valid
+ default authentication plugin specified for the connection, meeting all constraints
+ listed above).
+
+ - Fix for Bug#63526. The problem happens in com.mysql.jdbc.EscapeProcessor#escapeSQL. The function recognizes the string in the create table statement as an escape sequence (line 136+138). The "if" construct beginning in line 182 tries to match a white-space collapsed version of the string to prefixes for valid jdbc-escapes (till line 300). Since no matching escape sequence is found and no "else" clause is defined, neither the token, nor replacement are added to the resulting escaped SQL string.
+
+ - Fix for Bug#61203, noAccessToProcedureBodies does not work anymore.
+
+ - Fix for Bug#63811, pointless Socket.bind() when using ephemeral ports and interfaces, which limits scalability on some platforms.
+
+ - Connection.changeUser() would not check for closed connections, leading to NPEs when this method was called on a closed connection.
+
+ - Fix for Bug#63284, memory leak with Failover proxied Statement/PreparedStatement with DBCP due to improper implementation of equals().
+
+ - Prepared statements would needlessly allocate a 4K buffer for converting
+ streams when no set*Stream() methods had been used.
+
+10-03-11 - Version 5.1.18
+
+ - Fix for Bug#12565726, not putting the space between VALUES() and ON DUPLICATE KEY UPDATE
+ causes C/J a) enter rewriting the query although it has ON UPDATE
+ and b) to generate the wrong query with multiple ON DUPLICATE KEY
+
+ - Fix for Bug#12784170, "process fork failure" errors while running test suite via ant on Windows.
+ Added new ant flag, com.mysql.jdbc.junit.fork, which controls whether JUnit will fork new processes
+ for testing ("on", default and legacy behavior) or not ("off", required for Windows).
+
+ - Reverting changes made to ConnectionImpl.java,
+ private boolean characterSetNamesMatches function.
+
+ - Added function MYSQL_INDEX_TO_MYSQL_CHARSET to retrieve server charset name
+ using index instead of parsing variables to CharsetMapping.java.
+
+ - Completed fix for Bug#61201/12649557, fixed tests failures.
+
+ - Fix for Bug#61201/12649557, Can't establish connection when url has
+ sessionVariables and characterEncoding. Fix covers only MySQL server 4.1+
+
+ - Fix for Bug#61501 - Calling Statement.cancel() on a statement that isn't
+ currently executing will cause some later-executed query on the same
+ connection to be cancelled unexpectedly. The driver now guards against this
+ condition, but it is an underlying server issue. The MySQL statement "KILL QUERY"
+ (which is what the driver uses to implement Statement.cancel()) is rather
+ non-deterministic, and thus the use of Statement.cancel() should be avoided
+ if possible.
+
+ - Fix for Bug#61866/12791594 - Calling Statement.getWarnings() after
+ Statement.clearWarnings() has been called, returns the "old" warnings.
+
+ - Fix for Bug#13036537 - LRUCache was really a least-recently-added cache.
+
+ - Fix for Bug#13036309, Correcting parameter name in maxPerformance.properties.
+
+
+07-04-11 - Version 5.1.17
+
+ - Fix for Bug#61332 - LIKE not optimized in server when run against I__S tables and no wildcards used.
+ Databases/tables with "_" and/or "%" in their names (escaped or not) will be handled by this code path,
+ although slower, since it's rare to find these characters in table names in SQL. If there's a "_" or "%"
+ in the string, LIKE will take care of that, otherwise we now use = . The only exception is
+ information_schema database which is handled separately. Patch covers both getTables() and getColumns().
+
+ - Fix for Bug#61150 - First call to stored procedure fails with "No Database Selected".
+ The workaround introduced in DatabaseMetaData.getCallStmtParameterTypes to fix
+ the bug in server where SHOW CREATE PROCEDURE was not respecting lower-case table names
+ is misbehaving when connection is not attached to database and on non-casesensitive OS.
+
+ - Fix for Bug#61105 - Avoid a concurrent bottleneck in Java's character set
+ encoding/decoding when converting bytes to/from Strings.
+
+04-21-11 - Version 5.1.16
+
+ - Partial fix for BUG#54135 - setQueryTimeout unsafe across VIP. Fix prevents c/J from
+ killing the right ConnectionID but on wrong server.
+
+ - Fix for BUG#57808 - wasNull not set for DATE field with value 0000-00-00
+ in getDate() although zeroDateTimeBehavior is convertToNull.
+
+ - Fix for Bug#54425 - Bypassing the server protocol bug where DB should be null-terminated
+ whether it exists or not. Affects COM_CHANGE_USER.
+
+ - Fix for Bug#60313 (11890729), bug in
+ com.mysql.jdbc.ResultSetRow.getTimestampFast().
+
+ - Fix for bug 11782297, DBMD.getTables (so thus getColumns too) fails with
+ table names containing dot (like "junk_[Sp:e,c/ C-h+a=.r]").
+
+ - Added the ability to determine if the connection is against a server on the
+ same host via the Connection.isServerLocal() method.
+
+ - Fix for bug 12325877, Setting "autoReconnect=true" and
+ "cacheServerConfiguration=true" would cause connections created after
+ an existing connection fails to have non-existent values for server
+ variables which lead to exceeding of max allowed packet exceptions when the
+ new connections were used.
+
+02-08-11 - Version 5.1.15
+
+ - Fix for Bug#38367, parameters metadata did not reflect the fact that NULL is allowed
+ parameter value. So DatabaseMetaData.getProcedureColumns will set isNullable member to
+ java.sql.DatabaseMetaData.procedureNullable now.
+
+ - Completed fix for Bug#27916.
+
+ - Fix for Bug#59224, adding 5.5 reserved words to DatabaseMetaData.getSQLKeywords().
+
+ - Fixed an issue where statement comments set via Connection.setStatementComment()
+ weren't represented in autoGenerateTestcaseScript=true output.
+
+ - Added ability to include the current java thread dump in the exception message
+ given for deadlock/wait lock timeout exceptions, enable with
+ "includeThreadDumpInDeadlockExceptions=true" in your JDBC url.
+
+ - Added ability to include current thread name as a statement comment visible
+ in MySQL's "SHOW PROCESSLIST" and Innodb deadlock diagnostics, enable with
+ "includeThreadNamesAsStatementComment=true".
+
+ - Added an SLF4J logging adapter. Enable by adding setting the connection
+ property "logger" to "Slf4JLogger" and placing the appropriate bridge
+ from SLF4J to the logging framework of choice in your CLASSPATH. As with
+ other Connector/J logging adapters, the log category name used by the
+ driver is "MySQL". See http://www.slf4j.org/manual.html for more details.
+
+12-06-10 - Version 5.1.14
+
+ - Fix for Bug#58728, NPE in com.mysql.jdbc.jdbc2.optional.StatementWrappe.getResultSet()
+ if rs is null. Regression test case added to Statement regression tests.
+
+ - Fix for Bug#58751, DatabaseMetadata.getIndexInfo() CARDINALITY now clamped
+ to Integer.MAX_VALUE.
+
+ - Fix for BUG#58590
+ - Testsuite.Simple.DateTest, MetadataTest, NumbersTest and StatementsTest cleaned and fixed.
+
+ - Testsuite.simple, ConenctionTest & DataSourceTest are up to date. Major rework on
+ ConnectionTest.testDeadlockDetection (Sveta) and testUseCompress.
+
+ - Testsuite.simple, CallableStatementTest & CharsetTests are up to date.
+
+ - Testsuite.regression SubqueriesRegressionTest and StringRegressionTest are up to date.
+
+ - Testsuite.regression MicroPerformanceRegressionTest, NumbersRegressionTest, PooledConnectionRegressionTest,
+ ResultSetRegressionTest are up to date.
+
+ - Testsuite.regression.MetaDataRegressionTest up to date.
+
+ - Typo in StatementRegressionTest.testLikeWithBackslashes fixed. StatementRegressionTest
+ is up to date.
+
+ - Fix for Bug#58232 - CallableStatement fails to fetch OUT parameter against 5.5 server
+
+ - Testsuite.regression.Connection, tests for BUG#45419 refined by Todd so not to cause failures.
+
+ - Testsuite.regression.CallableStatement, tests for BUG#26959 failing against 5.5+ server.
+
+ - Bringing testsuite.regression.CachedRowsetTest up to date.
+
+ - Bringing BLOBregression tests up to date.
+
+ - Fix for Bug#58042 - Statements test failure not handled.
+
+ - Fix for Bug#57850 - Refresh SELECT statement doesn't use correct data type.
+ Added Field.valueNeedsQuoting (private final boolean) and protected boolean getvalueNeedsQuoting().
+ UpdatableResultSet refresher and updater call upon this value now.
+
+ - Removing commented source in fix for Bug#57697
+ - Fix for Bug#57697 - Metadata getTables() was not checking for table_name already been quoted.
+ - Fix for Bug#57694 - 3byte UTF8 can not be used with 5.5.3+ server.
+ - Fix for Bug#57701 - StatementsTest.testBatchRewriteErrors() failing on new servers.
+
+ - Fix for Bug#54756 - Cannot retrieve data from ResultSet by column name from a Sphinx daemon.
+ We were relying only on "server version string" passed. Now, determining
+ server version is done via protocol flags too, where applicable.
+
+ - Fix for Bug#57022 - cannot execute a store procedure with output parameters,
+ database parameter was ignored in db.sp notation. The fix is to "sanitize"
+ db.sp call just like in patch for noAccessToProcedureBodies. BaseTestCase
+ extended with createDatabase and dropDatabase. Regression test added.
+
+ - Fix for Bug#57262 - "useOldUTF8Behavior" behavior was broken since 5.1.3,
+ now explicitly sets connection character set to latin1 ("SET NAMES latin1")
+ during connection post-handshake process.
+
+ - Patch for problem where "noAccessToProcedureBodies=true" was causing
+ "underprivileged" user not to have access to procedures created by him.
+
+ - Patch for Bug#56305, unhandled NPE in DatabaseMetaData.java when calling
+ wrong-cased function without access to mysql.proc. Although simple by
+ itself, some more enhancements were needed for everything to function
+ properly. So, along with catching potential NPE due to server bug, a
+ guard against calling JDBC functions with db_name.proc_name notation was
+ also added. Necessary changes added to StringUtils.java too.
+
+ - Added ability to load-balance while auto-commit is enabled. This
+ introduces two new properties:
+
+ loadBalanceAutoCommitStatementThreshold defines the number of matching
+ statements which will trigger the driver to (potentially) swap physical
+ server connections,
+
+ loadBalanceAutoCommitStatementRegex defines the regular expression
+ against which statements must match. The default values (0 and blank,
+ respectively) retain the previously-established behavior that
+ connections with auto-commit enabled are never balanced. Feature
+ request documented in Bug#55723.
+
+ - Minor fix in getProcedureColumns() DisplaySize for Bug#51712. Fix for
+ Bug#41269 is not complete without this. getColumnDisplaySize on a
+ ResultSet already consisting of metadata is now functional thanks to
+ Bogdan.
+
+ - Minor fix for Bug#55217, return 4 as a result of DataBaseMetadata.getJDBCMajorVersion() as per manual.
+
+ - Added support for hosts specified in the URL of the form:
+ address=(key=value), supported keys are:
+
+ (protocol=tcp or pipe (for named pipes on Windows)
+ (path=[] for named pipes)
+ (host=[]) for TCP connections
+ (port=[]) for TCP connections
+
+ An example would be:
+
+ jdbc:mysql://address=(protocol=tcp)(host=localhost)(port=3306)(user=test)/db
+
+ Any other parameters are treated as host-specific properties that follow
+ the conventions of the JDBC URL properties. This now allows per-host
+ overrides of any configuration property for multi-host connections
+ (failover, loadbalance, replication). We do recommend that the overrides
+ are limited to user, password, network timeouts and statement and
+ metadata cache sizes. Unexpected behavior may be observed with other
+ per-host overrides.
+
+ - Fix for Bug#56099 - Added support for JDBC4-specific functionality when
+ using load-balanced connections.
+
+ - Fix for Bug#56200 - Added diagnostic information to SQLException message
+ thrown when a closed load-balanced connection is reused. This
+ information will identify the conditions which caused the connection to
+ be closed.
+
+ - Fix for Bug#56429 - When using Connector/J configured for failover
+ (jdbc:mysql://host1,host2,... URLs), the non-primary servers re-balance
+ and spawned new idle connections when the transactions on the master were
+ committed or rolled-back, eventually exceeding max_connections. It was
+ also discovered that session state (autocommit, isolation level, catalog)
+ wasn't being copied from the primary connection to secondary
+ connections correctly because of the same changes that caused this bug,
+ and this was fixed as well.
+
+ - Fix for Bug#56706 - Ensure read-only state is synchronized when new
+ load-balanced connections are selected.
+
+ - Fixed Bug#56955 - Connection properties "trustCertificateKeyStoreType"
+ and "clientCertificateKeyStoreType" have invalid defaults, therefore
+ connections that specify "useSSL" will sometimes fail with exceptions
+ from JSSE unless "JKS" has been specified for both of these properties.
+ The default value for these properties is now "JKS", and thus it no
+ longer has to be specified.
+
+ - Fixed Bug#56979 - Improper connection closing logic leads to TIME_WAIT
+ sockets on server
+
+ - Fixed Bug#57380 - DatabaseMetaData.supportsMultipleResultSets() now returns
+ true when connected to a 4.1 version or later server.
+
+ - Fixed Bug#58706 - Failover connections didn't honor "failOverReadOnly=false", and in some
+ situations would not fall back.
+
+ - Removed logging integrations with log4j and apache-commons-logging due to license
+ incompatibility. Replacing with SLF4J integration in next release.
+
+06-24-10 - Version 5.1.13
+
+ - Minor fix in previous patch for Bug#51904. Function ConnectionImpl.setCatalog() was passed quoted argument thus breaking with "...for the right syntax to use near 'test``'"
+
+ - Fix for Bug#51912 - Passing NULL as cat. param to getProcedureColumns with !nullCatalogMeansCurrent
+
+ - Fix for Bug#52167 - Can't parse parameter list with special characters inside
+
+ - Fix for Bug#51904 - getProcedureColumns() always returns PROCEDURE_CAT result column as NULL
+
+ - Fix for Bug#51712 - Display Size is always 0 for columns returned by getProcedureColumns()
+
+ - Fix for Bug#51908 - db variable might have end up unassigned when calling
+ getProcedureColumns()/Functions(). This is a followup on code changes made
+ for Bug#51022.
+
+ - Fixed Bug#51266 - jdbc:mysql:loadbalance:// would stick to the first
+ host in the list in some cases, especially exacerbated if the host was
+ down.
+
+ - Replaced URLs of the form jdbc:mysql://host-1,host-2 with a composite of
+ a normal connection and a jdbc:mysql:loadbalance:// connection for more
+ robustness and cleaner code.
+
+ - Fixed BUG#51643 - Connections using jdbc:mysql:loadbalance:// would
+ have statements (and prepared statements) that did not have their connections
+ changed upon commit()/rollback(), and thus applications that held statement
+ instances past commit()/rollback() could have data written to or read from
+ un-intended connections.
+
+ - Fixed BUG#51666 - StatementInterceptors were never "un-safed" after connection
+ establishment, causing interceptors which returned result sets pre/post execution
+ would not work.
+
+ - Fixed BUG#51783 - Load-balanced connections could throw a SQLException
+ incorrectly on commit() or rollback(). This was not caused by failures in commit
+ or rollback, but rather by the possibility that the newly-selected physical
+ connection was stale. Added logic to catch and retry if this happens, up to
+ the number of hosts specified for load-balancing. Also added new property,
+ loadBalanceValidateConnectionOnSwapServer, which controls whether to explicitly
+ ping the selected host (otherwise, the host is presumed to be up, and will only
+ be noticed if auto-commit or transaction isolation state needs to be set and
+ fails).
+
+ - Added loadBalancePingTimeout property to allow a specific timeout to be set
+ for each ping executed against the servers. This ping is executed when the
+ physical connections are rebalanced (commit/rollback or communication exception),
+ or when a query starting with (exactly) "/* ping */" is executed. The latter
+ causes each open underlying physical connection to be pinged.
+
+ - Fixed BUG#51776 - Connection.rollback() could swallow exceptions incorrectly.
+
+ - Fixed BUG#52231 - Differences in definitions of which SQLExceptions trigger
+ a failover event could result in failure to try more than a single host in
+ certain situations.
+
+ - Fixed BUG#52534 - Performance regression using load-balanced connection.
+
+ - More aggressively purge the statement timeout timers after they've been cancelled to
+ trade time for memory. This purge only happens if statement timeouts are in use.
+
+ - Added management of running load-balanced connections. Statistics can be obtained,
+ and hosts added/dropped via com.mysql.jdbc.ConnectionGroupManager or the JMX
+ implementation. This functionality is enabled by setting the new paramenter,
+ loadBalanceConnectionGroup to the name of the logical grouping of connections.
+ All load-balanced connections sharing the same loadBalanceConnectionGroup value,
+ regardless of how the application creates them, will be managed together. To
+ enable JMX-based management, set loadBalanceEnableJMX=true and ensure that remote
+ JMX is enabled in the JRE (eg, use -Dcom.sun.management.jmxremote).
+
+ - Added loadBalanceExceptionChecker property, which takes a fully-qualified class
+ name implementing com.mysql.jdbc.LoadBalancedExceptionChecker interface. This
+ allows custom evaluation of SQLExceptions thrown to determine whether they should
+ trigger failover to an alternate host in load-balanced deployments. The default
+ is com.mysql.jdbc.StandardLoadBalanceExceptionChecker.
+
+ - Added two new properties which allow more flexibility in determining which
+ SQLExceptions should trigger failover in a load-balanced deployment. The new
+ loadBalanceSQLStateFailover property takes a comma-delimited list of SQLState
+ codes which are compared to the SQLState of the SQLException (matching done
+ with trailing wildcard), while loadBalanceSQLExceptionSubclassFailover takes
+ a comma-delimited list of fully-qualified class/interface names, against
+ which the SQLException is checked to determine if it is an instance of any.
+ Matches trigger failover to an alternate host.
+
+ - Fixed Bug#51704 - Re-written batched statements don't honor escape processing
+ flag of their creator.
+
+ - Fixed Bug#43576 - Sometimes not able to register OUT parameters for
+ CallableStatements.
+
+ - Fixed Bug#54175 - Driver doesn't support utf8mb4 for servers 5.5.2 and newer. The
+ driver now auto-detects servers configured with character_set_server=utf8mb4 or
+ treats the Java encoding "utf-8" passed via "characterEncoding=..." as utf8mb4 in
+ the "SET NAMES=" calls it makes when establishing the connection.
+
+02-18-10 - Version 5.1.12
+
+ - NO_INDEX_USED and NO_GOOD_INDEX used were only being set when profileSQL
+ was set to "true", and in some cases their values were reversed.
+
+ - Fix for Bug#51022 - conn.getMetaData().getProcedures("schema",null,"%");
+ returns all stored procedures from all databases and not only for given
+ one.
+
+ - Fixed Bug#50538 - ${svn.revno} shows up in DBMD.getDriverVersion().
+
+ - Removed usage of timestamp nanoseconds in PreparedStatement.setTimestamp(),
+ as long as Bug#50774 exists in the server and there's no real support
+ for nanos/micros in TIMESTAMPs, avoid the performance regression usage of
+ them causes.
+
+
+01-20-10 - Version 5.1.11
+
+ - Fix for BUG#50288 - NullPointerException possible during invalidateCurrentConnection() for load-balanced
+ connections.
+
+ - Fix for BUG#49745 - deleteRow() for updatable result sets can cause full table scan because escaped hex
+ values are used for primary key identifiers.
+
+ - Fix for BUG#49607 - Provide Connection context in ExceptionInterceptor.
+
+ - Fix for BUG#48605 - Ping leaves closed connections in liveConnections, causing subsequent Exceptions when
+ that connection is used.
+
+ - Fix for BUG#48442 - Load-balanced Connection object returns inconsistent results for hashCode() and equals()
+ dependent upon state of underlying connections.
+
+ - Fix for BUG#48172 - Batch rewrite requires space immediately after "VALUES"
+
+ - Statement Interceptors didn't completely intercept server-side prepared statements.
+
+ - Fix for BUG#48486 Cannot use load balanced connections with MysqlConnectionPoolDataSource.
+
+ - Fix for Bug#32525 - "noDatetimeStringSync" doesn't work for server-side prepared statements. Now it does.
+
+ - Hooked up exception interceptors so they get called now.
+
+ - Rev'd the statement interceptor interface to pass on some server flags, warning counts and errors. See
+ the com.mysql.jdbc.StatementInteceptorsV2 interface for more details. The driver will create adaptors to
+ transparently convert older implementations to the newer interface at runtime.
+
+ - Statement Interceptors are now enabled at connection instantiation, but
+ can not return result sets (they will be ignored) until the connection
+ has bootstrapped itself. If during the init() method your interceptor
+ requires access to the connection itself, it should ensure that methods
+ that might throw exceptions if the connection is closed should handle
+ this in a robust manner.
+
+ - "Replication" connections (those with URLs that start with
+ jdbc:mysql:replication) now use a jdbc:mysql:loadbalance connection
+ under the hood for the slave "pool". This also means that one can set
+ load balancing properties such as "loadBalanceBlacklistTimeout" and
+ "loadBalanceStrategy" to choose a mechanism for balancing the load and
+ failover/fault tolerance strategy for the slave pool. This work was done
+ in order to fix Bug#49537.
+
+ - Fixed Bug#36565 - permgen leak from java.util.Timer. Unfortunately no great
+ fix exists that lets us keep the timer shared amongst connection instances, so
+ instead it's lazily created if need be per-instance, and torn down when the
+ connection is closed.
+
+ - Fixed BUG#49700 - Connections from ConnectionPoolDataSource don't
+ maintain any values set with "sesssionVariables=...". This was a bug
+ in Connection.changeUser()/resetServerState(), we now resubmit the
+ session variables during the execution of these methods.
+
+09-22-09 - Version 5.1.10
+
+ - Fix for BUG#47494 - Non standard port numbers in the URL are not honored.
09-16-09 - Version 5.1.9
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..ed7a065c4
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,49 @@
+# Contributing Guidelines
+
+We love getting feedback from our users. Bugs and code contributions are great forms of feedback and we thank you for any bugs you report or code you contribute.
+
+## Reporting Issues
+
+Before reporting a new bug, please [check first](https://bugs.mysql.com/search.php) to see if a similar bug already exists.
+
+Bug reports should be as complete as possible. Please try and include the following:
+
+* Complete steps to reproduce the issue.
+* Any information about platform and environment that could be specific to the bug.
+* Specific version of the product you are using.
+* Specific version of the server being used.
+* Sample code to help reproduce the issue, if possible.
+
+## Contributing Code
+
+Contributing to MySQL projects is easy. You just need to follow these steps.
+
+* Make sure you have a user account at [bugs.mysql.com](https://bugs.mysql.com). You will need to reference this user account when you submit your Oracle Contributor Agreement (OCA).
+* Sign the Oracle Contributor Agreement. You can find instructions for doing that at the [OCA Page](https://www.oracle.com/technetwork/community/oca-486395.html).
+* Develop your pull request. Make sure you are aware of the requirements for the project (e.g. do not require Java 7 if we are supporting Java 8 and higher).
+* Validate your pull request by including tests that sufficiently cover the functionality you are adding.
+* Verify that the entire test suite passes with your code applied.
+* Submit your pull request. While you can submit the pull request via [GitHub](https://github.com/mysql/mysql-connector-j/pulls), you can also submit it directly via [bugs.mysql.com](https://bugs.mysql.com).
+
+Thanks again for your wish to contribute to MySQL. We truly believe in the principles of open source development and appreciate any contributions to our projects.
+
+## Setting Up a Development Environment
+
+You can use your preferred Java IDE to view, edit, and compile the MySQL Connector/J source code. The configuration setup can be adapted from [Installing from Source](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-installing-source.html) with little effort.
+
+Running the entire test suite or your own test case is also possible by setting a few Ant properties in your IDE preferences setup. Refer to [Testing Connector/J](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-testing.html) for additional details.
+
+## Getting Help
+
+If you need help or just want to get in touch with us, please use the following resources:
+
+* [MySQL Connector/J, JDBC and Java forum](https://forums.mysql.com/list.php?39).
+* [`#connectors` channel in MySQL Community Slack](https://mysqlcommunity.slack.com/messages/connectors). ([Sign-up](https://lefred.be/mysql-community-on-slack/) required if you do not have an Oracle account.)
+* [@MySQL on Twitter](https://twitter.com/MySQL).
+* [MySQL and Java Mailing Lists](https://lists.mysql.com/java).
+* [InsideMySQL.com Connectors Blog](https://insidemysql.com/category/mysql-development/connectors/).
+* [MySQL Bugs database](https://bugs.mysql.com/).
+
+We hope to hear from you soon. Enjoy your coding!
+
+[](https://twitter.com/intent/follow?screen_name=MySQL)
diff --git a/COPYING b/COPYING
deleted file mode 100644
index 025ed9e7e..000000000
--- a/COPYING
+++ /dev/null
@@ -1,343 +0,0 @@
-GNU General Public License
-**************************
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
- freedom to share and change it. By contrast, the GNU General Public
- License is intended to guarantee your freedom to share and change free
- software--to make sure the software is free for all its users. This
- General Public License applies to most of the Free Software
- Foundation's software and to any other program whose authors commit to
- using it. (Some other Free Software Foundation software is covered by
- the GNU Library General Public License instead.) You can apply it to
- your programs, too.
-
- When we speak of free software, we are referring to freedom, not
- price. Our General Public Licenses are designed to make sure that you
- have the freedom to distribute copies of free software (and charge for
- this service if you wish), that you receive source code or can get it
- if you want it, that you can change the software or use pieces of it
- in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
- anyone to deny you these rights or to ask you to surrender the rights.
- These restrictions translate to certain responsibilities for you if you
- distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
- gratis or for a fee, you must give the recipients all the rights that
- you have. You must make sure that they, too, receive or can get the
- source code. And you must show them these terms so they know their
- rights.
-
- We protect your rights with two steps: (1) copyright the software, and
- (2) offer you this license which gives you legal permission to copy,
- distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
- that everyone understands that there is no warranty for this free
- software. If the software is modified by someone else and passed on, we
- want its recipients to know that what they have is not the original, so
- that any problems introduced by others will not reflect on the original
- authors' reputations.
-
- Finally, any free program is threatened constantly by software
- patents. We wish to avoid the danger that redistributors of a free
- program will individually obtain patent licenses, in effect making the
- program proprietary. To prevent this, we have made it clear that any
- patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
- modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
- a notice placed by the copyright holder saying it may be distributed
- under the terms of this General Public License. The "Program", below,
- refers to any such program or work, and a "work based on the Program"
- means either the Program or any derivative work under copyright law:
- that is to say, a work containing the Program or a portion of it,
- either verbatim or with modifications and/or translated into another
- language. (Hereinafter, translation is included without limitation in
- the term "modification".) Each licensee is addressed as "you".
-
- Activities other than copying, distribution and modification are not
- covered by this License; they are outside its scope. The act of
- running the Program is not restricted, and the output from the Program
- is covered only if its contents constitute a work based on the
- Program (independent of having been made by running the Program).
- Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
- source code as you receive it, in any medium, provided that you
- conspicuously and appropriately publish on each copy an appropriate
- copyright notice and disclaimer of warranty; keep intact all the
- notices that refer to this License and to the absence of any warranty;
- and give any other recipients of the Program a copy of this License
- along with the Program.
-
- You may charge a fee for the physical act of transferring a copy, and
- you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
- of it, thus forming a work based on the Program, and copy and
- distribute such modifications or work under the terms of Section 1
- above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
- These requirements apply to the modified work as a whole. If
- identifiable sections of that work are not derived from the Program,
- and can be reasonably considered independent and separate works in
- themselves, then this License, and its terms, do not apply to those
- sections when you distribute them as separate works. But when you
- distribute the same sections as part of a whole which is a work based
- on the Program, the distribution of the whole must be on the terms of
- this License, whose permissions for other licensees extend to the
- entire whole, and thus to each and every part regardless of who wrote it.
-
- Thus, it is not the intent of this section to claim rights or contest
- your rights to work written entirely by you; rather, the intent is to
- exercise the right to control the distribution of derivative or
- collective works based on the Program.
-
- In addition, mere aggregation of another work not based on the Program
- with the Program (or with a work based on the Program) on a volume of
- a storage or distribution medium does not bring the other work under
- the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
- under Section 2) in object code or executable form under the terms of
- Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
- The source code for a work means the preferred form of the work for
- making modifications to it. For an executable work, complete source
- code means all the source code for all modules it contains, plus any
- associated interface definition files, plus the scripts used to
- control compilation and installation of the executable. However, as a
- special exception, the source code distributed need not include
- anything that is normally distributed (in either source or binary
- form) with the major components (compiler, kernel, and so on) of the
- operating system on which the executable runs, unless that component
- itself accompanies the executable.
-
- If distribution of executable or object code is made by offering
- access to copy from a designated place, then offering equivalent
- access to copy the source code from the same place counts as
- distribution of the source code, even though third parties are not
- compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
- except as expressly provided under this License. Any attempt
- otherwise to copy, modify, sublicense or distribute the Program is
- void, and will automatically terminate your rights under this License.
- However, parties who have received copies, or rights, from you under
- this License will not have their licenses terminated so long as such
- parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
- signed it. However, nothing else grants you permission to modify or
- distribute the Program or its derivative works. These actions are
- prohibited by law if you do not accept this License. Therefore, by
- modifying or distributing the Program (or any work based on the
- Program), you indicate your acceptance of this License to do so, and
- all its terms and conditions for copying, distributing or modifying
- the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
- Program), the recipient automatically receives a license from the
- original licensor to copy, distribute or modify the Program subject to
- these terms and conditions. You may not impose any further
- restrictions on the recipients' exercise of the rights granted herein.
- You are not responsible for enforcing compliance by third parties to
- this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
- infringement or for any other reason (not limited to patent issues),
- conditions are imposed on you (whether by court order, agreement or
- otherwise) that contradict the conditions of this License, they do not
- excuse you from the conditions of this License. If you cannot
- distribute so as to satisfy simultaneously your obligations under this
- License and any other pertinent obligations, then as a consequence you
- may not distribute the Program at all. For example, if a patent
- license would not permit royalty-free redistribution of the Program by
- all those who receive copies directly or indirectly through you, then
- the only way you could satisfy both it and this License would be to
- refrain entirely from distribution of the Program.
-
- If any portion of this section is held invalid or unenforceable under
- any particular circumstance, the balance of the section is intended to
- apply and the section as a whole is intended to apply in other
- circumstances.
-
- It is not the purpose of this section to induce you to infringe any
- patents or other property right claims or to contest validity of any
- such claims; this section has the sole purpose of protecting the
- integrity of the free software distribution system, which is
- implemented by public license practices. Many people have made
- generous contributions to the wide range of software distributed
- through that system in reliance on consistent application of that
- system; it is up to the author/donor to decide if he or she is willing
- to distribute software through any other system and a licensee cannot
- impose that choice.
-
- This section is intended to make thoroughly clear what is believed to
- be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
- certain countries either by patents or by copyrighted interfaces, the
- original copyright holder who places the Program under this License
- may add an explicit geographical distribution limitation excluding
- those countries, so that distribution is permitted only in or among
- countries not thus excluded. In such case, this License incorporates
- the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
- of the General Public License from time to time. Such new versions will
- be similar in spirit to the present version, but may differ in detail to
- address new problems or concerns.
-
- Each version is given a distinguishing version number. If the Program
- specifies a version number of this License which applies to it and "any
- later version", you have the option of following the terms and conditions
- either of that version or of any later version published by the Free
- Software Foundation. If the Program does not specify a version number of
- this License, you may choose any version ever published by the Free Software
- Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
- programs whose distribution conditions are different, write to the author
- to ask for permission. For software which is copyrighted by the Free
- Software Foundation, write to the Free Software Foundation; we sometimes
- make exceptions for this. Our decision will be guided by the two goals
- of preserving the free status of all derivatives of our free software and
- of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
- possible use to the public, the best way to achieve this is to make it
- free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
- to attach them to the start of each source file to most effectively
- convey the exclusion of warranty; and each file should have at least
- the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C) 19yy
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Also add information on how to contact you by electronic and paper mail.
-
- If the program is interactive, make it output a short notice like this
- when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
- The hypothetical commands `show w' and `show c' should show the appropriate
- parts of the General Public License. Of course, the commands you use may
- be called something other than `show w' and `show c'; they could even be
- mouse-clicks or menu items--whatever suits your program.
-
- You should also get your employer (if you work as a programmer) or your
- school, if any, to sign a "copyright disclaimer" for the program, if
- necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- , 1 April 1989
- Ty Coon, President of Vice
-
- This General Public License does not permit incorporating your program into
- proprietary programs. If your program is a subroutine library, you may
- consider it more useful to permit linking proprietary applications with the
- library. If this is what you want to do, use the GNU Library General
- Public License instead of this License.
-
diff --git a/EXCEPTIONS-CONNECTOR-J b/EXCEPTIONS-CONNECTOR-J
deleted file mode 100644
index 3ccab7475..000000000
--- a/EXCEPTIONS-CONNECTOR-J
+++ /dev/null
@@ -1,119 +0,0 @@
-MySQL FLOSS License Exception
-
-The MySQL AB Exception for Free/Libre and Open Source
-Software-only Applications Using MySQL Client Libraries (the
-"FLOSS Exception").
-
-Version 0.6, 7 March 2007
-
-Exception Intent
-
-We want specified Free/Libre and Open Source Software (``FLOSS'')
-applications to be able to use specified GPL-licensed MySQL client
-libraries (the ``Program'') despite the fact that not all FLOSS
-licenses are compatible with version 2 of the GNU General Public
-License (the ``GPL'').
-
-Legal Terms and Conditions
-
-As a special exception to the terms and conditions of version 2.0
-of the GPL:
-
- 1. You are free to distribute a Derivative Work that is formed
- entirely from the Program and one or more works (each, a
- "FLOSS Work") licensed under one or more of the licenses
- listed below in section 1, as long as:
- a. You obey the GPL in all respects for the Program and the
- Derivative Work, except for identifiable sections of the
- Derivative Work which are not derived from the Program,
- and which can reasonably be considered independent and
- separate works in themselves,
- b. all identifiable sections of the Derivative Work which
- are not derived from the Program, and which can
- reasonably be considered independent and separate works
- in themselves,
- i. are distributed subject to one of the FLOSS licenses
- listed below, and
- ii. the object code or executable form of those sections
- are accompanied by the complete corresponding
- machine-readable source code for those sections on
- the same medium and under the same FLOSS license as
- the corresponding object code or executable forms of
- those sections, and
- c. any works which are aggregated with the Program or with a
- Derivative Work on a volume of a storage or distribution
- medium in accordance with the GPL, can reasonably be
- considered independent and separate works in themselves
- which are not derivatives of either the Program, a
- Derivative Work or a FLOSS Work.
- If the above conditions are not met, then the Program may only
- be copied, modified, distributed or used under the terms and
- conditions of the GPL or another valid licensing option from
- MySQL AB.
-
- 2. FLOSS License List
-
-License name Version(s)/Copyright Date
-Academic Free License 2.0
-Apache Software License 1.0/1.1/2.0
-Apple Public Source License 2.0
-Artistic license From Perl 5.8.0
-BSD license "July 22 1999"
-Common Development and Distribution License (CDDL) 1.0
-Common Public License 1.0
-Eclipse Public License 1.0
-GNU Library or "Lesser" General Public License (LGPL) 2.0/2.1
-Jabber Open Source License 1.0
-MIT license (As listed in file MIT-License.txt) ---
-Mozilla Public License (MPL) 1.0/1.1
-Open Software License 2.0
-OpenSSL license (with original SSLeay license) "2003" ("1998")
-PHP License 3.0
-Python license (CNRI Python License) ---
-Python Software Foundation License 2.1.1
-Sleepycat License "1999"
-University of Illinois/NCSA Open Source License ---
-W3C License "2001"
-X11 License "2001"
-Zlib/libpng License ---
-Zope Public License 2.0
-
- Due to the many variants of some of the above licenses, we
- require that any version follow the 2003 version of the Free
- Software Foundation's Free Software Definition
- (http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of
- the Open Source Definition by the Open Source Initiative
- (http://www.opensource.org/docs/definition.php).
-
- 3. Definitions
-
- a. Terms used, but not defined, herein shall have the
- meaning provided in the GPL.
- b. Derivative Work means a derivative work under copyright
- law.
-
- 4. Applicability: This FLOSS Exception applies to all Programs
- that contain a notice placed by MySQL AB saying that the
- Program may be distributed under the terms of this FLOSS
- Exception. If you create or distribute a work which is a
- Derivative Work of both the Program and any other work
- licensed under the GPL, then this FLOSS Exception is not
- available for that work; thus, you must remove the FLOSS
- Exception notice from that work and comply with the GPL in all
- respects, including by retaining all GPL notices. You may
- choose to redistribute a copy of the Program exclusively under
- the terms of the GPL by removing the FLOSS Exception notice
- from that copy of the Program, provided that the copy has
- never been modified by you or any third party.
-
-Appendix A. Qualified Libraries and Packages
-
-The following is a non-exhaustive list of libraries and packages
-which are covered by the FLOSS License Exception. Please note that
-this appendix is provided merely as an additional service to
-specific FLOSS projects wishing to simplify licensing information
-for their users. Compliance with one of the licenses noted under
-the "FLOSS license list" section remains a prerequisite.
-
-Package Name Qualifying License and Version
-Apache Portable Runtime (APR) Apache Software License 2.0
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..83e60a354
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,2051 @@
+Licensing Information User Manual
+
+MySQL Connector/J 8.0
+ __________________________________________________________________
+
+Introduction
+
+ This License Information User Manual contains Oracle's product license
+ and other licensing information, including licensing information for
+ third-party software which may be included in this distribution of
+ MySQL Connector/J 8.0.
+
+ Last updated: September 2021
+
+Licensing Information
+
+ This is a release of MySQL Connector/J 8.0, brought to you by the MySQL
+ team at Oracle. This software is released under version 2 of the GNU
+ General Public License (GPLv2), as set forth below, with the following
+ additional permissions:
+
+ This distribution of MySQL Connector/J 8.0 is distributed with certain
+ software that is licensed under separate terms, as designated in a
+ particular file or component or in the license documentation. Without
+ limiting your rights under the GPLv2, the authors of MySQL hereby grant
+ you an additional permission to link the program and your derivative
+ works with the separately licensed software that they have included
+ with the program.
+
+ Without limiting the foregoing grant of rights under the GPLv2 and
+ additional permission as to separately licensed software, this
+ Connector is also subject to the Universal FOSS Exception, version 1.0,
+ a copy of which is reproduced below and can also be found along with
+ its FAQ at http://oss.oracle.com/licenses/universal-foss-exception.
+
+ Copyright (c) 2017, 2021, Oracle and/or its affiliates.
+
+Election of GPLv2
+
+ For the avoidance of doubt, except that if any license choice other
+ than GPL or LGPL is available it will apply instead, Oracle elects to
+ use only the General Public License version 2 (GPLv2) at this time for
+ any software where a choice of GPL license versions is made available
+ with the language indicating that GPLv2 or any later version may be
+ used, or where a choice of which version of the GPL is applied is
+ otherwise unspecified.
+
+GNU General Public License Version 2.0, June 1991
+
+The following applies to all products licensed under the GNU General
+Public License, Version 2.0: You may not use the identified files
+except in compliance with the GNU General Public License, Version
+2.0 (the "License.") You may obtain a copy of the License at
+http://www.gnu.org/licenses/gpl-2.0.txt. A copy of the license is
+also reproduced below. Unless required by applicable law or agreed
+to in writing, software distributed under the License is distributed
+on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+either express or implied. See the License for the specific language
+governing permissions and limitations under the License.
+
+
+ ======================================================================
+ ======================================================================
+
+
+GNU GENERAL PUBLIC LICENSE
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+Everyone is permitted to copy and distribute verbatim
+copies of this license document, but changing it is not
+allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software,
+and (2) offer you this license which gives you legal permission to
+copy, distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on,
+we want its recipients to know that what they have is not the original,
+so that any problems introduced by others will not reflect on the
+original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software
+ interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as
+a special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new
+versions of the General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Program does not specify a
+version number of this License, you may choose any version ever
+published by the Free Software Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the
+author to ask for permission. For software which is copyrighted by the
+Free Software Foundation, write to the Free Software Foundation; we
+sometimes make exceptions for this. Our decision will be guided by the
+two goals of preserving the free status of all derivatives of our free
+software and of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND,
+EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS
+WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
+ type 'show w'. This is free software, and you are welcome
+ to redistribute it under certain conditions; type 'show c'
+ for details.
+
+The hypothetical commands 'show w' and 'show c' should show the
+appropriate parts of the General Public License. Of course, the
+commands you use may be called something other than 'show w' and
+'show c'; they could even be mouse-clicks or menu items--whatever
+suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ program 'Gnomovision' (which makes passes at compilers) written
+ by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library,
+you may consider it more useful to permit linking proprietary
+applications with the library. If this is what you want to do, use
+the GNU Lesser General Public License instead of this License.
+
+ ======================================================================
+ ======================================================================
+
+The Universal FOSS Exception, Version 1.0
+
+ In addition to the rights set forth in the other license(s) included in
+ the distribution for this software, data, and/or documentation
+ (collectively the "Software", and such licenses collectively with this
+ additional permission the "Software License"), the copyright holders
+ wish to facilitate interoperability with other software, data, and/or
+ documentation distributed with complete corresponding source under a
+ license that is OSI-approved and/or categorized by the FSF as free
+ (collectively "Other FOSS"). We therefore hereby grant the following
+ additional permission with respect to the use and distribution of the
+ Software with Other FOSS, and the constants, function signatures, data
+ structures and other invocation methods used to run or interact with
+ each of them (as to each, such software's "Interfaces"):
+
+ i. The Software's Interfaces may, to the extent permitted by the
+ license of the Other FOSS, be copied into, used and distributed in
+ the Other FOSS in order to enable interoperability, without
+ requiring a change to the license of the Other FOSS other than as
+ to any Interfaces of the Software embedded therein. The Software's
+ Interfaces remain at all times under the Software License,
+ including without limitation as used in the Other FOSS (which upon
+ any such use also then contains a portion of the Software under the
+ Software License).
+
+ ii. The Other FOSS's Interfaces may, to the extent permitted by the
+ license of the Other FOSS, be copied into, used and distributed in
+ the Software in order to enable interoperability, without requiring
+ that such Interfaces be licensed under the terms of the Software
+ License or otherwise altering their original terms, if this does
+ not require any portion of the Software other than such Interfaces
+ to be licensed under the terms other than the Software License.
+
+ iii. If only Interfaces and no other code is copied between the
+ Software and the Other FOSS in either direction, the use and/or
+ distribution of the Software with the Other FOSS shall not be
+ deemed to require that the Other FOSS be licensed under the license
+ of the Software, other than as to any Interfaces of the Software
+ copied into the Other FOSS. This includes, by way of example and
+ without limitation, statically or dynamically linking the Software
+ together with Other FOSS after enabling interoperability using the
+ Interfaces of one or both, and distributing the resulting
+ combination under different licenses for the respective portions
+ thereof. For avoidance of doubt, a license which is OSI-approved or
+ categorized by the FSF as free, includes, for the purpose of this
+ permission, such licenses with additional permissions, and any
+ license that has previously been so approved or categorized as
+ free, even if now deprecated or otherwise no longer recognized as
+ approved or free. Nothing in this additional permission grants any
+ right to distribute any portion of the Software on terms other than
+ those of the Software License or grants any additional permission
+ of any kind for use or distribution of the Software in conjunction
+ with software other than Other FOSS.
+
+ ======================================================================
+ ======================================================================
+
+Licenses for Third-Party Components
+
+ The following sections contain licensing information for libraries that
+ may be included with this product. We are thankful to all individuals
+ that have created these. Standard licenses referenced herein are
+ detailed in the Standard Licenses section.
+
+c3p0 JDBC Library
+
+ The MySQL Connector/J implements interfaces that are included in c3p0,
+ although no part of c3p0 is included or distributed with MySQL.
+
+Copyright (C) 2019 Machinery For Change, Inc.
+
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of EITHER:
+ *
+ * 1) The GNU Lesser General Public License (LGPL), version 2.1, as
+ * published by the Free Software Foundation
+ *
+ * OR
+ *
+ * 2) The Eclipse Public License (EPL), version 1.0
+ * You may choose which license to accept if you wish to redistribute
+ * or modify this work. You may offer derivatives of this work
+ * under the license you have chosen, or you may provide the same
+ * choice of license which you have been offered here.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received copies of both LGPL v2.1 and EPL v1.0
+ * along with this software; see the files LICENSE-EPL and LICENSE-LGPL.
+ * If not, the text of these licenses are currently available at
+ *
+ * LGPL v2.1: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+ * EPL v1.0: http://www.eclipse.org/org/documents/epl-v10.php
+
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation
+
+ distributed under this Agreement, and
+
+b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are
+distributed by that particular Contributor. A Contribution 'originates' from a
+Contributor if it was added to the Program by such Contributor itself or anyone
+acting on such Contributor's behalf. Contributions do not include additionsto
+the Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii) are not
+derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free copyright license to
+reproduce, prepare derivative works of, publicly display, publicly perform,
+distribute and sublicense the Contribution of such Contributor, if any, and such
+derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed
+Patents to make, use, sell, offer to sell, import and otherwise transfer the
+Contribution of such Contributor, if any, in source code and object code form.
+This patent license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor, such
+addition of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other combinations
+which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to
+its Contributions set forth herein, no assurances are provided by any
+Contributor that the Program does not infringe the patent or other intellectual
+property rights of any other entity. Each Contributor disclaims any liability to
+Recipient for claims brought by any other entity based on infringement of
+intellectual property rights or otherwise. As a condition to exercising the
+rights and licenses granted hereunder, each Recipient hereby assumes sole
+responsibility to secure any other intellectual property rights needed, if any.
+For example, if a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire that license
+before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright license
+set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under
+its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all warranties
+ and conditions, express and implied, including warranties or conditions
+ of title and non-infringement, and implied warranties or conditions of
+ merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for
+ damages, including direct, indirect, special, incidental and
+ consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are
+ offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within
+the Program.
+
+Each Contributor must identify itself as the originator of its Contribution,
+if any, in a manner that reasonably allows subsequent Recipients to identify
+the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore, if
+a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses, damages
+and costs (collectively "Losses") arising from claims, lawsuits and other legal
+actions brought by a third party against the Indemnified Contributor to the
+extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor to
+control, and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may participate in
+any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If that
+Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such
+Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a court
+requires any other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
+Recipient is solely responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its exercise of
+rights under this Agreement , including but not limited to the risks and costs
+of program errors, compliance with applicable laws, damage to or loss of data,
+programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable
+law, it shall not affect the validity or enforceability of the remainder of the
+terms of this Agreement, and without further action by the parties hereto, such
+provision shall be reformed to the minimum extent necessary to make such
+provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Program itself
+(excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted under
+Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to time.
+No one other than the Agreement Steward has the right to modify this Agreement.
+The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation
+may assign the responsibility to serve as the Agreement Steward to a suitable
+separate entity. Each new version of the Agreement will be given a
+distinguishing version number. The Program (including Contributions) may always
+be distributed subject to the version of the Agreement under which it was
+received. In addition, after a new version of the Agreement is published,
+Contributor may elect to distribute the Program (including its Contributions)
+under the new version. Except as expressly stated in Sections 2(a) and 2(b)
+above, Recipient receives no rights or licenses to the intellectual property of
+any Contributor under this Agreement, whether expressly, by implication,
+estoppel or otherwise. All rights in the Program not expressly granted under
+this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
+
+ The LGPL v2.1 can be found in GNU Lesser General Public License Version
+ 2.1, February 1999.
+
+ ======================================================================
+ ======================================================================
+
+Google Protocol Buffers
+
+Copyright 2008 Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Code generated by the Protocol Buffer compiler is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
+
+ ======================================================================
+ ======================================================================
+
+Java Hamcrest
+
+Copyright (c) 2000-2015 www.hamcrest.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list
+of conditions and the following disclaimer. Redistributions in binary form must
+reproduce the above copyright notice, this list of conditions and the following
+disclaimer in the documentation and/or other materials provided with the
+distribution.
+
+Neither the name of Hamcrest nor the names of its contributors may be used to
+endorse or promote products derived from this software without specific prior
+written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ ======================================================================
+ ======================================================================
+
+JUnit 5
+
+COPYRIGHT: Copyright 2015-2020 the original author or authors.
+
+Eclipse Public License - v 2.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
+ OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial content
+ Distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+ i) changes to the Program, and
+ ii) additions to the Program;
+ where such changes and/or additions to the Program originate from
+ and are Distributed by that particular Contributor. A Contribution
+ "originates" from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's behalf.
+ Contributions do not include changes or additions to the Program that
+ are not Modified Works.
+
+"Contributor" means any person or entity that Distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which
+are necessarily infringed by the use or sale of its Contribution alone
+or when combined with the Program.
+
+"Program" means the Contributions Distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement
+or any Secondary License (as applicable), including Contributors.
+
+"Derivative Works" shall mean any work, whether in Source Code or other
+form, that is based on (or derived from) the Program and for which the
+editorial revisions, annotations, elaborations, or other modifications
+represent, as a whole, an original work of authorship.
+
+"Modified Works" shall mean any work in Source Code or other form that
+results from an addition to, deletion from, or modification of the
+contents of the Program, including, for purposes of clarity any new file
+in Source Code form that contains any contents of the Program. Modified
+Works shall not include works that contain only declarations,
+interfaces, types, classes, structures, or files of the Program solely
+in each case in order to link to, bind by name, or subclass the Program
+or Modified Works thereof.
+
+"Distribute" means the acts of a) distributing or b) making available
+in any manner that enables the transfer of a copy.
+
+"Source Code" means the form of a Program preferred for making
+modifications, including but not limited to software source code,
+documentation source, and configuration files.
+
+"Secondary License" means either the GNU General Public License,
+Version 2.0, or any later versions of that license, including any
+exceptions or additional permissions as identified by the initial
+Contributor.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare Derivative Works of, publicly display,
+ publicly perform, Distribute and sublicense the Contribution of such
+ Contributor, if any, and such Derivative Works.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in Source Code or other form. This patent license shall
+ apply to the combination of the Contribution and the Program if, at
+ the time the Contribution is added by the Contributor, such addition
+ of the Contribution causes such combination to be covered by the
+ Licensed Patents. The patent license shall not apply to any other
+ combinations which include the Contribution. No hardware per se is
+ licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to Distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ e) Notwithstanding the terms of any Secondary License, no
+ Contributor makes additional grants to any Recipient (other than
+ those set forth in this Agreement) as a result of such Recipient's
+ receipt of the Program under the terms of a Secondary License
+ (if permitted under the terms of Section 3).
+
+3. REQUIREMENTS
+
+3.1 If a Contributor Distributes the Program in any form, then:
+
+ a) the Program must also be made available as Source Code, in
+ accordance with section 3.2, and the Contributor must accompany
+ the Program with a statement that the Source Code for the Program
+ is available under this Agreement, and informs Recipients how to
+ obtain it in a reasonable manner on or through a medium customarily
+ used for software exchange; and
+
+ b) the Contributor may Distribute the Program under a license
+ different than this Agreement, provided that such license:
+ i) effectively disclaims on behalf of all other Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and
+ implied warranties or conditions of merchantability and fitness
+ for a particular purpose;
+
+ ii) effectively excludes on behalf of all other Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) does not attempt to limit or alter the recipients' rights
+ in the Source Code under section 3.2; and
+
+ iv) requires any subsequent distribution of the Program by any
+ party to be under a license that satisfies the requirements
+ of this section 3.
+
+3.2 When the Program is Distributed as Source Code:
+
+ a) it must be made available under this Agreement, or if the
+ Program (i) is combined with other material in a separate file or
+ files made available under a Secondary License, and (ii) the initial
+ Contributor attached to the Source Code the notice described in
+ Exhibit A of this Agreement, then the Program may be made available
+ under the terms of such Secondary Licenses, and
+
+ b) a copy of this Agreement must be included with each copy of
+ the Program.
+
+3.3 Contributors may not remove or alter any copyright, patent,
+trademark, attribution notices, disclaimers of warranty, or limitations
+of liability ("notices") contained within the Program from any copy of
+the Program which they Distribute, provided that Contributors may add
+their own appropriate notices.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities
+with respect to end users, business partners and the like. While this
+license is intended to facilitate the commercial use of the Program,
+the Contributor who includes the Program in a commercial product
+offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes
+the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and indemnify every
+other Contributor ("Indemnified Contributor") against any losses,
+damages and costs (collectively "Losses") arising from claims, lawsuits
+and other legal actions brought by a third party against the Indemnified
+Contributor to the extent caused by the acts or omissions of such
+Commercial Contributor in connection with its distribution of the Program
+in a commercial product offering. The obligations in this section do not
+apply to any claims or Losses relating to any actual or alleged
+intellectual property infringement. In order to qualify, an Indemnified
+Contributor must: a) promptly notify the Commercial Contributor in
+writing of such claim, and b) allow the Commercial Contributor to control,
+and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may
+participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those performance
+claims and warranties, and if a court requires any other Contributor to
+pay any damages as a result, the Commercial Contributor must pay
+those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
+PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
+BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
+TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE. Each Recipient is solely responsible for determining the
+appropriateness of using and distributing the Program and assumes all
+risks associated with its exercise of rights under this Agreement,
+including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs
+or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
+PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
+SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
+EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other software
+or hardware) infringes such Recipient's patent(s), then such Recipient's
+rights granted under Section 2(b) shall terminate as of the date such
+litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign the
+responsibility to serve as the Agreement Steward to a suitable separate
+entity. Each new version of the Agreement will be given a distinguishing
+version number. The Program (including Contributions) may always be
+Distributed subject to the version of the Agreement under which it was
+received. In addition, after a new version of the Agreement is published,
+Contributor may elect to Distribute the Program (including its
+Contributions) under the new version.
+
+Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
+receives no rights or licenses to the intellectual property of any
+Contributor under this Agreement, whether expressly, by implication,
+estoppel or otherwise. All rights in the Program not expressly granted
+under this Agreement are reserved. Nothing in this Agreement is intended
+to be enforceable by any entity that is not a Contributor or Recipient.
+No third-party beneficiary rights are created under this Agreement.
+
+Exhibit A - Form of Secondary Licenses Notice
+
+"This Source Code may also be made available under the following
+Secondary Licenses when the conditions for such availability set forth
+in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
+version(s), and exceptions or additional permissions here}."
+
+ Simply including a copy of this Agreement, including this Exhibit A
+ is not sufficient to license the Source Code under Secondary Licenses.
+
+ If it is not possible or desirable to put the notice in a particular
+ file, then You may include the notice in a location (such as a LICENSE
+ file in a relevant directory) where a recipient would be likely to
+ look for such a notice.
+
+ You may add additional accurate notices of copyright ownership.
+===============================================================================
+
+This product may include a number of subcomponents with separate
+copyright notices and license terms. Your use of the source code for
+these subcomponents is subject to the terms and conditions of the
+subcomponent's license, as noted in the LICENSE-.md
+files.
+
+=== Copyright from source files ===
+/*
+ * Copyright 2015-2020 the original author or authors.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v2.0 which
+ * accompanies this distribution and is available at
+ *
+ * https://www.eclipse.org/legal/epl-v20.html
+*/
+
+Additionall licenses
+====================
+
+=== junit-jupiter-params & junit-platform-console ====
+Directories include an Apache license file
+
+Apache License Version 2.0, January 2004
+
+Additional external dependencies
+================================
+https://github.com/apiguardian-team/apiguardian/archive/r1.1.0.zip
+/*
+ * Copyright 2002-2017 the original author or authors.
+ *
+The above component is licensed under
+Apache License Version 2.0, January 2004
+
+https://github.com/ota4j-team/opentest4j/archive/r1.2.0.zip
+/*
+ * Copyright 2015-2018 the original author or authors.
+ *
+The above component is licensed under
+Apache License Version 2.0, January 2004
+
+
+
+ ======================================================================
+ ======================================================================
+
+Oracle OCI SDK for Java
+
+ Oracle OCI SDK for Java
+
+Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
+This software is dual-licensed to you under the Universal Permissive License
+(UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl
+or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0.
+You may choose either license.
+____________________________
+The Universal Permissive License (UPL), Version 1.0
+Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+Subject to the condition set forth below, permission is hereby granted to any
+person obtaining a copy of this software, associated documentation and/or
+data (collectively the "Software"), free of charge and under any and all
+copyright rights in the Software, and any and all patent rights owned or
+freely licensable by each licensor hereunder covering either (i) the
+unmodified Software as contributed to or provided by such licensor, or (ii)
+the Larger Works (as defined below), to deal in both
+(a) the Software, and
+(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
+one is included with the Software (each a "Larger Work" to which the Software
+is contributed by such licensors),
+without restriction, including without limitation the rights to copy, create
+derivative works of, display, perform, and distribute the Software and make,
+use, sell, offer for sale, import, export, have made, and have sold the
+Software and the Larger Work(s), and to sublicense the foregoing rights on
+either these or other terms.
+This license is subject to the following condition:
+The above copyright notice and either this complete permission notice or at a
+minimum a reference to the UPL must be included in all copies or substantial
+portions of the Software.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+The Apache Software License, Version 2.0
+Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); You may not
+use this product except in compliance with the License. You may obtain a
+copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of
+the license is also reproduced below. Unless required by applicable law or
+agreed to in writing, software distributed under the License is distributed
+on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+express or implied. See the License for the specific language governing
+permissions and limitations under the License.
+
+Apache License Version 2.0, January 2004
+
+Oracle's use of OCI SDK for Java in MySQL Community Edition is solely under
+the UPL
+
+ ======================================================================
+ ======================================================================
+
+Simple Logging Facade for Java (SLF4J)
+
+Simple Logging Facade for Java (SLF4J)
+
+Copyright (c) 2004-2011 QOS.ch
+All rights reserved.
+
+Permission is hereby granted, free of charge,
+to any person obtaining a copy of this software
+and associated documentation files (the "Software"),
+to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify,
+merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the
+following conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
+OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
+EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR OTHER DEALINGS IN THE SOFTWARE.
+
+ ======================================================================
+ ======================================================================
+
+Unicode Data Files
+
+ Unicode Data Files
+
+COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 1991-2014 Unicode, Inc. All rights reserved. Distributed under
+the Terms of Use in http://www.unicode.org/copyright.html.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of the Unicode data files and any associated documentation (the "Data Files")
+or Unicode software and any associated documentation (the "Software") to deal
+in the Data Files or Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+and/or sell copies of the Data Files or Software, and to permit persons to
+whom the Data Files or Software are furnished to do so, provided that (a) the
+above copyright notice(s) and this permission notice appear with all copies
+of the Data Files or Software, (b) both the above copyright notice(s) and
+this permission notice appear in associated documentation, and (c) there is
+clear notice in each modified Data File or in the Software as well as in the
+documentation associated with the Data File(s) or Software that the data or
+software has been modified.
+
+THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD
+PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
+NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
+DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder shall not be
+used in advertising or otherwise to promote the sale, use or other dealings in
+these Data Files or Software without prior written authorization of the
+copyright holder.
+
+ ======================================================================
+ ======================================================================
+
+Standard Licenses
+
+GNU Lesser General Public License Version 2.1, February 1999
+
+The following applies to all products licensed under the
+GNU Lesser General Public License, Version 2.1: You may
+not use the identified files except in compliance with
+the GNU Lesser General Public License, Version 2.1 (the
+"License"). You may obtain a copy of the License at
+http://www.gnu.org/licenses/lgpl-2.1.html. A copy of the
+license is also reproduced below. Unless required by
+applicable law or agreed to in writing, software distributed
+under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+or implied. See the License for the specific language governing
+permissions and limitations under the License.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard. To achieve this, non-free programs
+must be allowed to use the library. A more frequent case is that
+a free library does the same job as widely used non-free libraries.
+In this case, there is little to gain by limiting the free library
+to free software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended
+to apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James
+ Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+ ======================================================================
+ ======================================================================
+
+Apache License Version 2.0, January 2004
+
+The following applies to all products licensed under the Apache 2.0
+License: You may not use the identified files except in compliance
+with the Apache License, Version 2.0 (the "License.") You may obtain a
+copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A
+copy of the license is also reproduced below. Unless required by
+applicable law or agreed to in writing, software distributed under the
+License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the License for
+the specific language governing permissions and limitations under the
+License.
+
+Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction,
+and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the
+copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other
+entities that control, are controlled by, or are under common control
+with that entity. For the purposes of this definition, "control" means
+(i) the power, direct or indirect, to cause the direction or
+management of such entity, whether by contract or otherwise, or (ii)
+ownership of fifty percent (50%) or more of the outstanding shares, or
+(iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation
+source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical
+transformation or translation of a Source form, including but not
+limited to compiled object code, generated documentation, and
+conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object
+form, made available under the License, as indicated by a copyright
+notice that is included in or attached to the work (an example is
+provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object
+form, that is based on (or derived from) the Work and for which the
+editorial revisions, annotations, elaborations, or other modifications
+represent, as a whole, an original work of authorship. For the
+purposes of this License, Derivative Works shall not include works
+that remain separable from, or merely link (or bind by name) to the
+interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the
+original version of the Work and any modifications or additions to
+that Work or Derivative Works thereof, that is intentionally submitted
+to Licensor for inclusion in the Work by the copyright owner or by an
+individual or Legal Entity authorized to submit on behalf of the
+copyright owner. For the purposes of this definition, "submitted"
+means any form of electronic, verbal, or written communication sent to
+the Licensor or its representatives, including but not limited to
+communication on electronic mailing lists, source code control
+systems, and issue tracking systems that are managed by, or on behalf
+of, the Licensor for the purpose of discussing and improving the Work,
+but excluding communication that is conspicuously marked or otherwise
+designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity
+on behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of, publicly
+display, publicly perform, sublicense, and distribute the Work and
+such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except
+as stated in this section) patent license to make, have made, use,
+offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such
+Contributor that are necessarily infringed by their Contribution(s)
+alone or by combination of their Contribution(s) with the Work to
+which such Contribution(s) was submitted. If You institute patent
+litigation against any entity (including a cross-claim or counterclaim
+in a lawsuit) alleging that the Work or a Contribution incorporated
+within the Work constitutes direct or contributory patent
+infringement, then any patent licenses granted to You under this
+License for that Work shall terminate as of the date such litigation
+is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work
+or Derivative Works thereof in any medium, with or without
+modifications, and in Source or Object form, provided that You meet
+the following conditions:
+
+(a) You must give any other recipients of the Work or Derivative Works
+a copy of this License; and
+
+(b) You must cause any modified files to carry prominent notices
+stating that You changed the files; and
+
+(c) You must retain, in the Source form of any Derivative Works that
+You distribute, all copyright, patent, trademark, and attribution
+notices from the Source form of the Work, excluding those notices that
+do not pertain to any part of the Derivative Works; and
+
+(d) If the Work includes a "NOTICE" text file as part of its
+distribution, then any Derivative Works that You distribute must
+include a readable copy of the attribution notices contained
+
+within such NOTICE file, excluding those notices that do not pertain
+to any part of the Derivative Works, in at least one of the following
+places: within a NOTICE text file distributed as part of the
+Derivative Works; within the Source form or documentation, if provided
+along with the Derivative Works; or, within a display generated by the
+Derivative Works, if and wherever such third-party notices normally
+appear. The contents of the NOTICE file are for informational purposes
+only and do not modify the License. You may add Your own attribution
+notices within Derivative Works that You distribute, alongside or as
+an addendum to the NOTICE text from the Work, provided that such
+additional attribution notices cannot be construed as modifying the
+License.
+
+You may add Your own copyright statement to Your modifications and may
+provide additional or different license terms and conditions for use,
+reproduction, or distribution of Your modifications, or for any such
+Derivative Works as a whole, provided Your use, reproduction, and
+distribution of the Work otherwise complies with the conditions stated
+in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+any Contribution intentionally submitted for inclusion in the Work by
+You to the Licensor shall be under the terms and conditions of this
+License, without any additional terms or conditions. Notwithstanding
+the above, nothing herein shall supersede or modify the terms of any
+separate license agreement you may have executed with Licensor
+regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+names, trademarks, service marks, or product names of the Licensor,
+except as required for reasonable and customary use in describing the
+origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed
+to in writing, Licensor provides the Work (and each Contributor
+provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied, including, without
+limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
+responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your
+exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+whether in tort (including negligence), contract, or otherwise, unless
+required by applicable law (such as deliberate and grossly negligent
+acts) or agreed to in writing, shall any Contributor be liable to You
+for damages, including any direct, indirect, special, incidental, or
+consequential damages of any character arising as a result of this
+License or out of the use or inability to use the Work (including but
+not limited to damages for loss of goodwill, work stoppage, computer
+failure or malfunction, or any and all other commercial damages or
+losses), even if such Contributor has been advised of the possibility
+of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+the Work or Derivative Works thereof, You may choose to offer, and
+charge a fee for, acceptance of support, warranty, indemnity, or other
+liability obligations and/or rights consistent with this
+License. However, in accepting such obligations, You may act only on
+Your own behalf and on Your sole responsibility, not on behalf of any
+other Contributor, and only if You agree to indemnify, defend, and
+hold each Contributor harmless for any liability incurred by, or
+claims asserted against, such Contributor by reason of your accepting
+any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work
+
+To apply the Apache License to your work, attach the following boilerplate
+notice, with the fields enclosed by brackets "[]" replaced with your own
+identifying information. (Don't include the brackets!) The text should be
+enclosed in the appropriate comment syntax for the file format. We also
+recommend that a file or class name and description of purpose be included
+on the same "printed page" as the copyright notice for easier identification
+within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied. See the License for the specific language governing permissions
+and limitations under the License.
+
+ ======================================================================
+ ======================================================================
+
+Written Offer for Source Code
+
+ For any software that you receive from Oracle in binary form which is
+ licensed under an open source license that gives you the right to
+ receive the source code for that binary, you can obtain a copy of the
+ applicable source code by visiting
+ http://www.oracle.com/goto/opensourcecode. If the source code for the
+ binary was not provided to you with the binary, you can also receive a
+ copy of the source code on physical media by submitting a written
+ request to the address listed below or by sending an email to Oracle
+ using the following link:
+ http://www.oracle.com/goto/opensourcecode/request.
+
+ Oracle America, Inc.
+ Attn: Senior Vice President
+ Development and Engineering Legal
+ 500 Oracle Parkway, 10th Floor
+ Redwood Shores, CA 94065
+
+ Your request should include:
+
+ * The name of the binary for which you are requesting the source code
+
+ * The name and version number of the Oracle product containing the
+ binary
+
+ * The date you received the Oracle product
+
+ * Your name
+
+ * Your company name (if applicable)
+
+ * Your return mailing address and email, and
+
+ * A telephone number in the event we need to reach you.
+
+
+ We may charge you a fee to cover the cost of physical media and
+ processing.
+
+ Your request must be sent
+
+ a. within three (3) years of the date you received the Oracle product
+ that included the binary that is the subject of your request, or
+
+ b. in the case of code licensed under the GPL v3 for as long as Oracle
+ offers spare parts or customer support for that product model.
diff --git a/README b/README
index e2e0c4b79..0114ce35c 100644
--- a/README
+++ b/README
@@ -1,45 +1,28 @@
-MySQL Connector/J @MYSQL_CJ_VERSION@ (formerly MM.MySQL)
-Sun Microsystem's JDBC Driver for MySQL
-Copyright 2003-2008 MySQL AB, 2008 Sun Microsystems
+Copyright (c) 2000, 2022, Oracle and/or its affiliates.
-CONTENTS
+This is a release of MySQL Connector/J, a JDBC Type 4 driver for MySQL that
+also supports the new X DevAPI.
-* License
-* Documentation Location
+License information can be found in the LICENSE file.
+This distribution may include materials developed by third parties.
+For license and attribution notices for these materials, please refer to the
+LICENSE file.
-LICENSE
+For more information on MySQL Connector/J, visit
+ https://dev.mysql.com/doc/connector-j/8.0/en/
-MySQL Connector/J is licensed under the GPL or a commercial license
-from Sun Microsystems.
-
-If you have licensed this product under the GPL, please see the COPYING
-file for more information.
-
-There are special exceptions to the terms and conditions of the GPL
-as it is applied to this software. View the full text of the
-exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
-software distribution.
-
-If you have licensed this product under a commercial license from
-MySQL AB, please see the file "LICENSE.mysql" that comes with this
-distribution for the terms of the license.
-
-If you need non-GPL licenses for commercial distribution please contact
-me or .
-
-
-DOCUMENTATION LOCATION
-
-The documentation formerly contained in this file has moved into the
-'doc' directory, where it is available in HTML, PDF and plaintext
-forms.
-
-You may also find the latest copy of the documentation on the MySQL
-website at http://dev.mysql.com/doc/refman/5.0/en/connector-j.html
-
---
-This software is OSI Certified Open Source Software.
-OSI Certified is a certification mark of the Open Source Initiative.
+For additional downloads and the source of MySQL Connector/J, visit
+ https://dev.mysql.com/downloads/
+MySQL Connector/J is brought to you by the MySQL team at Oracle.
+Notice:
+- In order to use the logging capabilities provided by the default
+ implementation com.mysql.cj.log.Slf4JLogger, it is required to add one or
+ more jars for Simple Logging Facade for Java (SLF4J) to your CLASSPATH.
+- To use the X DevAPI features in Connector/J, you also need the external
+ library protobuf-java, which you can download manually from the official
+ Maven repository and add it to the CLASSPATH, or use Maven's automatic
+ dependency resolution features by adding a dependency to "GroupId: mysql"
+ and "ArtifactId: mysql-connector-java" to your project's pom.xml file.
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..46a3f00b7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,62 @@
+# MySQL Connector/J
+
+[](https://github.com/mysql/mysql-connector-j/tree/release/8.0/src) [](LICENSE) [](https://search.maven.org/artifact/mysql/mysql-connector-java/8.0.28/jar)
+
+MySQL provides connectivity for client applications developed in the Java programming language with MySQL Connector/J, a driver that implements the [Java Database Connectivity (JDBC) API](https://www.oracle.com/technetwork/java/javase/jdbc/) and also [MySQL X DevAPI](https://dev.mysql.com/doc/x-devapi-userguide/en/).
+
+MySQL Connector/J 8.0 is a JDBC Type 4 driver that is compatible with the [JDBC 4.2](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) specification. The Type 4 designation means that the driver is a pure Java implementation of the MySQL protocol and does not rely on the MySQL client libraries.
+
+The driver also contains an implementation of [MySQL X DevAPI](https://dev.mysql.com/doc/x-devapi-userguide/en/), an application programming interface for working with [MySQL as a Document Store](https://dev.mysql.com/doc/refman/8.0/en/document-store.html) through CRUD-based, NoSQL operations.
+
+For more information, please visit the official [MySQL Connector/J documentation](https://dev.mysql.com/doc/connector-j/8.0/en/).
+
+## Licensing
+
+Please refer to the [README](README) and [LICENSE](LICENSE) files, available in this repository, and the [Legal Notices in the Connector/J documentation](https://dev.mysql.com/doc/connector-j/8.0/en/preface.html) for further details.
+
+## Getting the Latest Release
+
+MySQL Connector/J is free for usage under the terms of the specified licensing and it runs on any operating system that is able to run a Java Virtual Machine.
+
+### Download and Install
+
+MySQL Connector/J can be installed from pre-compiled packages that can be downloaded from the [Connector/J download page](https://dev.mysql.com/downloads/connector/j/). Installing Connector/J only requires obtaining the corresponding JAR file from the downloaded bundle or installer and including it in the application's CLASSPATH.
+
+### As a Maven Dependency
+
+Alternatively, Connector/J can be obtained automatically via [Maven's dependency management](https://search.maven.org/search?q=g:mysql%20AND%20a:mysql-connector-java) by adding the following configuration in the application's Project Object Model (POM) file:
+
+```xml
+
+ mysql
+ mysql-connector-java
+ 8.0.28
+
+```
+
+### Build From Source
+
+This driver can also be complied and installed from the source available in this repository. Please refer to the Connector/J documentation for [detailed instructions](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-installing-source.html) on how to do it.
+
+### GitHub Repository
+
+This repository contains the MySQL Connector/J source code as per the latest release. No changes are made in this repository between releases.
+
+## Contributing
+
+There are a few ways to contribute to the Connector/J code. Please refer to the [contributing guidelines](CONTRIBUTING.md) for additional information.
+
+## Additional Resources
+
+* [MySQL Connector/J Developer Guide](https://dev.mysql.com/doc/connector-j/8.0/en/).
+* [MySQL Connector/J X DevAPI Reference](https://dev.mysql.com/doc/dev/connector-j/8.0/).
+* [MySQL Connector/J, JDBC and Java forum](https://forums.mysql.com/list.php?39).
+* [`#connectors` channel in MySQL Community Slack](https://mysqlcommunity.slack.com/messages/connectors). ([Sign-up](https://lefred.be/mysql-community-on-slack/) required if you do not have an Oracle account.)
+* [@MySQL on Twitter](https://twitter.com/MySQL).
+* [MySQL Blog](https://blogs.oracle.com/mysql/).
+* [MySQL Connectors Blog archive](https://dev.mysql.com/blog-archive/?cat=Connectors%20%2F%20Languages).
+* [MySQL Bugs Database](https://bugs.mysql.com/).
+
+For more information about this and other MySQL products, please visit [MySQL Contact & Questions](https://www.mysql.com/about/contact/).
+
+[](https://twitter.com/intent/follow?screen_name=MySQL)
diff --git a/build.xml b/build.xml
index 84fd517a0..c65df5250 100644
--- a/build.xml
+++ b/build.xml
@@ -1,1252 +1,1610 @@
-
+
+
+
+Compiling Connector/J
+=====================
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
+Connector/J 8.0 supports JDBC4.2 and implements the X DevAPI. This requires JDBC classes to be compiled with Java 8.
+The variable 'com.mysql.cj.build.jdk' is used to find the compiler when building the driver. Side by side with these, the variable 'com.mysql.cj.extra.libs'
+must point to the location of third-party libraries that we don't distribute and are required for compiling. Further details can be found in
+http://dev.mysql.com/doc/connector-j/en/connector-j-installing-source.html.
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
+Targets: "dist", "full-dist", "package", "full-package", "full-package-no-sources", "compile", "install"
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--->
+Testing Connector/J
+===================
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Compiling class files to ${compiler.output}...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- This version of MySQL Connector/J requires a compiler from Java-1.4 or Java-1.5 to be used, set your JAVA_HOME property to point to one of these versions of the JDK.
-
-Compiling this version also requires Java-6 for compiling the JDBC-4.0 implementation, please set the full path to the javac executable with the property "com.mysql.jdbc.java6.javac"
-and the full path to the rt.jar from Java-6 with the property "com.mysql.jdbc.java6.rtjar".
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Removing sources from ${distDir}/toArchive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+Connector/J 8.0 ships with an extensive test suite that can be run simply by providing a MySQL JDBC URL in the variable 'com.mysql.cj.testsuite.url' and by
+calling the target "test". If nothing more is set, these tests run with the JVM referred in the variable 'com.mysql.cj.build.jdk'.
+Alternatively, all tests can be run with a distinct JVM, provided that it is pointed out in the variable 'com.mysql.cj.testsuite.jvm'.
+Running only one test set is possible by setting the variable 'com.mysql.cj.testsuite.test.class' with the class' fully qualified name. If also a comma
+separated list of test names is provided in the variable 'com.mysql.cj.testsuite.test.methods', then only these will be executed.
-
-
-
+Targets: "test"
+
+
+Coverage and instrumentation
+============================
+
+This file ships with target "test-coverage" for collecting coverage results and "report-coverage" for creating the HTML coverage report.
+The JaCoCo library needed to run these targets can be found at https://github.com/jacoco/jacoco, its JARs should be placed
+into ${com.mysql.cj.extra.libs}/jacoco directory.
+The "test-coverage" target enables tests execution-time JaCoCo instrumentation, runs tests collecting coverage info into result file
+which path is set as ${com.mysql.cj.coverage.result.dir}/${com.mysql.cj.coverage.result.name}.
+The "report-coverage" target first merges coverage result files which are placed in 'com.mysql.cj.coverage.result.dir' directory and
+their comma-delimited names are passed via 'com.mysql.cj.coverage.merge.files' property. Merge result file path is passed
+via 'com.mysql.cj.coverage.merge.result' property. Finally this target builds the HTML report from
+'com.mysql.cj.coverage.merge.result' file into the directory passed via 'com.mysql.cj.coverage.report.dir' property.
+If some properties are not passed to ANT script then default values are used:
+ com.mysql.cj.coverage.result.dir - "${com.mysql.cj.testsuite.build.dir}/coverage"
+ com.mysql.cj.coverage.result.name - "jacoco.exec"
+ com.mysql.cj.coverage.merge.files - none, merge step is skipped
+ com.mysql.cj.coverage.merge.result - ${com.mysql.cj.coverage.result.dir}/jacoco.exec
+ com.mysql.cj.coverage.report.dir - ${com.mysql.cj.coverage.result.dir}/report
+
+Targets: "test-coverage", "report-coverage"
+
+
+Generate X DevAPI reference documentation
+=========================================
+
+The target "xdevapi-docs" generates the Javadocs for the X DevAPI classes. The property "com.mysql.cj.docs.xdevapi" can be used to set the destination of the
+Javadoc HTML files.
+
+Targets: "xdevapi-docs"
+
+
+Sample 'build.properties' that can be used to compile, build and test
+=====================================================================
+~~~start cut here~~~
+# Basic settings for 'compile', 'test' and targets that depend on these.
+
+# External libraries needed for both compiling and testing:
+# - Further details in http://dev.mysql.com/doc/connector-j/en/connector-j-installing-source.html
+# - Mandatory.
+com.mysql.cj.extra.libs=<full_path_to_connector-j-jardeps>
+
+# JDKs needed for compiling:
+# - Must point to JDK home directory.
+# - Also used for testing if 'com.mysql.cj.testsuite.jvm' is not provided.
+# - Mandatory.
+com.mysql.cj.build.jdk=<full_path_to_jdk1.8>
+
+# Single JVM/MySQL tests:
+# - Must point to JDK or JRE home directory.
+# - If not provided, JDBC tests are run with 'com.mysql.cj.build.jdk'.
+# - Optional.
+com.mysql.cj.testsuite.jvm=<full_path_to_a_jdk_or_jre>
+# - URL to the test database.
+# - Any of the current MySQL versions.
+# - Mandatory for 'test' target.
+com.mysql.cj.testsuite.url=jdbc:mysql://<host>:<port>/<testDB>?user=<user>&password=<pwd>
+com.mysql.cj.testsuite.mysqlx.url=jdbc:mysql://<user>:<pwd>@<host>:<port>/<testDB>
+
+# Cancels re-compiling between successive test executions.
+# - Comment variable if not needed.
+# - Optional.
+com.mysql.cj.build.noCleanBetweenCompiles=yes
+
+# Other targets may require specific settings. Check 'build.xml' for details.
+~~~end cut here~~~
+
+
+Available build properties
+==========================
+
+build.properties - path to properties file
+
+com.mysql.cj.extra.libs - location of third-party libraries: [${com.mysql.cj.extra.libs}]
+
+com.mysql.cj.build.jdk - path to JDK used for building driver: [${com.mysql.cj.build.jdk}]
+com.mysql.cj.build.addDebugInfo - should the driver be compiled with debugging info: [${com.mysql.cj.build.addDebugInfo}]
+com.mysql.cj.build.noCleanBetweenCompiles - don't clean artifacts from previous build: [_unset_]
+com.mysql.cj.build.failOnWarnings - fail the build when any warning is found: [_unset_]
+com.mysql.cj.build.verbose - log the extended build info: [_unset_]
+
+com.mysql.cj.build.commercial - build commercial variant of the driver: [_unset_]
+com.mysql.cj.build.filterLicense - build ISV variant of the driver: [_unset_]
+com.mysql.cj.build.noCrypto - build the driver without SSL support: [_unset_]
+
+com.mysql.cj.build.driver.version.major - major version: [${com.mysql.cj.build.driver.version.major}]
+com.mysql.cj.build.driver.version.minor - minor version: [${com.mysql.cj.build.driver.version.minor}]
+com.mysql.cj.build.driver.version.subminor - subminor version: [${com.mysql.cj.build.driver.version.subminor}]
+com.mysql.cj.build.driver.version.status - version status, such as '-rc' or '-dmr': [${com.mysql.cj.build.driver.version.status}]
+
+com.mysql.cj.build.driver.version - standard version string (includes version status): [${com.mysql.cj.build.driver.version.numeric}${com.mysql.cj.build.driver.version.status}]
+com.mysql.cj.build.driver.version.series - product series, i.e. x.y: [${com.mysql.cj.build.driver.version.major}.${com.mysql.cj.build.driver.version.minor}]
+com.mysql.cj.build.driver.version.numeric - numeric version, i.e. x.y.z: [${com.mysql.cj.build.driver.version.series}.${com.mysql.cj.build.driver.version.subminor}}
+com.mysql.cj.build.driver.version.extra - optional version information appended to the full version string: [${com.mysql.cj.build.driver.version.extra}]
+com.mysql.cj.build.driver.version.snapshot - optional version snapshot marker: [${com.mysql.cj.build.driver.version.snapshot}]
+com.mysql.cj.build.driver.version.full - full version string: [${com.mysql.cj.build.driver.version}${com.mysql.cj.build.driver.version.extra}${com.mysql.cj.build.driver.version.snapshot}]
+
+com.mysql.cj.build.driver.displayName - product display name: [${com.mysql.cj.build.driver.displayName}]
+com.mysql.cj.build.driver.name - product name: [${com.mysql.cj.build.driver.name}]
+com.mysql.cj.build.driver.extraName - optional extension to product name: [${com.mysql.cj.build.driver.extraName}]
+com.mysql.cj.build.driver.extendedName - final product name: [${com.mysql.cj.build.driver.name}${com.mysql.cj.build.driver.extraName}]
+com.mysql.cj.build.driver.fullName - full product name (includes version): [${com.mysql.cj.build.driver.extendedName}-${com.mysql.cj.build.driver.version.full}]
+
+com.mysql.cj.build.dir - root directory for driver build: [${com.mysql.cj.build.dir}]
+com.mysql.cj.build.dir.driver - driver build dir: [${com.mysql.cj.build.dir}/${com.mysql.cj.build.driver.fullName}]
+
+com.mysql.cj.dist.packageName - final package name: [${com.mysql.cj.build.driver.extendedName}[${com.mysql.cj.dist.packageWithSourcesSuffix}|${com.mysql.cj.dist.packageNoSourcesSuffix}|_none_]-${com.mysql.cj.build.driver.version.full}]
+com.mysql.cj.dist.packageSuffix - suffix added to package name (depends on package type): [${com.mysql.cj.dist.packageWithSourcesSuffix}|${com.mysql.cj.dist.packageNoSourcesSuffix}|_unset_]
+com.mysql.cj.dist.packageWithSourcesSuffix - suffix for packages containing sources if not by default: [${com.mysql.cj.dist.packageWithSourcesSuffix}]
+com.mysql.cj.dist.packageNoSourcesSuffix - suffix for packages not containing sources if not by default: [${com.mysql.cj.dist.packageNoSourcesSuffix}]
+com.mysql.cj.dist.noSources - don't include sources into dist packages: [_unset]
+com.mysql.cj.dist.noMavenSources - don't include sources into Maven package: [_unset_]
+com.mysql.cj.dist.licenseUrl - license book location: [${com.mysql.cj.dist.licenseUrl}]
+
+com.mysql.cj.dist.dir - root directory for driver packaging: [${com.mysql.cj.dist.dir}]
+com.mysql.cj.dist.dir.prepare - directory for preparing packages: [${com.mysql.cj.dist.dir.prepare}]
+com.mysql.cj.dist.dir.package - directory for preparing packages for given package name: [${com.mysql.cj.dist.dir.prepare}/${com.mysql.cj.build.driver.extendedName}[${com.mysql.cj.dist.packageWithSourcesSuffix}|${com.mysql.cj.dist.packageNoSourcesSuffix}|_none_]-${com.mysql.cj.build.driver.version.full}]
+com.mysql.cj.dist.dir.maven - directory for preparing Maven packages: [${com.mysql.cj.dist.dir.prepare}/${com.mysql.cj.build.driver.extendedName}[${com.mysql.cj.dist.packageWithSourcesSuffix}|${com.mysql.cj.dist.packageNoSourcesSuffix}|_none_]-${com.mysql.cj.build.driver.version.full}-maven-bundle]
+com.mysql.cj.dist.dir.prebuilt.docs - where to take prebuilt documentation files for adding them to packages: [${com.mysql.cj.dist.dir.prebuilt.docs}]
+
+com.mysql.cj.dist.deb.maintainerEmail - the deb package maintainer email: [${com.mysql.cj.dist.deb.maintainerEmail}]
+
+com.mysql.cj.docs.xdevapi - destination of the X DevAPI Javadoc HTML files.: [docs]
+
+Available test properties
+=========================
+
+com.mysql.cj.testsuite.build.dir - root directory for building testsuite, default '${com.mysql.cj.testsuite.build.dir}'
+com.mysql.cj.testsuite.junit.results - where to put junit reports, default '${com.mysql.cj.testsuite.junit.results}'
+com.mysql.cj.testsuite.jvm - run testsuite under this one JVM, default '${com.mysql.cj.testsuite.jvm}'
+com.mysql.cj.testsuite.url - connection string to the main test server, default _unset_
+com.mysql.cj.testsuite.mysqlx.url - connection string to the test server with xplugin, default _unset_
+com.mysql.cj.testsuite.test.class - testcase class name to run, default _unset_
+com.mysql.cj.testsuite.test.methods - a comma separated list of test names existing in class defined by 'com.mysql.cj.testsuite.test.class', default _unset_
+com.mysql.cj.testsuite.unavailable.host - a host:port pair used for tests checking socket connection timeout
+
+See also com.mysql.cj.conf.PropertyDefinitions.SYSP_* variables for other test options.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ build-date: ${com.mysql.cj.build.time}${line.separator}
+ os-info: ${os.name} ${os.arch} ${os.version}${line.separator}
+ compiler: ${com.mysql.cj.dist.jdk.compilerVersion}${line.separator}
+ build-tool: ${ant.version}${line.separator}
+
+
+ ## INFO_BIN ##${line.separator}${com.mysql.cj.build.infoBinFromFile}
+
+
+ version: ${com.mysql.cj.build.driver.version.full}${line.separator}
+ branch: ${com.mysql.cj.build.git.branch}${line.separator}
+ date: ${com.mysql.cj.build.git.date}${line.separator}
+ commit: ${com.mysql.cj.build.git.commit}${line.separator}
+ short: ${com.mysql.cj.build.git.short}${line.separator}
+
+
+ ## INFO_SRC ##${line.separator}${com.mysql.cj.build.infoSrcFromFile}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Removing sources from '${com.mysql.cj.dist.dir.prepare}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Compiling MySQL Connector/J JDBC implementation with '${com.mysql.cj.build.jdk}' to '${com.mysql.cj.build.compiler.output}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Compiling MySQL Connector/J testsuite with '${com.mysql.cj.build.jdk}' to '${com.mysql.cj.testsuite.compiler.output}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Compiling MySQL Connector/J-c3p0 integration with '${com.mysql.cj.build.jdk}' to '${com.mysql.cj.build.compiler.output}'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${com.mysql.cj.testsuite.message.test.mode}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Using Commercial settings
+
+
+
+
+
+
+
+ Using GPL settings
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/build/java/documentation/ErrorMappingsDocGenerator.java b/src/build/java/documentation/ErrorMappingsDocGenerator.java
new file mode 100644
index 000000000..a6a0a2e88
--- /dev/null
+++ b/src/build/java/documentation/ErrorMappingsDocGenerator.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2002, 2020, Oracle and/or its affiliates.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 2.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is also distributed with certain software (including but not
+ * limited to OpenSSL) that is licensed under separate terms, as designated in a
+ * particular file or component or in included license documentation. The
+ * authors of MySQL hereby grant you an additional permission to link the
+ * program and your derivative works with the separately licensed software that
+ * they have included with MySQL.
+ *
+ * Without limiting anything contained in the foregoing, this file, which is
+ * part of MySQL Connector/J, is also subject to the Universal FOSS Exception,
+ * version 1.0, a copy of which can be found at
+ * http://oss.oracle.com/licenses/universal-foss-exception.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package documentation;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+import com.mysql.cj.exceptions.MysqlErrorNumbers;
+
+/**
+ * Creates XML file describing mapping of MySQL error #'s to SQL92 and X/Open states.
+ */
+public class ErrorMappingsDocGenerator {
+
+ public static void main(String[] args) throws Exception {
+ dumpSqlStatesMappingsAsXml();
+ }
+
+ public static void dumpSqlStatesMappingsAsXml() throws Exception {
+ TreeMap allErrorNumbers = new TreeMap<>();
+ Map
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name; "" retrieves those without a schema
- * @param table
- * a table name
- * @param scope
- * the scope of interest; use same values as SCOPE
- * @param nullable
- * include columns that are nullable?
- * @return ResultSet each row is a column description
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getBestRowIdentifier(String catalog,
- String schema, final String table, int scope, boolean nullable)
- throws SQLException {
- if (table == null) {
- throw SQLError.createSQLException("Table not specified.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- Field[] fields = new Field[8];
- fields[0] = new Field("", "SCOPE", Types.SMALLINT, 5);
- fields[1] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
- fields[2] = new Field("", "DATA_TYPE", Types.INTEGER, 32);
- fields[3] = new Field("", "TYPE_NAME", Types.CHAR, 32);
- fields[4] = new Field("", "COLUMN_SIZE", Types.INTEGER, 10);
- fields[5] = new Field("", "BUFFER_LENGTH", Types.INTEGER, 10);
- fields[6] = new Field("", "DECIMAL_DIGITS", Types.SMALLINT, 10);
- fields[7] = new Field("", "PSEUDO_COLUMN", Types.SMALLINT, 5);
-
- final ArrayList rows = new ArrayList();
- final Statement stmt = this.conn.getMetadataSafeStatement();
-
- try {
-
- new IterateBlock(getCatalogIterator(catalog)) {
- void forEach(Object catalogStr) throws SQLException {
- ResultSet results = null;
-
- try {
- StringBuffer queryBuf = new StringBuffer(
- "SHOW COLUMNS FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(table);
- queryBuf.append(quotedId);
- queryBuf.append(" FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(catalogStr.toString());
- queryBuf.append(quotedId);
-
- results = stmt.executeQuery(queryBuf.toString());
-
- while (results.next()) {
- String keyType = results.getString("Key");
-
- if (keyType != null) {
- if (StringUtils.startsWithIgnoreCase(keyType,
- "PRI")) {
- byte[][] rowVal = new byte[8][];
- rowVal[0] = Integer
- .toString(
- java.sql.DatabaseMetaData.bestRowSession)
- .getBytes();
- rowVal[1] = results.getBytes("Field");
-
- String type = results.getString("Type");
- int size = MysqlIO.getMaxBuf();
- int decimals = 0;
-
- /*
- * Parse the Type column from MySQL
- */
- if (type.indexOf("enum") != -1) {
- String temp = type.substring(type
- .indexOf("("), type
- .indexOf(")"));
- java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(
- temp, ",");
- int maxLength = 0;
-
- while (tokenizer.hasMoreTokens()) {
- maxLength = Math.max(maxLength,
- (tokenizer.nextToken()
- .length() - 2));
- }
-
- size = maxLength;
- decimals = 0;
- type = "enum";
- } else if (type.indexOf("(") != -1) {
- if (type.indexOf(",") != -1) {
- size = Integer.parseInt(type
- .substring(type
- .indexOf("(") + 1,
- type.indexOf(",")));
- decimals = Integer.parseInt(type
- .substring(type
- .indexOf(",") + 1,
- type.indexOf(")")));
- } else {
- size = Integer.parseInt(type
- .substring(type
- .indexOf("(") + 1,
- type.indexOf(")")));
- }
-
- type = type.substring(0, type
- .indexOf("("));
- }
-
- rowVal[2] = s2b(String.valueOf(MysqlDefs
- .mysqlToJavaType(type)));
- rowVal[3] = s2b(type);
- rowVal[4] = Integer.toString(
- size + decimals).getBytes();
- rowVal[5] = Integer.toString(
- size + decimals).getBytes();
- rowVal[6] = Integer.toString(decimals)
- .getBytes();
- rowVal[7] = Integer
- .toString(
- java.sql.DatabaseMetaData.bestRowNotPseudo)
- .getBytes();
-
- rows.add(new ByteArrayRow(rowVal, getExceptionInterceptor()));
- }
- }
- }
- } catch (SQLException sqlEx) {
- if (!SQLError.SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND.equals(sqlEx.getSQLState())) {
- throw sqlEx;
- }
- } finally {
- if (results != null) {
- try {
- results.close();
- } catch (Exception ex) {
- ;
- }
-
- results = null;
- }
- }
- }
- }.doForAll();
- } finally {
- if (stmt != null) {
- stmt.close();
- }
- }
-
- java.sql.ResultSet results = buildResultSet(fields, rows);
-
- return results;
-
- }
-
- /*
- * * Each row in the ResultSet is a parameter desription or column
- * description with the following fields:
PROCEDURE_CAT
- * String => procedure catalog (may be null)
PROCEDURE_SCHEM
- * String => procedure schema (may be null)
PROCEDURE_NAME
- * String => procedure name
COLUMN_NAME String =>
- * column/parameter name
COLUMN_TYPE Short => kind of
- * column/parameter:
procedureColumnUnknown - nobody knows
- *
procedureColumnIn - IN parameter
procedureColumnInOut -
- * INOUT parameter
procedureColumnOut - OUT parameter
- * procedureColumnReturn - procedure return value
- * procedureColumnResult - result column in ResultSet
- * DATA_TYPE short => SQL type from java.sql.Types
Note: Some databases may not return the column
- * descriptions for a procedure. Additional columns beyond REMARKS can be
- * defined by the database.
@param catalog a catalog name; "" retrieves
- * those without a catalog @param schemaPattern a schema name pattern; ""
- * retrieves those without a schema @param procedureNamePattern a procedure
- * name pattern @param columnNamePattern a column name pattern @return
- * ResultSet each row is a stored procedure parameter or column description
- * @throws SQLException if a database access error occurs
- *
- * @see #getSearchStringEscape
- */
- private void getCallStmtParameterTypes(String catalog, String procName,
- String parameterNamePattern, List resultRows) throws SQLException {
- getCallStmtParameterTypes(catalog, procName,
- parameterNamePattern, resultRows, false);
- }
-
- private void getCallStmtParameterTypes(String catalog, String procName,
- String parameterNamePattern, List resultRows,
- boolean forGetFunctionColumns) throws SQLException {
- java.sql.Statement paramRetrievalStmt = null;
- java.sql.ResultSet paramRetrievalRs = null;
-
- if (parameterNamePattern == null) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- parameterNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Parameter/Column name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- byte[] procNameAsBytes = null;
-
- try {
- procNameAsBytes = procName.getBytes("UTF-8");
- } catch (UnsupportedEncodingException ueEx) {
- procNameAsBytes = s2b(procName);
-
- // Set all fields to connection encoding
- }
-
- String quoteChar = getIdentifierQuoteString();
-
- String parameterDef = null;
-
- boolean isProcedureInAnsiMode = false;
- String storageDefnDelims = null;
- String storageDefnClosures = null;
-
- try {
- paramRetrievalStmt = this.conn.getMetadataSafeStatement();
-
- if (this.conn.lowerCaseTableNames() && catalog != null
- && catalog.length() != 0) {
- // Workaround for bug in server wrt. to
- // SHOW CREATE PROCEDURE not respecting
- // lower-case table names
-
- String oldCatalog = this.conn.getCatalog();
- ResultSet rs = null;
-
- try {
- this.conn.setCatalog(catalog);
- rs = paramRetrievalStmt.executeQuery("SELECT DATABASE()");
- rs.next();
-
- catalog = rs.getString(1);
-
- } finally {
-
- this.conn.setCatalog(oldCatalog);
-
- if (rs != null) {
- rs.close();
- }
- }
- }
-
- if (paramRetrievalStmt.getMaxRows() != 0) {
- paramRetrievalStmt.setMaxRows(0);
- }
-
- int dotIndex = -1;
-
- if (!" ".equals(quoteChar)) {
- dotIndex = StringUtils.indexOfIgnoreCaseRespectQuotes(0,
- procName, ".", quoteChar.charAt(0), !this.conn
- .isNoBackslashEscapesSet());
- } else {
- dotIndex = procName.indexOf(".");
- }
-
- String dbName = null;
-
- if (dotIndex != -1 && (dotIndex + 1) < procName.length()) {
- dbName = procName.substring(0, dotIndex);
- procName = procName.substring(dotIndex + 1);
- } else {
- dbName = catalog;
- }
-
- StringBuffer procNameBuf = new StringBuffer();
-
- if (dbName != null) {
- if (!" ".equals(quoteChar) && !dbName.startsWith(quoteChar)) {
- procNameBuf.append(quoteChar);
- }
-
- procNameBuf.append(dbName);
-
- if (!" ".equals(quoteChar) && !dbName.startsWith(quoteChar)) {
- procNameBuf.append(quoteChar);
- }
-
- procNameBuf.append(".");
- }
-
- boolean procNameIsNotQuoted = !procName.startsWith(quoteChar);
-
- if (!" ".equals(quoteChar) && procNameIsNotQuoted) {
- procNameBuf.append(quoteChar);
- }
-
- procNameBuf.append(procName);
-
- if (!" ".equals(quoteChar) && procNameIsNotQuoted) {
- procNameBuf.append(quoteChar);
- }
-
- boolean parsingFunction = false;
-
- try {
- paramRetrievalRs = paramRetrievalStmt
- .executeQuery("SHOW CREATE PROCEDURE "
- + procNameBuf.toString());
- parsingFunction = false;
- } catch (SQLException sqlEx) {
- paramRetrievalRs = paramRetrievalStmt
- .executeQuery("SHOW CREATE FUNCTION "
- + procNameBuf.toString());
- parsingFunction = true;
- }
-
- if (paramRetrievalRs.next()) {
- String procedureDef = parsingFunction ? paramRetrievalRs
- .getString("Create Function") : paramRetrievalRs
- .getString("Create Procedure");
-
- if (procedureDef == null || procedureDef.length() == 0) {
- throw SQLError.createSQLException("User does not have access to metadata required to determine " +
- "stored procedure parameter types. If rights can not be granted, configure connection with \"noAccessToProcedureBodies=true\" " +
- "to have driver generate parameters that represent INOUT strings irregardless of actual parameter types.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- try {
- String sqlMode = paramRetrievalRs.getString("sql_mode");
-
- if (StringUtils.indexOfIgnoreCase(sqlMode, "ANSI") != -1) {
- isProcedureInAnsiMode = true;
- }
- } catch (SQLException sqlEx) {
- // doesn't exist
- }
-
- String identifierMarkers = isProcedureInAnsiMode ? "`\"" : "`";
- String identifierAndStringMarkers = "'" + identifierMarkers;
- storageDefnDelims = "(" + identifierMarkers;
- storageDefnClosures = ")" + identifierMarkers;
-
- // sanitize/normalize by stripping out comments
- procedureDef = StringUtils.stripComments(procedureDef,
- identifierAndStringMarkers, identifierAndStringMarkers, true, false, true, true);
-
- int openParenIndex = StringUtils
- .indexOfIgnoreCaseRespectQuotes(0, procedureDef, "(",
- quoteChar.charAt(0), !this.conn
- .isNoBackslashEscapesSet());
- int endOfParamDeclarationIndex = 0;
-
- endOfParamDeclarationIndex = endPositionOfParameterDeclaration(
- openParenIndex, procedureDef, quoteChar);
-
- if (parsingFunction) {
-
- // Grab the return column since it needs
- // to go first in the output result set
- int returnsIndex = StringUtils
- .indexOfIgnoreCaseRespectQuotes(0, procedureDef,
- " RETURNS ", quoteChar.charAt(0),
- !this.conn.isNoBackslashEscapesSet());
-
- int endReturnsDef = findEndOfReturnsClause(procedureDef,
- quoteChar, returnsIndex);
-
- // Trim off whitespace after "RETURNS"
-
- int declarationStart = returnsIndex + "RETURNS ".length();
-
- while (declarationStart < procedureDef.length()) {
- if (Character.isWhitespace(procedureDef.charAt(declarationStart))) {
- declarationStart++;
- } else {
- break;
- }
- }
-
- String returnsDefn = procedureDef.substring(declarationStart, endReturnsDef).trim();
- TypeDescriptor returnDescriptor = new TypeDescriptor(
- returnsDefn, null);
-
- resultRows.add(convertTypeDescriptorToProcedureRow(
- procNameAsBytes, "", false, false, true,
- returnDescriptor, forGetFunctionColumns, 0));
- }
-
- if ((openParenIndex == -1)
- || (endOfParamDeclarationIndex == -1)) {
- // parse error?
- throw SQLError
- .createSQLException(
- "Internal error when parsing callable statement metadata",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- parameterDef = procedureDef.substring(openParenIndex + 1,
- endOfParamDeclarationIndex);
- }
- } finally {
- SQLException sqlExRethrow = null;
-
- if (paramRetrievalRs != null) {
- try {
- paramRetrievalRs.close();
- } catch (SQLException sqlEx) {
- sqlExRethrow = sqlEx;
- }
-
- paramRetrievalRs = null;
- }
-
- if (paramRetrievalStmt != null) {
- try {
- paramRetrievalStmt.close();
- } catch (SQLException sqlEx) {
- sqlExRethrow = sqlEx;
- }
-
- paramRetrievalStmt = null;
- }
-
- if (sqlExRethrow != null) {
- throw sqlExRethrow;
- }
- }
-
- if (parameterDef != null) {
- int ordinal = 1;
-
- List parseList = StringUtils.split(parameterDef, ",",
- storageDefnDelims, storageDefnClosures, true);
-
- int parseListLen = parseList.size();
-
- for (int i = 0; i < parseListLen; i++) {
- String declaration = (String) parseList.get(i);
-
- if (declaration.trim().length() == 0) {
- break; // no parameters actually declared, but whitespace spans lines
- }
-
- StringTokenizer declarationTok = new StringTokenizer(
- declaration, " \t");
-
- String paramName = null;
- boolean isOutParam = false;
- boolean isInParam = false;
-
- if (declarationTok.hasMoreTokens()) {
- String possibleParamName = declarationTok.nextToken();
-
- if (possibleParamName.equalsIgnoreCase("OUT")) {
- isOutParam = true;
-
- if (declarationTok.hasMoreTokens()) {
- paramName = declarationTok.nextToken();
- } else {
- throw SQLError.createSQLException(
- "Internal error when parsing callable statement metadata (missing parameter name)",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- } else if (possibleParamName.equalsIgnoreCase("INOUT")) {
- isOutParam = true;
- isInParam = true;
-
- if (declarationTok.hasMoreTokens()) {
- paramName = declarationTok.nextToken();
- } else {
- throw SQLError.createSQLException(
- "Internal error when parsing callable statement metadata (missing parameter name)",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- } else if (possibleParamName.equalsIgnoreCase("IN")) {
- isOutParam = false;
- isInParam = true;
-
- if (declarationTok.hasMoreTokens()) {
- paramName = declarationTok.nextToken();
- } else {
- throw SQLError.createSQLException(
- "Internal error when parsing callable statement metadata (missing parameter name)",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- } else {
- isOutParam = false;
- isInParam = true;
-
- paramName = possibleParamName;
- }
-
- TypeDescriptor typeDesc = null;
-
- if (declarationTok.hasMoreTokens()) {
- StringBuffer typeInfoBuf = new StringBuffer(
- declarationTok.nextToken());
-
- while (declarationTok.hasMoreTokens()) {
- typeInfoBuf.append(" ");
- typeInfoBuf.append(declarationTok.nextToken());
- }
-
- String typeInfo = typeInfoBuf.toString();
-
- typeDesc = new TypeDescriptor(typeInfo, null);
- } else {
- throw SQLError.createSQLException(
- "Internal error when parsing callable statement metadata (missing parameter type)",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- if ((paramName.startsWith("`") && paramName.endsWith("`")) ||
- (isProcedureInAnsiMode && paramName.startsWith("\"") && paramName.endsWith("\""))) {
- paramName = paramName.substring(1, paramName.length() - 1);
- }
-
- int wildCompareRes = StringUtils.wildCompare(paramName,
- parameterNamePattern);
-
- if (wildCompareRes != StringUtils.WILD_COMPARE_NO_MATCH) {
- ResultSetRow row = convertTypeDescriptorToProcedureRow(
- procNameAsBytes, paramName, isOutParam,
- isInParam, false, typeDesc, forGetFunctionColumns,
- ordinal++);
-
- resultRows.add(row);
- }
- } else {
- throw SQLError.createSQLException(
- "Internal error when parsing callable statement metadata (unknown output from 'SHOW CREATE PROCEDURE')",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
- } else {
- // Is this an error? JDBC spec doesn't make it clear if stored
- // procedure doesn't
- // exist, is it an error....
- }
- }
- /**
- * Finds the end of the parameter declaration from the output of "SHOW
- * CREATE PROCEDURE".
- *
- * @param beginIndex
- * should be the index of the procedure body that contains the
- * first "(".
- * @param procedureDef
- * the procedure body
- * @param quoteChar
- * the identifier quote character in use
- * @return the ending index of the parameter declaration, not including the
- * closing ")"
- * @throws SQLException
- * if a parse error occurs.
- */
- private int endPositionOfParameterDeclaration(int beginIndex,
- String procedureDef, String quoteChar) throws SQLException {
- int currentPos = beginIndex + 1;
- int parenDepth = 1; // counting the first openParen
-
- while (parenDepth > 0 && currentPos < procedureDef.length()) {
- int closedParenIndex = StringUtils.indexOfIgnoreCaseRespectQuotes(
- currentPos, procedureDef, ")", quoteChar.charAt(0),
- !this.conn.isNoBackslashEscapesSet());
-
- if (closedParenIndex != -1) {
- int nextOpenParenIndex = StringUtils
- .indexOfIgnoreCaseRespectQuotes(currentPos,
- procedureDef, "(", quoteChar.charAt(0),
- !this.conn.isNoBackslashEscapesSet());
-
- if (nextOpenParenIndex != -1
- && nextOpenParenIndex < closedParenIndex) {
- parenDepth++;
- currentPos = closedParenIndex + 1; // set after closed
- // paren that increases
- // depth
- } else {
- parenDepth--;
- currentPos = closedParenIndex; // start search from same
- // position
- }
- } else {
- // we should always get closed paren of some sort
- throw SQLError
- .createSQLException(
- "Internal error when parsing callable statement metadata",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- return currentPos;
- }
-
- /**
- * Finds the end of the RETURNS clause for SQL Functions by using any of the
- * keywords allowed after the RETURNS clause, or a label.
- *
- * @param procedureDefn
- * the function body containing the definition of the function
- * @param quoteChar
- * the identifier quote string in use
- * @param positionOfReturnKeyword
- * the position of "RETRUNS" in the definition
- * @return the end of the returns clause
- * @throws SQLException
- * if a parse error occurs
- */
- private int findEndOfReturnsClause(String procedureDefn, String quoteChar,
- int positionOfReturnKeyword) throws SQLException {
- /*
- * characteristic: LANGUAGE SQL | [NOT] DETERMINISTIC | { CONTAINS SQL |
- * NO SQL | READS SQL DATA | MODIFIES SQL DATA } | SQL SECURITY {
- * DEFINER | INVOKER } | COMMENT 'string'
- */
-
- String[] tokens = new String[] { "LANGUAGE", "NOT", "DETERMINISTIC",
- "CONTAINS", "NO", "READ", "MODIFIES", "SQL", "COMMENT", "BEGIN",
- "RETURN" };
-
- int startLookingAt = positionOfReturnKeyword + "RETURNS".length() + 1;
-
- int endOfReturn = -1;
-
- for (int i = 0; i < tokens.length; i++) {
- int nextEndOfReturn = StringUtils.indexOfIgnoreCaseRespectQuotes(
- startLookingAt, procedureDefn, tokens[i], quoteChar
- .charAt(0), !this.conn.isNoBackslashEscapesSet());
-
- if (nextEndOfReturn != -1) {
- if (endOfReturn == -1 || (nextEndOfReturn < endOfReturn)) {
- endOfReturn = nextEndOfReturn;
- }
- }
- }
-
- if (endOfReturn != -1) {
- return endOfReturn;
- }
-
- // Label?
- endOfReturn = StringUtils.indexOfIgnoreCaseRespectQuotes(
- startLookingAt, procedureDefn, ":", quoteChar.charAt(0),
- !this.conn.isNoBackslashEscapesSet());
-
- if (endOfReturn != -1) {
- // seek back until whitespace
- for (int i = endOfReturn; i > 0; i--) {
- if (Character.isWhitespace(procedureDefn.charAt(i))) {
- return i;
- }
- }
- }
-
- // We can't parse it.
-
- throw SQLError.createSQLException(
- "Internal error when parsing callable statement metadata",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- /**
- * Parses the cascade option string and returns the DBMD constant that
- * represents it (for deletes)
- *
- * @param cascadeOptions
- * the comment from 'SHOW TABLE STATUS'
- * @return the DBMD constant that represents the cascade option
- */
- private int getCascadeDeleteOption(String cascadeOptions) {
- int onDeletePos = cascadeOptions.indexOf("ON DELETE");
-
- if (onDeletePos != -1) {
- String deleteOptions = cascadeOptions.substring(onDeletePos,
- cascadeOptions.length());
-
- if (deleteOptions.startsWith("ON DELETE CASCADE")) {
- return java.sql.DatabaseMetaData.importedKeyCascade;
- } else if (deleteOptions.startsWith("ON DELETE SET NULL")) {
- return java.sql.DatabaseMetaData.importedKeySetNull;
- } else if (deleteOptions.startsWith("ON DELETE RESTRICT")) {
- return java.sql.DatabaseMetaData.importedKeyRestrict;
- } else if (deleteOptions.startsWith("ON DELETE NO ACTION")) {
- return java.sql.DatabaseMetaData.importedKeyNoAction;
- }
- }
-
- return java.sql.DatabaseMetaData.importedKeyNoAction;
- }
-
- /**
- * Parses the cascade option string and returns the DBMD constant that
- * represents it (for Updates)
- *
- * @param cascadeOptions
- * the comment from 'SHOW TABLE STATUS'
- * @return the DBMD constant that represents the cascade option
- */
- private int getCascadeUpdateOption(String cascadeOptions) {
- int onUpdatePos = cascadeOptions.indexOf("ON UPDATE");
-
- if (onUpdatePos != -1) {
- String updateOptions = cascadeOptions.substring(onUpdatePos,
- cascadeOptions.length());
-
- if (updateOptions.startsWith("ON UPDATE CASCADE")) {
- return java.sql.DatabaseMetaData.importedKeyCascade;
- } else if (updateOptions.startsWith("ON UPDATE SET NULL")) {
- return java.sql.DatabaseMetaData.importedKeySetNull;
- } else if (updateOptions.startsWith("ON UPDATE RESTRICT")) {
- return java.sql.DatabaseMetaData.importedKeyRestrict;
- } else if (updateOptions.startsWith("ON UPDATE NO ACTION")) {
- return java.sql.DatabaseMetaData.importedKeyNoAction;
- }
- }
-
- return java.sql.DatabaseMetaData.importedKeyNoAction;
- }
-
- protected IteratorWithCleanup getCatalogIterator(String catalogSpec)
- throws SQLException {
- IteratorWithCleanup allCatalogsIter;
- if (catalogSpec != null) {
- if (!catalogSpec.equals("")) {
- allCatalogsIter = new SingleStringIterator(catalogSpec);
- } else {
- // legacy mode of operation
- allCatalogsIter = new SingleStringIterator(this.database);
- }
- } else if (this.conn.getNullCatalogMeansCurrent()) {
- allCatalogsIter = new SingleStringIterator(this.database);
- } else {
- allCatalogsIter = new ResultSetIterator(getCatalogs(), 1);
- }
-
- return allCatalogsIter;
- }
-
- /**
- * Get the catalog names available in this database. The results are ordered
- * by catalog name.
- *
- * The catalog column is:
- *
- *
TABLE_CAT String => catalog name
- *
- *
- *
- * @return ResultSet each row has a single String column that is a catalog
- * name
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getCatalogs() throws SQLException {
- java.sql.ResultSet results = null;
- java.sql.Statement stmt = null;
-
- try {
- stmt = this.conn.createStatement();
- stmt.setEscapeProcessing(false);
- results = stmt.executeQuery("SHOW DATABASES");
-
- java.sql.ResultSetMetaData resultsMD = results.getMetaData();
- Field[] fields = new Field[1];
- fields[0] = new Field("", "TABLE_CAT", Types.VARCHAR, resultsMD
- .getColumnDisplaySize(1));
-
- ArrayList tuples = new ArrayList();
-
- while (results.next()) {
- byte[][] rowVal = new byte[1][];
- rowVal[0] = results.getBytes(1);
- tuples.add(new ByteArrayRow(rowVal, getExceptionInterceptor()));
- }
-
- return buildResultSet(fields, tuples);
- } finally {
- if (results != null) {
- try {
- results.close();
- } catch (SQLException sqlEx) {
- AssertionFailedException.shouldNotHappen(sqlEx);
- }
-
- results = null;
- }
-
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException sqlEx) {
- AssertionFailedException.shouldNotHappen(sqlEx);
- }
-
- stmt = null;
- }
- }
- }
-
- /**
- * What's the separator between catalog and table name?
- *
- * @return the separator string
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getCatalogSeparator() throws SQLException {
- return ".";
- }
-
- // ----------------------------------------------------------------------
- // The following group of methods exposes various limitations
- // based on the target database with the current driver.
- // Unless otherwise specified, a result of zero means there is no
- // limit, or the limit is not known.
-
- /**
- * What's the database vendor's preferred term for "catalog"?
- *
- * @return the vendor term
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getCatalogTerm() throws SQLException {
- return "database";
- }
-
- /**
- * Get a description of the access rights for a table's columns.
- *
- * Only privileges matching the column name criteria are returned. They are
- * ordered by COLUMN_NAME and PRIVILEGE.
- *
- *
- * Each privilige description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
COLUMN_NAME String => column name
- *
GRANTOR => grantor of access (may be null)
- *
GRANTEE String => grantee of access
- *
PRIVILEGE String => name of access (SELECT, INSERT, UPDATE,
- * REFRENCES, ...)
- *
IS_GRANTABLE String => "YES" if grantee is permitted to
- * grant to others; "NO" if not; null if unknown
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name; "" retrieves those without a schema
- * @param table
- * a table name
- * @param columnNamePattern
- * a column name pattern
- * @return ResultSet each row is a column privilege description
- * @throws SQLException
- * if a database access error occurs
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getColumnPrivileges(String catalog,
- String schema, String table, String columnNamePattern)
- throws SQLException {
- Field[] fields = new Field[8];
- fields[0] = new Field("", "TABLE_CAT", Types.CHAR, 64);
- fields[1] = new Field("", "TABLE_SCHEM", Types.CHAR, 1);
- fields[2] = new Field("", "TABLE_NAME", Types.CHAR, 64);
- fields[3] = new Field("", "COLUMN_NAME", Types.CHAR, 64);
- fields[4] = new Field("", "GRANTOR", Types.CHAR, 77);
- fields[5] = new Field("", "GRANTEE", Types.CHAR, 77);
- fields[6] = new Field("", "PRIVILEGE", Types.CHAR, 64);
- fields[7] = new Field("", "IS_GRANTABLE", Types.CHAR, 3);
-
- StringBuffer grantQuery = new StringBuffer(
- "SELECT c.host, c.db, t.grantor, c.user, "
- + "c.table_name, c.column_name, c.column_priv "
- + "from mysql.columns_priv c, mysql.tables_priv t "
- + "where c.host = t.host and c.db = t.db and "
- + "c.table_name = t.table_name ");
-
- if ((catalog != null) && (catalog.length() != 0)) {
- grantQuery.append(" AND c.db='");
- grantQuery.append(catalog);
- grantQuery.append("' ");
- ;
- }
-
- grantQuery.append(" AND c.table_name ='");
- grantQuery.append(table);
- grantQuery.append("' AND c.column_name like '");
- grantQuery.append(columnNamePattern);
- grantQuery.append("'");
-
- Statement stmt = null;
- ResultSet results = null;
- ArrayList grantRows = new ArrayList();
-
- try {
- stmt = this.conn.createStatement();
- stmt.setEscapeProcessing(false);
- results = stmt.executeQuery(grantQuery.toString());
-
- while (results.next()) {
- String host = results.getString(1);
- String db = results.getString(2);
- String grantor = results.getString(3);
- String user = results.getString(4);
-
- if ((user == null) || (user.length() == 0)) {
- user = "%";
- }
-
- StringBuffer fullUser = new StringBuffer(user);
-
- if ((host != null) && this.conn.getUseHostsInPrivileges()) {
- fullUser.append("@");
- fullUser.append(host);
- }
-
- String columnName = results.getString(6);
- String allPrivileges = results.getString(7);
-
- if (allPrivileges != null) {
- allPrivileges = allPrivileges.toUpperCase(Locale.ENGLISH);
-
- StringTokenizer st = new StringTokenizer(allPrivileges, ",");
-
- while (st.hasMoreTokens()) {
- String privilege = st.nextToken().trim();
- byte[][] tuple = new byte[8][];
- tuple[0] = s2b(db);
- tuple[1] = null;
- tuple[2] = s2b(table);
- tuple[3] = s2b(columnName);
-
- if (grantor != null) {
- tuple[4] = s2b(grantor);
- } else {
- tuple[4] = null;
- }
-
- tuple[5] = s2b(fullUser.toString());
- tuple[6] = s2b(privilege);
- tuple[7] = null;
- grantRows.add(new ByteArrayRow(tuple, getExceptionInterceptor()));
- }
- }
- }
- } finally {
- if (results != null) {
- try {
- results.close();
- } catch (Exception ex) {
- ;
- }
-
- results = null;
- }
-
- if (stmt != null) {
- try {
- stmt.close();
- } catch (Exception ex) {
- ;
- }
-
- stmt = null;
- }
- }
-
- return buildResultSet(fields, grantRows);
- }
-
- /**
- * Get a description of table columns available in a catalog.
- *
- * Only column descriptions matching the catalog, schema, table and column
- * name criteria are returned. They are ordered by TABLE_SCHEM, TABLE_NAME
- * and ORDINAL_POSITION.
- *
- *
- * Each column description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
COLUMN_NAME String => column name
- *
DATA_TYPE short => SQL type from java.sql.Types
- *
TYPE_NAME String => Data source dependent type name
- *
COLUMN_SIZE int => column size. For char or date types this
- * is the maximum number of characters, for numeric or decimal types this is
- * precision.
- *
BUFFER_LENGTH is not used.
- *
DECIMAL_DIGITS int => the number of fractional digits
- *
NUM_PREC_RADIX int => Radix (typically either 10 or 2)
CHAR_OCTET_LENGTH int => for char types the maximum number
- * of bytes in the column
- *
ORDINAL_POSITION int => index of column in table (starting
- * at 1)
- *
IS_NULLABLE String => "NO" means column definitely does not
- * allow NULL values; "YES" means the column might allow NULL values. An
- * empty string means nobody knows.
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schemaPattern
- * a schema name pattern; "" retrieves those without a schema
- * @param tableNamePattern
- * a table name pattern
- * @param columnNamePattern
- * a column name pattern
- * @return ResultSet each row is a column description
- * @throws SQLException
- * if a database access error occurs
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getColumns(final String catalog,
- final String schemaPattern, final String tableNamePattern,
- String columnNamePattern) throws SQLException {
-
- if (columnNamePattern == null) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- columnNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Column name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- final String colPattern = columnNamePattern;
-
- Field[] fields = createColumnsFields();
-
- final ArrayList rows = new ArrayList();
- final Statement stmt = this.conn.getMetadataSafeStatement();
-
- try {
-
- new IterateBlock(getCatalogIterator(catalog)) {
- void forEach(Object catalogStr) throws SQLException {
-
- ArrayList tableNameList = new ArrayList();
-
- if (tableNamePattern == null) {
- // Select from all tables
- java.sql.ResultSet tables = null;
-
- try {
- tables = getTables((String)catalogStr, schemaPattern, "%",
- new String[0]);
-
- while (tables.next()) {
- String tableNameFromList = tables
- .getString("TABLE_NAME");
- tableNameList.add(tableNameFromList);
- }
- } finally {
- if (tables != null) {
- try {
- tables.close();
- } catch (Exception sqlEx) {
- AssertionFailedException
- .shouldNotHappen(sqlEx);
- }
-
- tables = null;
- }
- }
- } else {
- java.sql.ResultSet tables = null;
-
- try {
- tables = getTables((String)catalogStr, schemaPattern,
- tableNamePattern, new String[0]);
-
- while (tables.next()) {
- String tableNameFromList = tables
- .getString("TABLE_NAME");
- tableNameList.add(tableNameFromList);
- }
- } finally {
- if (tables != null) {
- try {
- tables.close();
- } catch (SQLException sqlEx) {
- AssertionFailedException
- .shouldNotHappen(sqlEx);
- }
-
- tables = null;
- }
- }
- }
-
- java.util.Iterator tableNames = tableNameList.iterator();
-
- while (tableNames.hasNext()) {
- String tableName = (String) tableNames.next();
-
- ResultSet results = null;
-
- try {
- StringBuffer queryBuf = new StringBuffer("SHOW ");
-
- if (conn.versionMeetsMinimum(4, 1, 0)) {
- queryBuf.append("FULL ");
- }
-
- queryBuf.append("COLUMNS FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(tableName);
- queryBuf.append(quotedId);
- queryBuf.append(" FROM ");
- queryBuf.append(quotedId);
- queryBuf.append((String)catalogStr);
- queryBuf.append(quotedId);
- queryBuf.append(" LIKE '");
- queryBuf.append(colPattern);
- queryBuf.append("'");
-
- // Return correct ordinals if column name pattern is
- // not '%'
- // Currently, MySQL doesn't show enough data to do
- // this, so we do it the 'hard' way...Once _SYSTEM
- // tables are in, this should be much easier
- boolean fixUpOrdinalsRequired = false;
- Map ordinalFixUpMap = null;
-
- if (!colPattern.equals("%")) {
- fixUpOrdinalsRequired = true;
-
- StringBuffer fullColumnQueryBuf = new StringBuffer(
- "SHOW ");
-
- if (conn.versionMeetsMinimum(4, 1, 0)) {
- fullColumnQueryBuf.append("FULL ");
- }
-
- fullColumnQueryBuf.append("COLUMNS FROM ");
- fullColumnQueryBuf.append(quotedId);
- fullColumnQueryBuf.append(tableName);
- fullColumnQueryBuf.append(quotedId);
- fullColumnQueryBuf.append(" FROM ");
- fullColumnQueryBuf.append(quotedId);
- fullColumnQueryBuf
- .append((String)catalogStr);
- fullColumnQueryBuf.append(quotedId);
-
- results = stmt.executeQuery(fullColumnQueryBuf
- .toString());
-
- ordinalFixUpMap = new HashMap();
-
- int fullOrdinalPos = 1;
-
- while (results.next()) {
- String fullOrdColName = results
- .getString("Field");
-
- ordinalFixUpMap.put(fullOrdColName,
- Constants.integerValueOf(fullOrdinalPos++));
- }
- }
-
- results = stmt.executeQuery(queryBuf.toString());
-
- int ordPos = 1;
-
- while (results.next()) {
- byte[][] rowVal = new byte[23][];
- rowVal[0] = s2b((String)catalogStr); // TABLE_CAT
- rowVal[1] = null; // TABLE_SCHEM (No schemas
- // in MySQL)
-
- rowVal[2] = s2b(tableName); // TABLE_NAME
- rowVal[3] = results.getBytes("Field");
-
- TypeDescriptor typeDesc = new TypeDescriptor(
- results.getString("Type"), results
- .getString("Null"));
-
- rowVal[4] = Short.toString(typeDesc.dataType)
- .getBytes();
-
- // DATA_TYPE (jdbc)
- rowVal[5] = s2b(typeDesc.typeName); // TYPE_NAME
- // (native)
- rowVal[6] = typeDesc.columnSize == null ? null : s2b(typeDesc.columnSize.toString());
- rowVal[7] = s2b(Integer.toString(typeDesc.bufferLength));
- rowVal[8] = typeDesc.decimalDigits == null ? null : s2b(typeDesc.decimalDigits.toString());
- rowVal[9] = s2b(Integer
- .toString(typeDesc.numPrecRadix));
- rowVal[10] = s2b(Integer
- .toString(typeDesc.nullability));
-
- //
- // Doesn't always have this field, depending on
- // version
- //
- //
- // REMARK column
- //
- try {
- if (conn.versionMeetsMinimum(4, 1, 0)) {
- rowVal[11] = results
- .getBytes("Comment");
- } else {
- rowVal[11] = results.getBytes("Extra");
- }
- } catch (Exception E) {
- rowVal[11] = new byte[0];
- }
-
- // COLUMN_DEF
- rowVal[12] = results.getBytes("Default");
-
- rowVal[13] = new byte[] { (byte) '0' }; // SQL_DATA_TYPE
- rowVal[14] = new byte[] { (byte) '0' }; // SQL_DATE_TIME_SUB
-
- if (StringUtils.indexOfIgnoreCase(typeDesc.typeName, "CHAR") != -1 ||
- StringUtils.indexOfIgnoreCase(typeDesc.typeName, "BLOB") != -1 ||
- StringUtils.indexOfIgnoreCase(typeDesc.typeName, "TEXT") != -1 ||
- StringUtils.indexOfIgnoreCase(typeDesc.typeName, "BINARY") != -1) {
- rowVal[15] = rowVal[6]; // CHAR_OCTET_LENGTH
- } else {
- rowVal[15] = null;
- }
-
- // ORDINAL_POSITION
- if (!fixUpOrdinalsRequired) {
- rowVal[16] = Integer.toString(ordPos++)
- .getBytes();
- } else {
- String origColName = results
- .getString("Field");
- Integer realOrdinal = (Integer) ordinalFixUpMap
- .get(origColName);
-
- if (realOrdinal != null) {
- rowVal[16] = realOrdinal.toString()
- .getBytes();
- } else {
- throw SQLError.createSQLException(
- "Can not find column in full column list to determine true ordinal position.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- rowVal[17] = s2b(typeDesc.isNullable);
-
- // We don't support REF or DISTINCT types
- rowVal[18] = null;
- rowVal[19] = null;
- rowVal[20] = null;
- rowVal[21] = null;
-
- rowVal[22] = s2b("");
-
- String extra = results.getString("Extra");
-
- if (extra != null) {
- rowVal[22] = s2b(StringUtils
- .indexOfIgnoreCase(extra,
- "auto_increment") != -1 ? "YES"
- : "NO");
- }
-
- rows.add(new ByteArrayRow(rowVal, getExceptionInterceptor()));
- }
- } finally {
- if (results != null) {
- try {
- results.close();
- } catch (Exception ex) {
- ;
- }
-
- results = null;
- }
- }
- }
- }
- }.doForAll();
- } finally {
- if (stmt != null) {
- stmt.close();
- }
- }
-
- java.sql.ResultSet results = buildResultSet(fields, rows);
-
- return results;
- }
-
- protected Field[] createColumnsFields() {
- Field[] fields = new Field[23];
- fields[0] = new Field("", "TABLE_CAT", Types.CHAR, 255);
- fields[1] = new Field("", "TABLE_SCHEM", Types.CHAR, 0);
- fields[2] = new Field("", "TABLE_NAME", Types.CHAR, 255);
- fields[3] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
- fields[4] = new Field("", "DATA_TYPE", Types.INTEGER, 5);
- fields[5] = new Field("", "TYPE_NAME", Types.CHAR, 16);
- fields[6] = new Field("", "COLUMN_SIZE", Types.INTEGER, Integer
- .toString(Integer.MAX_VALUE).length());
- fields[7] = new Field("", "BUFFER_LENGTH", Types.INTEGER, 10);
- fields[8] = new Field("", "DECIMAL_DIGITS", Types.INTEGER, 10);
- fields[9] = new Field("", "NUM_PREC_RADIX", Types.INTEGER, 10);
- fields[10] = new Field("", "NULLABLE", Types.INTEGER, 10);
- fields[11] = new Field("", "REMARKS", Types.CHAR, 0);
- fields[12] = new Field("", "COLUMN_DEF", Types.CHAR, 0);
- fields[13] = new Field("", "SQL_DATA_TYPE", Types.INTEGER, 10);
- fields[14] = new Field("", "SQL_DATETIME_SUB", Types.INTEGER, 10);
- fields[15] = new Field("", "CHAR_OCTET_LENGTH", Types.INTEGER, Integer
- .toString(Integer.MAX_VALUE).length());
- fields[16] = new Field("", "ORDINAL_POSITION", Types.INTEGER, 10);
- fields[17] = new Field("", "IS_NULLABLE", Types.CHAR, 3);
- fields[18] = new Field("", "SCOPE_CATALOG", Types.CHAR, 255);
- fields[19] = new Field("", "SCOPE_SCHEMA", Types.CHAR, 255);
- fields[20] = new Field("", "SCOPE_TABLE", Types.CHAR, 255);
- fields[21] = new Field("", "SOURCE_DATA_TYPE", Types.SMALLINT, 10);
- fields[22] = new Field("", "IS_AUTOINCREMENT", Types.CHAR, 3);
- return fields;
- }
-
- /**
- * JDBC 2.0 Return the connection that produced this metadata object.
- *
- * @return the connection that produced this metadata object.
- * @throws SQLException
- * if a database error occurs
- */
- public java.sql.Connection getConnection() throws SQLException {
- return this.conn;
- }
-
- /**
- * Get a description of the foreign key columns in the foreign key table
- * that reference the primary key columns of the primary key table (describe
- * how one table imports another's key.) This should normally return a
- * single foreign key/primary key pair (most tables only import a foreign
- * key from a table once.) They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
- * FKTABLE_NAME, and KEY_SEQ.
- *
- * Each foreign key column description has the following columns:
- *
KEY_SEQ short => sequence number within foreign key
- *
UPDATE_RULE short => What happens to foreign key when
- * primary is updated:
- *
- *
importedKeyCascade - change imported key to agree with primary key
- * update
- *
importedKeyRestrict - do not allow update of primary key if it has
- * been imported
- *
importedKeySetNull - change imported key to NULL if its primary key
- * has been updated
- *
- *
- *
DELETE_RULE short => What happens to the foreign key when
- * primary is deleted.
- *
- *
importedKeyCascade - delete rows that import a deleted key
- *
importedKeyRestrict - do not allow delete of primary key if it has
- * been imported
- *
importedKeySetNull - change imported key to NULL if its primary key
- * has been deleted
- *
- *
- *
FK_NAME String => foreign key name (may be null)
- *
PK_NAME String => primary key name (may be null)
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name pattern; "" retrieves those without a schema
- * @param table
- * a table name
- * @return ResultSet each row is a primary key column description
- * @throws SQLException
- * if a database access error occurs
- * @see #getExportedKeys
- */
- public java.sql.ResultSet getImportedKeys(String catalog, String schema,
- final String table) throws SQLException {
- if (table == null) {
- throw SQLError.createSQLException("Table not specified.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- Field[] fields = createFkMetadataFields();
-
- final ArrayList rows = new ArrayList();
-
- if (this.conn.versionMeetsMinimum(3, 23, 0)) {
-
- final Statement stmt = this.conn.getMetadataSafeStatement();
-
- try {
-
- new IterateBlock(getCatalogIterator(catalog)) {
- void forEach(Object catalogStr) throws SQLException {
- ResultSet fkresults = null;
-
- try {
-
- /*
- * Get foreign key information for table
- */
- if (conn.versionMeetsMinimum(3, 23, 50)) {
- // we can use 'SHOW CREATE TABLE'
-
- fkresults = extractForeignKeyFromCreateTable(
- catalogStr.toString(), table);
- } else {
- StringBuffer queryBuf = new StringBuffer(
- "SHOW TABLE STATUS ");
- queryBuf.append(" FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(catalogStr.toString());
- queryBuf.append(quotedId);
- queryBuf.append(" LIKE '");
- queryBuf.append(table);
- queryBuf.append("'");
-
- fkresults = stmt.executeQuery(queryBuf
- .toString());
- }
-
- /*
- * Parse imported foreign key information
- */
-
- while (fkresults.next()) {
- String tableType = fkresults.getString("Type");
-
- if ((tableType != null)
- && (tableType
- .equalsIgnoreCase("innodb") || tableType
- .equalsIgnoreCase(SUPPORTS_FK))) {
- String comment = fkresults.getString(
- "Comment").trim();
-
- if (comment != null) {
- StringTokenizer commentTokens = new StringTokenizer(
- comment, ";", false);
-
- if (commentTokens.hasMoreTokens()) {
- commentTokens.nextToken(); // Skip
- // InnoDB
- // comment
-
- while (commentTokens
- .hasMoreTokens()) {
- String keys = commentTokens
- .nextToken();
- getImportKeyResults(catalogStr
- .toString(), table,
- keys, rows);
- }
- }
- }
- }
- }
- } finally {
- if (fkresults != null) {
- try {
- fkresults.close();
- } catch (SQLException sqlEx) {
- AssertionFailedException
- .shouldNotHappen(sqlEx);
- }
-
- fkresults = null;
- }
- }
- }
- }.doForAll();
- } finally {
- if (stmt != null) {
- stmt.close();
- }
- }
- }
-
- java.sql.ResultSet results = buildResultSet(fields, rows);
-
- return results;
- }
-
- /**
- * Populates the tuples list with the imported keys of importingTable based
- * on the keysComment from the 'show table status' sql command. KeysComment
- * is that part of the comment field that follows the "InnoDB free ...;"
- * prefix.
- *
- * @param catalog
- * the database to use
- * @param importingTable
- * the table keys are being imported to
- * @param keysComment
- * the comment from 'show table status'
- * @param tuples
- * the rows to add results to
- * @throws SQLException
- * if a database access error occurs
- */
- private void getImportKeyResults(String catalog, String importingTable,
- String keysComment, List tuples) throws SQLException {
- getResultsImpl(catalog, importingTable, keysComment, tuples, null,
- false);
- }
-
- /**
- * Get a description of a table's indices and statistics. They are ordered
- * by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
- *
- * Each index column description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
NON_UNIQUE boolean => Can index values be non-unique? false
- * when TYPE is tableIndexStatistic
- *
INDEX_QUALIFIER String => index catalog (may be null); null
- * when TYPE is tableIndexStatistic
- *
INDEX_NAME String => index name; null when TYPE is
- * tableIndexStatistic
- *
TYPE short => index type:
- *
- *
tableIndexStatistic - this identifies table statistics that are
- * returned in conjuction with a table's index descriptions
- *
tableIndexClustered - this is a clustered index
- *
tableIndexHashed - this is a hashed index
- *
tableIndexOther - this is some other style of index
- *
- *
- *
ORDINAL_POSITION short => column sequence number within
- * index; zero when TYPE is tableIndexStatistic
- *
COLUMN_NAME String => column name; null when TYPE is
- * tableIndexStatistic
- *
ASC_OR_DESC String => column sort sequence, "A" =>
- * ascending, "D" => descending, may be null if sort sequence is not
- * supported; null when TYPE is tableIndexStatistic
- *
CARDINALITY int => When TYPE is tableIndexStatisic then this
- * is the number of rows in the table; otherwise it is the number of unique
- * values in the index.
- *
PAGES int => When TYPE is tableIndexStatisic then this is
- * the number of pages used for the table, otherwise it is the number of
- * pages used for the current index.
- *
FILTER_CONDITION String => Filter condition, if any. (may be
- * null)
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name pattern; "" retrieves those without a schema
- * @param table
- * a table name
- * @param unique
- * when true, return only indices for unique values; when false,
- * return indices regardless of whether unique or not
- * @param approximate
- * when true, result is allowed to reflect approximate or out of
- * data values; when false, results are requested to be accurate
- * @return ResultSet each row is an index column description
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getIndexInfo(String catalog, String schema,
- final String table, final boolean unique, boolean approximate)
- throws SQLException {
- /*
- * MySQL stores index information in the following fields: Table
- * Non_unique Key_name Seq_in_index Column_name Collation Cardinality
- * Sub_part
- */
-
- Field[] fields = createIndexInfoFields();
-
- final ArrayList rows = new ArrayList();
- final Statement stmt = this.conn.getMetadataSafeStatement();
-
- try {
-
- new IterateBlock(getCatalogIterator(catalog)) {
- void forEach(Object catalogStr) throws SQLException {
-
- ResultSet results = null;
-
- try {
- StringBuffer queryBuf = new StringBuffer(
- "SHOW INDEX FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(table);
- queryBuf.append(quotedId);
- queryBuf.append(" FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(catalogStr.toString());
- queryBuf.append(quotedId);
-
- try {
- results = stmt.executeQuery(queryBuf.toString());
- } catch (SQLException sqlEx) {
- int errorCode = sqlEx.getErrorCode();
-
- // If SQLState is 42S02, ignore this SQLException
- // it means the table doesn't exist....
- if (!"42S02".equals(sqlEx.getSQLState())) {
- // Sometimes not mapped correctly for pre-4.1
- // so use error code instead.
- if (errorCode != MysqlErrorNumbers.ER_NO_SUCH_TABLE) {
- throw sqlEx;
- }
- }
- }
-
- while (results != null && results.next()) {
- byte[][] row = new byte[14][];
- row[0] = ((catalogStr.toString() == null) ? new byte[0]
- : s2b(catalogStr.toString()));
- ;
- row[1] = null;
- row[2] = results.getBytes("Table");
-
- boolean indexIsUnique = results
- .getInt("Non_unique") == 0;
-
- row[3] = (!indexIsUnique ? s2b("true")
- : s2b("false"));
- row[4] = new byte[0];
- row[5] = results.getBytes("Key_name");
- row[6] = Integer.toString(
- java.sql.DatabaseMetaData.tableIndexOther)
- .getBytes();
- row[7] = results.getBytes("Seq_in_index");
- row[8] = results.getBytes("Column_name");
- row[9] = results.getBytes("Collation");
- row[10] = results.getBytes("Cardinality");
- row[11] = s2b("0");
- row[12] = null;
-
- if (unique) {
- if (indexIsUnique) {
- rows.add(new ByteArrayRow(row, getExceptionInterceptor()));
- }
- } else {
- // All rows match
- rows.add(new ByteArrayRow(row, getExceptionInterceptor()));
- }
- }
- } finally {
- if (results != null) {
- try {
- results.close();
- } catch (Exception ex) {
- ;
- }
-
- results = null;
- }
- }
- }
- }.doForAll();
-
- java.sql.ResultSet indexInfo = buildResultSet(fields, rows);
-
- return indexInfo;
- } finally {
- if (stmt != null) {
- stmt.close();
- }
- }
- }
-
- protected Field[] createIndexInfoFields() {
- Field[] fields = new Field[13];
- fields[0] = new Field("", "TABLE_CAT", Types.CHAR, 255);
- fields[1] = new Field("", "TABLE_SCHEM", Types.CHAR, 0);
- fields[2] = new Field("", "TABLE_NAME", Types.CHAR, 255);
- fields[3] = new Field("", "NON_UNIQUE", Types.BOOLEAN, 4);
- fields[4] = new Field("", "INDEX_QUALIFIER", Types.CHAR, 1);
- fields[5] = new Field("", "INDEX_NAME", Types.CHAR, 32);
- fields[6] = new Field("", "TYPE", Types.SMALLINT, 32);
- fields[7] = new Field("", "ORDINAL_POSITION", Types.SMALLINT, 5);
- fields[8] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
- fields[9] = new Field("", "ASC_OR_DESC", Types.CHAR, 1);
- fields[10] = new Field("", "CARDINALITY", Types.INTEGER, 10);
- fields[11] = new Field("", "PAGES", Types.INTEGER, 10);
- fields[12] = new Field("", "FILTER_CONDITION", Types.CHAR, 32);
- return fields;
- }
-
- /**
- * @see DatabaseMetaData#getJDBCMajorVersion()
- */
- public int getJDBCMajorVersion() throws SQLException {
- return 3;
- }
-
- /**
- * @see DatabaseMetaData#getJDBCMinorVersion()
- */
- public int getJDBCMinorVersion() throws SQLException {
- return 0;
- }
-
- /**
- * How many hex characters can you have in an inline binary literal?
- *
- * @return max literal length
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxBinaryLiteralLength() throws SQLException {
- return 16777208;
- }
-
- /**
- * What's the maximum length of a catalog name?
- *
- * @return max name length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxCatalogNameLength() throws SQLException {
- return 32;
- }
-
- /**
- * What's the max length for a character literal?
- *
- * @return max literal length
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxCharLiteralLength() throws SQLException {
- return 16777208;
- }
-
- /**
- * What's the limit on column name length?
- *
- * @return max literal length
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxColumnNameLength() throws SQLException {
- return 64;
- }
-
- /**
- * What's the maximum number of columns in a "GROUP BY" clause?
- *
- * @return max number of columns
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxColumnsInGroupBy() throws SQLException {
- return 64;
- }
-
- /**
- * What's the maximum number of columns allowed in an index?
- *
- * @return max columns
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxColumnsInIndex() throws SQLException {
- return 16;
- }
-
- /**
- * What's the maximum number of columns in an "ORDER BY" clause?
- *
- * @return max columns
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxColumnsInOrderBy() throws SQLException {
- return 64;
- }
-
- /**
- * What's the maximum number of columns in a "SELECT" list?
- *
- * @return max columns
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxColumnsInSelect() throws SQLException {
- return 256;
- }
-
- /**
- * What's maximum number of columns in a table?
- *
- * @return max columns
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxColumnsInTable() throws SQLException {
- return 512;
- }
-
- /**
- * How many active connections can we have at a time to this database?
- *
- * @return max connections
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxConnections() throws SQLException {
- return 0;
- }
-
- /**
- * What's the maximum cursor name length?
- *
- * @return max cursor name length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxCursorNameLength() throws SQLException {
- return 64;
- }
-
- /**
- * What's the maximum length of an index (in bytes)?
- *
- * @return max index length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxIndexLength() throws SQLException {
- return 256;
- }
-
- /**
- * What's the maximum length of a procedure name?
- *
- * @return max name length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxProcedureNameLength() throws SQLException {
- return 0;
- }
-
- /**
- * What's the maximum length of a single row?
- *
- * @return max row size in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxRowSize() throws SQLException {
- return Integer.MAX_VALUE - 8; // Max buffer size - HEADER
- }
-
- /**
- * What's the maximum length allowed for a schema name?
- *
- * @return max name length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxSchemaNameLength() throws SQLException {
- return 0;
- }
-
- /**
- * What's the maximum length of a SQL statement?
- *
- * @return max length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxStatementLength() throws SQLException {
- return MysqlIO.getMaxBuf() - 4; // Max buffer - header
- }
-
- /**
- * How many active statements can we have open at one time to this database?
- *
- * @return the maximum
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxStatements() throws SQLException {
- return 0;
- }
-
- /**
- * What's the maximum length of a table name?
- *
- * @return max name length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxTableNameLength() throws SQLException {
- return 64;
- }
-
- /**
- * What's the maximum number of tables in a SELECT?
- *
- * @return the maximum
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxTablesInSelect() throws SQLException {
- return 256;
- }
-
- /**
- * What's the maximum length of a user name?
- *
- * @return max name length in bytes
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getMaxUserNameLength() throws SQLException {
- return 16;
- }
-
- /**
- * Get a comma separated list of math functions.
- *
- * @return the list
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getNumericFunctions() throws SQLException {
- return "ABS,ACOS,ASIN,ATAN,ATAN2,BIT_COUNT,CEILING,COS,"
- + "COT,DEGREES,EXP,FLOOR,LOG,LOG10,MAX,MIN,MOD,PI,POW,"
- + "POWER,RADIANS,RAND,ROUND,SIN,SQRT,TAN,TRUNCATE";
- }
-
- /**
- * Get a description of a table's primary key columns. They are ordered by
- * COLUMN_NAME.
- *
- * Each column description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
COLUMN_NAME String => column name
- *
KEY_SEQ short => sequence number within primary key
- *
PK_NAME String => primary key name (may be null)
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name pattern; "" retrieves those without a schema
- * @param table
- * a table name
- * @return ResultSet each row is a primary key column description
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getPrimaryKeys(String catalog, String schema,
- final String table) throws SQLException {
- Field[] fields = new Field[6];
- fields[0] = new Field("", "TABLE_CAT", Types.CHAR, 255);
- fields[1] = new Field("", "TABLE_SCHEM", Types.CHAR, 0);
- fields[2] = new Field("", "TABLE_NAME", Types.CHAR, 255);
- fields[3] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
- fields[4] = new Field("", "KEY_SEQ", Types.SMALLINT, 5);
- fields[5] = new Field("", "PK_NAME", Types.CHAR, 32);
-
- if (table == null) {
- throw SQLError.createSQLException("Table not specified.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- final ArrayList rows = new ArrayList();
- final Statement stmt = this.conn.getMetadataSafeStatement();
-
- try {
-
- new IterateBlock(getCatalogIterator(catalog)) {
- void forEach(Object catalogStr) throws SQLException {
- ResultSet rs = null;
-
- try {
-
- StringBuffer queryBuf = new StringBuffer(
- "SHOW KEYS FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(table);
- queryBuf.append(quotedId);
- queryBuf.append(" FROM ");
- queryBuf.append(quotedId);
- queryBuf.append(catalogStr.toString());
- queryBuf.append(quotedId);
-
- rs = stmt.executeQuery(queryBuf.toString());
-
- TreeMap sortMap = new TreeMap();
-
- while (rs.next()) {
- String keyType = rs.getString("Key_name");
-
- if (keyType != null) {
- if (keyType.equalsIgnoreCase("PRIMARY")
- || keyType.equalsIgnoreCase("PRI")) {
- byte[][] tuple = new byte[6][];
- tuple[0] = ((catalogStr.toString() == null) ? new byte[0]
- : s2b(catalogStr.toString()));
- tuple[1] = null;
- tuple[2] = s2b(table);
-
- String columnName = rs
- .getString("Column_name");
- tuple[3] = s2b(columnName);
- tuple[4] = s2b(rs.getString("Seq_in_index"));
- tuple[5] = s2b(keyType);
- sortMap.put(columnName, tuple);
- }
- }
- }
-
- // Now pull out in column name sorted order
- Iterator sortedIterator = sortMap.values().iterator();
-
- while (sortedIterator.hasNext()) {
- rows.add(new ByteArrayRow((byte[][])sortedIterator.next(), getExceptionInterceptor()));
- }
-
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (Exception ex) {
- ;
- }
-
- rs = null;
- }
- }
- }
- }.doForAll();
- } finally {
- if (stmt != null) {
- stmt.close();
- }
- }
-
- java.sql.ResultSet results = buildResultSet(fields, rows);
-
- return results;
- }
-
- /**
- * Get a description of a catalog's stored procedure parameters and result
- * columns.
- *
- * Only descriptions matching the schema, procedure and parameter name
- * criteria are returned. They are ordered by PROCEDURE_SCHEM and
- * PROCEDURE_NAME. Within this, the return value, if any, is first. Next are
- * the parameter descriptions in call order. The column descriptions follow
- * in column number order.
- *
- *
- * Each row in the ResultSet is a parameter desription or column description
- * with the following fields:
- *
- *
PROCEDURE_CAT String => procedure catalog (may be null)
- *
- *
PROCEDURE_SCHEM String => procedure schema (may be null)
- *
- *
PROCEDURE_NAME String => procedure name
- *
COLUMN_NAME String => column/parameter name
- *
COLUMN_TYPE Short => kind of column/parameter:
- *
- *
procedureColumnUnknown - nobody knows
- *
procedureColumnIn - IN parameter
- *
procedureColumnInOut - INOUT parameter
- *
procedureColumnOut - OUT parameter
- *
procedureColumnReturn - procedure return value
- *
procedureColumnResult - result column in ResultSet
- * Note: Some databases may not return the column descriptions for a
- * procedure. Additional columns beyond REMARKS can be defined by the
- * database.
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schemaPattern
- * a schema name pattern; "" retrieves those without a schema
- * @param procedureNamePattern
- * a procedure name pattern
- * @param columnNamePattern
- * a column name pattern
- * @return ResultSet each row is a stored procedure parameter or column
- * description
- * @throws SQLException
- * if a database access error occurs
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getProcedureColumns(String catalog,
- String schemaPattern, String procedureNamePattern,
- String columnNamePattern) throws SQLException {
- Field[] fields = createProcedureColumnsFields();
-
- return getProcedureOrFunctionColumns(
- fields, catalog, schemaPattern,
- procedureNamePattern, columnNamePattern,
- true, true);
- }
-
- protected Field[] createProcedureColumnsFields() {
- Field[] fields = new Field[13];
-
- fields[0] = new Field("", "PROCEDURE_CAT", Types.CHAR, 0);
- fields[1] = new Field("", "PROCEDURE_SCHEM", Types.CHAR, 0);
- fields[2] = new Field("", "PROCEDURE_NAME", Types.CHAR, 0);
- fields[3] = new Field("", "COLUMN_NAME", Types.CHAR, 0);
- fields[4] = new Field("", "COLUMN_TYPE", Types.CHAR, 0);
- fields[5] = new Field("", "DATA_TYPE", Types.SMALLINT, 0);
- fields[6] = new Field("", "TYPE_NAME", Types.CHAR, 0);
- fields[7] = new Field("", "PRECISION", Types.INTEGER, 0);
- fields[8] = new Field("", "LENGTH", Types.INTEGER, 0);
- fields[9] = new Field("", "SCALE", Types.SMALLINT, 0);
- fields[10] = new Field("", "RADIX", Types.SMALLINT, 0);
- fields[11] = new Field("", "NULLABLE", Types.SMALLINT, 0);
- fields[12] = new Field("", "REMARKS", Types.CHAR, 0);
- return fields;
- }
-
- protected java.sql.ResultSet getProcedureOrFunctionColumns(
- Field[] fields, String catalog, String schemaPattern,
- String procedureOrFunctionNamePattern,
- String columnNamePattern, boolean returnProcedures,
- boolean returnFunctions) throws SQLException {
-
- List proceduresToExtractList = new ArrayList();
-
- if (supportsStoredProcedures()) {
- if ((procedureOrFunctionNamePattern.indexOf("%") == -1)
- && (procedureOrFunctionNamePattern.indexOf("?") == -1)) {
- proceduresToExtractList.add(procedureOrFunctionNamePattern);
- } else {
-
- ResultSet procedureNameRs = null;
-
- try {
-
- procedureNameRs = getProceduresAndOrFunctions(
- createFieldMetadataForGetProcedures(),
- catalog, schemaPattern,
- procedureOrFunctionNamePattern, returnProcedures,
- returnFunctions);
-
- while (procedureNameRs.next()) {
- proceduresToExtractList.add(procedureNameRs
- .getString(3));
- }
-
- // Required to be sorted in name-order by JDBC spec,
- // in 'normal' case getProcedures takes care of this for us,
- // but if system tables are inaccessible, we need to sort...
- // so just do this to be safe...
- Collections.sort(proceduresToExtractList);
- } finally {
- SQLException rethrowSqlEx = null;
-
- if (procedureNameRs != null) {
- try {
- procedureNameRs.close();
- } catch (SQLException sqlEx) {
- rethrowSqlEx = sqlEx;
- }
- }
-
- if (rethrowSqlEx != null) {
- throw rethrowSqlEx;
- }
- }
- }
- }
-
- ArrayList resultRows = new ArrayList();
-
- for (Iterator iter = proceduresToExtractList.iterator(); iter.hasNext();) {
- String procName = (String) iter.next();
-
- getCallStmtParameterTypes(catalog, procName, columnNamePattern,
- resultRows,
- fields.length == 17 /* for getFunctionColumns */);
- }
-
- return buildResultSet(fields, resultRows);
- }
-
- /**
- * Get a description of stored procedures available in a catalog.
- *
- * Only procedure descriptions matching the schema and procedure name
- * criteria are returned. They are ordered by PROCEDURE_SCHEM, and
- * PROCEDURE_NAME.
- *
- *
- * Each procedure description has the the following columns:
- *
- *
PROCEDURE_CAT String => procedure catalog (may be null)
- *
- *
PROCEDURE_SCHEM String => procedure schema (may be null)
- *
- *
PROCEDURE_NAME String => procedure name
- *
reserved for future use
- *
reserved for future use
- *
reserved for future use
- *
REMARKS String => explanatory comment on the procedure
- *
PROCEDURE_TYPE short => kind of procedure:
- *
- *
procedureResultUnknown - May return a result
- *
procedureNoResult - Does not return a result
- *
procedureReturnsResult - Returns a result
- *
- *
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schemaPattern
- * a schema name pattern; "" retrieves those without a schema
- * @param procedureNamePattern
- * a procedure name pattern
- * @return ResultSet each row is a procedure description
- * @throws SQLException
- * if a database access error occurs
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getProcedures(String catalog,
- String schemaPattern, String procedureNamePattern)
- throws SQLException {
- Field[] fields = createFieldMetadataForGetProcedures();
-
- return getProceduresAndOrFunctions(fields, catalog, schemaPattern,
- procedureNamePattern, true, true);
- }
-
- private Field[] createFieldMetadataForGetProcedures() {
- Field[] fields = new Field[9];
- fields[0] = new Field("", "PROCEDURE_CAT", Types.CHAR, 255);
- fields[1] = new Field("", "PROCEDURE_SCHEM", Types.CHAR, 255);
- fields[2] = new Field("", "PROCEDURE_NAME", Types.CHAR, 255);
- fields[3] = new Field("", "reserved1", Types.CHAR, 0);
- fields[4] = new Field("", "reserved2", Types.CHAR, 0);
- fields[5] = new Field("", "reserved3", Types.CHAR, 0);
- fields[6] = new Field("", "REMARKS", Types.CHAR, 255);
- fields[7] = new Field("", "PROCEDURE_TYPE", Types.SMALLINT, 6);
- fields[8] = new Field("", "SPECIFIC_NAME", Types.CHAR, 255);
-
- return fields;
- }
-
- protected java.sql.ResultSet getProceduresAndOrFunctions(
- final Field[] fields,
- String catalog,
- String schemaPattern,
- String procedureNamePattern,
- final boolean returnProcedures,
- final boolean returnFunctions) throws SQLException {
- if ((procedureNamePattern == null)
- || (procedureNamePattern.length() == 0)) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- procedureNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Procedure name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- final ArrayList procedureRows = new ArrayList();
-
- if (supportsStoredProcedures()) {
- final String procNamePattern = procedureNamePattern;
-
- final Map procedureRowsOrderedByName = new TreeMap();
-
- new IterateBlock(getCatalogIterator(catalog)) {
- void forEach(Object catalogStr) throws SQLException {
- String db = catalogStr.toString();
-
- boolean fromSelect = false;
- ResultSet proceduresRs = null;
- boolean needsClientFiltering = true;
- PreparedStatement proceduresStmt = (PreparedStatement) conn
- .clientPrepareStatement("SELECT name, type, comment FROM mysql.proc WHERE name like ? and db <=> ? ORDER BY name");
-
- try {
- //
- // Try using system tables first, as this is a little
- // bit more efficient....
- //
-
- boolean hasTypeColumn = false;
-
- if (db != null) {
- proceduresStmt.setString(2, db);
- } else {
- proceduresStmt.setNull(2, Types.VARCHAR);
- }
-
- int nameIndex = 1;
-
- if (proceduresStmt.getMaxRows() != 0) {
- proceduresStmt.setMaxRows(0);
- }
-
- proceduresStmt.setString(1, procNamePattern);
-
- try {
- proceduresRs = proceduresStmt.executeQuery();
- fromSelect = true;
- needsClientFiltering = false;
- hasTypeColumn = true;
- } catch (SQLException sqlEx) {
-
- //
- // Okay, system tables aren't accessible, so use
- // 'SHOW
- // ....'....
- //
- proceduresStmt.close();
-
- fromSelect = false;
-
- if (conn.versionMeetsMinimum(5, 0, 1)) {
- nameIndex = 2;
- } else {
- nameIndex = 1;
- }
-
- proceduresStmt = (PreparedStatement) conn
- .clientPrepareStatement("SHOW PROCEDURE STATUS LIKE ?");
-
- if (proceduresStmt.getMaxRows() != 0) {
- proceduresStmt.setMaxRows(0);
- }
-
- proceduresStmt.setString(1, procNamePattern);
-
- proceduresRs = proceduresStmt.executeQuery();
- }
-
- if (returnProcedures) {
- convertToJdbcProcedureList(fromSelect, db,
- proceduresRs, needsClientFiltering, db,
- procedureRowsOrderedByName, nameIndex);
- }
-
- if (!hasTypeColumn) {
- // need to go after functions too...
- if (proceduresStmt != null) {
- proceduresStmt.close();
- }
-
- proceduresStmt = (PreparedStatement) conn
- .clientPrepareStatement("SHOW FUNCTION STATUS LIKE ?");
-
- if (proceduresStmt.getMaxRows() != 0) {
- proceduresStmt.setMaxRows(0);
- }
-
- proceduresStmt.setString(1, procNamePattern);
-
- proceduresRs = proceduresStmt.executeQuery();
-
- if (returnFunctions) {
- convertToJdbcFunctionList(db, proceduresRs,
- needsClientFiltering, db,
- procedureRowsOrderedByName, nameIndex,
- fields);
- }
- }
-
- // Now, sort them
-
- Iterator proceduresIter = procedureRowsOrderedByName
- .values().iterator();
-
- while (proceduresIter.hasNext()) {
- procedureRows.add(proceduresIter.next());
- }
- } finally {
- SQLException rethrowSqlEx = null;
-
- if (proceduresRs != null) {
- try {
- proceduresRs.close();
- } catch (SQLException sqlEx) {
- rethrowSqlEx = sqlEx;
- }
- }
-
- if (proceduresStmt != null) {
- try {
- proceduresStmt.close();
- } catch (SQLException sqlEx) {
- rethrowSqlEx = sqlEx;
- }
- }
-
- if (rethrowSqlEx != null) {
- throw rethrowSqlEx;
- }
- }
- }
- }.doForAll();
- }
-
- return buildResultSet(fields, procedureRows);
- }
-
-
- /**
- * What's the database vendor's preferred term for "procedure"?
- *
- * @return the vendor term
- * @throws SQLException
- * if an error occurs (don't know why it would in this case...)
- */
- public String getProcedureTerm() throws SQLException {
- return "PROCEDURE";
- }
-
- /**
- * @see DatabaseMetaData#getResultSetHoldability()
- */
- public int getResultSetHoldability() throws SQLException {
- return ResultSet.HOLD_CURSORS_OVER_COMMIT;
- }
-
- private void getResultsImpl(String catalog, String table,
- String keysComment, List tuples, String fkTableName,
- boolean isExport) throws SQLException {
-
- LocalAndReferencedColumns parsedInfo = parseTableStatusIntoLocalAndReferencedColumns(keysComment);
-
- if (isExport && !parsedInfo.referencedTable.equals(table)) {
- return;
- }
-
- if (parsedInfo.localColumnsList.size() != parsedInfo.referencedColumnsList
- .size()) {
- throw SQLError.createSQLException(
- "Error parsing foreign keys definition,"
- + "number of local and referenced columns is not the same.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- Iterator localColumnNames = parsedInfo.localColumnsList.iterator();
- Iterator referColumnNames = parsedInfo.referencedColumnsList.iterator();
-
- int keySeqIndex = 1;
-
- while (localColumnNames.hasNext()) {
- byte[][] tuple = new byte[14][];
- String lColumnName = removeQuotedId(localColumnNames.next()
- .toString());
- String rColumnName = removeQuotedId(referColumnNames.next()
- .toString());
- tuple[FKTABLE_CAT] = ((catalog == null) ? new byte[0]
- : s2b(catalog));
- tuple[FKTABLE_SCHEM] = null;
- tuple[FKTABLE_NAME] = s2b((isExport) ? fkTableName : table);
- tuple[FKCOLUMN_NAME] = s2b(lColumnName);
- tuple[PKTABLE_CAT] = s2b(parsedInfo.referencedCatalog);
- tuple[PKTABLE_SCHEM] = null;
- tuple[PKTABLE_NAME] = s2b((isExport) ? table
- : parsedInfo.referencedTable);
- tuple[PKCOLUMN_NAME] = s2b(rColumnName);
- tuple[KEY_SEQ] = s2b(Integer.toString(keySeqIndex++));
-
- int[] actions = getForeignKeyActions(keysComment);
-
- tuple[UPDATE_RULE] = s2b(Integer.toString(actions[1]));
- tuple[DELETE_RULE] = s2b(Integer.toString(actions[0]));
- tuple[FK_NAME] = s2b(parsedInfo.constraintName);
- tuple[PK_NAME] = null; // not available from show table status
- tuple[DEFERRABILITY] = s2b(Integer
- .toString(java.sql.DatabaseMetaData.importedKeyNotDeferrable));
- tuples.add(new ByteArrayRow(tuple, getExceptionInterceptor()));
- }
- }
-
- /**
- * Get the schema names available in this database. The results are ordered
- * by schema name.
- *
- * The schema column is:
- *
- *
TABLE_SCHEM String => schema name
- *
- *
- *
- * @return ResultSet each row has a single String column that is a schema
- * name
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getSchemas() throws SQLException {
- Field[] fields = new Field[2];
- fields[0] = new Field("", "TABLE_SCHEM", java.sql.Types.CHAR, 0);
- fields[1] = new Field("", "TABLE_CATALOG", java.sql.Types.CHAR, 0);
-
- ArrayList tuples = new ArrayList();
- java.sql.ResultSet results = buildResultSet(fields, tuples);
-
- return results;
- }
-
- /**
- * What's the database vendor's preferred term for "schema"?
- *
- * @return the vendor term
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getSchemaTerm() throws SQLException {
- return "";
- }
-
- /**
- * This is the string that can be used to escape '_' or '%' in the string
- * pattern style catalog search parameters.
- *
- * The '_' character represents any single character.
- *
- *
- * The '%' character represents any sequence of zero or more characters.
- *
- *
- * @return the string used to escape wildcard characters
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getSearchStringEscape() throws SQLException {
- return "\\";
- }
-
- /**
- * Get a comma separated list of all a database's SQL keywords that are NOT
- * also SQL92 keywords.
- *
- * @return the list
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getSQLKeywords() throws SQLException {
- return mysqlKeywordsThatArentSQL92;
- }
-
- /**
- * @see DatabaseMetaData#getSQLStateType()
- */
- public int getSQLStateType() throws SQLException {
- if (this.conn.versionMeetsMinimum(4, 1, 0)) {
- return DatabaseMetaData.sqlStateSQL99;
- }
-
- if (this.conn.getUseSqlStateCodes()) {
- return DatabaseMetaData.sqlStateSQL99;
- }
-
- return DatabaseMetaData.sqlStateXOpen;
- }
-
- /**
- * Get a comma separated list of string functions.
- *
- * @return the list
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getStringFunctions() throws SQLException {
- return "ASCII,BIN,BIT_LENGTH,CHAR,CHARACTER_LENGTH,CHAR_LENGTH,CONCAT,"
- + "CONCAT_WS,CONV,ELT,EXPORT_SET,FIELD,FIND_IN_SET,HEX,INSERT,"
- + "INSTR,LCASE,LEFT,LENGTH,LOAD_FILE,LOCATE,LOCATE,LOWER,LPAD,"
- + "LTRIM,MAKE_SET,MATCH,MID,OCT,OCTET_LENGTH,ORD,POSITION,"
- + "QUOTE,REPEAT,REPLACE,REVERSE,RIGHT,RPAD,RTRIM,SOUNDEX,"
- + "SPACE,STRCMP,SUBSTRING,SUBSTRING,SUBSTRING,SUBSTRING,"
- + "SUBSTRING_INDEX,TRIM,UCASE,UPPER";
- }
-
- /**
- * @see DatabaseMetaData#getSuperTables(String, String, String)
- */
- public java.sql.ResultSet getSuperTables(String arg0, String arg1,
- String arg2) throws SQLException {
- Field[] fields = new Field[4];
- fields[0] = new Field("", "TABLE_CAT", Types.CHAR, 32);
- fields[1] = new Field("", "TABLE_SCHEM", Types.CHAR, 32);
- fields[2] = new Field("", "TABLE_NAME", Types.CHAR, 32);
- fields[3] = new Field("", "SUPERTABLE_NAME", Types.CHAR, 32);
-
- return buildResultSet(fields, new ArrayList());
- }
-
- /**
- * @see DatabaseMetaData#getSuperTypes(String, String, String)
- */
- public java.sql.ResultSet getSuperTypes(String arg0, String arg1,
- String arg2) throws SQLException {
- Field[] fields = new Field[6];
- fields[0] = new Field("", "TYPE_CAT", Types.CHAR, 32);
- fields[1] = new Field("", "TYPE_SCHEM", Types.CHAR, 32);
- fields[2] = new Field("", "TYPE_NAME", Types.CHAR, 32);
- fields[3] = new Field("", "SUPERTYPE_CAT", Types.CHAR, 32);
- fields[4] = new Field("", "SUPERTYPE_SCHEM", Types.CHAR, 32);
- fields[5] = new Field("", "SUPERTYPE_NAME", Types.CHAR, 32);
-
- return buildResultSet(fields, new ArrayList());
- }
-
- /**
- * Get a comma separated list of system functions.
- *
- * @return the list
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getSystemFunctions() throws SQLException {
- return "DATABASE,USER,SYSTEM_USER,SESSION_USER,PASSWORD,ENCRYPT,LAST_INSERT_ID,VERSION";
- }
-
- private String getTableNameWithCase(String table) {
- String tableNameWithCase = (this.conn.lowerCaseTableNames() ? table
- .toLowerCase() : table);
-
- return tableNameWithCase;
- }
-
- /**
- * Get a description of the access rights for each table available in a
- * catalog.
- *
- * Only privileges matching the schema and table name criteria are returned.
- * They are ordered by TABLE_SCHEM, TABLE_NAME, and PRIVILEGE.
- *
- *
- * Each privilige description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
COLUMN_NAME String => column name
- *
GRANTOR => grantor of access (may be null)
- *
GRANTEE String => grantee of access
- *
PRIVILEGE String => name of access (SELECT, INSERT, UPDATE,
- * REFRENCES, ...)
- *
IS_GRANTABLE String => "YES" if grantee is permitted to
- * grant to others; "NO" if not; null if unknown
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schemaPattern
- * a schema name pattern; "" retrieves those without a schema
- * @param tableNamePattern
- * a table name pattern
- * @return ResultSet each row is a table privilege description
- * @throws SQLException
- * if a database access error occurs
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getTablePrivileges(String catalog,
- String schemaPattern, String tableNamePattern) throws SQLException {
-
- if (tableNamePattern == null) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- tableNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Table name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- Field[] fields = new Field[7];
- fields[0] = new Field("", "TABLE_CAT", Types.CHAR, 64);
- fields[1] = new Field("", "TABLE_SCHEM", Types.CHAR, 1);
- fields[2] = new Field("", "TABLE_NAME", Types.CHAR, 64);
- fields[3] = new Field("", "GRANTOR", Types.CHAR, 77);
- fields[4] = new Field("", "GRANTEE", Types.CHAR, 77);
- fields[5] = new Field("", "PRIVILEGE", Types.CHAR, 64);
- fields[6] = new Field("", "IS_GRANTABLE", Types.CHAR, 3);
-
- StringBuffer grantQuery = new StringBuffer(
- "SELECT host,db,table_name,grantor,user,table_priv from mysql.tables_priv ");
- grantQuery.append(" WHERE ");
-
- if ((catalog != null) && (catalog.length() != 0)) {
- grantQuery.append(" db='");
- grantQuery.append(catalog);
- grantQuery.append("' AND ");
- }
-
- grantQuery.append("table_name like '");
- grantQuery.append(tableNamePattern);
- grantQuery.append("'");
-
- ResultSet results = null;
- ArrayList grantRows = new ArrayList();
- Statement stmt = null;
-
- try {
- stmt = this.conn.createStatement();
- stmt.setEscapeProcessing(false);
-
- results = stmt.executeQuery(grantQuery.toString());
-
- while (results.next()) {
- String host = results.getString(1);
- String db = results.getString(2);
- String table = results.getString(3);
- String grantor = results.getString(4);
- String user = results.getString(5);
-
- if ((user == null) || (user.length() == 0)) {
- user = "%";
- }
-
- StringBuffer fullUser = new StringBuffer(user);
-
- if ((host != null) && this.conn.getUseHostsInPrivileges()) {
- fullUser.append("@");
- fullUser.append(host);
- }
-
- String allPrivileges = results.getString(6);
-
- if (allPrivileges != null) {
- allPrivileges = allPrivileges.toUpperCase(Locale.ENGLISH);
-
- StringTokenizer st = new StringTokenizer(allPrivileges, ",");
-
- while (st.hasMoreTokens()) {
- String privilege = st.nextToken().trim();
-
- // Loop through every column in the table
- java.sql.ResultSet columnResults = null;
-
- try {
- columnResults = getColumns(catalog, schemaPattern,
- table, "%");
-
- while (columnResults.next()) {
- byte[][] tuple = new byte[8][];
- tuple[0] = s2b(db);
- tuple[1] = null;
- tuple[2] = s2b(table);
-
- if (grantor != null) {
- tuple[3] = s2b(grantor);
- } else {
- tuple[3] = null;
- }
-
- tuple[4] = s2b(fullUser.toString());
- tuple[5] = s2b(privilege);
- tuple[6] = null;
- grantRows.add(new ByteArrayRow(tuple, getExceptionInterceptor()));
- }
- } finally {
- if (columnResults != null) {
- try {
- columnResults.close();
- } catch (Exception ex) {
- ;
- }
- }
- }
- }
- }
- }
- } finally {
- if (results != null) {
- try {
- results.close();
- } catch (Exception ex) {
- ;
- }
-
- results = null;
- }
-
- if (stmt != null) {
- try {
- stmt.close();
- } catch (Exception ex) {
- ;
- }
-
- stmt = null;
- }
- }
-
- return buildResultSet(fields, grantRows);
- }
-
- /**
- * Get a description of tables available in a catalog.
- *
- * Only table descriptions matching the catalog, schema, table name and type
- * criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM and
- * TABLE_NAME.
- *
- *
- * Each table description has the following columns:
- *
- *
- *
- *
- * @return ResultSet each row has a single String column that is a table
- * type
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getTableTypes() throws SQLException {
- ArrayList tuples = new ArrayList();
- Field[] fields = new Field[1];
- fields[0] = new Field("", "TABLE_TYPE", Types.VARCHAR, 5);
-
- byte[][] tableTypeRow = new byte[1][];
- tableTypeRow[0] = TABLE_AS_BYTES;
- tuples.add(new ByteArrayRow(tableTypeRow, getExceptionInterceptor()));
-
- if (this.conn.versionMeetsMinimum(5, 0, 1)) {
- byte[][] viewTypeRow = new byte[1][];
- viewTypeRow[0] = VIEW_AS_BYTES;
- tuples.add(new ByteArrayRow(viewTypeRow, getExceptionInterceptor()));
- }
-
- byte[][] tempTypeRow = new byte[1][];
- tempTypeRow[0] = s2b("LOCAL TEMPORARY");
- tuples.add(new ByteArrayRow(tempTypeRow, getExceptionInterceptor()));
-
- return buildResultSet(fields, tuples);
- }
-
- /**
- * Get a comma separated list of time and date functions.
- *
- * @return the list
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getTimeDateFunctions() throws SQLException {
- return "DAYOFWEEK,WEEKDAY,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,"
- + "MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE,SECOND,PERIOD_ADD,"
- + "PERIOD_DIFF,TO_DAYS,FROM_DAYS,DATE_FORMAT,TIME_FORMAT,"
- + "CURDATE,CURRENT_DATE,CURTIME,CURRENT_TIME,NOW,SYSDATE,"
- + "CURRENT_TIMESTAMP,UNIX_TIMESTAMP,FROM_UNIXTIME,"
- + "SEC_TO_TIME,TIME_TO_SEC";
- }
-
- /**
- * Get a description of all the standard SQL types supported by this
- * database. They are ordered by DATA_TYPE and then by how closely the data
- * type maps to the corresponding JDBC SQL type.
- *
- * Each type description has the following columns:
- *
- *
TYPE_NAME String => Type name
- *
DATA_TYPE short => SQL data type from java.sql.Types
- *
PRECISION int => maximum precision
- *
LITERAL_PREFIX String => prefix used to quote a literal (may
- * be null)
- *
LITERAL_SUFFIX String => suffix used to quote a literal (may
- * be null)
- *
CREATE_PARAMS String => parameters used in creating the type
- * (may be null)
- *
NULLABLE short => can you use NULL for this type?
- *
- *
typeNoNulls - does not allow NULL values
- *
typeNullable - allows NULL values
- *
typeNullableUnknown - nullability unknown
- *
- *
- *
CASE_SENSITIVE boolean=> is it case sensitive?
- *
SEARCHABLE short => can you use "WHERE" based on this type:
- *
- *
typePredNone - No support
- *
typePredChar - Only supported with WHERE .. LIKE
- *
typePredBasic - Supported except for WHERE .. LIKE
- *
typeSearchable - Supported for all WHERE ..
- *
- *
- *
UNSIGNED_ATTRIBUTE boolean => is it unsigned?
- *
FIXED_PREC_SCALE boolean => can it be a money value?
- *
AUTO_INCREMENT boolean => can it be used for an
- * auto-increment value?
- *
LOCAL_TYPE_NAME String => localized version of type name
- * (may be null)
- *
MINIMUM_SCALE short => minimum scale supported
- *
MAXIMUM_SCALE short => maximum scale supported
- *
SQL_DATA_TYPE int => unused
- *
SQL_DATETIME_SUB int => unused
- *
NUM_PREC_RADIX int => usually 2 or 10
- *
- *
- *
- * @return ResultSet each row is a SQL type description
- * @throws SQLException
- * DOCUMENT ME!
- */
- /**
- * Get a description of all the standard SQL types supported by this
- * database. They are ordered by DATA_TYPE and then by how closely the data
- * type maps to the corresponding JDBC SQL type.
- *
- * Each type description has the following columns:
- *
- *
TYPE_NAME String => Type name
- *
DATA_TYPE short => SQL data type from java.sql.Types
- *
PRECISION int => maximum precision
- *
LITERAL_PREFIX String => prefix used to quote a literal (may
- * be null)
- *
LITERAL_SUFFIX String => suffix used to quote a literal (may
- * be null)
- *
CREATE_PARAMS String => parameters used in creating the type
- * (may be null)
- *
NULLABLE short => can you use NULL for this type?
- *
- *
typeNoNulls - does not allow NULL values
- *
typeNullable - allows NULL values
- *
typeNullableUnknown - nullability unknown
- *
- *
- *
CASE_SENSITIVE boolean=> is it case sensitive?
- *
SEARCHABLE short => can you use "WHERE" based on this type:
- *
- *
typePredNone - No support
- *
typePredChar - Only supported with WHERE .. LIKE
- *
typePredBasic - Supported except for WHERE .. LIKE
- *
typeSearchable - Supported for all WHERE ..
- *
- *
- *
UNSIGNED_ATTRIBUTE boolean => is it unsigned?
- *
FIXED_PREC_SCALE boolean => can it be a money value?
- *
AUTO_INCREMENT boolean => can it be used for an
- * auto-increment value?
- *
LOCAL_TYPE_NAME String => localized version of type name
- * (may be null)
- * Only types matching the catalog, schema, type name and type criteria are
- * returned. They are ordered by DATA_TYPE, TYPE_SCHEM and TYPE_NAME. The
- * type name parameter may be a fully qualified name. In this case, the
- * catalog and schemaPattern parameters are ignored.
- *
- *
- * Each type description has the following columns:
- *
- *
TYPE_CAT String => the type's catalog (may be null)
- *
TYPE_SCHEM String => type's schema (may be null)
- *
TYPE_NAME String => type name
- *
CLASS_NAME String => Java class name
- *
DATA_TYPE String => type value defined in java.sql.Types.
- * One of JAVA_OBJECT, STRUCT, or DISTINCT
- *
REMARKS String => explanatory comment on the type
- *
- *
- *
- * Note: If the driver does not support UDTs then an empty result
- * set is returned.
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog; null
- * means drop catalog name from the selection criteria
- * @param schemaPattern
- * a schema name pattern; "" retrieves those without a schema
- * @param typeNamePattern
- * a type name pattern; may be a fully qualified name
- * @param types
- * a list of user-named types to include (JAVA_OBJECT, STRUCT, or
- * DISTINCT); null returns all types
- * @return ResultSet - each row is a type description
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.ResultSet getUDTs(String catalog, String schemaPattern,
- String typeNamePattern, int[] types) throws SQLException {
- Field[] fields = new Field[6];
- fields[0] = new Field("", "TYPE_CAT", Types.VARCHAR, 32);
- fields[1] = new Field("", "TYPE_SCHEM", Types.VARCHAR, 32);
- fields[2] = new Field("", "TYPE_NAME", Types.VARCHAR, 32);
- fields[3] = new Field("", "CLASS_NAME", Types.VARCHAR, 32);
- fields[4] = new Field("", "DATA_TYPE", Types.VARCHAR, 32);
- fields[5] = new Field("", "REMARKS", Types.VARCHAR, 32);
-
- ArrayList tuples = new ArrayList();
-
- return buildResultSet(fields, tuples);
- }
-
- /**
- * What's the url for this database?
- *
- * @return the url or null if it can't be generated
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getURL() throws SQLException {
- return this.conn.getURL();
- }
-
- /**
- * What's our user name as known to the database?
- *
- * @return our database user name
- * @throws SQLException
- * DOCUMENT ME!
- */
- public String getUserName() throws SQLException {
- if (this.conn.getUseHostsInPrivileges()) {
- Statement stmt = null;
- ResultSet rs = null;
-
- try {
- stmt = this.conn.createStatement();
- stmt.setEscapeProcessing(false);
-
- rs = stmt.executeQuery("SELECT USER()");
- rs.next();
-
- return rs.getString(1);
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (Exception ex) {
- AssertionFailedException.shouldNotHappen(ex);
- }
-
- rs = null;
- }
-
- if (stmt != null) {
- try {
- stmt.close();
- } catch (Exception ex) {
- AssertionFailedException.shouldNotHappen(ex);
- }
-
- stmt = null;
- }
- }
- }
-
- return this.conn.getUser();
- }
-
- /**
- * Get a description of a table's columns that are automatically updated
- * when any value in a row is updated. They are unordered.
- *
- * Each column description has the following columns:
- *
- *
SCOPE short => is not used
- *
COLUMN_NAME String => column name
- *
DATA_TYPE short => SQL data type from java.sql.Types
- *
TYPE_NAME String => Data source dependent type name
- *
COLUMN_SIZE int => precision
- *
BUFFER_LENGTH int => length of column value in bytes
- *
DECIMAL_DIGITS short => scale
- *
PSEUDO_COLUMN short => is this a pseudo column like an
- * Oracle ROWID
- *
- *
versionColumnUnknown - may or may not be pseudo column
- *
versionColumnNotPseudo - is NOT a pseudo column
- *
versionColumnPseudo - is a pseudo column
- *
- *
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name; "" retrieves those without a schema
- * @param table
- * a table name
- * @return ResultSet each row is a column description
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getVersionColumns(String catalog, String schema,
- String table) throws SQLException {
- Field[] fields = new Field[8];
- fields[0] = new Field("", "SCOPE", Types.SMALLINT, 5);
- fields[1] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
- fields[2] = new Field("", "DATA_TYPE", Types.INTEGER, 5);
- fields[3] = new Field("", "TYPE_NAME", Types.CHAR, 16);
- fields[4] = new Field("", "COLUMN_SIZE", Types.INTEGER, 16);
- fields[5] = new Field("", "BUFFER_LENGTH", Types.INTEGER, 16);
- fields[6] = new Field("", "DECIMAL_DIGITS", Types.SMALLINT, 16);
- fields[7] = new Field("", "PSEUDO_COLUMN", Types.SMALLINT, 5);
-
- return buildResultSet(fields, new ArrayList());
-
- // do TIMESTAMP columns count?
- }
-
- /**
- * JDBC 2.0 Determine whether or not a visible row insert can be detected by
- * calling ResultSet.rowInserted().
- *
- * @param type
- * set type, i.e. ResultSet.TYPE_XXX
- * @return true if changes are detected by the resultset type
- * @exception SQLException
- * if a database-access error occurs.
- */
- public boolean insertsAreDetected(int type) throws SQLException {
- return false;
- }
-
- /**
- * Does a catalog appear at the start of a qualified table name? (Otherwise
- * it appears at the end)
- *
- * @return true if it appears at the start
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean isCatalogAtStart() throws SQLException {
- return true;
- }
-
- /**
- * Is the database in read-only mode?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean isReadOnly() throws SQLException {
- return false;
- }
-
- /**
- * @see DatabaseMetaData#locatorsUpdateCopy()
- */
- public boolean locatorsUpdateCopy() throws SQLException {
- return !this.conn.getEmulateLocators();
- }
-
- /**
- * Are concatenations between NULL and non-NULL values NULL? A JDBC
- * compliant driver always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean nullPlusNonNullIsNull() throws SQLException {
- return true;
- }
-
- /**
- * Are NULL values sorted at the end regardless of sort order?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean nullsAreSortedAtEnd() throws SQLException {
- return false;
- }
-
- /**
- * Are NULL values sorted at the start regardless of sort order?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean nullsAreSortedAtStart() throws SQLException {
- return (this.conn.versionMeetsMinimum(4, 0, 2) && !this.conn
- .versionMeetsMinimum(4, 0, 11));
- }
-
- /**
- * Are NULL values sorted high?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean nullsAreSortedHigh() throws SQLException {
- return false;
- }
-
- /**
- * Are NULL values sorted low?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean nullsAreSortedLow() throws SQLException {
- return !nullsAreSortedHigh();
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param type
- * DOCUMENT ME!
- * @return DOCUMENT ME!
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean othersDeletesAreVisible(int type) throws SQLException {
- return false;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param type
- * DOCUMENT ME!
- * @return DOCUMENT ME!
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean othersInsertsAreVisible(int type) throws SQLException {
- return false;
- }
-
- /**
- * JDBC 2.0 Determine whether changes made by others are visible.
- *
- * @param type
- * set type, i.e. ResultSet.TYPE_XXX
- * @return true if changes are visible for the result set type
- * @exception SQLException
- * if a database-access error occurs.
- */
- public boolean othersUpdatesAreVisible(int type) throws SQLException {
- return false;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param type
- * DOCUMENT ME!
- * @return DOCUMENT ME!
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean ownDeletesAreVisible(int type) throws SQLException {
- return false;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param type
- * DOCUMENT ME!
- * @return DOCUMENT ME!
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean ownInsertsAreVisible(int type) throws SQLException {
- return false;
- }
-
- /**
- * JDBC 2.0 Determine whether a result set's own changes visible.
- *
- * @param type
- * set type, i.e. ResultSet.TYPE_XXX
- * @return true if changes are visible for the result set type
- * @exception SQLException
- * if a database-access error occurs.
- */
- public boolean ownUpdatesAreVisible(int type) throws SQLException {
- return false;
- }
-
- private LocalAndReferencedColumns parseTableStatusIntoLocalAndReferencedColumns(
- String keysComment) throws SQLException {
- // keys will equal something like this:
- // (parent_service_id child_service_id) REFER
- // ds/subservices(parent_service_id child_service_id)
- //
- // simple-columned keys: (m) REFER
- // airline/tt(a)
- //
- // multi-columned keys : (m n) REFER
- // airline/vv(a b)
- //
- // parse of the string into three phases:
- // 1: parse the opening parentheses to determine how many results there
- // will be
- // 2: read in the schema name/table name
- // 3: parse the closing parentheses
-
- String columnsDelimitter = ","; // what version did this change in?
-
- char quoteChar = this.quotedId.length() == 0 ? 0 : this.quotedId
- .charAt(0);
-
- int indexOfOpenParenLocalColumns = StringUtils
- .indexOfIgnoreCaseRespectQuotes(0, keysComment, "(", quoteChar,
- true);
-
- if (indexOfOpenParenLocalColumns == -1) {
- throw SQLError.createSQLException("Error parsing foreign keys definition,"
- + " couldn't find start of local columns list.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- String constraintName = removeQuotedId(keysComment.substring(0,
- indexOfOpenParenLocalColumns).trim());
- keysComment = keysComment.substring(indexOfOpenParenLocalColumns,
- keysComment.length());
-
- String keysCommentTrimmed = keysComment.trim();
-
- int indexOfCloseParenLocalColumns = StringUtils
- .indexOfIgnoreCaseRespectQuotes(0, keysCommentTrimmed, ")",
- quoteChar, true);
-
- if (indexOfCloseParenLocalColumns == -1) {
- throw SQLError.createSQLException("Error parsing foreign keys definition,"
- + " couldn't find end of local columns list.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- String localColumnNamesString = keysCommentTrimmed.substring(1,
- indexOfCloseParenLocalColumns);
-
- int indexOfRefer = StringUtils.indexOfIgnoreCaseRespectQuotes(0,
- keysCommentTrimmed, "REFER ", this.quotedId.charAt(0), true);
-
- if (indexOfRefer == -1) {
- throw SQLError.createSQLException("Error parsing foreign keys definition,"
- + " couldn't find start of referenced tables list.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- int indexOfOpenParenReferCol = StringUtils
- .indexOfIgnoreCaseRespectQuotes(indexOfRefer,
- keysCommentTrimmed, "(", quoteChar, false);
-
- if (indexOfOpenParenReferCol == -1) {
- throw SQLError.createSQLException("Error parsing foreign keys definition,"
- + " couldn't find start of referenced columns list.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- String referCatalogTableString = keysCommentTrimmed.substring(
- indexOfRefer + "REFER ".length(), indexOfOpenParenReferCol);
-
- int indexOfSlash = StringUtils.indexOfIgnoreCaseRespectQuotes(0,
- referCatalogTableString, "/", this.quotedId.charAt(0), false);
-
- if (indexOfSlash == -1) {
- throw SQLError.createSQLException("Error parsing foreign keys definition,"
- + " couldn't find name of referenced catalog.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- String referCatalog = removeQuotedId(referCatalogTableString.substring(
- 0, indexOfSlash));
- String referTable = removeQuotedId(referCatalogTableString.substring(
- indexOfSlash + 1).trim());
-
- int indexOfCloseParenRefer = StringUtils
- .indexOfIgnoreCaseRespectQuotes(indexOfOpenParenReferCol,
- keysCommentTrimmed, ")", quoteChar, true);
-
- if (indexOfCloseParenRefer == -1) {
- throw SQLError.createSQLException("Error parsing foreign keys definition,"
- + " couldn't find end of referenced columns list.",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- String referColumnNamesString = keysCommentTrimmed.substring(
- indexOfOpenParenReferCol + 1, indexOfCloseParenRefer);
-
- List referColumnsList = StringUtils.split(referColumnNamesString,
- columnsDelimitter, this.quotedId, this.quotedId, false);
- List localColumnsList = StringUtils.split(localColumnNamesString,
- columnsDelimitter, this.quotedId, this.quotedId, false);
-
- return new LocalAndReferencedColumns(localColumnsList,
- referColumnsList, constraintName, referCatalog, referTable);
- }
-
- private String removeQuotedId(String s) {
- if (s == null) {
- return null;
- }
-
- if (this.quotedId.equals("")) {
- return s;
- }
-
- s = s.trim();
-
- int frontOffset = 0;
- int backOffset = s.length();
- int quoteLength = this.quotedId.length();
-
- if (s.startsWith(this.quotedId)) {
- frontOffset = quoteLength;
- }
-
- if (s.endsWith(this.quotedId)) {
- backOffset -= quoteLength;
- }
-
- return s.substring(frontOffset, backOffset);
- }
-
- /**
- * Converts the given string to bytes, using the connection's character
- * encoding, or if not available, the JVM default encoding.
- *
- * @param s
- * DOCUMENT ME!
- * @return DOCUMENT ME!
- */
- protected byte[] s2b(String s) throws SQLException {
- if (s == null) {
- return null;
- }
-
- return StringUtils.getBytes(s, this.conn.getCharacterSetMetadata(),
- this.conn.getServerCharacterEncoding(), this.conn
- .parserKnowsUnicode(), this.conn, getExceptionInterceptor());
- }
-
- /**
- * Does the database store mixed case unquoted SQL identifiers in lower
- * case?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean storesLowerCaseIdentifiers() throws SQLException {
- return this.conn.storesLowerCaseTableName();
- }
-
- /**
- * Does the database store mixed case quoted SQL identifiers in lower case?
- * A JDBC compliant driver will always return false.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
- return this.conn.storesLowerCaseTableName();
- }
-
- /**
- * Does the database store mixed case unquoted SQL identifiers in mixed
- * case?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean storesMixedCaseIdentifiers() throws SQLException {
- return !this.conn.storesLowerCaseTableName();
- }
- /**
- * Does the database store mixed case quoted SQL identifiers in mixed case?
- * A JDBC compliant driver will always return false.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
- return !this.conn.storesLowerCaseTableName();
- }
-
- /**
- * Does the database store mixed case unquoted SQL identifiers in upper
- * case?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean storesUpperCaseIdentifiers() throws SQLException {
- return false;
- }
-
- /**
- * Does the database store mixed case quoted SQL identifiers in upper case?
- * A JDBC compliant driver will always return true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
- return true; // not actually true, but required by JDBC spec!?
- }
-
- /**
- * Is "ALTER TABLE" with add column supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsAlterTableWithAddColumn() throws SQLException {
- return true;
- }
-
- /**
- * Is "ALTER TABLE" with drop column supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsAlterTableWithDropColumn() throws SQLException {
- return true;
- }
-
- /**
- * Is the ANSI92 entry level SQL grammar supported? All JDBC compliant
- * drivers must return true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsANSI92EntryLevelSQL() throws SQLException {
- return true;
- }
-
- /**
- * Is the ANSI92 full SQL grammar supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsANSI92FullSQL() throws SQLException {
- return false;
- }
-
- /**
- * Is the ANSI92 intermediate SQL grammar supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsANSI92IntermediateSQL() throws SQLException {
- return false;
- }
-
- /**
- * JDBC 2.0 Return true if the driver supports batch updates, else return
- * false.
- *
- * @return DOCUMENT ME!
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsBatchUpdates() throws SQLException {
- return true;
- }
-
- /**
- * Can a catalog name be used in a data manipulation statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsCatalogsInDataManipulation() throws SQLException {
- // Servers before 3.22 could not do this
- return this.conn.versionMeetsMinimum(3, 22, 0);
- }
-
- /**
- * Can a catalog name be used in a index definition statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
- // Servers before 3.22 could not do this
- return this.conn.versionMeetsMinimum(3, 22, 0);
- }
-
- /**
- * Can a catalog name be used in a privilege definition statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
- // Servers before 3.22 could not do this
- return this.conn.versionMeetsMinimum(3, 22, 0);
- }
-
- /**
- * Can a catalog name be used in a procedure call statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsCatalogsInProcedureCalls() throws SQLException {
- // Servers before 3.22 could not do this
- return this.conn.versionMeetsMinimum(3, 22, 0);
- }
-
- /**
- * Can a catalog name be used in a table definition statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsCatalogsInTableDefinitions() throws SQLException {
- // Servers before 3.22 could not do this
- return this.conn.versionMeetsMinimum(3, 22, 0);
- }
-
- /**
- * Is column aliasing supported?
- *
- * If so, the SQL AS clause can be used to provide names for computed
- * columns or to provide alias names for columns as required. A JDBC
- * compliant driver always returns true.
- *
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsColumnAliasing() throws SQLException {
- return true;
- }
-
- /**
- * Is the CONVERT function between SQL types supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsConvert() throws SQLException {
- return false;
- }
-
- /**
- * Is CONVERT between the given SQL types supported?
- *
- * @param fromType
- * the type to convert from
- * @param toType
- * the type to convert to
- * @return true if so
- * @throws SQLException
- * if an error occurs
- * @see Types
- */
- public boolean supportsConvert(int fromType, int toType)
- throws SQLException {
- switch (fromType) {
- /*
- * The char/binary types can be converted to pretty much anything.
- */
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
-
- switch (toType) {
- case java.sql.Types.DECIMAL:
- case java.sql.Types.NUMERIC:
- case java.sql.Types.REAL:
- case java.sql.Types.TINYINT:
- case java.sql.Types.SMALLINT:
- case java.sql.Types.INTEGER:
- case java.sql.Types.BIGINT:
- case java.sql.Types.FLOAT:
- case java.sql.Types.DOUBLE:
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- case java.sql.Types.OTHER:
- case java.sql.Types.DATE:
- case java.sql.Types.TIME:
- case java.sql.Types.TIMESTAMP:
- return true;
-
- default:
- return false;
- }
-
- /*
- * We don't handle the BIT type yet.
- */
- case java.sql.Types.BIT:
- return false;
-
- /*
- * The numeric types. Basically they can convert among themselves, and
- * with char/binary types.
- */
- case java.sql.Types.DECIMAL:
- case java.sql.Types.NUMERIC:
- case java.sql.Types.REAL:
- case java.sql.Types.TINYINT:
- case java.sql.Types.SMALLINT:
- case java.sql.Types.INTEGER:
- case java.sql.Types.BIGINT:
- case java.sql.Types.FLOAT:
- case java.sql.Types.DOUBLE:
-
- switch (toType) {
- case java.sql.Types.DECIMAL:
- case java.sql.Types.NUMERIC:
- case java.sql.Types.REAL:
- case java.sql.Types.TINYINT:
- case java.sql.Types.SMALLINT:
- case java.sql.Types.INTEGER:
- case java.sql.Types.BIGINT:
- case java.sql.Types.FLOAT:
- case java.sql.Types.DOUBLE:
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
-
- default:
- return false;
- }
-
- /* MySQL doesn't support a NULL type. */
- case java.sql.Types.NULL:
- return false;
-
- /*
- * With this driver, this will always be a serialized object, so the
- * char/binary types will work.
- */
- case java.sql.Types.OTHER:
-
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
-
- default:
- return false;
- }
-
- /* Dates can be converted to char/binary types. */
- case java.sql.Types.DATE:
-
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
-
- default:
- return false;
- }
-
- /* Time can be converted to char/binary types */
- case java.sql.Types.TIME:
-
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
-
- default:
- return false;
- }
-
- /*
- * Timestamp can be converted to char/binary types and date/time types
- * (with loss of precision).
- */
- case java.sql.Types.TIMESTAMP:
-
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- case java.sql.Types.TIME:
- case java.sql.Types.DATE:
- return true;
-
- default:
- return false;
- }
-
- /* We shouldn't get here! */
- default:
- return false; // not sure
- }
- }
-
- /**
- * Is the ODBC Core SQL grammar supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsCoreSQLGrammar() throws SQLException {
- return true;
- }
-
- /**
- * Are correlated subqueries supported? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsCorrelatedSubqueries() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 1, 0);
- }
-
- /**
- * Are both data definition and data manipulation statements within a
- * transaction supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsDataDefinitionAndDataManipulationTransactions()
- throws SQLException {
- return false;
- }
-
- /**
- * Are only data manipulation statements within a transaction supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsDataManipulationTransactionsOnly()
- throws SQLException {
- return false;
- }
-
- /**
- * If table correlation names are supported, are they restricted to be
- * different from the names of the tables? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsDifferentTableCorrelationNames() throws SQLException {
- return true;
- }
-
- /**
- * Are expressions in "ORDER BY" lists supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsExpressionsInOrderBy() throws SQLException {
- return true;
- }
-
- /**
- * Is the ODBC Extended SQL grammar supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsExtendedSQLGrammar() throws SQLException {
- return false;
- }
-
- /**
- * Are full nested outer joins supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsFullOuterJoins() throws SQLException {
- return false;
- }
-
- /**
- * JDBC 3.0
- *
- * @return DOCUMENT ME!
- */
- public boolean supportsGetGeneratedKeys() {
- return true;
- }
-
- /**
- * Is some form of "GROUP BY" clause supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsGroupBy() throws SQLException {
- return true;
- }
-
- /**
- * Can a "GROUP BY" clause add columns not in the SELECT provided it
- * specifies all the columns in the SELECT?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsGroupByBeyondSelect() throws SQLException {
- return true;
- }
-
- /**
- * Can a "GROUP BY" clause use columns not in the SELECT?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsGroupByUnrelated() throws SQLException {
- return true;
- }
-
- /**
- * Is the SQL Integrity Enhancement Facility supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsIntegrityEnhancementFacility() throws SQLException {
- if (!this.conn.getOverrideSupportsIntegrityEnhancementFacility()) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Is the escape character in "LIKE" clauses supported? A JDBC compliant
- * driver always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsLikeEscapeClause() throws SQLException {
- return true;
- }
-
- /**
- * Is there limited support for outer joins? (This will be true if
- * supportFullOuterJoins is true.)
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsLimitedOuterJoins() throws SQLException {
- return true;
- }
-
- /**
- * Is the ODBC Minimum SQL grammar supported? All JDBC compliant drivers
- * must return true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsMinimumSQLGrammar() throws SQLException {
- return true;
- }
-
- /**
- * Does the database support mixed case unquoted SQL identifiers?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsMixedCaseIdentifiers() throws SQLException {
- return !this.conn.lowerCaseTableNames();
- }
-
- /**
- * Does the database support mixed case quoted SQL identifiers? A JDBC
- * compliant driver will always return true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
- return !this.conn.lowerCaseTableNames();
- }
-
- /**
- * @see DatabaseMetaData#supportsMultipleOpenResults()
- */
- public boolean supportsMultipleOpenResults() throws SQLException {
- return true;
- }
-
- /**
- * Are multiple ResultSets from a single execute supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsMultipleResultSets() throws SQLException {
- return false;
- }
-
- /**
- * Can we have multiple transactions open at once (on different
- * connections)?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsMultipleTransactions() throws SQLException {
- return true;
- }
-
- /**
- * @see DatabaseMetaData#supportsNamedParameters()
- */
- public boolean supportsNamedParameters() throws SQLException {
- return false;
- }
-
- /**
- * Can columns be defined as non-nullable? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsNonNullableColumns() throws SQLException {
- return true;
- }
-
- /**
- * Can cursors remain open across commits?
- *
- * @return true if so
- * @throws SQLException
- * if a database access error occurs
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
- return false;
- }
-
- /**
- * Can cursors remain open across rollbacks?
- *
- * @return true if so
- * @throws SQLException
- * if an error occurs
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
- return false;
- }
-
- /**
- * Can statements remain open across commits?
- *
- * @return true if so
- * @throws SQLException
- * if an error occurs
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
- return false;
- }
-
- /**
- * Can statements remain open across rollbacks?
- *
- * @return true if so
- * @throws SQLException
- * if an error occurs
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
- return false;
- }
-
- /**
- * Can an "ORDER BY" clause use columns not in the SELECT?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsOrderByUnrelated() throws SQLException {
- return false;
- }
-
- /**
- * Is some form of outer join supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsOuterJoins() throws SQLException {
- return true;
- }
-
- /**
- * Is positioned DELETE supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsPositionedDelete() throws SQLException {
- return false;
- }
-
- /**
- * Is positioned UPDATE supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsPositionedUpdate() throws SQLException {
- return false;
- }
-
- /**
- * JDBC 2.0 Does the database support the concurrency type in combination
- * with the given result set type?
- *
- * @param type
- * defined in java.sql.ResultSet
- * @param concurrency
- * type defined in java.sql.ResultSet
- * @return true if so
- * @exception SQLException
- * if a database-access error occurs.
- * @see Connection
- */
- public boolean supportsResultSetConcurrency(int type, int concurrency)
- throws SQLException {
- switch (type) {
- case ResultSet.TYPE_SCROLL_INSENSITIVE:
- if ((concurrency == ResultSet.CONCUR_READ_ONLY)
- || (concurrency == ResultSet.CONCUR_UPDATABLE)) {
- return true;
- } else {
- throw SQLError.createSQLException(
- "Illegal arguments to supportsResultSetConcurrency()",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- case ResultSet.TYPE_FORWARD_ONLY:
- if ((concurrency == ResultSet.CONCUR_READ_ONLY)
- || (concurrency == ResultSet.CONCUR_UPDATABLE)) {
- return true;
- } else {
- throw SQLError.createSQLException(
- "Illegal arguments to supportsResultSetConcurrency()",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- case ResultSet.TYPE_SCROLL_SENSITIVE:
- return false;
- default:
- throw SQLError.createSQLException(
- "Illegal arguments to supportsResultSetConcurrency()",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- }
-
- /**
- * @see DatabaseMetaData#supportsResultSetHoldability(int)
- */
- public boolean supportsResultSetHoldability(int holdability)
- throws SQLException {
- return (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT);
- }
-
- /**
- * JDBC 2.0 Does the database support the given result set type?
- *
- * @param type
- * defined in java.sql.ResultSet
- * @return true if so
- * @exception SQLException
- * if a database-access error occurs.
- * @see Connection
- */
- public boolean supportsResultSetType(int type) throws SQLException {
- return (type == ResultSet.TYPE_SCROLL_INSENSITIVE);
- }
-
- /**
- * @see DatabaseMetaData#supportsSavepoints()
- */
- public boolean supportsSavepoints() throws SQLException {
-
- return (this.conn.versionMeetsMinimum(4, 0, 14) || this.conn
- .versionMeetsMinimum(4, 1, 1));
- }
-
- /**
- * Can a schema name be used in a data manipulation statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSchemasInDataManipulation() throws SQLException {
- return false;
- }
-
- /**
- * Can a schema name be used in an index definition statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSchemasInIndexDefinitions() throws SQLException {
- return false;
- }
-
- /**
- * Can a schema name be used in a privilege definition statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
- return false;
- }
-
- /**
- * Can a schema name be used in a procedure call statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSchemasInProcedureCalls() throws SQLException {
- return false;
- }
-
- /**
- * Can a schema name be used in a table definition statement?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSchemasInTableDefinitions() throws SQLException {
- return false;
- }
-
- /**
- * Is SELECT for UPDATE supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSelectForUpdate() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 0, 0);
- }
-
- /**
- * @see DatabaseMetaData#supportsStatementPooling()
- */
- public boolean supportsStatementPooling() throws SQLException {
- return false;
- }
-
- /**
- * Are stored procedure calls using the stored procedure escape syntax
- * supported?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsStoredProcedures() throws SQLException {
- return this.conn.versionMeetsMinimum(5, 0, 0);
- }
-
- /**
- * Are subqueries in comparison expressions supported? A JDBC compliant
- * driver always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSubqueriesInComparisons() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 1, 0);
- }
-
- /**
- * Are subqueries in exists expressions supported? A JDBC compliant driver
- * always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSubqueriesInExists() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 1, 0);
- }
-
- /**
- * Are subqueries in "in" statements supported? A JDBC compliant driver
- * always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSubqueriesInIns() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 1, 0);
- }
-
- /**
- * Are subqueries in quantified expressions supported? A JDBC compliant
- * driver always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsSubqueriesInQuantifieds() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 1, 0);
- }
-
- /**
- * Are table correlation names supported? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsTableCorrelationNames() throws SQLException {
- return true;
- }
-
- /**
- * Does the database support the given transaction isolation level?
- *
- * @param level
- * the values are defined in java.sql.Connection
- * @return true if so
- * @throws SQLException
- * if a database access error occurs
- * @see Connection
- */
- public boolean supportsTransactionIsolationLevel(int level)
- throws SQLException {
- if (this.conn.supportsIsolationLevel()) {
- switch (level) {
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
- case java.sql.Connection.TRANSACTION_READ_UNCOMMITTED:
- case java.sql.Connection.TRANSACTION_REPEATABLE_READ:
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
- return true;
-
- default:
- return false;
- }
- }
-
- return false;
- }
-
- /**
- * Are transactions supported? If not, commit is a noop and the isolation
- * level is TRANSACTION_NONE.
- *
- * @return true if transactions are supported
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsTransactions() throws SQLException {
- return this.conn.supportsTransactions();
- }
-
- /**
- * Is SQL UNION supported? A JDBC compliant driver always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsUnion() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 0, 0);
- }
-
- /**
- * Is SQL UNION ALL supported? A JDBC compliant driver always returns true.
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean supportsUnionAll() throws SQLException {
- return this.conn.versionMeetsMinimum(4, 0, 0);
- }
-
- /**
- * JDBC 2.0 Determine whether or not a visible row update can be detected by
- * calling ResultSet.rowUpdated().
- *
- * @param type
- * set type, i.e. ResultSet.TYPE_XXX
- * @return true if changes are detected by the resultset type
- * @exception SQLException
- * if a database-access error occurs.
- */
- public boolean updatesAreDetected(int type) throws SQLException {
- return false;
- }
-
- /**
- * Does the database use a file for each table?
- *
- * @return true if the database uses a local file for each table
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean usesLocalFilePerTable() throws SQLException {
- return false;
- }
-
- /**
- * Does the database store tables in a local file?
- *
- * @return true if so
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean usesLocalFiles() throws SQLException {
- return false;
- }
-
- //
- // JDBC-4.0 functions that aren't reliant on Java6
- /**
- * Retrieves a description of the given catalog's system or user
- * function parameters and return type.
- *
- * @see java.sql.DatabaseMetaData#getFunctionColumns(String, String, String, String)
- * @since 1.6
- */
- public ResultSet getFunctionColumns(String catalog,
- String schemaPattern,
- String functionNamePattern,
- String columnNamePattern) throws SQLException {
- Field[] fields = createFunctionColumnsFields();
-
- return getProcedureOrFunctionColumns(
- fields, catalog, schemaPattern,
- functionNamePattern, columnNamePattern,
- false, true);
- }
-
- protected Field[] createFunctionColumnsFields() {
- Field[] fields = {
- new Field("", "FUNCTION_CAT", Types.VARCHAR, 0),
- new Field("", "FUNCTION_SCHEM", Types.VARCHAR, 0),
- new Field("", "FUNCTION_NAME", Types.VARCHAR, 0),
- new Field("", "COLUMN_NAME", Types.VARCHAR, 0),
- new Field("", "COLUMN_TYPE", Types.VARCHAR, 0),
- new Field("", "DATA_TYPE", Types.SMALLINT, 0),
- new Field("", "TYPE_NAME", Types.VARCHAR, 0),
- new Field("", "PRECISION", Types.INTEGER, 0),
- new Field("", "LENGTH", Types.INTEGER, 0),
- new Field("", "SCALE", Types.SMALLINT, 0),
- new Field("", "RADIX", Types.SMALLINT, 0),
- new Field("", "NULLABLE", Types.SMALLINT, 0),
- new Field("", "REMARKS", Types.VARCHAR, 0),
- new Field("", "CHAR_OCTET_LENGTH", Types.INTEGER, 0),
- new Field("", "ORDINAL_POSITION", Types.INTEGER, 0),
- new Field("", "IS_NULLABLE", Types.VARCHAR, 3),
- new Field("", "SPECIFIC_NAME", Types.VARCHAR, 0)};
- return fields;
- }
-
- public boolean providesQueryObjectGenerator() throws SQLException {
- return false;
- }
-
- public ResultSet getSchemas(String catalog,
- String schemaPattern) throws SQLException {
- Field[] fields = {
- new Field("", "TABLE_SCHEM", Types.VARCHAR, 255),
- new Field("", "TABLE_CATALOG", Types.VARCHAR, 255)
- };
-
- return buildResultSet(fields, new ArrayList());
- }
-
- public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
- return true;
- }
-
- /**
- * Get a prepared statement to query information_schema tables.
- *
- * @return PreparedStatement
- * @throws SQLException
- */
- protected PreparedStatement prepareMetaDataSafeStatement(String sql)
- throws SQLException {
- // Can't use server-side here as we coerce a lot of types to match
- // the spec.
- PreparedStatement pStmt = (PreparedStatement) this.conn
- .clientPrepareStatement(sql);
-
- if (pStmt.getMaxRows() != 0) {
- pStmt.setMaxRows(0);
- }
-
- pStmt.setHoldResultsOpenOverClose(true);
-
- return pStmt;
- }
-}
diff --git a/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java b/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
deleted file mode 100644
index 61fcbe093..000000000
--- a/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java
+++ /dev/null
@@ -1,1526 +0,0 @@
-/*
- Copyright 2005-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-/**
- * DatabaseMetaData implementation that uses INFORMATION_SCHEMA available in
- * MySQL-5.0 and newer.
- *
- * The majority of the queries in this code were built for Connector/OO.org by
- * Georg Richter (georg_at_mysql.com).
- */
-public class DatabaseMetaDataUsingInfoSchema extends DatabaseMetaData {
-
- private boolean hasReferentialConstraintsView;
- private boolean hasParametersView;
-
- protected DatabaseMetaDataUsingInfoSchema(ConnectionImpl connToSet,
- String databaseToSet) throws SQLException {
- super(connToSet, databaseToSet);
-
- this.hasReferentialConstraintsView =
- this.conn.versionMeetsMinimum(5, 1, 10);
-
- ResultSet rs = null;
-
- try {
- rs = super.getTables("INFORMATION_SCHEMA", null, "PARAMETERS", new String[0]);
-
- this.hasParametersView = rs.next();
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
- }
-
- private ResultSet executeMetadataQuery(PreparedStatement pStmt)
- throws SQLException {
- ResultSet rs = pStmt.executeQuery();
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).setOwningStatement(null);
-
- return rs;
- }
-
- /**
- * Get a description of the access rights for a table's columns.
- *
- * Only privileges matching the column name criteria are returned. They are
- * ordered by COLUMN_NAME and PRIVILEGE.
- *
- *
- * Each privilige description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
COLUMN_NAME String => column name
- *
GRANTOR => grantor of access (may be null)
- *
GRANTEE String => grantee of access
- *
PRIVILEGE String => name of access (SELECT, INSERT, UPDATE,
- * REFRENCES, ...)
- *
IS_GRANTABLE String => "YES" if grantee is permitted to
- * grant to others; "NO" if not; null if unknown
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name; "" retrieves those without a schema
- * @param table
- * a table name
- * @param columnNamePattern
- * a column name pattern
- * @return ResultSet each row is a column privilege description
- * @throws SQLException
- * if a database access error occurs
- * @see #getSearchStringEscape
- */
- public java.sql.ResultSet getColumnPrivileges(String catalog,
- String schema, String table, String columnNamePattern)
- throws SQLException {
- if (columnNamePattern == null) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- columnNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Column name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- catalog = this.database;
- }
- }
-
- String sql = "SELECT TABLE_SCHEMA AS TABLE_CAT, NULL AS TABLE_SCHEM, TABLE_NAME,"
- +"COLUMN_NAME, NULL AS GRANTOR, GRANTEE, PRIVILEGE_TYPE AS PRIVILEGE, IS_GRANTABLE FROM "
- + "INFORMATION_SCHEMA.COLUMN_PRIVILEGES WHERE "
- + "TABLE_SCHEMA LIKE ? AND "
- + "TABLE_NAME =? AND COLUMN_NAME LIKE ? ORDER BY "
- + "COLUMN_NAME, PRIVILEGE_TYPE";
-
- PreparedStatement pStmt = null;
-
- try {
- pStmt = prepareMetaDataSafeStatement(sql);
-
- if (catalog != null) {
- pStmt.setString(1, catalog);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, table);
- pStmt.setString(3, columnNamePattern);
-
- ResultSet rs = executeMetadataQuery(pStmt);
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(new Field[] {
- new Field("", "TABLE_CAT", Types.CHAR, 64),
- new Field("", "TABLE_SCHEM", Types.CHAR, 1),
- new Field("", "TABLE_NAME", Types.CHAR, 64),
- new Field("", "COLUMN_NAME", Types.CHAR, 64),
- new Field("", "GRANTOR", Types.CHAR, 77),
- new Field("", "GRANTEE", Types.CHAR, 77),
- new Field("", "PRIVILEGE", Types.CHAR, 64),
- new Field("", "IS_GRANTABLE", Types.CHAR, 3)});
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Get a description of table columns available in a catalog.
- *
- * Only column descriptions matching the catalog, schema, table and column
- * name criteria are returned. They are ordered by TABLE_SCHEM, TABLE_NAME
- * and ORDINAL_POSITION.
- *
- *
- * Each column description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
COLUMN_NAME String => column name
- *
DATA_TYPE short => SQL type from java.sql.Types
- *
TYPE_NAME String => Data source dependent type name
- *
COLUMN_SIZE int => column size. For char or date types this
- * is the maximum number of characters, for numeric or decimal types this is
- * precision.
- *
BUFFER_LENGTH is not used.
- *
DECIMAL_DIGITS int => the number of fractional digits
- *
NUM_PREC_RADIX int => Radix (typically either 10 or 2)
CHAR_OCTET_LENGTH int => for char types the maximum number
- * of bytes in the column
- *
ORDINAL_POSITION int => index of column in table (starting
- * at 1)
- *
IS_NULLABLE String => "NO" means column definitely does not
- * allow NULL values; "YES" means the column might allow NULL values. An
- * empty string means nobody knows.
- *
- *
- */
- public ResultSet getColumns(String catalog, String schemaPattern,
- String tableName, String columnNamePattern) throws SQLException {
- if (columnNamePattern == null) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- columnNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Column name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- catalog = this.database;
- }
- }
-
- StringBuffer sqlBuf = new StringBuffer("SELECT "
- + "TABLE_SCHEMA AS TABLE_CAT, " + "NULL AS TABLE_SCHEM,"
- + "TABLE_NAME," + "COLUMN_NAME,");
- MysqlDefs.appendJdbcTypeMappingQuery(sqlBuf, "DATA_TYPE");
-
- sqlBuf.append(" AS DATA_TYPE, ");
-
- if (conn.getCapitalizeTypeNames()) {
- sqlBuf.append("UPPER(CASE WHEN LOCATE('unsigned', COLUMN_TYPE) != 0 AND LOCATE('unsigned', DATA_TYPE) = 0 THEN CONCAT(DATA_TYPE, ' unsigned') ELSE DATA_TYPE END) AS TYPE_NAME,");
- } else {
- sqlBuf.append("CASE WHEN LOCATE('unsigned', COLUMN_TYPE) != 0 AND LOCATE('unsigned', DATA_TYPE) = 0 THEN CONCAT(DATA_TYPE, ' unsigned') ELSE DATA_TYPE END AS TYPE_NAME,");
- }
-
- sqlBuf
- .append("CASE WHEN LCASE(DATA_TYPE)='date' THEN 10 WHEN LCASE(DATA_TYPE)='time' THEN 8 WHEN LCASE(DATA_TYPE)='datetime' THEN 19 WHEN LCASE(DATA_TYPE)='timestamp' THEN 19 WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION WHEN CHARACTER_MAXIMUM_LENGTH > "
- + Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + " ELSE CHARACTER_MAXIMUM_LENGTH END AS COLUMN_SIZE, "
- + MysqlIO.getMaxBuf() + " AS BUFFER_LENGTH,"
- + "NUMERIC_SCALE AS DECIMAL_DIGITS,"
- + "10 AS NUM_PREC_RADIX,"
- + "CASE WHEN IS_NULLABLE='NO' THEN " + columnNoNulls + " ELSE CASE WHEN IS_NULLABLE='YES' THEN " + columnNullable + " ELSE " + columnNullableUnknown + " END END AS NULLABLE,"
- + "COLUMN_COMMENT AS REMARKS,"
- + "COLUMN_DEFAULT AS COLUMN_DEF,"
- + "0 AS SQL_DATA_TYPE,"
- + "0 AS SQL_DATETIME_SUB,"
- + "CASE WHEN CHARACTER_OCTET_LENGTH > " + Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + " ELSE CHARACTER_OCTET_LENGTH END AS CHAR_OCTET_LENGTH,"
- + "ORDINAL_POSITION,"
- + "IS_NULLABLE,"
- + "NULL AS SCOPE_CATALOG,"
- + "NULL AS SCOPE_SCHEMA,"
- + "NULL AS SCOPE_TABLE,"
- + "NULL AS SOURCE_DATA_TYPE,"
- + "IF (EXTRA LIKE '%auto_increment%','YES','NO') AS IS_AUTOINCREMENT "
- + "FROM INFORMATION_SCHEMA.COLUMNS WHERE "
- + "TABLE_SCHEMA LIKE ? AND "
- + "TABLE_NAME LIKE ? AND COLUMN_NAME LIKE ? "
- + "ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION");
-
- PreparedStatement pStmt = null;
-
- try {
- pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
-
- if (catalog != null) {
- pStmt.setString(1, catalog);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, tableName);
- pStmt.setString(3, columnNamePattern);
-
- ResultSet rs = executeMetadataQuery(pStmt);
-
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(createColumnsFields());
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Get a description of the foreign key columns in the foreign key table
- * that reference the primary key columns of the primary key table (describe
- * how one table imports another's key.) This should normally return a
- * single foreign key/primary key pair (most tables only import a foreign
- * key from a table once.) They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
- * FKTABLE_NAME, and KEY_SEQ.
- *
- * Each foreign key column description has the following columns:
- *
KEY_SEQ short => sequence number within foreign key
- *
UPDATE_RULE short => What happens to foreign key when
- * primary is updated:
- *
- *
importedKeyCascade - change imported key to agree with primary key
- * update
- *
importedKeyRestrict - do not allow update of primary key if it has
- * been imported
- *
importedKeySetNull - change imported key to NULL if its primary key
- * has been updated
- *
- *
- *
DELETE_RULE short => What happens to the foreign key when
- * primary is deleted.
- *
- *
importedKeyCascade - delete rows that import a deleted key
- *
importedKeyRestrict - do not allow delete of primary key if it has
- * been imported
- *
importedKeySetNull - change imported key to NULL if its primary key
- * has been deleted
- *
- *
- *
FK_NAME String => foreign key name (may be null)
- *
PK_NAME String => primary key name (may be null)
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name pattern; "" retrieves those without a schema
- * @param table
- * a table name
- * @return ResultSet each row is a primary key column description
- * @throws SQLException
- * if a database access error occurs
- * @see #getExportedKeys
- */
- public java.sql.ResultSet getImportedKeys(String catalog, String schema,
- String table) throws SQLException {
- if (table == null) {
- throw SQLError.createSQLException("Table not specified.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- catalog = this.database;
- }
- }
-
- String sql = "SELECT "
- + "A.REFERENCED_TABLE_SCHEMA AS PKTABLE_CAT,"
- + "NULL AS PKTABLE_SCHEM,"
- + "A.REFERENCED_TABLE_NAME AS PKTABLE_NAME,"
- + "A.REFERENCED_COLUMN_NAME AS PKCOLUMN_NAME,"
- + "A.TABLE_SCHEMA AS FKTABLE_CAT,"
- + "NULL AS FKTABLE_SCHEM,"
- + "A.TABLE_NAME AS FKTABLE_NAME, "
- + "A.COLUMN_NAME AS FKCOLUMN_NAME, "
- + "A.ORDINAL_POSITION AS KEY_SEQ,"
- + generateUpdateRuleClause()
- + " AS UPDATE_RULE,"
- + generateDeleteRuleClause()
- + " AS DELETE_RULE,"
- + "A.CONSTRAINT_NAME AS FK_NAME,"
- + "(SELECT CONSTRAINT_NAME FROM"
- + " INFORMATION_SCHEMA.TABLE_CONSTRAINTS"
- + " WHERE TABLE_SCHEMA = A.REFERENCED_TABLE_SCHEMA AND"
- + " TABLE_NAME = A.REFERENCED_TABLE_NAME AND"
- + " CONSTRAINT_TYPE IN ('UNIQUE','PRIMARY KEY') LIMIT 1)"
- + " AS PK_NAME,"
- + importedKeyNotDeferrable
- + " AS DEFERRABILITY "
- + "FROM "
- + "INFORMATION_SCHEMA.KEY_COLUMN_USAGE A "
- + "JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS B USING "
- + "(CONSTRAINT_NAME, TABLE_NAME) "
- + generateOptionalRefContraintsJoin()
- + "WHERE "
- + "B.CONSTRAINT_TYPE = 'FOREIGN KEY' "
- + "AND A.TABLE_SCHEMA LIKE ? "
- + "AND A.TABLE_NAME=? "
- + "AND A.REFERENCED_TABLE_SCHEMA IS NOT NULL "
- + "ORDER BY "
- + "A.REFERENCED_TABLE_SCHEMA, A.REFERENCED_TABLE_NAME, "
- + "A.ORDINAL_POSITION";
-
- PreparedStatement pStmt = null;
-
- try {
- pStmt = prepareMetaDataSafeStatement(sql);
-
- if (catalog != null) {
- pStmt.setString(1, catalog);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, table);
-
- ResultSet rs = executeMetadataQuery(pStmt);
-
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(createFkMetadataFields());
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Get a description of a table's indices and statistics. They are ordered
- * by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
- *
- * Each index column description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
NON_UNIQUE boolean => Can index values be non-unique? false
- * when TYPE is tableIndexStatistic
- *
INDEX_QUALIFIER String => index catalog (may be null); null
- * when TYPE is tableIndexStatistic
- *
INDEX_NAME String => index name; null when TYPE is
- * tableIndexStatistic
- *
TYPE short => index type:
- *
- *
tableIndexStatistic - this identifies table statistics that are
- * returned in conjuction with a table's index descriptions
- *
tableIndexClustered - this is a clustered index
- *
tableIndexHashed - this is a hashed index
- *
tableIndexOther - this is some other style of index
- *
- *
- *
ORDINAL_POSITION short => column sequence number within
- * index; zero when TYPE is tableIndexStatistic
- *
COLUMN_NAME String => column name; null when TYPE is
- * tableIndexStatistic
- *
ASC_OR_DESC String => column sort sequence, "A" =>
- * ascending, "D" => descending, may be null if sort sequence is not
- * supported; null when TYPE is tableIndexStatistic
- *
CARDINALITY int => When TYPE is tableIndexStatisic then this
- * is the number of rows in the table; otherwise it is the number of unique
- * values in the index.
- *
PAGES int => When TYPE is tableIndexStatisic then this is
- * the number of pages used for the table, otherwise it is the number of
- * pages used for the current index.
- *
FILTER_CONDITION String => Filter condition, if any. (may be
- * null)
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name pattern; "" retrieves those without a schema
- * @param table
- * a table name
- * @param unique
- * when true, return only indices for unique values; when false,
- * return indices regardless of whether unique or not
- * @param approximate
- * when true, result is allowed to reflect approximate or out of
- * data values; when false, results are requested to be accurate
- * @return ResultSet each row is an index column description
- * @throws SQLException
- * DOCUMENT ME!
- */
- public ResultSet getIndexInfo(String catalog, String schema, String table,
- boolean unique, boolean approximate) throws SQLException {
- StringBuffer sqlBuf = new StringBuffer("SELECT "
- + "TABLE_SCHEMA AS TABLE_CAT, " + "NULL AS TABLE_SCHEM,"
- + "TABLE_NAME," + "NON_UNIQUE,"
- + "TABLE_SCHEMA AS INDEX_QUALIFIER," + "INDEX_NAME,"
- + tableIndexOther + " AS TYPE,"
- + "SEQ_IN_INDEX AS ORDINAL_POSITION," + "COLUMN_NAME,"
- + "COLLATION AS ASC_OR_DESC," + "CARDINALITY,"
- + "NULL AS PAGES," + "NULL AS FILTER_CONDITION "
- + "FROM INFORMATION_SCHEMA.STATISTICS WHERE "
- + "TABLE_SCHEMA LIKE ? AND " + "TABLE_NAME LIKE ?");
-
- if (unique) {
- sqlBuf.append(" AND NON_UNIQUE=0 ");
- }
-
- sqlBuf.append("ORDER BY NON_UNIQUE, INDEX_NAME, SEQ_IN_INDEX");
-
- PreparedStatement pStmt = null;
-
- try {
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- catalog = this.database;
- }
- }
-
- pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
-
- if (catalog != null) {
- pStmt.setString(1, catalog);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, table);
-
- ResultSet rs = executeMetadataQuery(pStmt);
-
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(createIndexInfoFields());
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Get a description of a table's primary key columns. They are ordered by
- * COLUMN_NAME.
- *
- * Each column description has the following columns:
- *
- *
TABLE_CAT String => table catalog (may be null)
- *
TABLE_SCHEM String => table schema (may be null)
- *
TABLE_NAME String => table name
- *
COLUMN_NAME String => column name
- *
KEY_SEQ short => sequence number within primary key
- *
PK_NAME String => primary key name (may be null)
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schema
- * a schema name pattern; "" retrieves those without a schema
- * @param table
- * a table name
- * @return ResultSet each row is a primary key column description
- * @throws SQLException
- * DOCUMENT ME!
- */
- public java.sql.ResultSet getPrimaryKeys(String catalog, String schema,
- String table) throws SQLException {
-
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- catalog = this.database;
- }
- }
-
- if (table == null) {
- throw SQLError.createSQLException("Table not specified.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- String sql = "SELECT TABLE_SCHEMA AS TABLE_CAT, NULL AS TABLE_SCHEM, TABLE_NAME, "
- + "COLUMN_NAME, SEQ_IN_INDEX AS KEY_SEQ, 'PRIMARY' AS PK_NAME FROM INFORMATION_SCHEMA.STATISTICS "
- + "WHERE TABLE_SCHEMA LIKE ? AND TABLE_NAME LIKE ? AND "
- + "INDEX_NAME='PRIMARY' ORDER BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX";
-
- PreparedStatement pStmt = null;
-
- try {
- pStmt = prepareMetaDataSafeStatement(sql);
-
- if (catalog != null) {
- pStmt.setString(1, catalog);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, table);
-
- ResultSet rs = executeMetadataQuery(pStmt);
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(new Field[] {
- new Field("", "TABLE_CAT", Types.CHAR, 255),
- new Field("", "TABLE_SCHEM", Types.CHAR, 0),
- new Field("", "TABLE_NAME", Types.CHAR, 255),
- new Field("", "COLUMN_NAME", Types.CHAR, 32),
- new Field("", "KEY_SEQ", Types.SMALLINT, 5),
- new Field("", "PK_NAME", Types.CHAR, 32) });
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Get a description of stored procedures available in a catalog.
- *
- * Only procedure descriptions matching the schema and procedure name
- * criteria are returned. They are ordered by PROCEDURE_SCHEM, and
- * PROCEDURE_NAME.
- *
- *
- * Each procedure description has the the following columns:
- *
- *
PROCEDURE_CAT String => procedure catalog (may be null)
- *
- *
PROCEDURE_SCHEM String => procedure schema (may be null)
- *
- *
PROCEDURE_NAME String => procedure name
- *
reserved for future use
- *
reserved for future use
- *
reserved for future use
- *
REMARKS String => explanatory comment on the procedure
- *
PROCEDURE_TYPE short => kind of procedure:
- *
- *
procedureResultUnknown - May return a result
- *
procedureNoResult - Does not return a result
- *
procedureReturnsResult - Returns a result
- *
- *
- *
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schemaPattern
- * a schema name pattern; "" retrieves those without a schema
- * @param procedureNamePattern
- * a procedure name pattern
- * @return ResultSet each row is a procedure description
- * @throws SQLException
- * if a database access error occurs
- * @see #getSearchStringEscape
- */
- public ResultSet getProcedures(String catalog, String schemaPattern,
- String procedureNamePattern) throws SQLException {
-
- if ((procedureNamePattern == null)
- || (procedureNamePattern.length() == 0)) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- procedureNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Procedure name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- String db = null;
-
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- db = this.database;
- }
- }
-
- String sql = "SELECT ROUTINE_SCHEMA AS PROCEDURE_CAT, "
- + "NULL AS PROCEDURE_SCHEM, "
- + "ROUTINE_NAME AS PROCEDURE_NAME, " + "NULL AS RESERVED_1, "
- + "NULL AS RESERVED_2, " + "NULL AS RESERVED_3, "
- + "ROUTINE_COMMENT AS REMARKS, "
- + "CASE WHEN ROUTINE_TYPE = 'PROCEDURE' THEN "
- + procedureNoResult + " WHEN ROUTINE_TYPE='FUNCTION' THEN "
- + procedureReturnsResult + " ELSE " + procedureResultUnknown
- + " END AS PROCEDURE_TYPE "
- + "FROM INFORMATION_SCHEMA.ROUTINES WHERE "
- + "ROUTINE_SCHEMA LIKE ? AND ROUTINE_NAME LIKE ? "
- + "ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME";
-
- PreparedStatement pStmt = null;
-
- try {
- pStmt = prepareMetaDataSafeStatement(sql);
-
- if (db != null) {
- pStmt.setString(1, db);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, procedureNamePattern);
-
- ResultSet rs = executeMetadataQuery(pStmt);
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(new Field[] {
- new Field("", "PROCEDURE_CAT", Types.CHAR, 0),
- new Field("", "PROCEDURE_SCHEM", Types.CHAR, 0),
- new Field("", "PROCEDURE_NAME", Types.CHAR, 0),
- new Field("", "reserved1", Types.CHAR, 0),
- new Field("", "reserved2", Types.CHAR, 0),
- new Field("", "reserved3", Types.CHAR, 0),
- new Field("", "REMARKS", Types.CHAR, 0),
- new Field("", "PROCEDURE_TYPE", Types.SMALLINT, 0) });
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Retrieves a description of the given catalog's system or user
- * function parameters and return type.
- *
- *
Only descriptions matching the schema, function and
- * parameter name criteria are returned. They are ordered by
- * FUNCTION_CAT, FUNCTION_SCHEM,
- * FUNCTION_NAME and
- * SPECIFIC_ NAME. Within this, the return value,
- * if any, is first. Next are the parameter descriptions in call
- * order. The column descriptions follow in column number order.
- *
- *
Each row in the ResultSet
- * is a parameter description, column description or
- * return type description with the following fields:
- *
- *
FUNCTION_CAT String => function catalog (may be null)
- *
FUNCTION_SCHEM String => function schema (may be null)
- *
FUNCTION_NAME String => function name. This is the name
- * used to invoke the function
- *
COLUMN_NAME String => column/parameter name
- *
COLUMN_TYPE Short => kind of column/parameter:
- *
- *
functionColumnUnknown - nobody knows
- *
functionColumnIn - IN parameter
- *
functionColumnInOut - INOUT parameter
- *
functionColumnOut - OUT parameter
- *
functionColumnReturn - function return value
- *
functionColumnResult - Indicates that the parameter or column
- * is a column in the ResultSet
- *
- *
DATA_TYPE int => SQL type from java.sql.Types
- *
TYPE_NAME String => SQL type name, for a UDT type the
- * type name is fully qualified
- *
PRECISION int => precision
- *
LENGTH int => length in bytes of data
- *
SCALE short => scale - null is returned for data types where
- * SCALE is not applicable.
- *
CHAR_OCTET_LENGTH int => the maximum length of binary
- * and character based parameters or columns. For any other datatype the returned value
- * is a NULL
- *
ORDINAL_POSITION int => the ordinal position, starting
- * from 1, for the input and output parameters. A value of 0
- * is returned if this row describes the function's return value.
- * For result set columns, it is the
- * ordinal position of the column in the result set starting from 1.
- *
IS_NULLABLE String => ISO rules are used to determine
- * the nullability for a parameter or column.
- *
- *
YES --- if the parameter or column can include NULLs
- *
NO --- if the parameter or column cannot include NULLs
- *
empty string --- if the nullability for the
- * parameter or column is unknown
- *
- *
SPECIFIC_NAME String => the name which uniquely identifies
- * this function within its schema. This is a user specified, or DBMS
- * generated, name that may be different then the FUNCTION_NAME
- * for example with overload functions
- *
- *
- *
The PRECISION column represents the specified column size for the given
- * parameter or column.
- * For numeric data, this is the maximum precision. For character data, this is the length in characters.
- * For datetime datatypes, this is the length in characters of the String representation (assuming the
- * maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype,
- * this is the length in bytes. Null is returned for data types where the
- * column size is not applicable.
- * @param catalog a catalog name; must match the catalog name as it
- * is stored in the database; "" retrieves those without a catalog;
- * null means that the catalog name should not be used to narrow
- * the search
- * @param schemaPattern a schema name pattern; must match the schema name
- * as it is stored in the database; "" retrieves those without a schema;
- * null means that the schema name should not be used to narrow
- * the search
- * @param functionNamePattern a procedure name pattern; must match the
- * function name as it is stored in the database
- * @param columnNamePattern a parameter name pattern; must match the
- * parameter or column name as it is stored in the database
- * @return ResultSet - each row describes a
- * user function parameter, column or return type
- *
- * @exception SQLException if a database access error occurs
- * @see #getSearchStringEscape
- * @since 1.6
- */
- public ResultSet getFunctionColumns(String catalog,
- String schemaPattern,
- String functionNamePattern,
- String columnNamePattern) throws SQLException {
- if (!this.conn.versionMeetsMinimum(5, 4, 0)) {
- return super.getFunctionColumns(catalog, schemaPattern, functionNamePattern,
- columnNamePattern);
- }
-
- if (!this.hasParametersView) {
- return super.getFunctionColumns(catalog, schemaPattern, functionNamePattern, columnNamePattern);
- }
-
- if ((functionNamePattern == null)
- || (functionNamePattern.length() == 0)) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- functionNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Procedure name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- String db = null;
-
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- db = this.database;
- }
- }
-
- // FIXME: Use DBMD constants when we leave Java5
- // FUNCTION_CAT
- // FUNCTION_SCHEM
- // FUNCTION_NAME
- // COLUMN_NAME
- // COLUMN_TYPE
- StringBuffer sqlBuf = new StringBuffer("SELECT SPECIFIC_SCHEMA AS FUNCTION_CAT, "
- + "NULL AS `FUNCTION_SCHEM`, "
- + "SPECIFIC_NAME AS `FUNCTION_NAME`, "
- + "PARAMETER_NAME AS `COLUMN_NAME`, "
- + "CASE WHEN PARAMETER_MODE = 'IN' THEN "
- + 1 /* functionColumnIn */ + " WHEN PARAMETER_MODE='OUT' THEN " + 3 /* functionColumnOut */
- + " WHEN PARAMETER_MODE='INOUT' THEN " + 2 /* functionColumnInOut */
- + " WHEN ORDINAL_POSITION=0 THEN " + 4 /* functionReturn */
- + " ELSE " + 0 /* functionColumnUnknown */
- + " END AS `COLUMN_TYPE`, ");
-
- //DATA_TYPE
- MysqlDefs.appendJdbcTypeMappingQuery(sqlBuf, "DATA_TYPE");
-
- sqlBuf.append(" AS `DATA_TYPE`, ");
-
- // TYPE_NAME
- if (conn.getCapitalizeTypeNames()) {
- sqlBuf.append("UPPER(CASE WHEN LOCATE('unsigned', DATA_TYPE) != 0 AND LOCATE('unsigned', DATA_TYPE) = 0 THEN CONCAT(DATA_TYPE, ' unsigned') ELSE DATA_TYPE END) AS `TYPE_NAME`,");
- } else {
- sqlBuf.append("CASE WHEN LOCATE('unsigned', DATA_TYPE) != 0 AND LOCATE('unsigned', DATA_TYPE) = 0 THEN CONCAT(DATA_TYPE, ' unsigned') ELSE DATA_TYPE END AS `TYPE_NAME`,");
- }
-
- // PRECISION int => precision
- sqlBuf.append("NUMERIC_PRECISION AS `PRECISION`, ");
- // LENGTH int => length in bytes of data
- sqlBuf
- .append("CASE WHEN LCASE(DATA_TYPE)='date' THEN 10 WHEN LCASE(DATA_TYPE)='time' THEN 8 WHEN LCASE(DATA_TYPE)='datetime' THEN 19 WHEN LCASE(DATA_TYPE)='timestamp' THEN 19 WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION WHEN CHARACTER_MAXIMUM_LENGTH > "
- + Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + " ELSE CHARACTER_MAXIMUM_LENGTH END AS LENGTH, ");
-
- // SCALE short => scale
- sqlBuf.append("NUMERIC_SCALE AS `SCALE`, ");
- // RADIX short => radix
- sqlBuf.append("10 AS RADIX,");
- // NULLABLE
- // REMARKS
- // CHAR_OCTET_LENGTH *
- // ORDINAL_POSITION *
- // IS_NULLABLE *
- // SPECIFIC_NAME *
- sqlBuf.append(2 /* functionNullableUnknown */ + " AS `NULLABLE`, "
- + " NULL AS `REMARKS`, "
- + "CHARACTER_OCTET_LENGTH AS `CHAR_OCTET_LENGTH`, "
- + " ORDINAL_POSITION, "
- + "'' AS `IS_NULLABLE`, "
- + "SPECIFIC_NAME "
- + "FROM INFORMATION_SCHEMA.PARAMETERS WHERE "
- + "SPECIFIC_SCHEMA LIKE ? AND SPECIFIC_NAME LIKE ? AND (PARAMETER_NAME LIKE ? OR PARAMETER_NAME IS NULL) "
- + "AND ROUTINE_TYPE='FUNCTION' ORDER BY SPECIFIC_SCHEMA, SPECIFIC_NAME, ORDINAL_POSITION");
-
- PreparedStatement pStmt = null;
-
- try {
- pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
-
- if (db != null) {
- pStmt.setString(1, db);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, functionNamePattern);
- pStmt.setString(3, columnNamePattern);
-
- ResultSet rs = executeMetadataQuery(pStmt);
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(createFunctionColumnsFields());
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Retrieves a description of the given catalog's stored procedure parameter
- * and result columns.
- *
- *
Only descriptions matching the schema, procedure and
- * parameter name criteria are returned. They are ordered by
- * PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value,
- * if any, is first. Next are the parameter descriptions in call
- * order. The column descriptions follow in column number order.
- *
- *
Each row in the ResultSet is a parameter description or
- * column description with the following fields:
- *
- *
PROCEDURE_CAT String => procedure catalog (may be null)
- *
PROCEDURE_SCHEM String => procedure schema (may be null)
- *
PROCEDURE_NAME String => procedure name
- *
COLUMN_NAME String => column/parameter name
- *
COLUMN_TYPE Short => kind of column/parameter:
- *
- *
procedureColumnUnknown - nobody knows
- *
procedureColumnIn - IN parameter
- *
procedureColumnInOut - INOUT parameter
- *
procedureColumnOut - OUT parameter
- *
procedureColumnReturn - procedure return value
- *
procedureColumnResult - result column in ResultSet
- *
- *
DATA_TYPE int => SQL type from java.sql.Types
- *
TYPE_NAME String => SQL type name, for a UDT type the
- * type name is fully qualified
- *
Note: Some databases may not return the column
- * descriptions for a procedure. Additional columns beyond
- * REMARKS can be defined by the database.
- *
- * @param catalog a catalog name; must match the catalog name as it
- * is stored in the database; "" retrieves those without a catalog;
- * null means that the catalog name should not be used to narrow
- * the search
- * @param schemaPattern a schema name pattern; must match the schema name
- * as it is stored in the database; "" retrieves those without a schema;
- * null means that the schema name should not be used to narrow
- * the search
- * @param procedureNamePattern a procedure name pattern; must match the
- * procedure name as it is stored in the database
- * @param columnNamePattern a column name pattern; must match the column name
- * as it is stored in the database
- * @return ResultSet - each row describes a stored procedure parameter or
- * column
- * @exception SQLException if a database access error occurs
- * @see #getSearchStringEscape
- */
- public ResultSet getProcedureColumns(String catalog, String schemaPattern,
- String procedureNamePattern, String columnNamePattern)
- throws SQLException {
- if (!this.conn.versionMeetsMinimum(5, 4, 0)) {
- return super.getProcedureColumns(catalog, schemaPattern, procedureNamePattern,
- columnNamePattern);
- }
-
- if (!this.hasParametersView) {
- return super.getProcedureColumns(catalog, schemaPattern, procedureNamePattern, columnNamePattern);
- }
-
- if ((procedureNamePattern == null)
- || (procedureNamePattern.length() == 0)) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- procedureNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Procedure name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- String db = null;
-
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- db = this.database;
- }
- }
-
- // Here's what we get from MySQL ...
- // SPECIFIC_CATALOG NULL
- // SPECIFIC_SCHEMA db17
- // SPECIFIC_NAME p
- // ORDINAL_POSITION 1
- // PARAMETER_MODE OUT
- // PARAMETER_NAME a
- // DATA_TYPE int
- // CHARACTER_MAXIMUM_LENGTH NULL
- // CHARACTER_OCTET_LENGTH NULL
- // CHARACTER_SET_NAME NULL
- // COLLATION_NAME NULL
- // NUMERIC_PRECISION 10
- // NUMERIC_SCALE 0
- // DTD_IDENTIFIER int(11)
-
- StringBuffer sqlBuf = new StringBuffer("SELECT SPECIFIC_SCHEMA AS PROCEDURE_CAT, "
- + "NULL AS `PROCEDURE_SCHEM`, "
- + "SPECIFIC_NAME AS `PROCEDURE_NAME`, "
- + "PARAMETER_NAME AS `COLUMN_NAME`, "
- + "CASE WHEN PARAMETER_MODE = 'IN' THEN "
- + procedureColumnIn + " WHEN PARAMETER_MODE='OUT' THEN " + procedureColumnOut
- + " WHEN PARAMETER_MODE='INOUT' THEN " + procedureColumnInOut
- + " WHEN ORDINAL_POSITION=0 THEN " + procedureColumnReturn
- + " ELSE " + procedureColumnUnknown
- + " END AS `COLUMN_TYPE`, ");
-
- //DATA_TYPE
- MysqlDefs.appendJdbcTypeMappingQuery(sqlBuf, "DATA_TYPE");
-
- sqlBuf.append(" AS `DATA_TYPE`, ");
-
- // TYPE_NAME
- if (conn.getCapitalizeTypeNames()) {
- sqlBuf.append("UPPER(CASE WHEN LOCATE('unsigned', DATA_TYPE) != 0 AND LOCATE('unsigned', DATA_TYPE) = 0 THEN CONCAT(DATA_TYPE, ' unsigned') ELSE DATA_TYPE END) AS `TYPE_NAME`,");
- } else {
- sqlBuf.append("CASE WHEN LOCATE('unsigned', DATA_TYPE) != 0 AND LOCATE('unsigned', DATA_TYPE) = 0 THEN CONCAT(DATA_TYPE, ' unsigned') ELSE DATA_TYPE END AS `TYPE_NAME`,");
- }
-
- // PRECISION int => precision
- sqlBuf.append("NUMERIC_PRECISION AS `PRECISION`, ");
- // LENGTH int => length in bytes of data
- sqlBuf
- .append("CASE WHEN LCASE(DATA_TYPE)='date' THEN 10 WHEN LCASE(DATA_TYPE)='time' THEN 8 WHEN LCASE(DATA_TYPE)='datetime' THEN 19 WHEN LCASE(DATA_TYPE)='timestamp' THEN 19 WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION WHEN CHARACTER_MAXIMUM_LENGTH > "
- + Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + " ELSE CHARACTER_MAXIMUM_LENGTH END AS LENGTH, ");
-
- // SCALE short => scale
- sqlBuf.append("NUMERIC_SCALE AS `SCALE`, ");
- // RADIX short => radix
- sqlBuf.append("10 AS RADIX,");
- sqlBuf.append(procedureNullableUnknown + " AS `NULLABLE`, "
- + " NULL AS `REMARKS` "
- + "FROM INFORMATION_SCHEMA.PARAMETERS WHERE "
- + "SPECIFIC_SCHEMA LIKE ? AND SPECIFIC_NAME LIKE ? AND (PARAMETER_NAME LIKE ? OR PARAMETER_NAME IS NULL) "
- + "ORDER BY SPECIFIC_SCHEMA, SPECIFIC_NAME, ORDINAL_POSITION");
-
- PreparedStatement pStmt = null;
-
- try {
- pStmt = prepareMetaDataSafeStatement(sqlBuf.toString());
-
- if (db != null) {
- pStmt.setString(1, db);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, procedureNamePattern);
- pStmt.setString(3, columnNamePattern);
-
- ResultSet rs = executeMetadataQuery(pStmt);
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(createProcedureColumnsFields());
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
- /**
- * Get a description of tables available in a catalog.
- *
- * Only table descriptions matching the catalog, schema, table name and type
- * criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM and
- * TABLE_NAME.
- *
- *
- * Each table description has the following columns:
- *
REMARKS String => explanatory comment on the table
- *
- *
- *
- * Note: Some databases may not return information for all tables.
- *
- *
- * @param catalog
- * a catalog name; "" retrieves those without a catalog
- * @param schemaPattern
- * a schema name pattern; "" retrieves those without a schema
- * @param tableNamePattern
- * a table name pattern
- * @param types
- * a list of table types to include; null returns all types
- * @return ResultSet each row is a table description
- * @throws SQLException
- * DOCUMENT ME!
- * @see #getSearchStringEscape
- */
- public ResultSet getTables(String catalog, String schemaPattern,
- String tableNamePattern, String[] types) throws SQLException {
- if (catalog == null) {
- if (this.conn.getNullCatalogMeansCurrent()) {
- catalog = this.database;
- }
- }
-
- if (tableNamePattern == null) {
- if (this.conn.getNullNamePatternMatchesAll()) {
- tableNamePattern = "%";
- } else {
- throw SQLError.createSQLException(
- "Table name pattern can not be NULL or empty.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- PreparedStatement pStmt = null;
-
- String sql = "SELECT TABLE_SCHEMA AS TABLE_CAT, "
- + "NULL AS TABLE_SCHEM, TABLE_NAME, "
- + "CASE WHEN TABLE_TYPE='BASE TABLE' THEN 'TABLE' WHEN TABLE_TYPE='TEMPORARY' THEN 'LOCAL_TEMPORARY' ELSE TABLE_TYPE END AS TABLE_TYPE, "
- + "TABLE_COMMENT AS REMARKS "
- + "FROM INFORMATION_SCHEMA.TABLES WHERE "
- + "TABLE_SCHEMA LIKE ? AND TABLE_NAME LIKE ? AND TABLE_TYPE IN (?,?,?) "
- + "ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME";
- try {
- pStmt = prepareMetaDataSafeStatement(sql);
-
- if (catalog != null) {
- pStmt.setString(1, catalog);
- } else {
- pStmt.setString(1, "%");
- }
-
- pStmt.setString(2, tableNamePattern);
-
- // This overloading of IN (...) allows us to cache this
- // prepared statement
- if (types == null || types.length == 0) {
- pStmt.setString(3, "BASE TABLE");
- pStmt.setString(4, "VIEW");
- pStmt.setString(5, "TEMPORARY");
- } else {
- pStmt.setNull(3, Types.VARCHAR);
- pStmt.setNull(4, Types.VARCHAR);
- pStmt.setNull(5, Types.VARCHAR);
-
- for (int i = 0; i < types.length; i++) {
- if ("TABLE".equalsIgnoreCase(types[i])) {
- pStmt.setString(3, "BASE TABLE");
- }
-
- if ("VIEW".equalsIgnoreCase(types[i])) {
- pStmt.setString(4, "VIEW");
- }
-
- if ("LOCAL TEMPORARY".equalsIgnoreCase(types[i])) {
- pStmt.setString(5, "TEMPORARY");
- }
- }
- }
-
- ResultSet rs = executeMetadataQuery(pStmt);
-
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).redefineFieldsForDBMD(new Field[] {
- new Field("", "TABLE_CAT", java.sql.Types.VARCHAR,
- (catalog == null) ? 0 : catalog.length()),
- new Field("", "TABLE_SCHEM", java.sql.Types.VARCHAR, 0),
- new Field("", "TABLE_NAME", java.sql.Types.VARCHAR, 255),
- new Field("", "TABLE_TYPE", java.sql.Types.VARCHAR, 5),
- new Field("", "REMARKS", java.sql.Types.VARCHAR, 0) });
-
- return rs;
- } finally {
- if (pStmt != null) {
- pStmt.close();
- }
- }
- }
-
-
-}
diff --git a/src/com/mysql/jdbc/DocsConnectionPropsHelper.java b/src/com/mysql/jdbc/DocsConnectionPropsHelper.java
deleted file mode 100644
index 1c6125673..000000000
--- a/src/com/mysql/jdbc/DocsConnectionPropsHelper.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Created on Jan 12, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package com.mysql.jdbc;
-
-/**
- * @author mmatthew
- *
- * To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-public class DocsConnectionPropsHelper extends ConnectionPropertiesImpl {
-
- public static void main(String[] args) throws Exception {
- System.out.println(new DocsConnectionPropsHelper().exposeAsXml());
- }
-}
diff --git a/src/com/mysql/jdbc/Driver.java b/src/com/mysql/jdbc/Driver.java
deleted file mode 100644
index 9836f15cd..000000000
--- a/src/com/mysql/jdbc/Driver.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-/**
- * The Java SQL framework allows for multiple database drivers. Each driver
- * should supply a class that implements the Driver interface
- *
- *
- * The DriverManager will try to load as many drivers as it can find and then
- * for any given connection request, it will ask each driver in turn to try to
- * connect to the target URL.
- *
- *
- * It is strongly recommended that each Driver class should be small and
- * standalone so that the Driver class can be loaded and queried without
- * bringing in vast quantities of supporting code.
- *
- *
- * When a Driver class is loaded, it should create an instance of itself and
- * register it with the DriverManager. This means that a user can load and
- * register a driver by doing Class.forName("foo.bah.Driver")
- *
- * @see org.gjt.mm.mysql.Connection
- * @see java.sql.Driver
- * @author Mark Matthews
- * @version $Id$
- */
-public class Driver extends NonRegisteringDriver implements java.sql.Driver {
- // ~ Static fields/initializers
- // ---------------------------------------------
-
- //
- // Register ourselves with the DriverManager
- //
- static {
- try {
- java.sql.DriverManager.registerDriver(new Driver());
- } catch (SQLException E) {
- throw new RuntimeException("Can't register driver!");
- }
- }
-
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Construct a new driver and register it with DriverManager
- *
- * @throws SQLException
- * if a database error occurs.
- */
- public Driver() throws SQLException {
- // Required for Class.forName().newInstance()
- }
-}
diff --git a/src/com/mysql/jdbc/EscapeProcessor.java b/src/com/mysql/jdbc/EscapeProcessor.java
deleted file mode 100644
index 4b2d3efcf..000000000
--- a/src/com/mysql/jdbc/EscapeProcessor.java
+++ /dev/null
@@ -1,776 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-
-/**
- * EscapeProcessor performs all escape code processing as outlined in the JDBC
- * spec by JavaSoft.
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-class EscapeProcessor {
- private static Map JDBC_CONVERT_TO_MYSQL_TYPE_MAP;
-
- private static Map JDBC_NO_CONVERT_TO_MYSQL_EXPRESSION_MAP;
-
- static {
- Map tempMap = new HashMap();
-
- tempMap.put("BIGINT", "0 + ?");
- tempMap.put("BINARY", "BINARY");
- tempMap.put("BIT", "0 + ?");
- tempMap.put("CHAR", "CHAR");
- tempMap.put("DATE", "DATE");
- tempMap.put("DECIMAL", "0.0 + ?");
- tempMap.put("DOUBLE", "0.0 + ?");
- tempMap.put("FLOAT", "0.0 + ?");
- tempMap.put("INTEGER", "0 + ?");
- tempMap.put("LONGVARBINARY", "BINARY");
- tempMap.put("LONGVARCHAR", "CONCAT(?)");
- tempMap.put("REAL", "0.0 + ?");
- tempMap.put("SMALLINT", "CONCAT(?)");
- tempMap.put("TIME", "TIME");
- tempMap.put("TIMESTAMP", "DATETIME");
- tempMap.put("TINYINT", "CONCAT(?)");
- tempMap.put("VARBINARY", "BINARY");
- tempMap.put("VARCHAR", "CONCAT(?)");
-
- JDBC_CONVERT_TO_MYSQL_TYPE_MAP = Collections.unmodifiableMap(tempMap);
-
- tempMap = new HashMap(JDBC_CONVERT_TO_MYSQL_TYPE_MAP);
-
- tempMap.put("BINARY", "CONCAT(?)");
- tempMap.put("CHAR", "CONCAT(?)");
- tempMap.remove("DATE");
- tempMap.put("LONGVARBINARY", "CONCAT(?)");
- tempMap.remove("TIME");
- tempMap.remove("TIMESTAMP");
- tempMap.put("VARBINARY", "CONCAT(?)");
-
- JDBC_NO_CONVERT_TO_MYSQL_EXPRESSION_MAP = Collections
- .unmodifiableMap(tempMap);
-
- }
-
- /**
- * Escape process one string
- *
- * @param sql
- * the SQL to escape process.
- *
- * @return the SQL after it has been escape processed.
- *
- * @throws java.sql.SQLException
- * DOCUMENT ME!
- * @throws SQLException
- * DOCUMENT ME!
- */
- public static final Object escapeSQL(String sql,
- boolean serverSupportsConvertFn, ConnectionImpl conn)
- throws java.sql.SQLException {
- boolean replaceEscapeSequence = false;
- String escapeSequence = null;
-
- if (sql == null) {
- return null;
- }
-
- /*
- * Short circuit this code if we don't have a matching pair of "{}". -
- * Suggested by Ryan Gustafason
- */
- int beginBrace = sql.indexOf('{');
- int nextEndBrace = (beginBrace == -1) ? (-1) : sql.indexOf('}',
- beginBrace);
-
- if (nextEndBrace == -1) {
- return sql;
- }
-
- StringBuffer newSql = new StringBuffer();
-
- EscapeTokenizer escapeTokenizer = new EscapeTokenizer(sql);
-
- byte usesVariables = StatementImpl.USES_VARIABLES_FALSE;
- boolean callingStoredFunction = false;
-
- while (escapeTokenizer.hasMoreTokens()) {
- String token = escapeTokenizer.nextToken();
-
- if (token.length() != 0) {
- if (token.charAt(0) == '{') { // It's an escape code
-
- if (!token.endsWith("}")) {
- throw SQLError
- .createSQLException("Not a valid escape sequence: "
- + token, conn.getExceptionInterceptor());
- }
-
- if (token.length() > 2) {
- int nestedBrace = token.indexOf('{', 2);
-
- if (nestedBrace != -1) {
- StringBuffer buf = new StringBuffer(token
- .substring(0, 1));
-
- Object remainingResults = escapeSQL(token
- .substring(1, token.length() - 1),
- serverSupportsConvertFn, conn);
-
- String remaining = null;
-
- if (remainingResults instanceof String) {
- remaining = (String) remainingResults;
- } else {
- remaining = ((EscapeProcessorResult) remainingResults).escapedSql;
-
- if (usesVariables != StatementImpl.USES_VARIABLES_TRUE) {
- usesVariables = ((EscapeProcessorResult) remainingResults).usesVariables;
- }
- }
-
- buf.append(remaining);
-
- buf.append('}');
-
- token = buf.toString();
- }
- }
-
- // nested escape code
- // Compare to tokens with _no_ whitespace
- String collapsedToken = removeWhitespace(token);
-
- /*
- * Process the escape code
- */
- if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{escape")) {
- try {
- StringTokenizer st = new StringTokenizer(token,
- " '");
- st.nextToken(); // eat the "escape" token
- escapeSequence = st.nextToken();
-
- if (escapeSequence.length() < 3) {
- newSql.append(token); // it's just part of the
- // query, push possible
- // syntax errors onto
- // server's shoulders
- } else {
-
- escapeSequence = escapeSequence.substring(1,
- escapeSequence.length() - 1);
- replaceEscapeSequence = true;
- }
- } catch (java.util.NoSuchElementException e) {
- newSql.append(token); // it's just part of the
- // query, push possible
- // syntax errors onto
- // server's shoulders
- }
- } else if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{fn")) {
- int startPos = token.toLowerCase().indexOf("fn ") + 3;
- int endPos = token.length() - 1; // no }
-
- String fnToken = token.substring(startPos, endPos);
-
- // We need to handle 'convert' by ourselves
-
- if (StringUtils.startsWithIgnoreCaseAndWs(fnToken,
- "convert")) {
- newSql.append(processConvertToken(fnToken,
- serverSupportsConvertFn, conn));
- } else {
- // just pass functions right to the DB
- newSql.append(fnToken);
- }
- } else if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{d")) {
- int startPos = token.indexOf('\'') + 1;
- int endPos = token.lastIndexOf('\''); // no }
-
- if ((startPos == -1) || (endPos == -1)) {
- newSql.append(token); // it's just part of the
- // query, push possible
- // syntax errors onto
- // server's shoulders
- } else {
-
- String argument = token.substring(startPos, endPos);
-
- try {
- StringTokenizer st = new StringTokenizer(
- argument, " -");
- String year4 = st.nextToken();
- String month2 = st.nextToken();
- String day2 = st.nextToken();
- String dateString = "'" + year4 + "-" + month2
- + "-" + day2 + "'";
- newSql.append(dateString);
- } catch (java.util.NoSuchElementException e) {
- throw SQLError.createSQLException(
- "Syntax error for DATE escape sequence '"
- + argument + "'", "42000", conn.getExceptionInterceptor());
- }
- }
- } else if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{ts")) {
- processTimestampToken(conn, newSql, token);
- } else if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{t")) {
- processTimeToken(conn, newSql, token);
- } else if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{call")
- || StringUtils.startsWithIgnoreCase(collapsedToken,
- "{?=call")) {
-
- int startPos = StringUtils.indexOfIgnoreCase(token,
- "CALL") + 5;
- int endPos = token.length() - 1;
-
- if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{?=call")) {
- callingStoredFunction = true;
- newSql.append("SELECT ");
- newSql.append(token.substring(startPos, endPos));
- } else {
- callingStoredFunction = false;
- newSql.append("CALL ");
- newSql.append(token.substring(startPos, endPos));
- }
-
- for (int i = endPos - 1; i >= startPos; i--) {
- char c = token.charAt(i);
-
- if (Character.isWhitespace(c)) {
- continue;
- }
-
- if (c != ')') {
- newSql.append("()"); // handle no-parenthesis
- // no-arg call not
- // supported
- // by MySQL parser
- }
-
- break;
- }
- } else if (StringUtils.startsWithIgnoreCase(collapsedToken,
- "{oj")) {
- // MySQL already handles this escape sequence
- // because of ODBC. Cool.
- newSql.append(token);
- }
- } else {
- newSql.append(token); // it's just part of the query
- }
- }
- }
-
- String escapedSql = newSql.toString();
-
- //
- // FIXME: Let MySQL do this, however requires
- // lightweight parsing of statement
- //
- if (replaceEscapeSequence) {
- String currentSql = escapedSql;
-
- while (currentSql.indexOf(escapeSequence) != -1) {
- int escapePos = currentSql.indexOf(escapeSequence);
- String lhs = currentSql.substring(0, escapePos);
- String rhs = currentSql.substring(escapePos + 1, currentSql
- .length());
- currentSql = lhs + "\\" + rhs;
- }
-
- escapedSql = currentSql;
- }
-
- EscapeProcessorResult epr = new EscapeProcessorResult();
- epr.escapedSql = escapedSql;
- epr.callingStoredFunction = callingStoredFunction;
-
- if (usesVariables != StatementImpl.USES_VARIABLES_TRUE) {
- if (escapeTokenizer.sawVariableUse()) {
- epr.usesVariables = StatementImpl.USES_VARIABLES_TRUE;
- } else {
- epr.usesVariables = StatementImpl.USES_VARIABLES_FALSE;
- }
- }
-
- return epr;
- }
-
- private static void processTimeToken(ConnectionImpl conn,
- StringBuffer newSql, String token) throws SQLException {
- int startPos = token.indexOf('\'') + 1;
- int endPos = token.lastIndexOf('\''); // no }
-
- if ((startPos == -1) || (endPos == -1)) {
- newSql.append(token); // it's just part of the
- // query, push possible
- // syntax errors onto
- // server's shoulders
- } else {
-
- String argument = token.substring(startPos, endPos);
-
- try {
- StringTokenizer st = new StringTokenizer(
- argument, " :");
- String hour = st.nextToken();
- String minute = st.nextToken();
- String second = st.nextToken();
-
- if (!conn.getUseTimezone()
- || !conn.getUseLegacyDatetimeCode()) {
- String timeString = "'" + hour + ":"
- + minute + ":" + second + "'";
- newSql.append(timeString);
- } else {
- Calendar sessionCalendar = null;
-
- if (conn != null) {
- sessionCalendar = conn
- .getCalendarInstanceForSessionOrNew();
- } else {
- sessionCalendar = new GregorianCalendar();
- }
-
- try {
- int hourInt = Integer.parseInt(hour);
- int minuteInt = Integer
- .parseInt(minute);
- int secondInt = Integer
- .parseInt(second);
-
- synchronized (sessionCalendar) {
- Time toBeAdjusted = TimeUtil
- .fastTimeCreate(
- sessionCalendar,
- hourInt, minuteInt,
- secondInt, conn.getExceptionInterceptor());
-
- Time inServerTimezone = TimeUtil
- .changeTimezone(
- conn,
- sessionCalendar,
- null,
- toBeAdjusted,
- sessionCalendar
- .getTimeZone(),
- conn
- .getServerTimezoneTZ(),
- false);
-
- newSql.append("'");
- newSql.append(inServerTimezone
- .toString());
- newSql.append("'");
- }
-
- } catch (NumberFormatException nfe) {
- throw SQLError
- .createSQLException(
- "Syntax error in TIMESTAMP escape sequence '"
- + token + "'.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, conn.getExceptionInterceptor());
- }
- }
- } catch (java.util.NoSuchElementException e) {
- throw SQLError.createSQLException(
- "Syntax error for escape sequence '"
- + argument + "'", "42000", conn.getExceptionInterceptor());
- }
- }
- }
-
- private static void processTimestampToken(ConnectionImpl conn,
- StringBuffer newSql, String token) throws SQLException {
- int startPos = token.indexOf('\'') + 1;
- int endPos = token.lastIndexOf('\''); // no }
-
- if ((startPos == -1) || (endPos == -1)) {
- newSql.append(token); // it's just part of the
- // query, push possible
- // syntax errors onto
- // server's shoulders
- } else {
-
- String argument = token.substring(startPos, endPos);
-
- try {
- if (!conn.getUseLegacyDatetimeCode()) {
- Timestamp ts = Timestamp.valueOf(argument);
- SimpleDateFormat tsdf = new SimpleDateFormat(
- "''yyyy-MM-dd HH:mm:ss''", Locale.US); //$NON-NLS-1$
-
- tsdf
- .setTimeZone(conn
- .getServerTimezoneTZ());
-
- newSql.append(tsdf.format(ts));
- } else {
- StringTokenizer st = new StringTokenizer(
- argument, " .-:");
- try {
- String year4 = st.nextToken();
- String month2 = st.nextToken();
- String day2 = st.nextToken();
- String hour = st.nextToken();
- String minute = st.nextToken();
- String second = st.nextToken();
-
- /*
- * For now, we get the fractional
- * seconds part, but we don't use it, as
- * MySQL doesn't support it in it's
- * TIMESTAMP data type
- *
- * String fractionalSecond = "";
- *
- * if (st.hasMoreTokens()) {
- * fractionalSecond = st.nextToken(); }
- */
-
- /*
- * Use the full format because number
- * format will not work for "between"
- * clauses.
- *
- * Ref. Mysql Docs
- *
- * You can specify DATETIME, DATE and
- * TIMESTAMP values using any of a
- * common set of formats:
- *
- * As a string in either 'YYYY-MM-DD
- * HH:MM:SS' or 'YY-MM-DD HH:MM:SS'
- * format.
- *
- * Thanks to Craig Longman for pointing
- * out this bug
- */
-
- if (!conn.getUseTimezone()
- && !conn
- .getUseJDBCCompliantTimezoneShift()) {
- newSql.append("'").append(year4)
- .append("-").append(month2)
- .append("-").append(day2)
- .append(" ").append(hour)
- .append(":").append(minute)
- .append(":").append(second)
- .append("'");
- } else {
- Calendar sessionCalendar;
-
- if (conn != null) {
- sessionCalendar = conn
- .getCalendarInstanceForSessionOrNew();
- } else {
- sessionCalendar = new GregorianCalendar();
- sessionCalendar
- .setTimeZone(TimeZone
- .getTimeZone("GMT"));
- }
-
- try {
- int year4Int = Integer
- .parseInt(year4);
- int month2Int = Integer
- .parseInt(month2);
- int day2Int = Integer
- .parseInt(day2);
- int hourInt = Integer
- .parseInt(hour);
- int minuteInt = Integer
- .parseInt(minute);
- int secondInt = Integer
- .parseInt(second);
-
- synchronized (sessionCalendar) {
- boolean useGmtMillis = conn
- .getUseGmtMillisForDatetimes();
-
- Timestamp toBeAdjusted = TimeUtil
- .fastTimestampCreate(
- useGmtMillis,
- useGmtMillis ? Calendar
- .getInstance(TimeZone
- .getTimeZone("GMT"))
- : null,
- sessionCalendar,
- year4Int,
- month2Int,
- day2Int,
- hourInt,
- minuteInt,
- secondInt,
- 0);
-
- Timestamp inServerTimezone = TimeUtil
- .changeTimezone(
- conn,
- sessionCalendar,
- null,
- toBeAdjusted,
- sessionCalendar
- .getTimeZone(),
- conn
- .getServerTimezoneTZ(),
- false);
-
- newSql.append("'");
-
- String timezoneLiteral = inServerTimezone
- .toString();
-
- int indexOfDot = timezoneLiteral
- .indexOf(".");
-
- if (indexOfDot != -1) {
- timezoneLiteral = timezoneLiteral
- .substring(0,
- indexOfDot);
- }
-
- newSql
- .append(timezoneLiteral);
- }
-
- newSql.append("'");
-
- } catch (NumberFormatException nfe) {
- throw SQLError
- .createSQLException(
- "Syntax error in TIMESTAMP escape sequence '"
- + token
- + "'.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, conn.getExceptionInterceptor());
- }
- }
- } catch (java.util.NoSuchElementException e) {
- throw SQLError.createSQLException(
- "Syntax error for TIMESTAMP escape sequence '"
- + argument + "'",
- "42000", conn.getExceptionInterceptor());
- }
- }
- } catch (IllegalArgumentException illegalArgumentException) {
- SQLException sqlEx = SQLError
- .createSQLException(
- "Syntax error for TIMESTAMP escape sequence '"
- + argument + "'",
- "42000", conn.getExceptionInterceptor());
- sqlEx.initCause(illegalArgumentException);
-
- throw sqlEx;
- }
- }
- }
-
- /**
- * Re-writes {fn convert (expr, type)} as cast(expr AS type)
- *
- * @param functionToken
- * @return
- * @throws SQLException
- */
- private static String processConvertToken(String functionToken,
- boolean serverSupportsConvertFn, ConnectionImpl conn) throws SQLException {
- // The JDBC spec requires these types:
- //
- // BIGINT
- // BINARY
- // BIT
- // CHAR
- // DATE
- // DECIMAL
- // DOUBLE
- // FLOAT
- // INTEGER
- // LONGVARBINARY
- // LONGVARCHAR
- // REAL
- // SMALLINT
- // TIME
- // TIMESTAMP
- // TINYINT
- // VARBINARY
- // VARCHAR
-
- // MySQL supports these types:
- //
- // BINARY
- // CHAR
- // DATE
- // DATETIME
- // SIGNED (integer)
- // UNSIGNED (integer)
- // TIME
-
- int firstIndexOfParen = functionToken.indexOf("(");
-
- if (firstIndexOfParen == -1) {
- throw SQLError
- .createSQLException(
- "Syntax error while processing {fn convert (... , ...)} token, missing opening parenthesis in token '"
- + functionToken + "'.",
- SQLError.SQL_STATE_SYNTAX_ERROR, conn.getExceptionInterceptor());
- }
-
- int tokenLength = functionToken.length();
-
- int indexOfComma = functionToken.lastIndexOf(",");
-
- if (indexOfComma == -1) {
- throw SQLError
- .createSQLException(
- "Syntax error while processing {fn convert (... , ...)} token, missing comma in token '"
- + functionToken + "'.",
- SQLError.SQL_STATE_SYNTAX_ERROR, conn.getExceptionInterceptor());
- }
-
- int indexOfCloseParen = functionToken.indexOf(')', indexOfComma);
-
- if (indexOfCloseParen == -1) {
- throw SQLError
- .createSQLException(
- "Syntax error while processing {fn convert (... , ...)} token, missing closing parenthesis in token '"
- + functionToken + "'.",
- SQLError.SQL_STATE_SYNTAX_ERROR, conn.getExceptionInterceptor());
-
- }
-
- String expression = functionToken.substring(firstIndexOfParen + 1,
- indexOfComma);
- String type = functionToken.substring(indexOfComma + 1,
- indexOfCloseParen);
-
- String newType = null;
-
- String trimmedType = type.trim();
-
- if (StringUtils.startsWithIgnoreCase(trimmedType, "SQL_")) {
- trimmedType = trimmedType.substring(4, trimmedType.length());
- }
-
- if (serverSupportsConvertFn) {
- newType = (String) JDBC_CONVERT_TO_MYSQL_TYPE_MAP.get(trimmedType
- .toUpperCase(Locale.ENGLISH));
- } else {
- newType = (String) JDBC_NO_CONVERT_TO_MYSQL_EXPRESSION_MAP
- .get(trimmedType.toUpperCase(Locale.ENGLISH));
-
- // We need a 'special' check here to give a better error message. If
- // we're in this
- // block, the version of MySQL we're connected to doesn't support
- // CAST/CONVERT,
- // so we can't re-write some data type conversions
- // (date,time,timestamp, datetime)
-
- if (newType == null) {
- throw SQLError
- .createSQLException(
- "Can't find conversion re-write for type '"
- + type
- + "' that is applicable for this server version while processing escape tokens.",
- SQLError.SQL_STATE_GENERAL_ERROR, conn.getExceptionInterceptor());
- }
- }
-
- if (newType == null) {
- throw SQLError.createSQLException("Unsupported conversion type '"
- + type.trim() + "' found while processing escape token.",
- SQLError.SQL_STATE_GENERAL_ERROR, conn.getExceptionInterceptor());
- }
-
- int replaceIndex = newType.indexOf("?");
-
- if (replaceIndex != -1) {
- StringBuffer convertRewrite = new StringBuffer(newType.substring(0,
- replaceIndex));
- convertRewrite.append(expression);
- convertRewrite.append(newType.substring(replaceIndex + 1, newType
- .length()));
-
- return convertRewrite.toString();
- } else {
-
- StringBuffer castRewrite = new StringBuffer("CAST(");
- castRewrite.append(expression);
- castRewrite.append(" AS ");
- castRewrite.append(newType);
- castRewrite.append(")");
-
- return castRewrite.toString();
- }
- }
-
- /**
- * Removes all whitespace from the given String. We use this to make escape
- * token comparison white-space ignorant.
- *
- * @param toCollapse
- * the string to remove the whitespace from
- *
- * @return a string with _no_ whitespace.
- */
- private static String removeWhitespace(String toCollapse) {
- if (toCollapse == null) {
- return null;
- }
-
- int length = toCollapse.length();
-
- StringBuffer collapsed = new StringBuffer(length);
-
- for (int i = 0; i < length; i++) {
- char c = toCollapse.charAt(i);
-
- if (!Character.isWhitespace(c)) {
- collapsed.append(c);
- }
- }
-
- return collapsed.toString();
- }
-}
diff --git a/src/com/mysql/jdbc/EscapeProcessorResult.java b/src/com/mysql/jdbc/EscapeProcessorResult.java
deleted file mode 100644
index 9c6bdf99c..000000000
--- a/src/com/mysql/jdbc/EscapeProcessorResult.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-/**
- * Wraps output from EscapeProcessor, to help prevent multiple passes over the
- * query string, to detect characters such as '@' (defining/using a variable),
- * which are used further up the call stack to handle failover.
- *
- * @author Mark Matthews
- *
- * @version $Id: EscapeProcessorResult.java,v 1.1.2.1 2005/05/13 18:58:38
- * mmatthews Exp $
- */
-class EscapeProcessorResult {
- boolean callingStoredFunction = false;
-
- String escapedSql;
-
- byte usesVariables = StatementImpl.USES_VARIABLES_FALSE;
-}
diff --git a/src/com/mysql/jdbc/EscapeTokenizer.java b/src/com/mysql/jdbc/EscapeTokenizer.java
deleted file mode 100644
index 8802d1586..000000000
--- a/src/com/mysql/jdbc/EscapeTokenizer.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-/**
- * EscapeTokenizer breaks up an SQL statement into SQL and escape code parts.
- *
- * @author Mark Matthews
- */
-public class EscapeTokenizer {
- // ~ Instance fields
- // --------------------------------------------------------
-
- private int bracesLevel = 0;
-
- private boolean emittingEscapeCode = false;
-
- private boolean inComment = false;
-
- private boolean inQuotes = false;
-
- private char lastChar = 0;
-
- private char lastLastChar = 0;
-
- private int pos = 0;
-
- private char quoteChar = 0;
-
- private boolean sawVariableUse = false;
-
- private String source = null;
-
- private int sourceLength = 0;
-
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Creates a new EscapeTokenizer object.
- *
- * @param s
- * the string to tokenize
- */
- public EscapeTokenizer(String s) {
- this.source = s;
- this.sourceLength = s.length();
- this.pos = 0;
- }
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * Does this tokenizer have more tokens available?
- *
- * @return if this tokenizer has more tokens available
- */
- public synchronized boolean hasMoreTokens() {
- return (this.pos < this.sourceLength);
- }
-
- /**
- * Returns the next token
- *
- * @return the next token.
- */
- public synchronized String nextToken() {
- StringBuffer tokenBuf = new StringBuffer();
-
- if (this.emittingEscapeCode) {
- tokenBuf.append("{"); //$NON-NLS-1$
- this.emittingEscapeCode = false;
- }
-
- for (; this.pos < this.sourceLength; this.pos++) {
- char c = this.source.charAt(this.pos);
-
- // Detect variable usage
-
- if (!this.inQuotes && c == '@') {
- this.sawVariableUse = true;
- }
-
- if ((c == '\'' || c == '"') && !inComment) {
- if (this.inQuotes && c == quoteChar) {
- if (this.pos + 1 < this.sourceLength) {
- if (this.source.charAt(this.pos + 1) == quoteChar) {
- // Doubled-up quote escape, if the first quote isn't already escaped
- if (this.lastChar != '\\') {
- tokenBuf.append(quoteChar);
- tokenBuf.append(quoteChar);
- this.pos++;
- continue;
- }
- }
- }
- }
- if (this.lastChar != '\\') {
- if (this.inQuotes) {
- if (this.quoteChar == c) {
- this.inQuotes = false;
- }
- } else {
- this.inQuotes = true;
- this.quoteChar = c;
- }
- } else if (this.lastLastChar == '\\') {
- if (this.inQuotes) {
- if (this.quoteChar == c) {
- this.inQuotes = false;
- }
- } else {
- this.inQuotes = true;
- this.quoteChar = c;
- }
- }
-
- tokenBuf.append(c);
- } else if (c == '-') {
- if ((this.lastChar == '-')
- && ((this.lastLastChar != '\\') && !this.inQuotes)) {
- this.inComment = true;
- }
-
- tokenBuf.append(c);
- } else if ((c == '\n') || (c == '\r')) {
- this.inComment = false;
-
- tokenBuf.append(c);
- } else if (c == '{') {
- if (this.inQuotes || this.inComment) {
- tokenBuf.append(c);
- } else {
- this.bracesLevel++;
-
- if (this.bracesLevel == 1) {
- this.pos++;
- this.emittingEscapeCode = true;
-
- return tokenBuf.toString();
- }
-
- tokenBuf.append(c);
- }
- } else if (c == '}') {
- tokenBuf.append(c);
-
- if (!this.inQuotes && !this.inComment) {
- this.lastChar = c;
-
- this.bracesLevel--;
-
- if (this.bracesLevel == 0) {
- this.pos++;
-
- return tokenBuf.toString();
- }
- }
- } else {
- tokenBuf.append(c);
- }
-
- this.lastLastChar = this.lastChar;
- this.lastChar = c;
- }
-
- return tokenBuf.toString();
- }
-
- boolean sawVariableUse() {
- return this.sawVariableUse;
- }
-}
diff --git a/src/com/mysql/jdbc/ExceptionInterceptor.java b/src/com/mysql/jdbc/ExceptionInterceptor.java
deleted file mode 100644
index 698edb205..000000000
--- a/src/com/mysql/jdbc/ExceptionInterceptor.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Copyright 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-public interface ExceptionInterceptor extends Extension {
- public abstract SQLException interceptException(SQLException sqlEx);
-}
diff --git a/src/com/mysql/jdbc/ExportControlled.java b/src/com/mysql/jdbc/ExportControlled.java
deleted file mode 100644
index 142268c7d..000000000
--- a/src/com/mysql/jdbc/ExportControlled.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.sql.SQLException;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-
-/**
- * Holds functionality that falls under export-control regulations.
- *
- * @author Mark Matthews
- *
- * @version $Id: ExportControlled.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews
- * Exp $
- */
-public class ExportControlled {
- private static final String SQL_STATE_BAD_SSL_PARAMS = "08000";
-
- protected static boolean enabled() {
- // we may wish to un-static-ify this class
- // this static method call may be removed entirely by the compiler
- return true;
- }
-
- /**
- * Converts the socket being used in the given MysqlIO to an SSLSocket by
- * performing the SSL/TLS handshake.
- *
- * @param mysqlIO
- * the MysqlIO instance containing the socket to convert to an
- * SSLSocket.
- *
- * @throws CommunicationsException
- * if the handshake fails, or if this distribution of
- * Connector/J doesn't contain the SSL crytpo hooks needed to
- * perform the handshake.
- */
- protected static void transformSocketToSSLSocket(MysqlIO mysqlIO)
- throws SQLException {
- javax.net.ssl.SSLSocketFactory sslFact = getSSLSocketFactoryDefaultOrConfigured(mysqlIO);
-
- try {
- mysqlIO.mysqlConnection = sslFact.createSocket(
- mysqlIO.mysqlConnection, mysqlIO.host, mysqlIO.port, true);
-
- // need to force TLSv1, or else JSSE tries to do a SSLv2 handshake
- // which MySQL doesn't understand
- ((javax.net.ssl.SSLSocket) mysqlIO.mysqlConnection)
- .setEnabledProtocols(new String[] { "TLSv1" }); //$NON-NLS-1$
- ((javax.net.ssl.SSLSocket) mysqlIO.mysqlConnection)
- .startHandshake();
-
- if (mysqlIO.connection.getUseUnbufferedInput()) {
- mysqlIO.mysqlInput = mysqlIO.mysqlConnection.getInputStream();
- } else {
- mysqlIO.mysqlInput = new BufferedInputStream(
- mysqlIO.mysqlConnection.getInputStream(), 16384);
- }
-
- mysqlIO.mysqlOutput = new BufferedOutputStream(
- mysqlIO.mysqlConnection.getOutputStream(), 16384);
-
- mysqlIO.mysqlOutput.flush();
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(mysqlIO.connection,
- mysqlIO.getLastPacketSentTimeMs(), mysqlIO.getLastPacketReceivedTimeMs(),
- ioEx, mysqlIO.getExceptionInterceptor());
- }
- }
-
- private ExportControlled() { /* prevent instantiation */
- }
-
- private static SSLSocketFactory getSSLSocketFactoryDefaultOrConfigured(
- MysqlIO mysqlIO) throws SQLException {
- String clientCertificateKeyStoreUrl = mysqlIO.connection
- .getClientCertificateKeyStoreUrl();
- String trustCertificateKeyStoreUrl = mysqlIO.connection
- .getTrustCertificateKeyStoreUrl();
- String clientCertificateKeyStoreType = mysqlIO.connection
- .getClientCertificateKeyStoreType();
- String clientCertificateKeyStorePassword = mysqlIO.connection
- .getClientCertificateKeyStorePassword();
- String trustCertificateKeyStoreType = mysqlIO.connection
- .getTrustCertificateKeyStoreType();
- String trustCertificateKeyStorePassword = mysqlIO.connection
- .getTrustCertificateKeyStorePassword();
-
- if (StringUtils.isNullOrEmpty(clientCertificateKeyStoreUrl)
- && StringUtils.isNullOrEmpty(trustCertificateKeyStoreUrl)) {
- if (mysqlIO.connection.getVerifyServerCertificate()) {
- return (javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory
- .getDefault();
- }
- }
-
- TrustManagerFactory tmf = null;
- KeyManagerFactory kmf = null;
-
- try {
- tmf = TrustManagerFactory.getInstance(TrustManagerFactory
- .getDefaultAlgorithm());
- kmf = KeyManagerFactory.getInstance(KeyManagerFactory
- .getDefaultAlgorithm());
- } catch (NoSuchAlgorithmException nsae) {
- throw SQLError
- .createSQLException(
- "Default algorithm definitions for TrustManager and/or KeyManager are invalid. Check java security properties file.",
- SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- }
-
- if (!StringUtils.isNullOrEmpty(clientCertificateKeyStoreUrl)) {
- try {
- if (!StringUtils.isNullOrEmpty(clientCertificateKeyStoreType)) {
- KeyStore clientKeyStore = KeyStore
- .getInstance(clientCertificateKeyStoreType);
- URL ksURL = new URL(clientCertificateKeyStoreUrl);
- char[] password = (clientCertificateKeyStorePassword == null) ? new char[0]
- : clientCertificateKeyStorePassword.toCharArray();
- clientKeyStore.load(ksURL.openStream(), password);
- kmf.init(clientKeyStore, password);
- }
- } catch (UnrecoverableKeyException uke) {
- throw SQLError
- .createSQLException(
- "Could not recover keys from client keystore. Check password?",
- SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- } catch (NoSuchAlgorithmException nsae) {
- throw SQLError.createSQLException(
- "Unsupported keystore algorithm [" + nsae.getMessage()
- + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- } catch (KeyStoreException kse) {
- throw SQLError.createSQLException(
- "Could not create KeyStore instance ["
- + kse.getMessage() + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- } catch (CertificateException nsae) {
- throw SQLError.createSQLException("Could not load client"
- + clientCertificateKeyStoreType + " keystore from "
- + clientCertificateKeyStoreUrl, mysqlIO.getExceptionInterceptor());
- } catch (MalformedURLException mue) {
- throw SQLError.createSQLException(clientCertificateKeyStoreUrl
- + " does not appear to be a valid URL.", SQL_STATE_BAD_SSL_PARAMS, 0,
- false, mysqlIO.getExceptionInterceptor());
- } catch (IOException ioe) {
- SQLException sqlEx = SQLError.createSQLException("Cannot open "
- + clientCertificateKeyStoreUrl + " ["
- + ioe.getMessage() + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- sqlEx.initCause(ioe);
-
- throw sqlEx;
- }
- }
-
- if (!StringUtils.isNullOrEmpty(trustCertificateKeyStoreUrl)) {
-
- try {
- if (!StringUtils.isNullOrEmpty(trustCertificateKeyStoreType)) {
- KeyStore trustKeyStore = KeyStore
- .getInstance(trustCertificateKeyStoreType);
- URL ksURL = new URL(trustCertificateKeyStoreUrl);
-
- char[] password = (trustCertificateKeyStorePassword == null) ? new char[0]
- : trustCertificateKeyStorePassword.toCharArray();
- trustKeyStore.load(ksURL.openStream(), password);
- tmf.init(trustKeyStore);
- }
- } catch (NoSuchAlgorithmException nsae) {
- throw SQLError.createSQLException(
- "Unsupported keystore algorithm [" + nsae.getMessage()
- + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- } catch (KeyStoreException kse) {
- throw SQLError.createSQLException(
- "Could not create KeyStore instance ["
- + kse.getMessage() + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- } catch (CertificateException nsae) {
- throw SQLError.createSQLException("Could not load trust"
- + trustCertificateKeyStoreType + " keystore from "
- + trustCertificateKeyStoreUrl, SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- } catch (MalformedURLException mue) {
- throw SQLError.createSQLException(trustCertificateKeyStoreUrl
- + " does not appear to be a valid URL.", SQL_STATE_BAD_SSL_PARAMS, 0,
- false, mysqlIO.getExceptionInterceptor());
- } catch (IOException ioe) {
- SQLException sqlEx = SQLError.createSQLException("Cannot open "
- + trustCertificateKeyStoreUrl + " [" + ioe.getMessage()
- + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
-
- sqlEx.initCause(ioe);
-
- throw sqlEx;
- }
- }
-
- SSLContext sslContext = null;
-
- try {
- sslContext = SSLContext.getInstance("TLS");
- sslContext.init(StringUtils.isNullOrEmpty(clientCertificateKeyStoreUrl) ? null : kmf.getKeyManagers(), mysqlIO.connection
- .getVerifyServerCertificate() ? tmf.getTrustManagers()
- : new X509TrustManager[] { new X509TrustManager() {
- public void checkClientTrusted(X509Certificate[] chain,
- String authType) {
- // return without complaint
- }
-
- public void checkServerTrusted(X509Certificate[] chain,
- String authType) throws CertificateException {
- // return without complaint
- }
-
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
- } }, null);
-
- return sslContext.getSocketFactory();
- } catch (NoSuchAlgorithmException nsae) {
- throw SQLError.createSQLException("TLS"
- + " is not a valid SSL protocol.",
- SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- } catch (KeyManagementException kme) {
- throw SQLError.createSQLException("KeyManagementException: "
- + kme.getMessage(), SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/Extension.java b/src/com/mysql/jdbc/Extension.java
deleted file mode 100644
index 556fdcc9f..000000000
--- a/src/com/mysql/jdbc/Extension.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.Properties;
-
-public interface Extension {
-
- /**
- * Called once per connection that wants to use the extension
- *
- * The properties are the same ones passed in in the URL or arguments to
- * Driver.connect() or DriverManager.getConnection().
- *
- * @param conn the connection for which this extension is being created
- * @param props configuration values as passed to the connection. Note that
- * in order to support javax.sql.DataSources, configuration properties specific
- * to an interceptor must be passed via setURL() on the
- * DataSource. Extension properties are not exposed via
- * accessor/mutator methods on DataSources.
- *
- * @throws SQLException should be thrown if the the Extension
- * can not initialize itself.
- */
-
- public abstract void init(Connection conn, Properties props) throws SQLException;
-
- /**
- * Called by the driver when this extension should release any resources
- * it is holding and cleanup internally before the connection is
- * closed.
- */
- public abstract void destroy();
-}
diff --git a/src/com/mysql/jdbc/Field.java b/src/com/mysql/jdbc/Field.java
deleted file mode 100644
index 6b8df7deb..000000000
--- a/src/com/mysql/jdbc/Field.java
+++ /dev/null
@@ -1,1052 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.UnsupportedEncodingException;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * Field is a class used to describe fields in a ResultSet
- *
- * @author Mark Matthews
- * @version $Id$
- */
-public class Field {
-
- private static final int AUTO_INCREMENT_FLAG = 512;
-
- private static final int NO_CHARSET_INFO = -1;
-
- private byte[] buffer;
-
- private int charsetIndex = 0;
-
- private String charsetName = null;
-
- private int colDecimals;
-
- private short colFlag;
-
- private String collationName = null;
-
- private ConnectionImpl connection = null;
-
- private String databaseName = null;
-
- private int databaseNameLength = -1;
-
- // database name info
- private int databaseNameStart = -1;
-
- private int defaultValueLength = -1;
-
- // default value info - from COM_LIST_FIELDS execution
- private int defaultValueStart = -1;
-
- private String fullName = null;
-
- private String fullOriginalName = null;
-
- private boolean isImplicitTempTable = false;
-
- private long length; // Internal length of the field;
-
- private int mysqlType = -1; // the MySQL type
-
- private String name; // The Field name
-
- private int nameLength;
-
- private int nameStart;
-
- private String originalColumnName = null;
-
- private int originalColumnNameLength = -1;
-
- // column name info (before aliasing)
- private int originalColumnNameStart = -1;
-
- private String originalTableName = null;
-
- private int originalTableNameLength = -1;
-
- // table name info (before aliasing)
- private int originalTableNameStart = -1;
-
- private int precisionAdjustFactor = 0;
-
- private int sqlType = -1; // the java.sql.Type
-
- private String tableName; // The Name of the Table
-
- private int tableNameLength;
-
- private int tableNameStart;
-
- private boolean useOldNameMetadata = false;
-
- private boolean isSingleBit;
-
- private int maxBytesPerChar;
-
- /**
- * Constructor used when communicating with 4.1 and newer servers
- */
- Field(ConnectionImpl conn, byte[] buffer, int databaseNameStart,
- int databaseNameLength, int tableNameStart, int tableNameLength,
- int originalTableNameStart, int originalTableNameLength,
- int nameStart, int nameLength, int originalColumnNameStart,
- int originalColumnNameLength, long length, int mysqlType,
- short colFlag, int colDecimals, int defaultValueStart,
- int defaultValueLength, int charsetIndex) throws SQLException {
- this.connection = conn;
- this.buffer = buffer;
- this.nameStart = nameStart;
- this.nameLength = nameLength;
- this.tableNameStart = tableNameStart;
- this.tableNameLength = tableNameLength;
- this.length = length;
- this.colFlag = colFlag;
- this.colDecimals = colDecimals;
- this.mysqlType = mysqlType;
-
- // 4.1 field info...
- this.databaseNameStart = databaseNameStart;
- this.databaseNameLength = databaseNameLength;
-
- this.originalTableNameStart = originalTableNameStart;
- this.originalTableNameLength = originalTableNameLength;
-
- this.originalColumnNameStart = originalColumnNameStart;
- this.originalColumnNameLength = originalColumnNameLength;
-
- this.defaultValueStart = defaultValueStart;
- this.defaultValueLength = defaultValueLength;
-
- // If we're not running 4.1 or newer, use the connection's
- // charset
- this.charsetIndex = charsetIndex;
-
-
- // Map MySqlTypes to java.sql Types
- this.sqlType = MysqlDefs.mysqlToJavaType(this.mysqlType);
-
- checkForImplicitTemporaryTable();
- // Re-map to 'real' blob type, if we're a BLOB
- boolean isFromFunction = this.originalTableNameLength == 0;
-
- if (this.mysqlType == MysqlDefs.FIELD_TYPE_BLOB) {
- if (this.connection != null && this.connection.getBlobsAreStrings() ||
- (this.connection.getFunctionsNeverReturnBlobs() && isFromFunction)) {
- this.sqlType = Types.VARCHAR;
- this.mysqlType = MysqlDefs.FIELD_TYPE_VARCHAR;
- } else if (this.charsetIndex == 63 ||
- !this.connection.versionMeetsMinimum(4, 1, 0)) {
- if (this.connection.getUseBlobToStoreUTF8OutsideBMP()
- && shouldSetupForUtf8StringInBlob()) {
- setupForUtf8StringInBlob();
- } else {
- setBlobTypeBasedOnLength();
- this.sqlType = MysqlDefs.mysqlToJavaType(this.mysqlType);
- }
- } else {
- // *TEXT masquerading as blob
- this.mysqlType = MysqlDefs.FIELD_TYPE_VAR_STRING;
- this.sqlType = Types.LONGVARCHAR;
- }
- }
-
- if (this.sqlType == Types.TINYINT && this.length == 1
- && this.connection.getTinyInt1isBit()) {
- // Adjust for pseudo-boolean
- if (conn.getTinyInt1isBit()) {
- if (conn.getTransformedBitIsBoolean()) {
- this.sqlType = Types.BOOLEAN;
- } else {
- this.sqlType = Types.BIT;
- }
- }
-
- }
-
- if (!isNativeNumericType() && !isNativeDateTimeType()) {
- this.charsetName = this.connection
- .getCharsetNameForIndex(this.charsetIndex);
-
-
- // Handle VARBINARY/BINARY (server doesn't have a different type
- // for this
-
- boolean isBinary = isBinary();
-
- if (this.connection.versionMeetsMinimum(4, 1, 0) &&
- this.mysqlType == MysqlDefs.FIELD_TYPE_VAR_STRING &&
- isBinary &&
- this.charsetIndex == 63) {
- if (this.connection != null && (this.connection.getFunctionsNeverReturnBlobs() && isFromFunction)) {
- this.sqlType = Types.VARCHAR;
- this.mysqlType = MysqlDefs.FIELD_TYPE_VARCHAR;
- } else if (this.isOpaqueBinary()) {
- this.sqlType = Types.VARBINARY;
- }
- }
-
- if (this.connection.versionMeetsMinimum(4, 1, 0) &&
- this.mysqlType == MysqlDefs.FIELD_TYPE_STRING &&
- isBinary && this.charsetIndex == 63) {
- //
- // Okay, this is a hack, but there's currently no way
- // to easily distinguish something like DATE_FORMAT( ..)
- // from the "BINARY" column type, other than looking
- // at the original column name.
- //
-
- if (isOpaqueBinary() && !this.connection.getBlobsAreStrings()) {
- this.sqlType = Types.BINARY;
- }
- }
-
-
-
- if (this.mysqlType == MysqlDefs.FIELD_TYPE_BIT) {
- this.isSingleBit = (this.length == 0);
-
- if (this.connection != null && (this.connection.versionMeetsMinimum(5, 0, 21) ||
- this.connection.versionMeetsMinimum(5, 1, 10)) && this.length == 1) {
- this.isSingleBit = true;
- }
-
- if (this.isSingleBit) {
- this.sqlType = Types.BIT;
- } else {
- this.sqlType = Types.VARBINARY;
- this.colFlag |= 128; // we need to pretend this is a full
- this.colFlag |= 16; // binary blob
- isBinary = true;
- }
- }
-
- //
- // Handle TEXT type (special case), Fix proposed by Peter McKeown
- //
- if ((this.sqlType == java.sql.Types.LONGVARBINARY) && !isBinary) {
- this.sqlType = java.sql.Types.LONGVARCHAR;
- } else if ((this.sqlType == java.sql.Types.VARBINARY) && !isBinary) {
- this.sqlType = java.sql.Types.VARCHAR;
- }
- } else {
- this.charsetName = "US-ASCII";
- }
-
- //
- // Handle odd values for 'M' for floating point/decimal numbers
- //
- if (!isUnsigned()) {
- switch (this.mysqlType) {
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- this.precisionAdjustFactor = -1;
-
- break;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- case MysqlDefs.FIELD_TYPE_FLOAT:
- this.precisionAdjustFactor = 1;
-
- break;
- }
- } else {
- switch (this.mysqlType) {
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- case MysqlDefs.FIELD_TYPE_FLOAT:
- this.precisionAdjustFactor = 1;
-
- break;
- }
- }
- }
-
- private boolean shouldSetupForUtf8StringInBlob() throws SQLException {
- String includePattern = this.connection
- .getUtf8OutsideBmpIncludedColumnNamePattern();
- String excludePattern = this.connection
- .getUtf8OutsideBmpExcludedColumnNamePattern();
-
- if (excludePattern != null
- && !StringUtils.isEmptyOrWhitespaceOnly(excludePattern)) {
- try {
- if (getOriginalName().matches(excludePattern)) {
- if (includePattern != null
- && !StringUtils.isEmptyOrWhitespaceOnly(includePattern)) {
- try {
- if (getOriginalName().matches(includePattern)) {
- return true;
- }
- } catch (PatternSyntaxException pse) {
- SQLException sqlEx = SQLError
- .createSQLException(
- "Illegal regex specified for \"utf8OutsideBmpIncludedColumnNamePattern\"",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.connection.getExceptionInterceptor());
-
- if (!this.connection.getParanoid()) {
- sqlEx.initCause(pse);
- }
-
- throw sqlEx;
- }
- }
-
- return false;
- }
- } catch (PatternSyntaxException pse) {
- SQLException sqlEx = SQLError
- .createSQLException(
- "Illegal regex specified for \"utf8OutsideBmpExcludedColumnNamePattern\"",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.connection.getExceptionInterceptor());
-
- if (!this.connection.getParanoid()) {
- sqlEx.initCause(pse);
- }
-
- throw sqlEx;
- }
- }
-
- return true;
- }
-
- private void setupForUtf8StringInBlob() {
- if (this.length == MysqlDefs.LENGTH_TINYBLOB || this.length == MysqlDefs.LENGTH_BLOB) {
- this.mysqlType = MysqlDefs.FIELD_TYPE_VARCHAR;
- this.sqlType = Types.VARCHAR;
- } else {
- this.mysqlType = MysqlDefs.FIELD_TYPE_VAR_STRING;
- this.sqlType = Types.LONGVARCHAR;
- }
-
- this.charsetIndex = 33;
- }
-
- /**
- * Constructor used when communicating with pre 4.1 servers
- */
- Field(ConnectionImpl conn, byte[] buffer, int nameStart, int nameLength,
- int tableNameStart, int tableNameLength, int length, int mysqlType,
- short colFlag, int colDecimals) throws SQLException {
- this(conn, buffer, -1, -1, tableNameStart, tableNameLength, -1, -1,
- nameStart, nameLength, -1, -1, length, mysqlType, colFlag,
- colDecimals, -1, -1, NO_CHARSET_INFO);
- }
-
- /**
- * Constructor used by DatabaseMetaData methods.
- */
- Field(String tableName, String columnName, int jdbcType, int length) {
- this.tableName = tableName;
- this.name = columnName;
- this.length = length;
- this.sqlType = jdbcType;
- this.colFlag = 0;
- this.colDecimals = 0;
- }
-
- /**
- * Used by prepared statements to re-use result set data conversion methods
- * when generating bound parmeter retrieval instance for statement
- * interceptors.
- *
- * @param tableName
- * not used
- * @param columnName
- * not used
- * @param charsetIndex
- * the MySQL collation/character set index
- * @param jdbcType
- * from java.sql.Types
- * @param length
- * length in characters or bytes (for BINARY data).
- */
- Field(String tableName, String columnName, int charsetIndex, int jdbcType,
- int length) {
- this.tableName = tableName;
- this.name = columnName;
- this.length = length;
- this.sqlType = jdbcType;
- this.colFlag = 0;
- this.colDecimals = 0;
- this.charsetIndex = charsetIndex;
-
- switch (this.sqlType) {
- case Types.BINARY:
- case Types.VARBINARY:
- this.colFlag |= 128;
- this.colFlag |= 16;
- break;
- }
- }
-
- private void checkForImplicitTemporaryTable() {
- this.isImplicitTempTable = this.tableNameLength > 5
- && this.buffer[tableNameStart] == (byte) '#'
- && this.buffer[tableNameStart + 1] == (byte) 's'
- && this.buffer[tableNameStart + 2] == (byte) 'q'
- && this.buffer[tableNameStart + 3] == (byte) 'l'
- && this.buffer[tableNameStart + 4] == (byte) '_';
- }
-
- /**
- * Returns the character set (if known) for this field.
- *
- * @return the character set
- */
- public String getCharacterSet() throws SQLException {
- return this.charsetName;
- }
-
- public void setCharacterSet(String javaEncodingName) throws SQLException {
- this.charsetName = javaEncodingName;
- this.charsetIndex = CharsetMapping
- .getCharsetIndexForMysqlEncodingName(javaEncodingName);
- }
-
- public synchronized String getCollation() throws SQLException {
- if (this.collationName == null) {
- if (this.connection != null) {
- if (this.connection.versionMeetsMinimum(4, 1, 0)) {
- if (this.connection.getUseDynamicCharsetInfo()) {
- java.sql.DatabaseMetaData dbmd = this.connection
- .getMetaData();
-
- String quotedIdStr = dbmd.getIdentifierQuoteString();
-
- if (" ".equals(quotedIdStr)) { //$NON-NLS-1$
- quotedIdStr = ""; //$NON-NLS-1$
- }
-
- String csCatalogName = getDatabaseName();
- String csTableName = getOriginalTableName();
- String csColumnName = getOriginalName();
-
- if (csCatalogName != null && csCatalogName.length() != 0
- && csTableName != null && csTableName.length() != 0
- && csColumnName != null
- && csColumnName.length() != 0) {
- StringBuffer queryBuf = new StringBuffer(csCatalogName
- .length()
- + csTableName.length() + 28);
- queryBuf.append("SHOW FULL COLUMNS FROM "); //$NON-NLS-1$
- queryBuf.append(quotedIdStr);
- queryBuf.append(csCatalogName);
- queryBuf.append(quotedIdStr);
- queryBuf.append("."); //$NON-NLS-1$
- queryBuf.append(quotedIdStr);
- queryBuf.append(csTableName);
- queryBuf.append(quotedIdStr);
-
- java.sql.Statement collationStmt = null;
- java.sql.ResultSet collationRs = null;
-
- try {
- collationStmt = this.connection.createStatement();
-
- collationRs = collationStmt.executeQuery(queryBuf
- .toString());
-
- while (collationRs.next()) {
- if (csColumnName.equals(collationRs
- .getString("Field"))) { //$NON-NLS-1$
- this.collationName = collationRs
- .getString("Collation"); //$NON-NLS-1$
-
- break;
- }
- }
- } finally {
- if (collationRs != null) {
- collationRs.close();
- collationRs = null;
- }
-
- if (collationStmt != null) {
- collationStmt.close();
- collationStmt = null;
- }
- }
- }
- } else {
- this.collationName = CharsetMapping.INDEX_TO_COLLATION[charsetIndex];
- }
- }
- }
- }
-
- return this.collationName;
- }
-
- public String getColumnLabel() throws SQLException {
- return getName(); // column name if not aliased, alias if used
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getDatabaseName() throws SQLException {
- if ((this.databaseName == null) && (this.databaseNameStart != -1)
- && (this.databaseNameLength != -1)) {
- this.databaseName = getStringFromBytes(this.databaseNameStart,
- this.databaseNameLength);
- }
-
- return this.databaseName;
- }
-
- int getDecimals() {
- return this.colDecimals;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getFullName() throws SQLException {
- if (this.fullName == null) {
- StringBuffer fullNameBuf = new StringBuffer(getTableName().length()
- + 1 + getName().length());
- fullNameBuf.append(this.tableName);
-
- // much faster to append a char than a String
- fullNameBuf.append('.');
- fullNameBuf.append(this.name);
- this.fullName = fullNameBuf.toString();
- fullNameBuf = null;
- }
-
- return this.fullName;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getFullOriginalName() throws SQLException {
- getOriginalName();
-
- if (this.originalColumnName == null) {
- return null; // we don't have this information
- }
-
- if (this.fullName == null) {
- StringBuffer fullOriginalNameBuf = new StringBuffer(
- getOriginalTableName().length() + 1
- + getOriginalName().length());
- fullOriginalNameBuf.append(this.originalTableName);
-
- // much faster to append a char than a String
- fullOriginalNameBuf.append('.');
- fullOriginalNameBuf.append(this.originalColumnName);
- this.fullOriginalName = fullOriginalNameBuf.toString();
- fullOriginalNameBuf = null;
- }
-
- return this.fullOriginalName;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public long getLength() {
- return this.length;
- }
-
- public synchronized int getMaxBytesPerCharacter() throws SQLException {
- if (this.maxBytesPerChar == 0) {
- this.maxBytesPerChar = this.connection.getMaxBytesPerChar(getCharacterSet());
- }
-
- return this.maxBytesPerChar;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public int getMysqlType() {
- return this.mysqlType;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getName() throws SQLException {
- if (this.name == null) {
- this.name = getStringFromBytes(this.nameStart, this.nameLength);
- }
-
- return this.name;
- }
-
- public String getNameNoAliases() throws SQLException {
- if (this.useOldNameMetadata) {
- return getName();
- }
-
- if (this.connection != null &&
- this.connection.versionMeetsMinimum(4, 1, 0)) {
- return getOriginalName();
- }
-
- return getName();
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getOriginalName() throws SQLException {
- if ((this.originalColumnName == null)
- && (this.originalColumnNameStart != -1)
- && (this.originalColumnNameLength != -1)) {
- this.originalColumnName = getStringFromBytes(
- this.originalColumnNameStart, this.originalColumnNameLength);
- }
-
- return this.originalColumnName;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getOriginalTableName() throws SQLException {
- if ((this.originalTableName == null)
- && (this.originalTableNameStart != -1)
- && (this.originalTableNameLength != -1)) {
- this.originalTableName = getStringFromBytes(
- this.originalTableNameStart, this.originalTableNameLength);
- }
-
- return this.originalTableName;
- }
-
- /**
- * Returns amount of correction that should be applied to the precision
- * value.
- *
- * Different versions of MySQL report different precision values.
- *
- * @return the amount to adjust precision value by.
- */
- public int getPrecisionAdjustFactor() {
- return this.precisionAdjustFactor;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public int getSQLType() {
- return this.sqlType;
- }
-
- /**
- * Create a string with the correct charset encoding from the byte-buffer
- * that contains the data for this field
- */
- private String getStringFromBytes(int stringStart, int stringLength)
- throws SQLException {
- if ((stringStart == -1) || (stringLength == -1)) {
- return null;
- }
-
- String stringVal = null;
-
- if (this.connection != null) {
- if (this.connection.getUseUnicode()) {
- String encoding = this.connection.getCharacterSetMetadata();
-
- if (encoding == null) {
- encoding = connection.getEncoding();
- }
-
- if (encoding != null) {
- SingleByteCharsetConverter converter = null;
-
- if (this.connection != null) {
- converter = this.connection
- .getCharsetConverter(encoding);
- }
-
- if (converter != null) { // we have a converter
- stringVal = converter.toString(this.buffer,
- stringStart, stringLength);
- } else {
- // we have no converter, use JVM converter
- byte[] stringBytes = new byte[stringLength];
-
- int endIndex = stringStart + stringLength;
- int pos = 0;
-
- for (int i = stringStart; i < endIndex; i++) {
- stringBytes[pos++] = this.buffer[i];
- }
-
- try {
- stringVal = new String(stringBytes, encoding);
- } catch (UnsupportedEncodingException ue) {
- throw new RuntimeException(Messages
- .getString("Field.12") + encoding //$NON-NLS-1$
- + Messages.getString("Field.13")); //$NON-NLS-1$
- }
- }
- } else {
- // we have no encoding, use JVM standard charset
- stringVal = StringUtils.toAsciiString(this.buffer,
- stringStart, stringLength);
- }
- } else {
- // we are not using unicode, so use JVM standard charset
- stringVal = StringUtils.toAsciiString(this.buffer, stringStart,
- stringLength);
- }
- } else {
- // we don't have a connection, so punt
- stringVal = StringUtils.toAsciiString(this.buffer, stringStart,
- stringLength);
- }
-
- return stringVal;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getTable() throws SQLException {
- return getTableName();
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String getTableName() throws SQLException {
- if (this.tableName == null) {
- this.tableName = getStringFromBytes(this.tableNameStart,
- this.tableNameLength);
- }
-
- return this.tableName;
- }
-
- public String getTableNameNoAliases() throws SQLException {
- if (this.connection.versionMeetsMinimum(4, 1, 0)) {
- return getOriginalTableName();
- }
-
- return getTableName(); // pre-4.1, no aliases returned
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isAutoIncrement() {
- return ((this.colFlag & AUTO_INCREMENT_FLAG) > 0);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isBinary() {
- return ((this.colFlag & 128) > 0);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isBlob() {
- return ((this.colFlag & 16) > 0);
- }
-
- /**
- * Is this field owned by a server-created temporary table?
- *
- * @return
- */
- private boolean isImplicitTemporaryTable() {
- return this.isImplicitTempTable;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isMultipleKey() {
- return ((this.colFlag & 8) > 0);
- }
-
- boolean isNotNull() {
- return ((this.colFlag & 1) > 0);
- }
-
- boolean isOpaqueBinary() throws SQLException {
-
- //
- // Detect CHAR(n) CHARACTER SET BINARY which is a synonym for
- // fixed-length binary types
- //
-
- if (this.charsetIndex == 63 && isBinary()
- && (this.getMysqlType() == MysqlDefs.FIELD_TYPE_STRING ||
- this.getMysqlType() == MysqlDefs.FIELD_TYPE_VAR_STRING)) {
-
- if (this.originalTableNameLength == 0 && (
- this.connection != null && !this.connection.versionMeetsMinimum(5, 0, 25))) {
- return false; // Probably from function
- }
-
- // Okay, queries resolved by temp tables also have this 'signature',
- // check for that
-
- return !isImplicitTemporaryTable();
- }
-
- return (this.connection.versionMeetsMinimum(4, 1, 0) && "binary"
- .equalsIgnoreCase(getCharacterSet()));
-
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isPrimaryKey() {
- return ((this.colFlag & 2) > 0);
- }
-
- /**
- * Is this field _definitely_ not writable?
- *
- * @return true if this field can not be written to in an INSERT/UPDATE
- * statement.
- */
- boolean isReadOnly() throws SQLException {
- if (this.connection.versionMeetsMinimum(4, 1, 0)) {
- String orgColumnName = getOriginalName();
- String orgTableName = getOriginalTableName();
-
- return !(orgColumnName != null && orgColumnName.length() > 0
- && orgTableName != null && orgTableName.length() > 0);
- }
-
- return false; // we can't tell definitively in this case.
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isUniqueKey() {
- return ((this.colFlag & 4) > 0);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isUnsigned() {
- return ((this.colFlag & 32) > 0);
- }
-
- public void setUnsigned() {
- this.colFlag |= 32;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isZeroFill() {
- return ((this.colFlag & 64) > 0);
- }
-
- //
- // MySQL only has one protocol-level BLOB type that it exposes
- // which is FIELD_TYPE_BLOB, although we can divine what the
- // actual type is by the length reported ...
- //
- private void setBlobTypeBasedOnLength() {
- if (this.length == MysqlDefs.LENGTH_TINYBLOB) {
- this.mysqlType = MysqlDefs.FIELD_TYPE_TINY_BLOB;
- } else if (this.length == MysqlDefs.LENGTH_BLOB) {
- this.mysqlType = MysqlDefs.FIELD_TYPE_BLOB;
- } else if (this.length == MysqlDefs.LENGTH_MEDIUMBLOB) {
- this.mysqlType = MysqlDefs.FIELD_TYPE_MEDIUM_BLOB;
- } else if (this.length == MysqlDefs.LENGTH_LONGBLOB) {
- this.mysqlType = MysqlDefs.FIELD_TYPE_LONG_BLOB;
- }
- }
-
- private boolean isNativeNumericType() {
- return ((this.mysqlType >= MysqlDefs.FIELD_TYPE_TINY &&
- this.mysqlType <= MysqlDefs.FIELD_TYPE_DOUBLE) ||
- this.mysqlType == MysqlDefs.FIELD_TYPE_LONGLONG ||
- this.mysqlType == MysqlDefs.FIELD_TYPE_YEAR);
- }
-
- private boolean isNativeDateTimeType() {
- return (this.mysqlType == MysqlDefs.FIELD_TYPE_DATE ||
- this.mysqlType == MysqlDefs.FIELD_TYPE_NEWDATE ||
- this.mysqlType == MysqlDefs.FIELD_TYPE_DATETIME ||
- this.mysqlType == MysqlDefs.FIELD_TYPE_TIME ||
- this.mysqlType == MysqlDefs.FIELD_TYPE_TIMESTAMP);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param conn
- * DOCUMENT ME!
- */
- public void setConnection(ConnectionImpl conn) {
- this.connection = conn;
-
- if (this.charsetName == null || this.charsetIndex == 0) {
- this.charsetName = this.connection.getEncoding();
- }
- }
-
- void setMysqlType(int type) {
- this.mysqlType = type;
- this.sqlType = MysqlDefs.mysqlToJavaType(this.mysqlType);
- }
-
- protected void setUseOldNameMetadata(boolean useOldNameMetadata) {
- this.useOldNameMetadata = useOldNameMetadata;
- }
-
- public String toString() {
- try {
- StringBuffer asString = new StringBuffer();
- asString.append(super.toString());
- asString.append("[");
- asString.append("catalog=");
- asString.append(this.getDatabaseName());
- asString.append(",tableName=");
- asString.append(this.getTableName());
- asString.append(",originalTableName=");
- asString.append(this.getOriginalTableName());
- asString.append(",columnName=");
- asString.append(this.getName());
- asString.append(",originalColumnName=");
- asString.append(this.getOriginalName());
- asString.append(",mysqlType=");
- asString.append(getMysqlType());
- asString.append("(");
- asString.append(MysqlDefs.typeToName(getMysqlType()));
- asString.append(")");
- asString.append(",flags=");
-
- if (isAutoIncrement()) {
- asString.append(" AUTO_INCREMENT");
- }
-
- if (isPrimaryKey()) {
- asString.append(" PRIMARY_KEY");
- }
-
- if (isUniqueKey()) {
- asString.append(" UNIQUE_KEY");
- }
-
- if (isBinary()) {
- asString.append(" BINARY");
- }
-
- if (isBlob()) {
- asString.append(" BLOB");
- }
-
- if (isMultipleKey()) {
- asString.append(" MULTI_KEY");
- }
-
- if (isUnsigned()) {
- asString.append(" UNSIGNED");
- }
-
- if (isZeroFill()) {
- asString.append(" ZEROFILL");
- }
-
- asString.append(", charsetIndex=");
- asString.append(this.charsetIndex);
- asString.append(", charsetName=");
- asString.append(this.charsetName);
-
-
- //if (this.buffer != null) {
- // asString.append("\n\nData as received from server:\n\n");
- // asString.append(StringUtils.dumpAsHex(this.buffer,
- // this.buffer.length));
- //}
-
- asString.append("]");
-
- return asString.toString();
- } catch (Throwable t) {
- return super.toString();
- }
- }
-
- protected boolean isSingleBit() {
- return this.isSingleBit;
- }
-}
diff --git a/src/com/mysql/jdbc/IterateBlock.java b/src/com/mysql/jdbc/IterateBlock.java
deleted file mode 100644
index 2e83b0565..000000000
--- a/src/com/mysql/jdbc/IterateBlock.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.Iterator;
-
-import com.mysql.jdbc.DatabaseMetaData.IteratorWithCleanup;
-
-public abstract class IterateBlock {
- IteratorWithCleanup iteratorWithCleanup;
- Iterator javaIterator;
- boolean stopIterating = false;
-
- IterateBlock(IteratorWithCleanup i) {
- this.iteratorWithCleanup = i;
- this.javaIterator = null;
- }
-
- IterateBlock(Iterator i) {
- this.javaIterator = i;
- this.iteratorWithCleanup = null;
- }
-
- public void doForAll() throws SQLException {
- if (this.iteratorWithCleanup != null) {
- try {
- while (this.iteratorWithCleanup.hasNext()) {
- forEach(this.iteratorWithCleanup.next());
-
- if (this.stopIterating) {
- break;
- }
- }
- } finally {
- this.iteratorWithCleanup.close();
- }
- } else {
- while (this.javaIterator.hasNext()) {
- forEach(this.javaIterator.next());
-
- if (this.stopIterating) {
- break;
- }
- }
- }
- }
-
- abstract void forEach(Object each) throws SQLException;
-
- public final boolean fullIteration() {
- return !this.stopIterating;
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/JDBC4CallableStatement.java b/src/com/mysql/jdbc/JDBC4CallableStatement.java
deleted file mode 100644
index 74f8c9766..000000000
--- a/src/com/mysql/jdbc/JDBC4CallableStatement.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.SQLException;
-import java.sql.RowId;
-import java.sql.SQLXML;
-import java.sql.NClob;
-
-
-
-public class JDBC4CallableStatement extends CallableStatement {
-
- public JDBC4CallableStatement(ConnectionImpl conn,
- CallableStatementParamInfo paramInfo) throws SQLException {
- super(conn, paramInfo);
- }
-
- public JDBC4CallableStatement(ConnectionImpl conn, String sql,
- String catalog, boolean isFunctionCall) throws SQLException {
- super(conn, sql, catalog, isFunctionCall);
- }
-
-
- public void setRowId(int parameterIndex, RowId x) throws SQLException {
- JDBC4PreparedStatementHelper.setRowId(this, parameterIndex, x);
- }
-
- public void setRowId(String parameterName, RowId x) throws SQLException {
- JDBC4PreparedStatementHelper.setRowId(this, getNamedParamIndex(
- parameterName, false), x);
- }
-
- public void setSQLXML(int parameterIndex, SQLXML xmlObject)
- throws SQLException {
- JDBC4PreparedStatementHelper.setSQLXML(this, parameterIndex, xmlObject);
- }
-
- public void setSQLXML(String parameterName, SQLXML xmlObject)
- throws SQLException {
- JDBC4PreparedStatementHelper.setSQLXML(this, getNamedParamIndex(
- parameterName, false), xmlObject);
-
- }
-
- public SQLXML getSQLXML(int parameterIndex) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(parameterIndex);
-
- SQLXML retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getSQLXML(mapOutputParameterIndexToRsIndex(parameterIndex));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
-
- }
-
- public SQLXML getSQLXML(String parameterName) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(0); // definitely
- // not going to
- // be
- // from ?=
-
- SQLXML retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getSQLXML(fixParameterName(parameterName));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- public RowId getRowId(int parameterIndex) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(parameterIndex);
-
- RowId retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getRowId(mapOutputParameterIndexToRsIndex(parameterIndex));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- public RowId getRowId(String parameterName) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(0); // definitely
- // not going to
- // be
- // from ?=
-
- RowId retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getRowId(fixParameterName(parameterName));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * JDBC 4.0 Set a NCLOB parameter.
- *
- * @param i
- * the first parameter is 1, the second is 2, ...
- * @param x
- * an object representing a NCLOB
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void setNClob(int parameterIndex, NClob value) throws SQLException {
- JDBC4PreparedStatementHelper.setNClob(this, parameterIndex, value);
- }
-
- public void setNClob(String parameterName, NClob value) throws SQLException {
- JDBC4PreparedStatementHelper.setNClob(this, getNamedParamIndex(
- parameterName, false), value);
-
- }
-
- public void setNClob(String parameterName, Reader reader)
- throws SQLException {
- setNClob(getNamedParamIndex(parameterName, false), reader);
-
- }
-
- public void setNClob(String parameterName, Reader reader, long length)
- throws SQLException {
- setNClob(getNamedParamIndex(parameterName, false), reader, length);
-
- }
-
- public void setNString(String parameterName, String value)
- throws SQLException {
- setNString(getNamedParamIndex(parameterName, false), value);
- }
-
- /**
- * @see java.sql.CallableStatement#getCharacterStream(int)
- */
- public Reader getCharacterStream(int parameterIndex) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(parameterIndex);
-
- Reader retValue = rs
- .getCharacterStream(mapOutputParameterIndexToRsIndex(parameterIndex));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * @see java.sql.CallableStatement#getCharacterStream(java.lang.String)
- */
- public Reader getCharacterStream(String parameterName) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(0); // definitely
- // not going to
- // be
- // from ?=
-
- Reader retValue = rs
- .getCharacterStream(fixParameterName(parameterName));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * @see java.sql.CallableStatement#getNCharacterStream(int)
- */
- public Reader getNCharacterStream(int parameterIndex) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(parameterIndex);
-
- Reader retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getNCharacterStream(mapOutputParameterIndexToRsIndex(parameterIndex));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * @see java.sql.CallableStatement#getNCharacterStream(java.lang.String)
- */
- public Reader getNCharacterStream(String parameterName) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(0); // definitely
- // not going to
- // be
- // from ?=
-
- Reader retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getNCharacterStream(fixParameterName(parameterName));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * @see java.sql.CallableStatement#getNClob(int)
- */
- public NClob getNClob(int parameterIndex) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(parameterIndex);
-
- NClob retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getNClob(mapOutputParameterIndexToRsIndex(parameterIndex));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * @see java.sql.CallableStatement#getNClob(java.lang.String)
- */
- public NClob getNClob(String parameterName) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(0); // definitely
- // not going to
- // be
- // from ?=
-
- NClob retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getNClob(fixParameterName(parameterName));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * @see java.sql.CallableStatement#getNString(int)
- */
- public String getNString(int parameterIndex) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(parameterIndex);
-
- String retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getNString(mapOutputParameterIndexToRsIndex(parameterIndex));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-
- /**
- * @see java.sql.CallableStatement#getNString(java.lang.String)
- */
- public String getNString(String parameterName) throws SQLException {
- ResultSetInternalMethods rs = getOutputParameters(0); // definitely
- // not going to
- // be
- // from ?=
-
- String retValue = ((com.mysql.jdbc.JDBC4ResultSet) rs)
- .getNString(fixParameterName(parameterName));
-
- this.outputParamWasNull = rs.wasNull();
-
- return retValue;
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4ClientInfoProvider.java b/src/com/mysql/jdbc/JDBC4ClientInfoProvider.java
deleted file mode 100644
index 6c84cd385..000000000
--- a/src/com/mysql/jdbc/JDBC4ClientInfoProvider.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.sql.SQLClientInfoException;
-import java.util.Properties;
-
-
-
-/**
- * Classes that implement this interface and provide a no-args constructor
- * can be used by the driver to store and retrieve client information and/or
- * labels.
- *
- * The driver will create an instance for each Connection instance, and call
- * initialize() once and only once. When the connection is closed, destroy()
- * will be called, and the provider is expected to clean up any resources at
- * this time.
- *
- * @version $Id: $
- */
-public interface JDBC4ClientInfoProvider {
- /**
- * Called once by the driver when it needs to configure the provider.
- *
- * @param conn the connection that the provider belongs too.
- * @param configurationProps a java.util.Properties instance that contains
- * configuration information for the connection.
- * @throws SQLException if initialization fails.
- */
- public void initialize(java.sql.Connection conn, Properties configurationProps) throws SQLException;
-
- /**
- * Called once by the driver when the connection this provider instance
- * belongs to is being closed.
- *
- * Implementations are expected to clean up and resources at this point
- * in time.
- *
- * @throws SQLException if an error occurs.
- */
- public void destroy() throws SQLException;
-
- /**
- * Returns the client info for the connection that this provider
- * instance belongs to. The connection instance is passed as an argument
- * for convenience's sake.
- *
- * Providers can use the connection to communicate with the database,
- * but it will be within the scope of any ongoing transactions, so therefore
- * implementations should not attempt to change isolation level, autocommit settings
- * or call rollback() or commit() on the connection.
- *
- * @param conn
- * @return
- * @throws SQLException
- *
- * @see java.sql.Connection#getClientInfo()
- */
- public Properties getClientInfo(java.sql.Connection conn) throws SQLException;
-
- /**
- * Returns the client info for the connection that this provider
- * instance belongs to. The connection instance is passed as an argument
- * for convenience's sake.
- *
- * Providers can use the connection to communicate with the database,
- * but it will be within the scope of any ongoing transactions, so therefore
- * implementations should not attempt to change isolation level, autocommit settings
- * or call rollback() or commit() on the connection.
- *
- * @param conn
- * @return
- * @throws SQLException
- *
- * @see java.sql.Connection#getClientInfo(java.lang.String)
- */
- public String getClientInfo(java.sql.Connection conn, String name) throws SQLException;
-
- /**
- * Sets the client info for the connection that this provider
- * instance belongs to. The connection instance is passed as an argument
- * for convenience's sake.
- *
- * Providers can use the connection to communicate with the database,
- * but it will be within the scope of any ongoing transactions, so therefore
- * implementations should not attempt to change isolation level, autocommit settings
- * or call rollback() or commit() on the connection.
- *
- * @param conn
- * @return
- * @throws SQLException
- *
- * @see java.sql.Connection#setClientInfo(java.util.Properties)
- */
- public void setClientInfo(java.sql.Connection conn, Properties properties) throws SQLClientInfoException;
-
- /**
- * Sets the client info for the connection that this provider
- * instance belongs to. The connection instance is passed as an argument
- * for convenience's sake.
- *
- * Providers can use the connection to communicate with the database,
- * but it will be within the scope of any ongoing transactions, so therefore
- * implementations should not attempt to change isolation level, autocommit settings
- * or call rollback() or commit() on the connection.
- *
- * @param conn
- * @return
- * @throws SQLException
- *
- * @see java.sql.Connection#setClientInfo(java.lang.String,java.lang.String)
- */
- public void setClientInfo(java.sql.Connection conn, String name, String value) throws SQLClientInfoException;
-}
diff --git a/src/com/mysql/jdbc/JDBC4ClientInfoProviderSP.java b/src/com/mysql/jdbc/JDBC4ClientInfoProviderSP.java
deleted file mode 100644
index 4fcc13c14..000000000
--- a/src/com/mysql/jdbc/JDBC4ClientInfoProviderSP.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLClientInfoException;
-import java.util.Enumeration;
-import java.util.Properties;
-
-public class JDBC4ClientInfoProviderSP implements JDBC4ClientInfoProvider {
- PreparedStatement setClientInfoSp;
-
- PreparedStatement getClientInfoSp;
-
- PreparedStatement getClientInfoBulkSp;
-
- public synchronized void initialize(java.sql.Connection conn,
- Properties configurationProps) throws SQLException {
- String identifierQuote = conn.getMetaData().getIdentifierQuoteString();
- String setClientInfoSpName = configurationProps.getProperty(
- "clientInfoSetSPName", "setClientInfo");
- String getClientInfoSpName = configurationProps.getProperty(
- "clientInfoGetSPName", "getClientInfo");
- String getClientInfoBulkSpName = configurationProps.getProperty(
- "clientInfoGetBulkSPName", "getClientInfoBulk");
- String clientInfoCatalog = configurationProps.getProperty(
- "clientInfoCatalog", ""); // "" means use current from
- // connection
-
- String catalog = "".equals(clientInfoCatalog) ? conn.getCatalog()
- : clientInfoCatalog;
-
- this.setClientInfoSp = ((com.mysql.jdbc.Connection) conn)
- .clientPrepareStatement("CALL " + identifierQuote + catalog
- + identifierQuote + "." + identifierQuote
- + setClientInfoSpName + identifierQuote + "(?, ?)");
-
- this.getClientInfoSp = ((com.mysql.jdbc.Connection) conn)
- .clientPrepareStatement("CALL" + identifierQuote + catalog
- + identifierQuote + "." + identifierQuote
- + getClientInfoSpName + identifierQuote + "(?)");
-
- this.getClientInfoBulkSp = ((com.mysql.jdbc.Connection) conn)
- .clientPrepareStatement("CALL " + identifierQuote + catalog
- + identifierQuote + "." + identifierQuote
- + getClientInfoBulkSpName + identifierQuote + "()");
- }
-
- public synchronized void destroy() throws SQLException {
- if (this.setClientInfoSp != null) {
- this.setClientInfoSp.close();
- this.setClientInfoSp = null;
- }
-
- if (this.getClientInfoSp != null) {
- this.getClientInfoSp.close();
- this.getClientInfoSp = null;
- }
-
- if (this.getClientInfoBulkSp != null) {
- this.getClientInfoBulkSp.close();
- this.getClientInfoBulkSp = null;
- }
- }
-
- public synchronized Properties getClientInfo(java.sql.Connection conn)
- throws SQLException {
- ResultSet rs = null;
-
- Properties props = new Properties();
-
- try {
- this.getClientInfoBulkSp.execute();
-
- rs = this.getClientInfoBulkSp.getResultSet();
-
- while (rs.next()) {
- props.setProperty(rs.getString(1), rs.getString(2));
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
-
- return props;
- }
-
- public synchronized String getClientInfo(java.sql.Connection conn,
- String name) throws SQLException {
- ResultSet rs = null;
-
- String clientInfo = null;
-
- try {
- this.getClientInfoSp.setString(1, name);
- this.getClientInfoSp.execute();
-
- rs = this.getClientInfoSp.getResultSet();
-
- if (rs.next()) {
- clientInfo = rs.getString(1);
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
-
- return clientInfo;
- }
-
- public synchronized void setClientInfo(java.sql.Connection conn,
- Properties properties) throws SQLClientInfoException {
- try {
- Enumeration propNames = properties.propertyNames();
-
- while (propNames.hasMoreElements()) {
- String name = (String) propNames.nextElement();
- String value = properties.getProperty(name);
-
- setClientInfo(conn, name, value);
- }
- } catch (SQLException sqlEx) {
- SQLClientInfoException clientInfoEx = new SQLClientInfoException();
- clientInfoEx.initCause(sqlEx);
-
- throw clientInfoEx;
- }
- }
-
- public synchronized void setClientInfo(java.sql.Connection conn,
- String name, String value) throws SQLClientInfoException {
- try {
- this.setClientInfoSp.setString(1, name);
- this.setClientInfoSp.setString(2, value);
- this.setClientInfoSp.execute();
- } catch (SQLException sqlEx) {
- SQLClientInfoException clientInfoEx = new SQLClientInfoException();
- clientInfoEx.initCause(sqlEx);
-
- throw clientInfoEx;
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/JDBC4CommentClientInfoProvider.java b/src/com/mysql/jdbc/JDBC4CommentClientInfoProvider.java
deleted file mode 100644
index 504b24b38..000000000
--- a/src/com/mysql/jdbc/JDBC4CommentClientInfoProvider.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLClientInfoException;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * An implementation of JDBC4ClientInfoProvider that exposes
- * the client info as a comment prepended to all statements issued
- * by the driver.
- *
- * Client information is never read from the server with this
- * implementation, it is always cached locally.
- *
- * @version $Id: $
- */
-
-public class JDBC4CommentClientInfoProvider implements JDBC4ClientInfoProvider {
- private Properties clientInfo;
-
- public synchronized void initialize(java.sql.Connection conn,
- Properties configurationProps) throws SQLException {
- this.clientInfo = new Properties();
- }
-
- public synchronized void destroy() throws SQLException {
- this.clientInfo = null;
- }
-
- public synchronized Properties getClientInfo(java.sql.Connection conn)
- throws SQLException {
- return this.clientInfo;
- }
-
- public synchronized String getClientInfo(java.sql.Connection conn,
- String name) throws SQLException {
- return this.clientInfo.getProperty(name);
- }
-
- public synchronized void setClientInfo(java.sql.Connection conn,
- Properties properties) throws SQLClientInfoException {
- this.clientInfo = new Properties();
-
- Enumeration propNames = properties.propertyNames();
-
- while (propNames.hasMoreElements()) {
- String name = (String)propNames.nextElement();
-
- this.clientInfo.put(name, properties.getProperty(name));
- }
-
- setComment(conn);
- }
-
- public synchronized void setClientInfo(java.sql.Connection conn,
- String name, String value) throws SQLClientInfoException {
- this.clientInfo.setProperty(name, value);
- setComment(conn);
- }
-
- private synchronized void setComment(java.sql.Connection conn) {
- StringBuffer commentBuf = new StringBuffer();
- Iterator elements = this.clientInfo.entrySet().iterator();
-
- while (elements.hasNext()) {
- if (commentBuf.length() > 0) {
- commentBuf.append(", ");
- }
-
- Map.Entry entry = (Map.Entry)elements.next();
- commentBuf.append("" + entry.getKey());
- commentBuf.append("=");
- commentBuf.append("" + entry.getValue());
- }
-
- ((com.mysql.jdbc.Connection)conn).setStatementComment(
- commentBuf.toString());
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/JDBC4Connection.java b/src/com/mysql/jdbc/JDBC4Connection.java
deleted file mode 100644
index 977d5726c..000000000
--- a/src/com/mysql/jdbc/JDBC4Connection.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.NClob;
-import java.sql.Struct;
-import java.util.Properties;
-import java.util.TimerTask;
-
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.Messages;
-import com.mysql.jdbc.SQLError;
-
-
-public class JDBC4Connection extends ConnectionImpl {
- private JDBC4ClientInfoProvider infoProvider;
-
- public JDBC4Connection(String hostToConnectTo, int portToConnectTo, Properties info, String databaseToConnectTo, String url) throws SQLException {
- super(hostToConnectTo, portToConnectTo, info, databaseToConnectTo, url);
- // TODO Auto-generated constructor stub
- }
-
- public SQLXML createSQLXML() throws SQLException {
- return new JDBC4MysqlSQLXML(getExceptionInterceptor());
- }
-
- public java.sql.Array createArrayOf(String typeName, Object[] elements) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- public Properties getClientInfo() throws SQLException {
- return getClientInfoProviderImpl().getClientInfo(this);
- }
-
- public String getClientInfo(String name) throws SQLException {
- return getClientInfoProviderImpl().getClientInfo(this, name);
- }
-
- /**
- * Returns true if the connection has not been closed and is still valid.
- * The driver shall submit a query on the connection or use some other
- * mechanism that positively verifies the connection is still valid when
- * this method is called.
- *
- * The query submitted by the driver to validate the connection shall be
- * executed in the context of the current transaction.
- *
- * @param timeout - The time in seconds to wait for the database operation
- * used to validate the connection to complete. If
- * the timeout period expires before the operation
- * completes, this method returns false. A value of
- * 0 indicates a timeout is not applied to the
- * database operation.
- *
- * @return true if the connection is valid, false otherwise
- * @exception SQLException if the value supplied for timeout
- * is less then 0
- * @since 1.6
- */
- public synchronized boolean isValid(int timeout) throws SQLException {
- if (isClosed()) {
- return false;
- }
-
- try {
- synchronized (getMutex()) {
- try {
- pingInternal(false, timeout * 1000);
- } catch (Throwable t) {
- try {
- abortInternal();
- } catch (Throwable ignoreThrown) {
- // we're dead now anyway
- }
-
- return false;
- }
- }
- } catch (Throwable t) {
- return false;
- }
-
- return true;
- }
-
- public void setClientInfo(Properties properties) throws SQLClientInfoException {
- try {
- getClientInfoProviderImpl().setClientInfo(this, properties);
- } catch (SQLClientInfoException ciEx) {
- throw ciEx;
- } catch (SQLException sqlEx) {
- SQLClientInfoException clientInfoEx = new SQLClientInfoException();
- clientInfoEx.initCause(sqlEx);
-
- throw clientInfoEx;
- }
- }
-
- public void setClientInfo(String name, String value) throws SQLClientInfoException {
- try {
- getClientInfoProviderImpl().setClientInfo(this, name, value);
- } catch (SQLClientInfoException ciEx) {
- throw ciEx;
- } catch (SQLException sqlEx) {
- SQLClientInfoException clientInfoEx = new SQLClientInfoException();
- clientInfoEx.initCause(sqlEx);
-
- throw clientInfoEx;
- }
- }
-
- /**
- * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
- * for an object that does. Returns false otherwise. If this implements the interface then return true,
- * else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
- * object. If this does not implement the interface and is not a wrapper, return false.
- * This method should be implemented as a low-cost operation compared to unwrap so that
- * callers can use this method to avoid expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument should succeed.
- *
- * @param interfaces a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly wraps an object that does.
- * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
- * for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
- checkClosed();
-
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to non-standard methods,
- * or standard methods not exposed by the proxy.
- * The result may be either the object found to implement the interface or a proxy for that object.
- * If the receiver implements the interface then that is the object. If the receiver is a wrapper
- * and the wrapped object implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped object. If the receiver is not a
- * wrapper and does not implement the interface, then an SQLException is thrown.
- *
- * @param iface A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the actual implementing object.
- * @throws java.sql.SQLException If no object found that implements the interface
- * @since 1.6
- */
- public T unwrap(java.lang.Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.cast(this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- /**
- * @see java.sql.Connection#createBlob()
- */
- public Blob createBlob() {
- return new com.mysql.jdbc.Blob(getExceptionInterceptor());
- }
-
- /**
- * @see java.sql.Connection#createClob()
- */
- public Clob createClob() {
- return new com.mysql.jdbc.Clob(getExceptionInterceptor());
- }
-
- /**
- * @see java.sql.Connection#createNClob()
- */
- public NClob createNClob() {
- return new com.mysql.jdbc.JDBC4NClob(getExceptionInterceptor());
- }
-
- protected synchronized JDBC4ClientInfoProvider getClientInfoProviderImpl() throws SQLException {
- if (this.infoProvider == null) {
- try {
- try {
- this.infoProvider = (JDBC4ClientInfoProvider)Util.getInstance(getClientInfoProvider(),
- new Class[0], new Object[0], getExceptionInterceptor());
- } catch (SQLException sqlEx) {
- if (sqlEx.getCause() instanceof ClassCastException) {
- // try with package name prepended
- this.infoProvider = (JDBC4ClientInfoProvider)Util.getInstance(
- "com.mysql.jdbc." + getClientInfoProvider(),
- new Class[0], new Object[0], getExceptionInterceptor());
- }
- }
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException(Messages
- .getString("JDBC4Connection.ClientInfoNotImplemented", new Object[] {getClientInfoProvider()}),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- this.infoProvider.initialize(this, this.props);
- }
-
- return this.infoProvider;
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4DatabaseMetaData.java b/src/com/mysql/jdbc/JDBC4DatabaseMetaData.java
deleted file mode 100644
index 80bf6d89d..000000000
--- a/src/com/mysql/jdbc/JDBC4DatabaseMetaData.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.ResultSet;
-import java.sql.RowIdLifetime;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-
-import java.util.List;
-
-import com.mysql.jdbc.Field;
-
-public class JDBC4DatabaseMetaData extends DatabaseMetaData {
- public JDBC4DatabaseMetaData(ConnectionImpl connToSet, String databaseToSet) {
- super(connToSet, databaseToSet);
- }
-
- public RowIdLifetime getRowIdLifetime() throws SQLException {
- return RowIdLifetime.ROWID_UNSUPPORTED;
- }
-
- /**
- * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
- * for an object that does. Returns false otherwise. If this implements the interface then return true,
- * else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
- * object. If this does not implement the interface and is not a wrapper, return false.
- * This method should be implemented as a low-cost operation compared to unwrap so that
- * callers can use this method to avoid expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument should succeed.
- *
- * @param interfaces a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly wraps an object that does.
- * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
- * for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to non-standard methods,
- * or standard methods not exposed by the proxy.
- * The result may be either the object found to implement the interface or a proxy for that object.
- * If the receiver implements the interface then that is the object. If the receiver is a wrapper
- * and the wrapped object implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped object. If the receiver is not a
- * wrapper and does not implement the interface, then an SQLException is thrown.
- *
- * @param iface A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the actual implementing object.
- * @throws java.sql.SQLException If no object found that implements the interface
- * @since 1.6
- */
- public T unwrap(java.lang.Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.cast(this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.conn.getExceptionInterceptor());
- }
- }
-
- /**
- * Retrieves a list of the client info properties
- * that the driver supports. The result set contains the following columns
- *
- *
- *
NAME String=> The name of the client info property
- *
MAX_LEN int=> The maximum length of the value for the property
- *
DEFAULT_VALUE String=> The default value of the property
- *
DESCRIPTION String=> A description of the property. This will typically
- * contain information as to where this property is
- * stored in the database.
- *
- *
- * The ResultSet is sorted by the NAME column
- *
- * @return A ResultSet object; each row is a supported client info
- * property
- *
- * @exception SQLException if a database access error occurs
- *
- * @since 1.6
- */
- public ResultSet getClientInfoProperties()
- throws SQLException {
- // We don't have any built-ins, we actually support whatever
- // the client wants to provide, however we don't have a way
- // to express this with the interface given
- Field[] fields = new Field[4];
- fields[0] = new Field("", "NAME", Types.VARCHAR, 255);
- fields[1] = new Field("", "MAX_LEN", Types.INTEGER, 10);
- fields[2] = new Field("", "DEFAULT_VALUE", Types.VARCHAR, 255);
- fields[3] = new Field("", "DESCRIPTION", Types.VARCHAR, 255);
-
- ArrayList tuples = new ArrayList();
-
- return buildResultSet(fields, tuples, this.conn);
- }
-
- public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
- return false;
- }
-
- /**
- * Retrieves a description of the system and user functions available
- * in the given catalog.
- *
- * Only system and user function descriptions matching the schema and
- * function name criteria are returned. They are ordered by
- * FUNCTION_CAT, FUNCTION_SCHEM,
- * FUNCTION_NAME and
- * SPECIFIC_ NAME.
- *
- *
Each function description has the the following columns:
- *
- *
FUNCTION_CAT String => function catalog (may be null)
- *
FUNCTION_SCHEM String => function schema (may be null)
- *
FUNCTION_NAME String => function name. This is the name
- * used to invoke the function
- *
REMARKS String => explanatory comment on the function
- *
FUNCTION_TYPE short => kind of function:
- *
- *
functionResultUnknown - Cannot determine if a return value
- * or table will be returned
- *
functionNoTable- Does not return a table
- *
functionReturnsTable - Returns a table
- *
- *
SPECIFIC_NAME String => the name which uniquely identifies
- * this function within its schema. This is a user specified, or DBMS
- * generated, name that may be different then the FUNCTION_NAME
- * for example with overload functions
- *
- *
- * A user may not have permission to execute any of the functions that are
- * returned by getFunctions
- *
- * @param catalog a catalog name; must match the catalog name as it
- * is stored in the database; "" retrieves those without a catalog;
- * null means that the catalog name should not be used to narrow
- * the search
- * @param schemaPattern a schema name pattern; must match the schema name
- * as it is stored in the database; "" retrieves those without a schema;
- * null means that the schema name should not be used to narrow
- * the search
- * @param functionNamePattern a function name pattern; must match the
- * function name as it is stored in the database
- * @return ResultSet - each row is a function description
- * @exception SQLException if a database access error occurs
- * @see #getSearchStringEscape
- * @since 1.6
- */
- public java.sql.ResultSet getFunctions(String catalog, String schemaPattern,
- String functionNamePattern) throws SQLException {
- Field[] fields = new Field[6];
-
- fields[0] = new Field("", "FUNCTION_CAT", Types.CHAR, 255);
- fields[1] = new Field("", "FUNCTION_SCHEM", Types.CHAR, 255);
- fields[2] = new Field("", "FUNCTION_NAME", Types.CHAR, 255);
- fields[3] = new Field("", "REMARKS", Types.CHAR, 255);
- fields[4] = new Field("", "FUNCTION_TYPE", Types.SMALLINT, 6);
- fields[5] = new Field("", "SPECIFIC_NAME", Types.CHAR, 255);
-
- return getProceduresAndOrFunctions(
- fields,
- catalog,
- schemaPattern,
- functionNamePattern,
- false,
- true);
- }
-
- protected int getJDBC4FunctionNoTableConstant() {
- return functionNoTable;
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/JDBC4DatabaseMetaDataUsingInfoSchema.java b/src/com/mysql/jdbc/JDBC4DatabaseMetaDataUsingInfoSchema.java
deleted file mode 100644
index 3c4b91931..000000000
--- a/src/com/mysql/jdbc/JDBC4DatabaseMetaDataUsingInfoSchema.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.ResultSet;
-import java.sql.RowIdLifetime;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-
-import java.util.List;
-
-public class JDBC4DatabaseMetaDataUsingInfoSchema extends DatabaseMetaDataUsingInfoSchema {
- public JDBC4DatabaseMetaDataUsingInfoSchema(ConnectionImpl connToSet, String databaseToSet) throws SQLException {
- super(connToSet, databaseToSet);
- }
-
- public RowIdLifetime getRowIdLifetime() throws SQLException {
- return RowIdLifetime.ROWID_UNSUPPORTED;
- }
-
- /**
- * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
- * for an object that does. Returns false otherwise. If this implements the interface then return true,
- * else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
- * object. If this does not implement the interface and is not a wrapper, return false.
- * This method should be implemented as a low-cost operation compared to unwrap so that
- * callers can use this method to avoid expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument should succeed.
- *
- * @param interfaces a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly wraps an object that does.
- * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
- * for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to non-standard methods,
- * or standard methods not exposed by the proxy.
- * The result may be either the object found to implement the interface or a proxy for that object.
- * If the receiver implements the interface then that is the object. If the receiver is a wrapper
- * and the wrapped object implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped object. If the receiver is not a
- * wrapper and does not implement the interface, then an SQLException is thrown.
- *
- * @param iface A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the actual implementing object.
- * @throws java.sql.SQLException If no object found that implements the interface
- * @since 1.6
- */
- public T unwrap(java.lang.Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.cast(this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.conn.getExceptionInterceptor());
- }
- }
-
- protected int getJDBC4FunctionNoTableConstant() {
- return functionNoTable;
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4MysqlSQLXML.java b/src/com/mysql/jdbc/JDBC4MysqlSQLXML.java
deleted file mode 100644
index 92fef053a..000000000
--- a/src/com/mysql/jdbc/JDBC4MysqlSQLXML.java
+++ /dev/null
@@ -1,837 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLXML;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stax.StAXResult;
-import javax.xml.transform.stax.StAXSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.SAXException;
-
-
-
-public class JDBC4MysqlSQLXML implements SQLXML {
-
- private XMLInputFactory inputFactory;
-
- private XMLOutputFactory outputFactory;
-
- private String stringRep;
-
- private ResultSetInternalMethods owningResultSet;
-
- private int columnIndexOfXml;
-
- private boolean fromResultSet;
-
- private boolean isClosed = false;
-
- private boolean workingWithResult;
-
- private DOMResult asDOMResult;
-
- private SAXResult asSAXResult;
-
- private SimpleSaxToReader saxToReaderConverter;
-
- private StringWriter asStringWriter;
-
- private ByteArrayOutputStream asByteArrayOutputStream;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- protected JDBC4MysqlSQLXML(ResultSetInternalMethods owner, int index, ExceptionInterceptor exceptionInterceptor) {
- this.owningResultSet = owner;
- this.columnIndexOfXml = index;
- this.fromResultSet = true;
- this.exceptionInterceptor = exceptionInterceptor;
- }
-
- protected JDBC4MysqlSQLXML(ExceptionInterceptor exceptionInterceptor) {
- this.fromResultSet = false;
- this.exceptionInterceptor = exceptionInterceptor;
- }
-
- public synchronized void free() throws SQLException {
- this.stringRep = null;
- this.asDOMResult = null;
- this.asSAXResult = null;
- this.inputFactory = null;
- this.outputFactory = null;
- this.owningResultSet = null;
- this.workingWithResult = false;
- this.isClosed = true;
-
- }
-
- public synchronized String getString() throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- if (this.fromResultSet) {
- return this.owningResultSet.getString(this.columnIndexOfXml);
- }
-
- return this.stringRep;
- }
-
- private synchronized void checkClosed() throws SQLException {
- if (this.isClosed) {
- throw SQLError
- .createSQLException("SQLXMLInstance has been free()d", this.exceptionInterceptor);
- }
- }
-
- private synchronized void checkWorkingWithResult() throws SQLException {
- if (this.workingWithResult) {
- throw SQLError
- .createSQLException(
- "Can't perform requested operation after getResult() has been called to write XML data",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-
- /**
- * Sets the XML value designated by this SQLXML instance to the given String
- * representation. The format of this String is defined by
- * org.xml.sax.InputSource, where the characters in the stream represent the
- * unicode code points for XML according to section 2 and appendix B of the
- * XML 1.0 specification. Although an encoding declaration other than
- * unicode may be present, the encoding of the String is unicode. The
- * behavior of this method is the same as ResultSet.updateString() when the
- * designated column of the ResultSet has a type java.sql.Types of SQLXML.
- *
- * The SQL XML object becomes not writeable when this method is called and
- * may also become not readable depending on implementation.
- *
- * @param value
- * the XML value
- * @throws SQLException
- * if there is an error processing the XML value. The getCause()
- * method of the exception may provide a more detailed
- * exception, for example, if the stream does not contain valid
- * characters. An exception is thrown if the state is not
- * writable.
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- * @since 1.6
- */
-
- public synchronized void setString(String str) throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- this.stringRep = str;
- this.fromResultSet = false;
- }
-
- public synchronized boolean isEmpty() throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- if (!this.fromResultSet) {
- return this.stringRep == null || this.stringRep.length() == 0;
- }
-
- return false;
- }
-
- public synchronized InputStream getBinaryStream() throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- return this.owningResultSet.getBinaryStream(this.columnIndexOfXml);
- }
-
- /**
- * Retrieves the XML value designated by this SQLXML instance as a
- * java.io.Reader object. The format of this stream is defined by
- * org.xml.sax.InputSource, where the characters in the stream represent the
- * unicode code points for XML according to section 2 and appendix B of the
- * XML 1.0 specification. Although an encoding declaration other than
- * unicode may be present, the encoding of the stream is unicode. The
- * behavior of this method is the same as ResultSet.getCharacterStream()
- * when the designated column of the ResultSet has a type java.sql.Types of
- * SQLXML.
- *
- * The SQL XML object becomes not readable when this method is called and
- * may also become not writable depending on implementation.
- *
- * @return a stream containing the XML data.
- * @throws SQLException
- * if there is an error processing the XML value. The getCause()
- * method of the exception may provide a more detailed
- * exception, for example, if the stream does not contain valid
- * characters. An exception is thrown if the state is not
- * readable.
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- * @since 1.6
- */
- public synchronized Reader getCharacterStream() throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- return this.owningResultSet.getCharacterStream(this.columnIndexOfXml);
- }
-
- /**
- * Returns a Source for reading the XML value designated by this SQLXML
- * instance. Sources are used as inputs to XML parsers and XSLT
- * transformers.
- *
- * Sources for XML parsers will have namespace processing on by default. The
- * systemID of the Source is implementation dependent.
- *
- * The SQL XML object becomes not readable when this method is called and
- * may also become not writable depending on implementation.
- *
- * Note that SAX is a callback architecture, so a returned SAXSource should
- * then be set with a content handler that will receive the SAX events from
- * parsing. The content handler will receive callbacks based on the contents
- * of the XML.
- *
- *
- *
- * @param sourceClass
- * The class of the source, or null. If the class is null, a
- * vendor specifc Source implementation will be returned. The
- * following classes are supported at a minimum:
- *
- * (MySQL returns a SAXSource if sourceClass == null)
- *
- *
- * javax.xml.transform.dom.DOMSource - returns a DOMSource
- * javax.xml.transform.sax.SAXSource - returns a SAXSource
- * javax.xml.transform.stax.StAXSource - returns a StAXSource
- * javax.xml.transform.stream.StreamSource - returns a StreamSource
- *
- *
- * @return a Source for reading the XML value.
- * @throws SQLException
- * if there is an error processing the XML value or if this
- * feature is not supported. The getCause() method of the
- * exception may provide a more detailed exception, for example,
- * if an XML parser exception occurs. An exception is thrown if
- * the state is not readable.
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- * @since 1.6
- */
- public synchronized Source getSource(Class clazz) throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- // Note that we try and use streams here wherever possible
- // for the day that the server actually supports streaming
- // from server -> client (futureproofing)
-
- if (clazz == null || clazz.equals(SAXSource.class)) {
-
- InputSource inputSource = null;
-
- if (this.fromResultSet) {
- inputSource = new InputSource(this.owningResultSet
- .getCharacterStream(this.columnIndexOfXml));
- } else {
- inputSource = new InputSource(new StringReader(this.stringRep));
- }
-
- return new SAXSource(inputSource);
- } else if (clazz.equals(DOMSource.class)) {
- try {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory
- .newInstance();
- builderFactory.setNamespaceAware(true);
- DocumentBuilder builder = builderFactory.newDocumentBuilder();
-
- InputSource inputSource = null;
-
- if (this.fromResultSet) {
- inputSource = new InputSource(this.owningResultSet
- .getCharacterStream(this.columnIndexOfXml));
- } else {
- inputSource = new InputSource(new StringReader(
- this.stringRep));
- }
-
- return new DOMSource(builder.parse(inputSource));
- } catch (Throwable t) {
- SQLException sqlEx = SQLError.createSQLException(t
- .getMessage(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- sqlEx.initCause(t);
-
- throw sqlEx;
- }
-
- } else if (clazz.equals(StreamSource.class)) {
- Reader reader = null;
-
- if (this.fromResultSet) {
- reader = this.owningResultSet
- .getCharacterStream(this.columnIndexOfXml);
- } else {
- reader = new StringReader(this.stringRep);
- }
-
- return new StreamSource(reader);
- } else if (clazz.equals(StAXSource.class)) {
- try {
- Reader reader = null;
-
- if (this.fromResultSet) {
- reader = this.owningResultSet
- .getCharacterStream(this.columnIndexOfXml);
- } else {
- reader = new StringReader(this.stringRep);
- }
-
- return new StAXSource(this.inputFactory
- .createXMLStreamReader(reader));
- } catch (XMLStreamException ex) {
- SQLException sqlEx = SQLError.createSQLException(ex
- .getMessage(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- } else {
- throw SQLError.createSQLException("XML Source of type \""
- + clazz.toString() + "\" Not supported.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-
- /**
- * Retrieves a stream that can be used to write the XML value that this
- * SQLXML instance represents. The stream begins at position 0. The bytes of
- * the stream are interpreted according to appendix F of the XML 1.0
- * specification The behavior of this method is the same as
- * ResultSet.updateBinaryStream() when the designated column of the
- * ResultSet has a type java.sql.Types of SQLXML.
- *
- * The SQL XML object becomes not writeable when this method is called and
- * may also become not readable depending on implementation.
- *
- * @return a stream to which data can be written.
- * @throws SQLException
- * if there is an error processing the XML value. An exception
- * is thrown if the state is not writable.
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- * @since 1.6
- */
- public synchronized OutputStream setBinaryStream() throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- this.workingWithResult = true;
-
- return setBinaryStreamInternal();
- }
-
- private synchronized OutputStream setBinaryStreamInternal()
- throws SQLException {
- this.asByteArrayOutputStream = new ByteArrayOutputStream();
-
- return this.asByteArrayOutputStream;
- }
-
- /**
- * Retrieves a stream to be used to write the XML value that this SQLXML
- * instance represents. The format of this stream is defined by
- * org.xml.sax.InputSource, where the characters in the stream represent the
- * unicode code points for XML according to section 2 and appendix B of the
- * XML 1.0 specification. Although an encoding declaration other than
- * unicode may be present, the encoding of the stream is unicode. The
- * behavior of this method is the same as ResultSet.updateCharacterStream()
- * when the designated column of the ResultSet has a type java.sql.Types of
- * SQLXML.
- *
- * The SQL XML object becomes not writeable when this method is called and
- * may also become not readable depending on implementation.
- *
- * @return a stream to which data can be written.
- * @throws SQLException
- * if there is an error processing the XML value. The getCause()
- * method of the exception may provide a more detailed
- * exception, for example, if the stream does not contain valid
- * characters. An exception is thrown if the state is not
- * writable.
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- * @since 1.6
- */
- public synchronized Writer setCharacterStream() throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- this.workingWithResult = true;
-
- return setCharacterStreamInternal();
- }
-
- private synchronized Writer setCharacterStreamInternal()
- throws SQLException {
- this.asStringWriter = new StringWriter();
-
- return this.asStringWriter;
- }
-
- /**
- * Returns a Result for setting the XML value designated by this SQLXML
- * instance.
- *
- * The systemID of the Result is implementation dependent.
- *
- * The SQL XML object becomes not writeable when this method is called and
- * may also become not readable depending on implementation.
- *
- * Note that SAX is a callback architecture and the returned SAXResult has a
- * content handler assigned that will receive the SAX events based on the
- * contents of the XML. Call the content handler with the contents of the
- * XML document to assign the values.
- *
- *
- * SAXResult saxResult = sqlxml.setResult(SAXResult.class);
- * ContentHandler contentHandler = saxResult.getXMLReader().getContentHandler();
- * contentHandler.startDocument();
- * // set the XML elements and attributes into the result
- * contentHandler.endDocument();
- *
- *
- * @param resultClass
- * The class of the result, or null. If resultClass is null, a
- * vendor specific Result implementation will be returned. The
- * following classes are supported at a minimum:
- *
- *
- * javax.xml.transform.dom.DOMResult - returns a DOMResult
- * javax.xml.transform.sax.SAXResult - returns a SAXResult
- * javax.xml.transform.stax.StAXResult - returns a StAXResult
- * javax.xml.transform.stream.StreamResult - returns a StreamResult
- *
- *
- * @return Returns a Result for setting the XML value.
- * @throws SQLException
- * if there is an error processing the XML value or if this
- * feature is not supported. The getCause() method of the
- * exception may provide a more detailed exception, for example,
- * if an XML parser exception occurs. An exception is thrown if
- * the state is not writable.
- * @exception SQLFeatureNotSupportedException
- * if the JDBC driver does not support this method
- * @since 1.6
- */
- public synchronized Result setResult(Class clazz) throws SQLException {
- checkClosed();
- checkWorkingWithResult();
-
- this.workingWithResult = true;
- this.asDOMResult = null;
- this.asSAXResult = null;
- this.saxToReaderConverter = null;
- this.stringRep = null;
- this.asStringWriter = null;
- this.asByteArrayOutputStream = null;
-
- if (clazz == null || clazz.equals(SAXResult.class)) {
- this.saxToReaderConverter = new SimpleSaxToReader();
-
- this.asSAXResult = new SAXResult(this.saxToReaderConverter);
-
- return this.asSAXResult;
- } else if (clazz.equals(DOMResult.class)) {
-
- this.asDOMResult = new DOMResult();
- return this.asDOMResult;
-
- } else if (clazz.equals(StreamResult.class)) {
- return new StreamResult(setCharacterStreamInternal());
- } else if (clazz.equals(StAXResult.class)) {
- try {
- if (this.outputFactory == null) {
- this.outputFactory = XMLOutputFactory.newInstance();
- }
-
- return new StAXResult(this.outputFactory
- .createXMLEventWriter(setCharacterStreamInternal()));
- } catch (XMLStreamException ex) {
- SQLException sqlEx = SQLError.createSQLException(ex
- .getMessage(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- } else {
- throw SQLError.createSQLException("XML Result of type \""
- + clazz.toString() + "\" Not supported.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-
- private Reader binaryInputStreamStreamToReader(ByteArrayOutputStream out) {
-
- try {
- // There's got to be an easier way to do this, but
- // I don't feel like coding up Appendix F of the XML Spec
- // myself, when there's a reusable way to do it, and we
- // can warn folks away from BINARY xml streams that have
- // to be parsed to determine the character encoding :P
-
- String encoding = "UTF-8";
-
- try {
- ByteArrayInputStream bIn = new ByteArrayInputStream(out
- .toByteArray());
- XMLStreamReader reader = this.inputFactory
- .createXMLStreamReader(bIn);
-
- int eventType = 0;
-
- while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
- if (eventType == XMLStreamReader.START_DOCUMENT) {
- String possibleEncoding = reader.getEncoding();
-
- if (possibleEncoding != null) {
- encoding = possibleEncoding;
- }
-
- break;
- }
- }
- } catch (Throwable t) {
- // ignore, dealt with later when the string can't be parsed
- // into valid XML
- }
-
- return new StringReader(new String(out.toByteArray(), encoding));
- } catch (UnsupportedEncodingException badEnc) {
- throw new RuntimeException(badEnc);
- }
- }
-
- protected String readerToString(Reader reader) throws SQLException {
- StringBuffer buf = new StringBuffer();
-
- int charsRead = 0;
-
- char[] charBuf = new char[512];
-
- try {
- while ((charsRead = reader.read(charBuf)) != -1) {
- buf.append(charBuf, 0, charsRead);
- }
- } catch (IOException ioEx) {
- SQLException sqlEx = SQLError.createSQLException(ioEx
- .getMessage(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- sqlEx.initCause(ioEx);
-
- throw sqlEx;
- }
-
- return buf.toString();
- }
-
- protected synchronized Reader serializeAsCharacterStream()
- throws SQLException {
- checkClosed();
- if (this.workingWithResult) {
- // figure out what kind of result
- if (this.stringRep != null) {
- return new StringReader(this.stringRep);
- }
-
- if (this.asDOMResult != null) {
- return new StringReader(domSourceToString());
- }
-
- if (this.asStringWriter != null) { // stax result
- return new StringReader(this.asStringWriter.toString());
- }
-
- if (this.asSAXResult != null) {
- return this.saxToReaderConverter.toReader();
- }
-
- if (this.asByteArrayOutputStream != null) {
- return binaryInputStreamStreamToReader(this.asByteArrayOutputStream);
- }
- }
-
- return this.owningResultSet.getCharacterStream(this.columnIndexOfXml);
- }
-
- protected String domSourceToString() throws SQLException {
- try {
- DOMSource source = new DOMSource(this.asDOMResult.getNode());
- Transformer identity = TransformerFactory.newInstance()
- .newTransformer();
- StringWriter stringOut = new StringWriter();
- Result result = new StreamResult(stringOut);
- identity.transform(source, result);
-
- return stringOut.toString();
- } catch (Throwable t) {
- SQLException sqlEx = SQLError.createSQLException(t
- .getMessage(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- sqlEx.initCause(t);
-
- throw sqlEx;
- }
- }
-
- protected synchronized String serializeAsString() throws SQLException {
- checkClosed();
- if (this.workingWithResult) {
- // figure out what kind of result
- if (this.stringRep != null) {
- return this.stringRep;
- }
-
- if (this.asDOMResult != null) {
- return domSourceToString();
- }
-
- if (this.asStringWriter != null) { // stax result
- return this.asStringWriter.toString();
- }
-
- if (this.asSAXResult != null) {
- return readerToString(this.saxToReaderConverter.toReader());
- }
-
- if (this.asByteArrayOutputStream != null) {
- return readerToString(
- binaryInputStreamStreamToReader(this.asByteArrayOutputStream));
- }
- }
-
- return this.owningResultSet.getString(this.columnIndexOfXml);
- }
-
- /*
- * The SimpleSaxToReader class is an adaptation of the SAX "Writer"
- * example from the Apache XercesJ-2 Project. The license for this
- * code is as follows:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- class SimpleSaxToReader extends DefaultHandler {
- StringBuffer buf = new StringBuffer();
-
- public void startDocument() throws SAXException {
- buf.append("");
- }
-
- public void endDocument() throws SAXException {
- // Do we need to override this?
- }
-
- public void startElement(String namespaceURI, String sName,
- String qName, Attributes attrs) throws SAXException {
-
- this.buf.append("<");
- this.buf.append(qName);
-
- if (attrs != null) {
- for (int i = 0; i < attrs.getLength(); i++) {
- this.buf.append(" ");
- this.buf.append(attrs.getQName(i)).append("=\"");
- escapeCharsForXml(attrs.getValue(i), true);
- this.buf.append("\"");
- }
- }
-
- this.buf.append(">");
- }
-
- public void characters(char buf[], int offset, int len)
- throws SAXException {
- if (!this.inCDATA) {
- escapeCharsForXml(buf, offset, len, false);
- } else {
- this.buf.append(buf, offset, len);
- }
- }
-
- public void ignorableWhitespace(char ch[], int start, int length)
- throws SAXException {
- characters(ch, start, length);
- }
-
- private boolean inCDATA = false;
-
- public void startCDATA() throws SAXException {
- this.buf.append("");
- }
-
- public void comment(char ch[], int start, int length)
- throws SAXException {
- // if (!fCanonical && fElementDepth > 0) {
- this.buf.append("");
- // }
- }
-
- Reader toReader() {
- return new StringReader(this.buf.toString());
- }
-
- private void escapeCharsForXml(String str, boolean isAttributeData) {
- if (str == null) {
- return;
- }
-
- int strLen = str.length();
-
- for (int i = 0; i < strLen; i++) {
- escapeCharsForXml(str.charAt(i), isAttributeData);
- }
- }
-
- private void escapeCharsForXml(char[] buf, int offset, int len,
- boolean isAttributeData) {
-
- if (buf == null) {
- return;
- }
-
- for (int i = 0; i < len; i++) {
- escapeCharsForXml(buf[offset + i], isAttributeData);
- }
- }
-
- private void escapeCharsForXml(char c, boolean isAttributeData) {
- switch (c) {
- case '<':
- this.buf.append("<");
- break;
-
- case '>':
- this.buf.append(">");
- break;
-
- case '&':
- this.buf.append("&");
- break;
-
- case '"':
-
- if (!isAttributeData) {
- this.buf.append("\"");
- }
- else {
- this.buf.append(""");
- }
-
- break;
-
- case '\r':
- this.buf.append("
");
- break;
-
-
- default:
-
- if (((c >= 0x01 && c <= 0x1F && c != 0x09 && c != 0x0A)
- || (c >= 0x7F && c <= 0x9F) || c == 0x2028)
- || isAttributeData && (c == 0x09 || c == 0x0A)) {
- this.buf.append("");
- this.buf.append(Integer.toHexString(c).toUpperCase());
- this.buf.append(";");
- }
- else {
- this.buf.append(c);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/JDBC4NClob.java b/src/com/mysql/jdbc/JDBC4NClob.java
deleted file mode 100644
index 1d1901bca..000000000
--- a/src/com/mysql/jdbc/JDBC4NClob.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import com.mysql.jdbc.ExceptionInterceptor;
-
-
-/**
- * Simplistic implementation of java.sql.NClob for MySQL Connector/J
- *
- * @author Tetsuro Ikeda
- * @version $Id: NClob.java 4963 2006-02-21 13:28:14Z tikeda $
- */
-public class JDBC4NClob extends Clob implements java.sql.NClob {
-
- JDBC4NClob(ExceptionInterceptor exceptionInterceptor) {
- super(exceptionInterceptor);
- }
-
- JDBC4NClob(String charDataInit, ExceptionInterceptor exceptionInterceptor) {
- super(charDataInit, exceptionInterceptor);
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4PreparedStatement.java b/src/com/mysql/jdbc/JDBC4PreparedStatement.java
deleted file mode 100644
index b9df5fcd8..000000000
--- a/src/com/mysql/jdbc/JDBC4PreparedStatement.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.sql.NClob;
-import java.sql.RowId;
-import java.sql.SQLXML;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.PreparedStatement;
-import com.mysql.jdbc.PreparedStatement.ParseInfo;
-
-
-public class JDBC4PreparedStatement extends PreparedStatement {
-
- public JDBC4PreparedStatement(ConnectionImpl conn, String catalog) throws SQLException {
- super(conn, catalog);
- }
-
- public JDBC4PreparedStatement(ConnectionImpl conn, String sql, String catalog)
- throws SQLException {
- super(conn, sql, catalog);
- }
-
- public JDBC4PreparedStatement(ConnectionImpl conn, String sql, String catalog,
- ParseInfo cachedParseInfo) throws SQLException {
- super(conn, sql, catalog, cachedParseInfo);
- }
-
- public void setRowId(int parameterIndex, RowId x) throws SQLException {
- JDBC4PreparedStatementHelper.setRowId(this, parameterIndex, x);
- }
-
- /**
- * JDBC 4.0 Set a NCLOB parameter.
- *
- * @param i
- * the first parameter is 1, the second is 2, ...
- * @param x
- * an object representing a NCLOB
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void setNClob(int parameterIndex, NClob value) throws SQLException {
- JDBC4PreparedStatementHelper.setNClob(this, parameterIndex, value);
- }
-
- public void setSQLXML(int parameterIndex, SQLXML xmlObject)
- throws SQLException {
- JDBC4PreparedStatementHelper.setSQLXML(this, parameterIndex, xmlObject);
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4PreparedStatementHelper.java b/src/com/mysql/jdbc/JDBC4PreparedStatementHelper.java
deleted file mode 100644
index 3e8d997f1..000000000
--- a/src/com/mysql/jdbc/JDBC4PreparedStatementHelper.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.mysql.jdbc;
-
-import java.io.Reader;
-import java.sql.NClob;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Types;
-
-import com.mysql.jdbc.PreparedStatement;
-
-
-public class JDBC4PreparedStatementHelper {
- private JDBC4PreparedStatementHelper() {
-
- }
-
- static void setRowId(PreparedStatement pstmt, int parameterIndex, RowId x) throws SQLException {
- throw SQLError.notImplemented();
- }
-
-
- /**
- * JDBC 4.0 Set a NCLOB parameter.
- *
- * @param i
- * the first parameter is 1, the second is 2, ...
- * @param x
- * an object representing a NCLOB
- *
- * @throws SQLException
- * if a database error occurs
- */
- static void setNClob(PreparedStatement pstmt, int parameterIndex, NClob value) throws SQLException {
- if (value == null) {
- pstmt.setNull(parameterIndex, java.sql.Types.NCLOB);
- } else {
- pstmt.setNCharacterStream(parameterIndex, value.getCharacterStream(), value.length());
- }
- }
-
- static void setNClob(PreparedStatement pstmt, int parameterIndex, Reader reader) throws SQLException {
- pstmt.setNCharacterStream(parameterIndex, reader);
- }
-
- /**
- * JDBC 4.0 Set a NCLOB parameter.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param reader
- * the java reader which contains the UNICODE data
- * @param length
- * the number of characters in the stream
- *
- * @throws SQLException
- * if a database error occurs
- */
- static void setNClob(PreparedStatement pstmt, int parameterIndex, Reader reader, long length)
- throws SQLException {
- if (reader == null) {
- pstmt.setNull(parameterIndex, java.sql.Types.NCLOB);
- } else {
- pstmt.setNCharacterStream(parameterIndex, reader, length);
- }
- }
-
- static void setSQLXML(PreparedStatement pstmt, int parameterIndex, SQLXML xmlObject)
- throws SQLException {
- if (xmlObject == null) {
- pstmt.setNull(parameterIndex, Types.SQLXML);
- } else {
- // FIXME: Won't work for Non-MYSQL SQLXMLs
- pstmt.setCharacterStream(parameterIndex, ((JDBC4MysqlSQLXML)xmlObject).serializeAsCharacterStream());
- }
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4ResultSet.java b/src/com/mysql/jdbc/JDBC4ResultSet.java
deleted file mode 100644
index 3bd6bc5d2..000000000
--- a/src/com/mysql/jdbc/JDBC4ResultSet.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.sql.NClob;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.Field;
-import com.mysql.jdbc.NotUpdatable;
-import com.mysql.jdbc.ResultSetImpl;
-import com.mysql.jdbc.RowData;
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.Statement;
-
-
-public class JDBC4ResultSet extends ResultSetImpl {
-
- public JDBC4ResultSet(long updateCount, long updateID,
- ConnectionImpl conn, StatementImpl creatorStmt) {
- super(updateCount, updateID, conn, creatorStmt);
- }
-
- public JDBC4ResultSet(String catalog, Field[] fields, RowData tuples,
- ConnectionImpl conn, StatementImpl creatorStmt) throws SQLException {
- super(catalog, fields, tuples, conn, creatorStmt);
- }
-
- /**
- * JDBC 4.0
- *
- *
- * Get the value of a column in the current row as a java.io.Reader.
- *
- *
- * @param columnIndex
- * the column to get the value from
- *
- * @return the value in the column as a java.io.Reader.
- *
- * @throws SQLException
- * if an error occurs
- */
- public Reader getNCharacterStream(int columnIndex) throws SQLException {
- checkColumnBounds(columnIndex);
-
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException(
- "Can not call getNCharacterStream() when field's charset isn't UTF-8");
- }
- return getCharacterStream(columnIndex);
- }
-
- /**
- * JDBC 4.0
- *
- *
- * Get the value of a column in the current row as a java.io.Reader.
- *
- *
- * @param columnName
- * the column name to retrieve the value from
- *
- * @return the value as a java.io.Reader
- *
- * @throws SQLException
- * if an error occurs
- */
- public Reader getNCharacterStream(String columnName) throws SQLException {
- return getNCharacterStream(findColumn(columnName));
- }
-
- /**
- * JDBC 4.0 Get a NCLOB column.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a NCLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- public NClob getNClob(int columnIndex) throws SQLException {
- checkColumnBounds(columnIndex);
-
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException(
- "Can not call getNClob() when field's charset isn't UTF-8");
- }
- if (!this.isBinaryEncoded) {
- String asString = getStringForNClob(columnIndex);
-
- if (asString == null) {
- return null;
- }
-
- return new com.mysql.jdbc.JDBC4NClob(asString, getExceptionInterceptor());
- }
-
- return getNativeNClob(columnIndex);
- }
-
- /**
- * JDBC 4.0 Get a NCLOB column.
- *
- * @param colName
- * the column name
- *
- * @return an object representing a NCLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- public NClob getNClob(String columnName) throws SQLException {
- return getNClob(findColumn(columnName));
- }
-
- /**
- * JDBC 4.0 Get a NCLOB column.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a NCLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- protected java.sql.NClob getNativeNClob(int columnIndex)
- throws SQLException {
- String stringVal = getStringForNClob(columnIndex);
-
- if (stringVal == null) {
- return null;
- }
-
- return getNClobFromString(stringVal, columnIndex);
- }
-
- private String getStringForNClob(int columnIndex) throws SQLException {
- String asString = null;
-
- String forcedEncoding = "UTF-8";
-
- try {
- byte[] asBytes = null;
-
- if (!this.isBinaryEncoded) {
- asBytes = getBytes(columnIndex);
- } else {
- asBytes = getNativeBytes(columnIndex, true);
- }
-
- if (asBytes != null) {
- asString = new String(asBytes, forcedEncoding);
- }
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException("Unsupported character encoding "
- + forcedEncoding, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- return asString;
- }
-
- private final java.sql.NClob getNClobFromString(String stringVal,
- int columnIndex) throws SQLException {
- return new com.mysql.jdbc.JDBC4NClob(stringVal, getExceptionInterceptor());
- }
-
- /**
- * JDBC 4.0
- *
- * Get the value of a column in the current row as a Java String
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value, null for SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public String getNString(int columnIndex) throws SQLException {
- checkColumnBounds(columnIndex);
-
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException(
- "Can not call getNString() when field's charset isn't UTF-8");
- }
- return getString(columnIndex);
- }
-
- /**
- * JDBC 4.0
- *
- * The following routines simply convert the columnName into a columnIndex
- * and then call the appropriate routine above.
- *
- * @param columnName
- * is the SQL name of the column
- *
- * @return the column value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public String getNString(String columnName) throws SQLException {
- return getNString(findColumn(columnName));
- }
-
- /**
- * JDBC 4.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateNCharacterStream(int columnIndex, Reader x, int length)
- throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 4.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param reader
- * the stream to update the column with
- * @param length
- * of the stream
- *
- * @throws SQLException
- * if a database-access error occurs
- */
- public void updateNCharacterStream(String columnName, Reader reader,
- int length) throws SQLException {
- updateNCharacterStream(findColumn(columnName), reader, length);
- }
-
- /**
- * @see ResultSet#updateNClob(String, NClob)
- */
- public void updateNClob(String columnName, NClob nClob) throws SQLException {
- updateNClob(findColumn(columnName), nClob);
- }
-
- public void updateRowId(int columnIndex, RowId x) throws SQLException {
- throw new NotUpdatable();
- }
-
- public void updateRowId(String columnName, RowId x) throws SQLException {
- updateRowId(findColumn(columnName), x);
- }
-
- public int getHoldability() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- public RowId getRowId(int columnIndex) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- public RowId getRowId(String columnLabel) throws SQLException {
- return getRowId(findColumn(columnLabel));
- }
-
- public SQLXML getSQLXML(int columnIndex) throws SQLException {
- checkColumnBounds(columnIndex);
-
- return new JDBC4MysqlSQLXML(this, columnIndex, getExceptionInterceptor());
- }
-
- public SQLXML getSQLXML(String columnLabel) throws SQLException {
- return getSQLXML(findColumn(columnLabel));
- }
-
- public synchronized boolean isClosed() throws SQLException {
- return this.isClosed;
- }
-
- public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
- updateAsciiStream(findColumn(columnLabel), x);
-
- }
-
- public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
- updateAsciiStream(findColumn(columnLabel), x, length);
- }
-
- public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
- updateBinaryStream(findColumn(columnLabel), x);
- }
-
- public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
- updateBinaryStream(findColumn(columnLabel), x, length);
- }
-
- public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
- throw new NotUpdatable();
- }
-
- public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
- updateBlob(findColumn(columnLabel), inputStream);
- }
-
- public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
- updateBlob(findColumn(columnLabel), inputStream, length);
- }
-
- public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
- updateCharacterStream(findColumn(columnLabel), reader);
- }
-
- public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- updateCharacterStream(findColumn(columnLabel), reader, length);
- }
-
- public void updateClob(int columnIndex, Reader reader) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateClob(String columnLabel, Reader reader) throws SQLException {
- updateClob(findColumn(columnLabel), reader);
- }
-
- public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
- updateClob(findColumn(columnLabel), reader, length);
- }
-
- public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
- updateNCharacterStream(findColumn(columnLabel), reader);
-
- }
-
- public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- updateNCharacterStream(findColumn(columnLabel), reader, length);
- }
-
- public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNClob(int columnIndex, Reader reader) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNClob(String columnLabel, Reader reader) throws SQLException {
- updateNClob(findColumn(columnLabel), reader);
-
- }
-
- public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
- throw new NotUpdatable();
- }
-
- public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
- updateNClob(findColumn(columnLabel), reader, length);
- }
-
- public void updateNString(int columnIndex, String nString) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNString(String columnLabel, String nString) throws SQLException {
- updateNString(findColumn(columnLabel), nString);
- }
-
- public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
- updateSQLXML(findColumn(columnLabel), xmlObject);
-
- }
-
- /**
- * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
- * for an object that does. Returns false otherwise. If this implements the interface then return true,
- * else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
- * object. If this does not implement the interface and is not a wrapper, return false.
- * This method should be implemented as a low-cost operation compared to unwrap so that
- * callers can use this method to avoid expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument should succeed.
- *
- * @param interfaces a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly wraps an object that does.
- * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
- * for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
- checkClosed();
-
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to non-standard methods,
- * or standard methods not exposed by the proxy.
- * The result may be either the object found to implement the interface or a proxy for that object.
- * If the receiver implements the interface then that is the object. If the receiver is a wrapper
- * and the wrapped object implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped object. If the receiver is not a
- * wrapper and does not implement the interface, then an SQLException is thrown.
- *
- * @param iface A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the actual implementing object.
- * @throws java.sql.SQLException If no object found that implements the interface
- * @since 1.6
- */
- public T unwrap(java.lang.Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.cast(this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4ServerPreparedStatement.java b/src/com/mysql/jdbc/JDBC4ServerPreparedStatement.java
deleted file mode 100644
index 2ecac5b39..000000000
--- a/src/com/mysql/jdbc/JDBC4ServerPreparedStatement.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.io.Reader;
-import java.sql.NClob;
-import java.sql.RowId;
-import java.sql.SQLXML;
-import java.sql.SQLException;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.MysqlDefs;
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.ServerPreparedStatement;
-import com.mysql.jdbc.ServerPreparedStatement.BindValue;
-
-public class JDBC4ServerPreparedStatement extends ServerPreparedStatement {
-
- public JDBC4ServerPreparedStatement(ConnectionImpl conn, String sql,
- String catalog, int resultSetType, int resultSetConcurrency)
- throws SQLException {
- super(conn, sql, catalog, resultSetType, resultSetConcurrency);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader,
- * long)
- */
- public void setNCharacterStream(int parameterIndex, Reader reader,
- long length) throws SQLException {
- // can't take if characterEncoding isn't utf8
- if (!this.charEncoding.equalsIgnoreCase("UTF-8")
- && !this.charEncoding.equalsIgnoreCase("utf8")) {
- throw SQLError
- .createSQLException("Can not call setNCharacterStream() when connection character set isn't UTF-8", getExceptionInterceptor());
- }
-
- checkClosed();
-
- if (reader == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- BindValue binding = getBinding(parameterIndex, true);
- setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
-
- binding.value = reader;
- binding.isNull = false;
- binding.isLongData = true;
-
- if (this.connection.getUseStreamLengthsInPrepStmts()) {
- binding.bindLength = length;
- } else {
- binding.bindLength = -1;
- }
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob)
- */
- public void setNClob(int parameterIndex, NClob x) throws SQLException {
- setNClob(parameterIndex, x.getCharacterStream(), this.connection
- .getUseStreamLengthsInPrepStmts() ? x.length() : -1);
- }
-
- /**
- * JDBC 4.0 Set a NCLOB parameter.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param reader
- * the java reader which contains the UNICODE data
- * @param length
- * the number of characters in the stream
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void setNClob(int parameterIndex, Reader reader, long length)
- throws SQLException {
- // can't take if characterEncoding isn't utf8
- if (!this.charEncoding.equalsIgnoreCase("UTF-8")
- && !this.charEncoding.equalsIgnoreCase("utf8")) {
- throw SQLError
- .createSQLException("Can not call setNClob() when connection character set isn't UTF-8", getExceptionInterceptor());
- }
-
- checkClosed();
-
- if (reader == null) {
- setNull(parameterIndex, java.sql.Types.NCLOB);
- } else {
- BindValue binding = getBinding(parameterIndex, true);
- setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
-
- binding.value = reader;
- binding.isNull = false;
- binding.isLongData = true;
-
- if (this.connection.getUseStreamLengthsInPrepStmts()) {
- binding.bindLength = length;
- } else {
- binding.bindLength = -1;
- }
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setNString(int, java.lang.String)
- */
- public void setNString(int parameterIndex, String x) throws SQLException {
- if (this.charEncoding.equalsIgnoreCase("UTF-8")
- || this.charEncoding.equalsIgnoreCase("utf8")) {
- setString(parameterIndex, x);
- } else {
- throw SQLError
- .createSQLException("Can not call setNString() when connection character set isn't UTF-8", getExceptionInterceptor());
- }
- }
-
- public void setRowId(int parameterIndex, RowId x) throws SQLException {
- JDBC4PreparedStatementHelper.setRowId(this, parameterIndex, x);
- }
-
- public void setSQLXML(int parameterIndex, SQLXML xmlObject)
- throws SQLException {
- JDBC4PreparedStatementHelper.setSQLXML(this, parameterIndex, xmlObject);
- }
-}
diff --git a/src/com/mysql/jdbc/JDBC4UpdatableResultSet.java b/src/com/mysql/jdbc/JDBC4UpdatableResultSet.java
deleted file mode 100644
index ddb8e4a06..000000000
--- a/src/com/mysql/jdbc/JDBC4UpdatableResultSet.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.sql.NClob;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.Field;
-import com.mysql.jdbc.NotUpdatable;
-import com.mysql.jdbc.RowData;
-import com.mysql.jdbc.Statement;
-import com.mysql.jdbc.StringUtils;
-import com.mysql.jdbc.UpdatableResultSet;
-
-
-
-public class JDBC4UpdatableResultSet extends UpdatableResultSet {
- public JDBC4UpdatableResultSet(String catalog, Field[] fields, RowData tuples,
- ConnectionImpl conn, StatementImpl creatorStmt) throws SQLException {
- super(catalog, fields, tuples, conn, creatorStmt);
- }
-
- public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
- throw new NotUpdatable();
- }
-
- public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
-
- public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateClob(int columnIndex, Reader reader) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- updateNCharacterStream(columnIndex, x, (int) length);
-
- }
-
-
- public void updateNClob(int columnIndex, Reader reader) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
- throw new NotUpdatable();
- }
-
- public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
- throw new NotUpdatable();
-
- }
-
- public void updateRowId(int columnIndex, RowId x) throws SQLException {
- throw new NotUpdatable();
- }
-
- public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
- updateAsciiStream(findColumn(columnLabel), x);
- }
-
- public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
- updateAsciiStream(findColumn(columnLabel), x, length);
- }
-
- public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
- updateBinaryStream(findColumn(columnLabel), x);
- }
-
- public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
- updateBinaryStream(findColumn(columnLabel), x, length);
- }
-
- public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
- updateBlob(findColumn(columnLabel), inputStream);
- }
-
- public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
- updateBlob(findColumn(columnLabel), inputStream, length);
- }
-
- public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
- updateCharacterStream(findColumn(columnLabel), reader);
- }
-
- public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- updateCharacterStream(findColumn(columnLabel), reader, length);
- }
-
- public void updateClob(String columnLabel, Reader reader) throws SQLException {
- updateClob(findColumn(columnLabel), reader);
- }
-
- public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
- updateClob(findColumn(columnLabel), reader, length);
- }
-
- public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
- updateNCharacterStream(findColumn(columnLabel), reader);
-
- }
-
- public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- updateNCharacterStream(findColumn(columnLabel), reader, length);
- }
-
-
- public void updateNClob(String columnLabel, Reader reader) throws SQLException {
- updateNClob(findColumn(columnLabel), reader);
-
- }
-
- public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
- updateNClob(findColumn(columnLabel), reader, length);
- }
-
- public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
- updateSQLXML(findColumn(columnLabel), xmlObject);
-
- }
-
- /**
- * JDBC 4.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateNCharacterStream(int columnIndex,
- java.io.Reader x, int length) throws SQLException {
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException(
- "Can not call updateNCharacterStream() when field's character set isn't UTF-8");
- }
-
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- ((com.mysql.jdbc.JDBC4PreparedStatement)this.updater).setNCharacterStream(columnIndex, x, length);
- } else {
- ((com.mysql.jdbc.JDBC4PreparedStatement)this.inserter).setNCharacterStream(columnIndex, x, length);
-
- if (x == null) {
- this.thisRow.setColumnValue(columnIndex - 1, null);
- } else {
- this.thisRow.setColumnValue(columnIndex - 1, STREAM_DATA_MARKER);
- }
- }
- }
-
- /**
- * JDBC 4.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param reader
- * the new column value
- * @param length
- * of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateNCharacterStream(String columnName,
- java.io.Reader reader, int length) throws SQLException {
- updateNCharacterStream(findColumn(columnName), reader, length);
- }
-
- /**
- * @see ResultSet#updateNClob(int, NClob)
- */
- public void updateNClob(int columnIndex, java.sql.NClob nClob)
- throws SQLException {
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException("Can not call updateNClob() when field's character set isn't UTF-8");
- }
-
- if (nClob == null) {
- updateNull(columnIndex);
- } else {
- updateNCharacterStream(columnIndex, nClob.getCharacterStream(),
- (int) nClob.length());
- }
- }
-
- /**
- * @see ResultSet#updateClob(int, Clob)
- */
- public void updateNClob(String columnName, java.sql.NClob nClob)
- throws SQLException {
- updateNClob(findColumn(columnName), nClob);
- }
-
- /**
- * JDBC 4.0 Update a column with NATIONAL CHARACTER. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateNString(int columnIndex, String x)
- throws SQLException {
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException("Can not call updateNString() when field's character set isn't UTF-8");
- }
-
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- ((com.mysql.jdbc.JDBC4PreparedStatement)this.updater).setNString(columnIndex, x);
- } else {
- ((com.mysql.jdbc.JDBC4PreparedStatement)this.inserter).setNString(columnIndex, x);
-
- if (x == null) {
- this.thisRow.setColumnValue(columnIndex - 1, null);
- } else {
- this.thisRow.setColumnValue(columnIndex - 1, StringUtils.getBytes(x,
- this.charConverter, fieldEncoding,
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), getExceptionInterceptor()));
- }
- }
- }
-
- /**
- * JDBC 4.0 Update a column with NATIONAL CHARACTER. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateNString(String columnName, String x)
- throws SQLException {
- updateNString(findColumn(columnName), x);
- }
-
- public int getHoldability() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 4.0 Get a NCLOB column.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a NCLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- protected java.sql.NClob getNativeNClob(int columnIndex)
- throws SQLException {
- String stringVal = getStringForNClob(columnIndex);
-
- if (stringVal == null) {
- return null;
- }
-
- return getNClobFromString(stringVal, columnIndex);
- }
-
- /**
- * JDBC 4.0
- *
- *
- * Get the value of a column in the current row as a java.io.Reader.
- *
- *
- * @param columnIndex
- * the column to get the value from
- *
- * @return the value in the column as a java.io.Reader.
- *
- * @throws SQLException
- * if an error occurs
- */
- public Reader getNCharacterStream(int columnIndex) throws SQLException {
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException(
- "Can not call getNCharacterStream() when field's charset isn't UTF-8");
- }
-
- return getCharacterStream(columnIndex);
- }
-
- /**
- * JDBC 4.0
- *
- *
- * Get the value of a column in the current row as a java.io.Reader.
- *
- *
- * @param columnName
- * the column name to retrieve the value from
- *
- * @return the value as a java.io.Reader
- *
- * @throws SQLException
- * if an error occurs
- */
- public Reader getNCharacterStream(String columnName) throws SQLException {
- return getNCharacterStream(findColumn(columnName));
- }
-
- /**
- * JDBC 4.0 Get a NCLOB column.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a NCLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- public NClob getNClob(int columnIndex) throws SQLException {
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
-
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException(
- "Can not call getNClob() when field's charset isn't UTF-8");
- }
-
- if (!this.isBinaryEncoded) {
- String asString = getStringForNClob(columnIndex);
-
- if (asString == null) {
- return null;
- }
-
- return new com.mysql.jdbc.JDBC4NClob(asString, getExceptionInterceptor());
- }
-
- return getNativeNClob(columnIndex);
- }
-
- /**
- * JDBC 4.0 Get a NCLOB column.
- *
- * @param colName
- * the column name
- *
- * @return an object representing a NCLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- public NClob getNClob(String columnName) throws SQLException {
- return getNClob(findColumn(columnName));
- }
-
- private final java.sql.NClob getNClobFromString(String stringVal,
- int columnIndex) throws SQLException {
- return new com.mysql.jdbc.JDBC4NClob(stringVal, getExceptionInterceptor());
- }
-
- /**
- * JDBC 4.0
- *
- * Get the value of a column in the current row as a Java String
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value, null for SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public String getNString(int columnIndex) throws SQLException {
- String fieldEncoding = this.fields[columnIndex - 1].getCharacterSet();
-
- if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
- throw new SQLException(
- "Can not call getNString() when field's charset isn't UTF-8");
- }
-
- return getString(columnIndex);
- }
-
- /**
- * JDBC 4.0
- *
- * The following routines simply convert the columnName into a columnIndex
- * and then call the appropriate routine above.
- *
- * @param columnName
- * is the SQL name of the column
- *
- * @return the column value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public String getNString(String columnName) throws SQLException {
- return getNString(findColumn(columnName));
- }
-
- public RowId getRowId(int columnIndex) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- public RowId getRowId(String columnLabel) throws SQLException {
- return getRowId(findColumn(columnLabel));
- }
-
- public SQLXML getSQLXML(int columnIndex) throws SQLException {
- return new JDBC4MysqlSQLXML(this, columnIndex, getExceptionInterceptor());
- }
-
- public SQLXML getSQLXML(String columnLabel) throws SQLException {
- return getSQLXML(findColumn(columnLabel));
- }
-
- private String getStringForNClob(int columnIndex) throws SQLException {
- String asString = null;
-
- String forcedEncoding = "UTF-8";
-
- try {
- byte[] asBytes = null;
-
- if (!this.isBinaryEncoded) {
- asBytes = getBytes(columnIndex);
- } else {
- asBytes = getNativeBytes(columnIndex, true);
- }
-
- if (asBytes != null) {
- asString = new String(asBytes, forcedEncoding);
- }
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException("Unsupported character encoding "
- + forcedEncoding, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- return asString;
- }
-
- public synchronized boolean isClosed() throws SQLException {
- return this.isClosed;
- }
-
- /**
- * Returns true if this either implements the interface argument or is
- * directly or indirectly a wrapper for an object that does. Returns false
- * otherwise. If this implements the interface then return true, else if
- * this is a wrapper then return the result of recursively calling
- * isWrapperFor on the wrapped object. If this does not
- * implement the interface and is not a wrapper, return false. This method
- * should be implemented as a low-cost operation compared to
- * unwrap so that callers can use this method to avoid
- * expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument
- * should succeed.
- *
- * @param interfaces
- * a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly
- * wraps an object that does.
- * @throws java.sql.SQLException
- * if an error occurs while determining whether this is a
- * wrapper for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
- checkClosed();
-
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to
- * non-standard methods, or standard methods not exposed by the proxy. The
- * result may be either the object found to implement the interface or a
- * proxy for that object. If the receiver implements the interface then that
- * is the object. If the receiver is a wrapper and the wrapped object
- * implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped
- * object. If the receiver is not a wrapper and does not implement the
- * interface, then an SQLException is thrown.
- *
- * @param iface
- * A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the
- * actual implementing object.
- * @throws java.sql.SQLException
- * If no object found that implements the interface
- * @since 1.6
- */
- public T unwrap(java.lang.Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.cast(this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-}
diff --git a/src/com/mysql/jdbc/LicenseConfiguration.java b/src/com/mysql/jdbc/LicenseConfiguration.java
deleted file mode 100644
index a5f896875..000000000
--- a/src/com/mysql/jdbc/LicenseConfiguration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.Map;
-
-/**
- * Used in commercially-licensed clients that require connections to
- * commercially-licensed servers as part of the licensing terms.
- *
- * @author Mark Matthews
- * @version $Id: LicenseConfiguration.java,v 1.1.2.1 2005/05/13 18:58:38
- * mmatthews Exp $
- */
-class LicenseConfiguration {
-
- /**
- * Used in commercially-licensed clients that require connections to
- * commercially-licensed servers as part of the licensing terms.
- *
- * @param serverVariables
- * a Map of the output of 'show variables' from the server we're
- * connecting to.
- *
- * @throws SQLException
- * if commercial license is required, but not found
- */
- static void checkLicenseType(Map serverVariables) throws SQLException {
- // This is a GPL build, so we don't check anything...
- }
-
- private LicenseConfiguration() {
- // this is a static utility class
- }
-}
diff --git a/src/com/mysql/jdbc/LoadBalancingConnectionProxy.java b/src/com/mysql/jdbc/LoadBalancingConnectionProxy.java
deleted file mode 100644
index ca61406e6..000000000
--- a/src/com/mysql/jdbc/LoadBalancingConnectionProxy.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * An implementation of java.sql.Connection that load balances requests across a
- * series of MySQL JDBC connections, where the balancing takes place at
- * transaction commit.
- *
- * Therefore, for this to work (at all), you must use transactions, even if only
- * reading data.
- *
- * This implementation will invalidate connections that it detects have had
- * communication errors when processing a request. Problematic hosts will
- * be added to a global blacklist for loadBalanceBlacklistTimeout ms, after
- * which they will be removed from the blacklist and made eligible once again
- * to be selected for new connections.
- *
- * This implementation is thread-safe, but it's questionable whether sharing a
- * connection instance amongst threads is a good idea, given that transactions
- * are scoped to connections in JDBC.
- *
- * @version $Id: $
- *
- */
-public class LoadBalancingConnectionProxy implements InvocationHandler, PingTarget {
-
- private static Method getLocalTimeMethod;
-
- public static final String BLACKLIST_TIMEOUT_PROPERTY_KEY = "loadBalanceBlacklistTimeout";
-
- static {
- try {
- getLocalTimeMethod = System.class.getMethod("nanoTime",
- new Class[0]);
- } catch (SecurityException e) {
- // ignore
- } catch (NoSuchMethodException e) {
- // ignore
- }
- }
-
- // Lifted from C/J 5.1's JDBC-2.0 connection pool classes, let's merge this
- // if/when this gets into 5.1
- protected class ConnectionErrorFiringInvocationHandler implements
- InvocationHandler {
- Object invokeOn = null;
-
- public ConnectionErrorFiringInvocationHandler(Object toInvokeOn) {
- invokeOn = toInvokeOn;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- Object result = null;
-
- try {
- result = method.invoke(invokeOn, args);
-
- if (result != null) {
- result = proxyIfInterfaceIsJdbc(result, result.getClass());
- }
- } catch (InvocationTargetException e) {
- dealWithInvocationException(e);
- }
-
- return result;
- }
- }
-
- private Connection currentConn;
-
- private List hostList;
-
- private Map liveConnections;
-
- private Map connectionsToHostsMap;
-
- private long[] responseTimes;
-
- private Map hostsToListIndexMap;
-
- private boolean inTransaction = false;
-
- private long transactionStartTime = 0;
-
- private Properties localProps;
-
- private boolean isClosed = false;
-
- private BalanceStrategy balancer;
-
- private int retriesAllDown;
-
- private static Map globalBlacklist = new HashMap();
-
- private int globalBlacklistTimeout = 0;
-
- /**
- * Creates a proxy for java.sql.Connection that routes requests between the
- * given list of host:port and uses the given properties when creating
- * connections.
- *
- * @param hosts
- * @param props
- * @throws SQLException
- */
- LoadBalancingConnectionProxy(List hosts, Properties props)
- throws SQLException {
- this.hostList = hosts;
-
- int numHosts = this.hostList.size();
-
- this.liveConnections = new HashMap(numHosts);
- this.connectionsToHostsMap = new HashMap(numHosts);
- this.responseTimes = new long[numHosts];
- this.hostsToListIndexMap = new HashMap(numHosts);
-
- for (int i = 0; i < numHosts; i++) {
- this.hostsToListIndexMap.put(this.hostList.get(i), new Integer(i));
- }
-
- this.localProps = (Properties) props.clone();
- this.localProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
- this.localProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);
- this.localProps.setProperty("useLocalSessionState", "true");
-
- String strategy = this.localProps.getProperty("loadBalanceStrategy",
- "random");
-
- String retriesAllDownAsString = this.localProps.getProperty("retriesAllDown", "120");
-
- try {
- this.retriesAllDown = Integer.parseInt(retriesAllDownAsString);
- } catch (NumberFormatException nfe) {
- throw SQLError.createSQLException(Messages.getString(
- "LoadBalancingConnectionProxy.badValueForRetriesAllDown",
- new Object[] { retriesAllDownAsString }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, null);
- }
- String blacklistTimeoutAsString = this.localProps.getProperty(BLACKLIST_TIMEOUT_PROPERTY_KEY, "0");
-
- try {
- this.globalBlacklistTimeout = Integer.parseInt(blacklistTimeoutAsString);
- } catch (NumberFormatException nfe) {
- throw SQLError.createSQLException(Messages.getString(
- "LoadBalancingConnectionProxy.badValueForLoadBalanceBlacklistTimeout",
- new Object[] { retriesAllDownAsString }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, null);
- }
-
- if ("random".equals(strategy)) {
- this.balancer = (BalanceStrategy) Util.loadExtensions(null, props,
- "com.mysql.jdbc.RandomBalanceStrategy",
- "InvalidLoadBalanceStrategy", null).get(0);
- } else if ("bestResponseTime".equals(strategy)) {
- this.balancer = (BalanceStrategy) Util.loadExtensions(null, props,
- "com.mysql.jdbc.BestResponseTimeBalanceStrategy",
- "InvalidLoadBalanceStrategy", null).get(0);
- } else {
- this.balancer = (BalanceStrategy) Util.loadExtensions(null, props,
- strategy, "InvalidLoadBalanceStrategy", null).get(0);
- }
-
- this.balancer.init(null, props);
-
- pickNewConnection();
- }
-
- /**
- * Creates a new physical connection for the given host:port and updates
- * required internal mappings and statistics for that connection.
- *
- * @param hostPortSpec
- * @return
- * @throws SQLException
- */
- public synchronized Connection createConnectionForHost(String hostPortSpec)
- throws SQLException {
- Properties connProps = (Properties) this.localProps.clone();
-
- String[] hostPortPair = NonRegisteringDriver
- .parseHostPortPair(hostPortSpec);
-
- if (hostPortPair[1] == null) {
- hostPortPair[1] = "3306";
- }
-
- connProps.setProperty(NonRegisteringDriver.HOST_PROPERTY_KEY,
- hostPortSpec);
- connProps.setProperty(NonRegisteringDriver.PORT_PROPERTY_KEY,
- hostPortPair[1]);
-
- Connection conn = ConnectionImpl.getInstance(hostPortSpec, Integer
- .parseInt(hostPortPair[1]), connProps, connProps
- .getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY),
- "jdbc:mysql://" + hostPortPair[0] + ":" + hostPortPair[1] + "/");
-
- this.liveConnections.put(hostPortSpec, conn);
- this.connectionsToHostsMap.put(conn, hostPortSpec);
-
- return conn;
- }
-
- /**
- * @param e
- * @throws SQLException
- * @throws Throwable
- * @throws InvocationTargetException
- */
- void dealWithInvocationException(InvocationTargetException e)
- throws SQLException, Throwable, InvocationTargetException {
- Throwable t = e.getTargetException();
-
- if (t != null) {
- if (t instanceof SQLException) {
- String sqlState = ((SQLException) t).getSQLState();
-
- if (sqlState != null) {
- if (sqlState.startsWith("08")) {
- // connection error, close up shop on current
- // connection
- invalidateCurrentConnection();
- }
- }
- }
-
- throw t;
- }
-
- throw e;
- }
-
- /**
- * Closes current connection and removes it from required mappings.
- *
- * @throws SQLException
- */
- synchronized void invalidateCurrentConnection() throws SQLException {
- try {
- if (!this.currentConn.isClosed()) {
- this.currentConn.close();
- }
-
- } finally {
- // add host to the global blacklist, if enabled
- if (this.isGlobalBlacklistEnabled()) {
- this.addToGlobalBlacklist((String) this.connectionsToHostsMap.get(this.currentConn));
-
- }
- // remove from liveConnections
- this.liveConnections.remove(this.connectionsToHostsMap
- .get(this.currentConn));
-
- int hostIndex = ((Integer) this.hostsToListIndexMap
- .get(this.connectionsToHostsMap.get(this.currentConn)))
- .intValue();
-
- // reset the statistics for the host
- synchronized (this.responseTimes) {
- this.responseTimes[hostIndex] = 0;
- }
-
- this.connectionsToHostsMap.remove(this.currentConn);
- }
- }
-
- /**
- * Proxies method invocation on the java.sql.Connection interface, trapping
- * "close", "isClosed" and "commit/rollback" (to switch connections for load
- * balancing).
- */
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- String methodName = method.getName();
-
- if ("equals".equals(methodName) && args.length == 1) {
- if (args[0] instanceof Proxy) {
- return Boolean.valueOf((((Proxy)args[0]).equals(this)));
- }
-
- return Boolean.valueOf(equals(args[0]));
- }
-
- if ("close".equals(methodName)) {
- synchronized (this) {
- // close all underlying connections
- Iterator allConnections = this.liveConnections.values()
- .iterator();
-
- while (allConnections.hasNext()) {
- ((Connection) allConnections.next()).close();
- }
-
- if (!this.isClosed) {
- this.balancer.destroy();
- }
-
- this.liveConnections.clear();
- this.connectionsToHostsMap.clear();
- }
-
- return null;
- }
-
- if ("isClosed".equals(methodName)) {
- return Boolean.valueOf(this.isClosed);
- }
-
- if (this.isClosed) {
- throw SQLError.createSQLException(
- "No operations allowed after connection closed.",
- SQLError.SQL_STATE_CONNECTION_NOT_OPEN, null /* no access to a interceptor here... */);
- }
-
- if (!inTransaction) {
- this.inTransaction = true;
- this.transactionStartTime = getLocalTimeBestResolution();
- }
-
- Object result = null;
-
- try {
- result = method.invoke(this.currentConn, args);
-
- if (result != null) {
- if (result instanceof com.mysql.jdbc.Statement) {
- ((com.mysql.jdbc.Statement)result).setPingTarget(this);
- }
-
- result = proxyIfInterfaceIsJdbc(result, result.getClass());
- }
- } catch (InvocationTargetException e) {
- dealWithInvocationException(e);
- } finally {
- if ("commit".equals(methodName) || "rollback".equals(methodName)) {
- this.inTransaction = false;
-
- // Update stats
- String host = (String) this.connectionsToHostsMap.get(this.currentConn);
- // avoid NPE if the connection has already been removed from connectionsToHostsMap
- // in invalidateCurrenctConnection()
- if ( host != null ) {
- int hostIndex = ((Integer) this.hostsToListIndexMap
- .get( host ))
- .intValue();
-
-
- synchronized (this.responseTimes) {
- this.responseTimes[hostIndex] = getLocalTimeBestResolution()
- - this.transactionStartTime;
- }
- }
-
- pickNewConnection();
- }
- }
-
- return result;
- }
-
- /**
- * Picks the "best" connection to use for the next transaction based on the
- * BalanceStrategy in use.
- *
- * @throws SQLException
- */
- private synchronized void pickNewConnection() throws SQLException {
- if (this.currentConn == null) {
- this.currentConn = this.balancer.pickConnection(this,
- Collections.unmodifiableList(this.hostList),
- Collections.unmodifiableMap(this.liveConnections),
- (long[]) this.responseTimes.clone(),
- this.retriesAllDown);
-
- return;
- }
-
- Connection newConn = this.balancer.pickConnection(this,
- Collections.unmodifiableList(this.hostList),
- Collections.unmodifiableMap(this.liveConnections),
- (long[]) this.responseTimes.clone(),
- this.retriesAllDown);
-
- newConn.setTransactionIsolation(this.currentConn
- .getTransactionIsolation());
- newConn.setAutoCommit(this.currentConn.getAutoCommit());
- this.currentConn = newConn;
- }
-
- /**
- * Recursively checks for interfaces on the given object to determine if it
- * implements a java.sql interface, and if so, proxies the instance so that
- * we can catch and fire SQL errors.
- *
- * @param toProxy
- * @param clazz
- * @return
- */
- Object proxyIfInterfaceIsJdbc(Object toProxy, Class clazz) {
- Class[] interfaces = clazz.getInterfaces();
-
- for (int i = 0; i < interfaces.length; i++) {
- String packageName = interfaces[i].getPackage().getName();
-
- if ("java.sql".equals(packageName)
- || "javax.sql".equals(packageName)) {
- return Proxy.newProxyInstance(toProxy.getClass()
- .getClassLoader(), interfaces,
- new ConnectionErrorFiringInvocationHandler(toProxy));
- }
-
- return proxyIfInterfaceIsJdbc(toProxy, interfaces[i]);
- }
-
- return toProxy;
- }
-
- /**
- * Returns best-resolution representation of local time, using nanoTime() if
- * availble, otherwise defaulting to currentTimeMillis().
- */
- private static long getLocalTimeBestResolution() {
- if (getLocalTimeMethod != null) {
- try {
- return ((Long) getLocalTimeMethod.invoke(null, null))
- .longValue();
- } catch (IllegalArgumentException e) {
- // ignore - we fall through to currentTimeMillis()
- } catch (IllegalAccessException e) {
- // ignore - we fall through to currentTimeMillis()
- } catch (InvocationTargetException e) {
- // ignore - we fall through to currentTimeMillis()
- }
- }
-
- return System.currentTimeMillis();
- }
-
- public synchronized void doPing() throws SQLException {
- if(this.isGlobalBlacklistEnabled()){
- SQLException se = null;
- boolean foundHost = false;
- synchronized(this){
- for(Iterator i = this.hostList.iterator(); i.hasNext(); ){
- String host = (String) i.next();
- Connection conn = (Connection) this.liveConnections.get(host);
- if(conn == null){
- continue;
- }
- try{
- conn.ping();
- foundHost = true;
- } catch (SQLException e){
- se = e;
- this.addToGlobalBlacklist(host);
- }
- }
- }
- if(!foundHost){
- throw se;
- }
- } else {
- Iterator allConns = this.liveConnections.values().iterator();
- while (allConns.hasNext()) {
- ((Connection)allConns.next()).ping();
- }
- }
-
- }
-
- public void addToGlobalBlacklist(String host) {
- if(this.isGlobalBlacklistEnabled()) {
- synchronized(globalBlacklist){
- globalBlacklist.put(host, new Long(System.currentTimeMillis()
- + this.globalBlacklistTimeout));
- }
- }
- }
-
- public boolean isGlobalBlacklistEnabled() {
- return (this.globalBlacklistTimeout > 0);
- }
-
- public Map getGlobalBlacklist() {
- if(!this.isGlobalBlacklistEnabled()) {
- return new HashMap(1);
- }
-
- // Make a local copy of the blacklist
- Map blacklistClone = new HashMap(globalBlacklist.size());
- // Copy everything from synchronized global blacklist to local copy for manipulation
- synchronized (globalBlacklist) {
- blacklistClone.putAll(globalBlacklist);
- }
- Set keys = blacklistClone.keySet();
-
- // we're only interested in blacklisted hosts that are in the hostList
- keys.retainAll(this.hostList);
- if(keys.size() == this.hostList.size()){
- // return an empty blacklist, let the BalanceStrategy implementations try to connect to everything
- // since it appears that all hosts are unavailable - we don't want to wait for
- // loadBalanceBlacklistTimeout to expire.
- return new HashMap(1);
- }
-
- // Don't need to synchronize here as we using a local copy
- for(Iterator i = keys.iterator(); i.hasNext(); ) {
- String host = (String) i.next();
- // OK if null is returned because another thread already purged Map entry.
- Long timeout = (Long) globalBlacklist.get(host);
- if(timeout != null && timeout.longValue() < System.currentTimeMillis()){
- // Timeout has expired, remove from blacklist
- synchronized(globalBlacklist){
- globalBlacklist.remove(host);
- }
- i.remove();
- }
-
- }
-
- return blacklistClone;
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/LocalizedErrorMessages.properties b/src/com/mysql/jdbc/LocalizedErrorMessages.properties
deleted file mode 100644
index c304e02d1..000000000
--- a/src/com/mysql/jdbc/LocalizedErrorMessages.properties
+++ /dev/null
@@ -1,637 +0,0 @@
-#
-# Fixed
-#
-
-ResultSet.Retrieved__1=Retrieved
-ResultSet.Bad_format_for_BigDecimal=Bad format for BigDecimal ''{0}'' in column {1}.
-ResultSet.Bad_format_for_BigInteger=Bad format for BigInteger ''{0}'' in column {1}.
-ResultSet.Column_Index_out_of_range_low=Column Index out of range, {0} < 1.
-ResultSet.Column_Index_out_of_range_high=Column Index out of range, {0} > {1}.
-ResultSet.Value_is_out_of_range=Value ''{0}'' is out of range [{1}, {2}].
-ResultSet.Positioned_Update_not_supported=Positioned Update not supported.
-ResultSet.Bad_format_for_Date=Bad format for DATE ''{0}'' in column {1}.
-ResultSet.Bad_format_for_Column=Bad format for {0} ''{1}'' in column {2} ({3}).
-ResultSet.Bad_format_for_number=Bad format for number ''{0}'' in column {1}.
-ResultSet.Illegal_operation_on_empty_result_set=Illegal operation on empty result set.
-
-Statement.0=Connection is closed.
-Statement.2=Unsupported character encoding ''{0}''
-Statement.5=Illegal value for setFetchDirection().
-Statement.7=Illegal value for setFetchSize().
-Statement.11=Illegal value for setMaxFieldSize().
-Statement.13=Can not set max field size > max allowed packet of {0} bytes.
-Statement.15=setMaxRows() out of range.
-Statement.19=Illegal flag for getMoreResults(int).
-Statement.21=Illegal value for setQueryTimeout().
-Statement.27=Connection is read-only.
-Statement.28=Queries leading to data modification are not allowed.
-Statement.34=Connection is read-only.
-Statement.35=Queries leading to data modification are not allowed.
-Statement.40=Can not issue INSERT/UPDATE/DELETE with executeQuery().
-Statement.42=Connection is read-only.
-Statement.43=Queries leading to data modification are not allowed.
-Statement.46=Can not issue SELECT via executeUpdate().
-Statement.49=No operations allowed after statement closed.
-Statement.57=Can not issue data manipulation statements with executeQuery().
-Statement.59=Can not issue NULL query.
-Statement.61=Can not issue empty query.
-Statement.63=Statement not closed explicitly. You should call close() on created
-Statement.64=Statement instances from your code to be more efficient.
-Statement.GeneratedKeysNotRequested=Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement().
-Statement.ConnectionKilledDueToTimeout=Connection closed to due to statement timeout being reached and "queryTimeoutKillsConnection" being set to "true".
-UpdatableResultSet.1=Can not call deleteRow() when on insert row.
-UpdatableResultSet.2=Can not call deleteRow() on empty result set.
-UpdatableResultSet.3=Before start of result set. Can not call deleteRow().
-UpdatableResultSet.4=After end of result set. Can not call deleteRow().
-UpdatableResultSet.7=Not on insert row.
-UpdatableResultSet.8=Can not call refreshRow() when on insert row.
-UpdatableResultSet.9=Can not call refreshRow() on empty result set.
-UpdatableResultSet.10=Before start of result set. Can not call refreshRow().
-UpdatableResultSet.11=After end of result set. Can not call refreshRow().
-UpdatableResultSet.12=refreshRow() called on row that has been deleted or had primary key changed.
-UpdatableResultSet.34=Updatable result set created, but never updated. You should only create updatable result sets when you want to update/insert/delete values using the updateRow(), deleteRow() and insertRow() methods.
-UpdatableResultSet.39=Unsupported character encoding ''{0}''.
-UpdatableResultSet.43=Can not create updatable result sets when there is no currently selected database and MySQL server version < 4.1.
-
-#
-# Possible re-names
-#
-
-ResultSet.Query_generated_no_fields_for_ResultSet_57=Query generated no fields for ResultSet
-ResultSet.Illegal_value_for_fetch_direction_64=Illegal value for fetch direction
-ResultSet.Value_must_be_between_0_and_getMaxRows()_66=Value must be between 0 and getMaxRows()
-ResultSet.Query_generated_no_fields_for_ResultSet_99=Query generated no fields for ResultSet
-ResultSet.Cannot_absolute_position_to_row_0_110=Cannot absolute position to row 0
-ResultSet.Operation_not_allowed_after_ResultSet_closed_144=Operation not allowed after ResultSet closed
-ResultSet.Before_start_of_result_set_146=Before start of result set
-ResultSet.After_end_of_result_set_148=After end of result set
-ResultSet.Query_generated_no_fields_for_ResultSet_133=Query generated no fields for ResultSet
-ResultSet.ResultSet_is_from_UPDATE._No_Data_115=ResultSet is from UPDATE. No Data.
-ResultSet.N/A_159=N/A
-
-#
-# To fix
-#
-
-ResultSet.Invalid_value_for_getFloat()_-____68=Invalid value for getFloat() - \'
-ResultSet.Invalid_value_for_getInt()_-____74=Invalid value for getInt() - \'
-ResultSet.Invalid_value_for_getLong()_-____79=Invalid value for getLong() - \'
-ResultSet.Invalid_value_for_getFloat()_-____200=Invalid value for getFloat() - \'
-ResultSet.___in_column__201=\' in column
-ResultSet.Invalid_value_for_getInt()_-____206=Invalid value for getInt() - \'
-ResultSet.___in_column__207=\' in column
-ResultSet.Invalid_value_for_getLong()_-____211=Invalid value for getLong() - \'
-ResultSet.___in_column__212=\' in column
-ResultSet.Invalid_value_for_getShort()_-____217=Invalid value for getShort() - \'
-ResultSet.___in_column__218=\' in column
-
-ResultSet.Class_not_found___91=Class not found:
-ResultSet._while_reading_serialized_object_92=\ while reading serialized object
-
-ResultSet.Invalid_value_for_getShort()_-____96=Invalid value for getShort() - \'
-ResultSet.Unsupported_character_encoding____101=Unsupported character encoding \'
-
-ResultSet.Malformed_URL____104=Malformed URL \'
-ResultSet.Malformed_URL____107=Malformed URL \'
-ResultSet.Malformed_URL____141=Malformed URL \'
-
-ResultSet.Column____112=Column \'
-ResultSet.___not_found._113=\' not found.
-
-ResultSet.Unsupported_character_encoding____135=Unsupported character encoding \'
-ResultSet.Unsupported_character_encoding____138=Unsupported character encoding \'
-
-#
-# Usage advisor messages for ResultSets
-#
-
-ResultSet.ResultSet_implicitly_closed_by_driver=ResultSet implicitly closed by driver.\n\nYou should close ResultSets explicitly from your code to free up resources in a more efficient manner.
-ResultSet.Possible_incomplete_traversal_of_result_set=Possible incomplete traversal of result set. Cursor was left on row {0} of {1} rows when it was closed.\n\nYou should consider re-formulating your query to return only the rows you are interested in using.
-ResultSet.The_following_columns_were_never_referenced=The following columns were part of the SELECT statement for this result set, but were never referenced:
-ResultSet.Too_Large_Result_Set=Result set size of {0} rows is larger than \"resultSetSizeThreshold\" of {1} rows. Application may be requesting more data than it is using. Consider reformulating the query.
-ResultSet.CostlyConversion=ResultSet type conversion via parsing detected when calling {0} for column {1} (column named ''{2}'') in table ''{3}''{4}\n\nJava class of column type is ''{5}'', MySQL field type is ''{6}''.\n\nTypes that could be converted directly without parsing are:\n{7}
-ResultSet.CostlyConversionCreatedFromQuery= created from query:\n\n
-
-ResultSet.Value____173=Value \'
-ResultSetMetaData.46=Column index out of range.
-ResultSet.___is_out_of_range_[-127,127]_174=\' is out of range [-127,127]
-ResultSet.Bad_format_for_Date____180=Bad format for Date \'
-
-ResultSet.Timestamp_too_small_to_convert_to_Time_value_in_column__223=Timestamp too small to convert to Time value in column
-ResultSet.Precision_lost_converting_TIMESTAMP_to_Time_with_getTime()_on_column__227=Precision lost converting TIMESTAMP to Time with getTime() on column
-ResultSet.Precision_lost_converting_DATETIME_to_Time_with_getTime()_on_column__230=Precision lost converting DATETIME to Time with getTime() on column
-ResultSet.Bad_format_for_Time____233=Bad format for Time \'
-ResultSet.___in_column__234=\' in column
-ResultSet.Bad_format_for_Timestamp____244=Bad format for Timestamp \'
-ResultSet.___in_column__245=\' in column
-ResultSet.Cannot_convert_value____249=Cannot convert value \'
-ResultSet.___from_column__250=\' from column
-ResultSet._)_to_TIMESTAMP._252=\ ) to TIMESTAMP.
-ResultSet.Timestamp_too_small_to_convert_to_Time_value_in_column__257=Timestamp too small to convert to Time value in column
-ResultSet.Precision_lost_converting_TIMESTAMP_to_Time_with_getTime()_on_column__261=Precision lost converting TIMESTAMP to Time with getTime() on column
-ResultSet.Precision_lost_converting_DATETIME_to_Time_with_getTime()_on_column__264=Precision lost converting DATETIME to Time with getTime() on column
-ResultSet.Bad_format_for_Time____267=Bad format for Time \'
-ResultSet.___in_column__268=\' in column
-ResultSet.Bad_format_for_Timestamp____278=Bad format for Timestamp \'
-ResultSet.___in_column__279=\' in column
-ResultSet.Cannot_convert_value____283=Cannot convert value \'
-ResultSet.___from_column__284=\' from column
-ResultSet._)_to_TIMESTAMP._286=\ ) to TIMESTAMP.
-CallableStatement.2=Parameter name can not be NULL or zero-length.
-CallableStatement.3=No parameter named '
-CallableStatement.4='
-CallableStatement.5=Parameter named '
-CallableStatement.6=' is not an OUT parameter
-CallableStatement.7=No output parameters registered.
-CallableStatement.8=No output parameters returned by procedure.
-CallableStatement.9=Parameter number
-CallableStatement.10=\ is not an OUT parameter
-CallableStatement.11=Parameter index of
-CallableStatement.12=\ is out of range (1,
-CallableStatement.13=)
-CallableStatement.14=Can not use streaming result sets with callable statements that have output parameters
-CallableStatement.1=Unable to retrieve metadata for procedure.
-CallableStatement.0=Parameter name can not be
-CallableStatement.15=null.
-CallableStatement.16=empty.
-CallableStatement.21=Parameter
-CallableStatement.22=\ is not registered as an output parameter
-CommunicationsException.2=\ is longer than the server configured value of
-CommunicationsException.3='wait_timeout'
-CommunicationsException.4='interactive_timeout'
-CommunicationsException.5=may or may not be greater than the server-side timeout
-CommunicationsException.6=(the driver was unable to determine the value of either the
-CommunicationsException.7='wait_timeout' or 'interactive_timeout' configuration values from
-CommunicationsException.8=the server.
-CommunicationsException.11=. You should consider either expiring and/or testing connection validity
-CommunicationsException.12=before use in your application, increasing the server configured values for client timeouts,
-CommunicationsException.13=or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
-CommunicationsException.TooManyClientConnections=The driver was unable to create a connection due to an inability to establish the client portion of a socket.\n\nThis is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. \n\nFor Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.\n\nFor Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).
-CommunicationsException.LocalSocketAddressNotAvailable=The configuration parameter \"localSocketAddress\" has been set to a network interface not available for use by the JVM.
-CommunicationsException.20=Communications link failure
-CommunicationsException.21=\ due to underlying exception:
-CommunicationsException.ClientWasStreaming=Application was streaming results when the connection failed. Consider raising value of 'net_write_timeout' on the server.
-CommunicationsException.ServerPacketTimingInfoNoRecv=The last packet sent successfully to the server was {0} milliseconds ago. The driver has not received any packets from the server.
-CommunicationsException.ServerPacketTimingInfo=The last packet successfully received from the server was {0} milliseconds ago. The last packet sent successfully to the server was {1} milliseconds ago.
-NonRegisteringDriver.3=Hostname of MySQL Server
-NonRegisteringDriver.7=Port number of MySQL Server
-NonRegisteringDriver.13=Username to authenticate as
-NonRegisteringDriver.16=Password to use for authentication
-NonRegisteringDriver.17=Cannot load connection class because of underlying exception: '
-NonRegisteringDriver.18='.
-NonRegisteringDriver.37=Must specify port after ':' in connection string
-SQLError.35=Disconnect error
-SQLError.36=Data truncated
-SQLError.37=Privilege not revoked
-SQLError.38=Invalid connection string attribute
-SQLError.39=Error in row
-SQLError.40=No rows updated or deleted
-SQLError.41=More than one row updated or deleted
-SQLError.42=Wrong number of parameters
-SQLError.43=Unable to connect to data source
-SQLError.44=Connection in use
-SQLError.45=Connection not open
-SQLError.46=Data source rejected establishment of connection
-SQLError.47=Connection failure during transaction
-SQLError.48=Communication link failure
-SQLError.49=Insert value list does not match column list
-SQLError.50=Numeric value out of range
-SQLError.51=Datetime field overflow
-SQLError.52=Division by zero
-SQLError.53=Deadlock found when trying to get lock; Try restarting transaction
-SQLError.54=Invalid authorization specification
-SQLError.55=Syntax error or access violation
-SQLError.56=Base table or view not found
-SQLError.57=Base table or view already exists
-SQLError.58=Base table not found
-SQLError.59=Index already exists
-SQLError.60=Index not found
-SQLError.61=Column already exists
-SQLError.62=Column not found
-SQLError.63=No default for column
-SQLError.64=General error
-SQLError.65=Memory allocation failure
-SQLError.66=Invalid column number
-SQLError.67=Invalid argument value
-SQLError.68=Driver not capable
-SQLError.69=Timeout expired
-ChannelBuffer.0=Unsupported character encoding '
-ChannelBuffer.1='
-Field.12=Unsupported character encoding '
-Field.13='
-
-Blob.0=indexToWriteAt must be >= 1
-Blob.1=IO Error while writing bytes to blob
-Blob.2=Position 'pos' can not be < 1
-Blob.invalidStreamLength=Requested stream length of {2} is out of range, given blob length of {0} and starting position of {1}.
-Blob.invalidStreamPos=Position 'pos' can not be < 1 or > blob length.
-
-StringUtils.0=Unsupported character encoding '
-StringUtils.1='.
-StringUtils.5=Unsupported character encoding '
-StringUtils.6='.
-StringUtils.10=Unsupported character encoding '
-StringUtils.11='.
-RowDataDynamic.2=WARN: Possible incomplete traversal of result set. Streaming result set had
-RowDataDynamic.3=\ rows left to read when it was closed.
-RowDataDynamic.4=\n\nYou should consider re-formulating your query to
-RowDataDynamic.5=return only the rows you are interested in using.
-RowDataDynamic.6=\n\nResultSet was created at:
-RowDataDynamic.7=\n\nNested Stack Trace:\n
-RowDataDynamic.8=Error retrieving record: Unexpected Exception:
-RowDataDynamic.9=\ message given:
-RowDataDynamic.10=Operation not supported for streaming result sets
-Clob.0=indexToWriteAt must be >= 1
-Clob.1=indexToWriteAt must be >= 1
-Clob.2=Starting position can not be < 1
-Clob.3=String to set can not be NULL
-Clob.4=Starting position can not be < 1
-Clob.5=String to set can not be NULL
-Clob.6=CLOB start position can not be < 1
-Clob.7=CLOB start position + length can not be > length of CLOB
-Clob.8=Illegal starting position for search, '
-Clob.9='
-Clob.10=Starting position for search is past end of CLOB
-Clob.11=Cannot truncate CLOB of length
-Clob.12=\ to length of
-Clob.13=.
-PacketTooBigException.0=Packet for query is too large (
-PacketTooBigException.1=\ >
-PacketTooBigException.2=).
-PacketTooBigException.3=You can change this value on the server by setting the
-PacketTooBigException.4=max_allowed_packet' variable.
-Util.1=\n\n** BEGIN NESTED EXCEPTION ** \n\n
-Util.2=\nMESSAGE:
-Util.3=\n\nSTACKTRACE:\n\n
-Util.4=\n\n** END NESTED EXCEPTION **\n\n
-MiniAdmin.0=Conection can not be null.
-MiniAdmin.1=MiniAdmin can only be used with MySQL connections
-NamedPipeSocketFactory.2=Can not specify NULL or empty value for property '
-NamedPipeSocketFactory.3='.
-NamedPipeSocketFactory.4=Named pipe path can not be null or empty
-MysqlIO.1=Unexpected end of input stream
-MysqlIO.2=Reading packet of length
-MysqlIO.3=\nPacket header:\n
-MysqlIO.4=readPacket() payload:\n
-MysqlIO.8=Slow query explain results for '
-MysqlIO.9=' :\n\n
-MysqlIO.10=\ message from server: "
-MysqlIO.15=SSL Connection required, but not supported by server.
-MysqlIO.17=Attempt to close streaming result set
-MysqlIO.18=\ when no streaming result set was registered. This is an internal error.
-MysqlIO.19=Attempt to close streaming result set
-MysqlIO.20=\ that was not registered.
-MysqlIO.21=\ Only one streaming result set may be open and in use per-connection. Ensure that you have called .close() on
-MysqlIO.22=\ any active result sets before attempting more queries.
-MysqlIO.23=Can not use streaming results with multiple result statements
-MysqlIO.25=\ ... (truncated)
-MysqlIO.SlowQuery=Slow query (exceeded {0} {1}, duration: {2} {1}):
-MysqlIO.ServerSlowQuery=The server processing the query has indicated that the query was marked "slow".
-Nanoseconds=ns
-Milliseconds=ms
-MysqlIO.28=Not issuing EXPLAIN for query of size >
-MysqlIO.29=\ bytes.
-MysqlIO.33=The following query was executed with a bad index, use 'EXPLAIN' for more details:
-MysqlIO.35=The following query was executed using no index, use 'EXPLAIN' for more details:
-MysqlIO.36=\n\nLarge packet dump truncated at
-MysqlIO.37=\ bytes.
-MysqlIO.39=Streaming result set
-MysqlIO.40=\ is still active.
-MysqlIO.41=\ No statements may be issued when any streaming result sets are open and in use on a given connection.
-MysqlIO.42=\ Ensure that you have called .close() on any active streaming result sets before attempting more queries.
-MysqlIO.43=Unexpected end of input stream
-MysqlIO.44=Reading reusable packet of length
-MysqlIO.45=\nPacket header:\n
-MysqlIO.46=reuseAndReadPacket() payload:\n
-MysqlIO.47=Unexpected end of input stream
-MysqlIO.48=Unexpected end of input stream
-MysqlIO.49=Packets received out of order
-MysqlIO.50=Short read from server, expected
-MysqlIO.51=\ bytes, received only
-MysqlIO.53=Packets received out of order
-MysqlIO.54=Short read from server, expected
-MysqlIO.55=\ bytes, received only
-MysqlIO.57=send() compressed packet:\n
-MysqlIO.58=\n\nOriginal packet (uncompressed):\n
-MysqlIO.59=send() packet payload:\n
-MysqlIO.60=Unable to open file
-MysqlIO.63=for 'LOAD DATA LOCAL INFILE' command.
-MysqlIO.64=Due to underlying IOException:
-MysqlIO.65=Unable to close local file during LOAD DATA LOCAL INFILE command
-MysqlIO.68=\ message from server: "
-MysqlIO.70=Unknown column
-MysqlIO.72=\ message from server: "
-MysqlIO.75=No name specified for socket factory
-MysqlIO.76=Could not create socket factory '
-MysqlIO.77=' due to underlying exception:
-MysqlIO.79=Unexpected end of input stream
-MysqlIO.80=Unexpected end of input stream
-MysqlIO.81=Unexpected end of input stream
-MysqlIO.82=Unexpected end of input stream
-MysqlIO.83=Packets received out of order
-MysqlIO.84=Packets received out of order
-MysqlIO.85=Unexpected end of input stream
-MysqlIO.86=Unexpected end of input stream
-MysqlIO.87=Unexpected end of input stream
-MysqlIO.88=Packets received out of order
-MysqlIO.89=Packets received out of order
-MysqlIO.91=Failed to create message digest 'SHA-1' for authentication.
-MysqlIO.92=\ You must use a JDK that supports JCE to be able to use secure connection authentication
-MysqlIO.93=Failed to create message digest 'SHA-1' for authentication.
-MysqlIO.94=\ You must use a JDK that supports JCE to be able to use secure connection authentication
-MysqlIO.95=Failed to create message digest 'SHA-1' for authentication.
-MysqlIO.96=\ You must use a JDK that supports JCE to be able to use secure connection authentication
-MysqlIO.97=Unknown type '
-MysqlIO.98=\ in column
-MysqlIO.99=\ of
-MysqlIO.100=\ in binary-encoded result set.
-MysqlIO.102=, underlying cause:
-MysqlIO.EOF=Can not read response from server. Expected to read {0} bytes, read {1} bytes before connection was unexpectedly lost.
-MysqlIO.NoInnoDBStatusFound=No InnoDB status output returned by server.
-MysqlIO.InnoDBStatusFailed=Couldn't retrieve InnoDB status due to underlying exception:
-MysqlIO.LoadDataLocalNotAllowed=Server asked for stream in response to LOAD DATA LOCAL INFILE but functionality is disabled at client by 'allowLoadLocalInfile' being set to 'false'.
-NotImplemented.0=Feature not implemented
-PreparedStatement.0=SQL String can not be NULL
-PreparedStatement.1=SQL String can not be NULL
-PreparedStatement.2=Parameter index out of range (
-PreparedStatement.3=\ >
-PreparedStatement.4=)
-PreparedStatement.16=Unknown Types value
-PreparedStatement.17=Cannot convert
-PreparedStatement.18=\ to SQL type requested due to
-PreparedStatement.19=\ -
-PreparedStatement.20=Connection is read-only.
-PreparedStatement.21=Queries leading to data modification are not allowed
-PreparedStatement.25=Connection is read-only.
-PreparedStatement.26=Queries leading to data modification are not allowed
-PreparedStatement.32=Unsupported character encoding '
-PreparedStatement.33='
-PreparedStatement.34=Connection is read-only.
-PreparedStatement.35=Queries leading to data modification are not allowed
-PreparedStatement.37=Can not issue executeUpdate() for SELECTs
-PreparedStatement.40=No value specified for parameter
-PreparedStatement.43=PreparedStatement created, but used 1 or fewer times. It is more efficient to prepare statements once, and re-use them many times
-PreparedStatement.48=PreparedStatement has been closed. No further operations allowed.
-PreparedStatement.49=Parameter index out of range (
-PreparedStatement.50=\ < 1 ).
-PreparedStatement.51=Parameter index out of range (
-PreparedStatement.52=\ > number of parameters, which is
-PreparedStatement.53=).
-PreparedStatement.54=Invalid argument value:
-PreparedStatement.55=Error reading from InputStream
-PreparedStatement.56=Error reading from InputStream
-PreparedStatement.61=SQL String can not be NULL
-ServerPreparedStatement.2=Connection is read-only.
-ServerPreparedStatement.3=Queries leading to data modification are not allowed
-ServerPreparedStatement.6=\ unable to materialize as string due to underlying SQLException:
-ServerPreparedStatement.7=Not supported for server-side prepared statements.
-ServerPreparedStatement.8=No parameters defined during prepareCall()
-ServerPreparedStatement.9=Parameter index out of bounds.
-ServerPreparedStatement.10=\ is not between valid values of 1 and
-ServerPreparedStatement.11=Driver can not re-execute prepared statement when a parameter has been changed
-ServerPreparedStatement.12=from a streaming type to an intrinsic data type without calling clearParameters() first.
-ServerPreparedStatement.13=Statement parameter
-ServerPreparedStatement.14=\ not set.
-ServerPreparedStatement.15=Slow query (exceeded
-ServerPreparedStatement.15a=\ ms., duration:\
-ServerPreparedStatement.16=\ ms):
-ServerPreparedStatement.18=Unknown LONG DATA type '
-ServerPreparedStatement.22=Unsupported character encoding '
-ServerPreparedStatement.24=Error while reading binary stream:
-ServerPreparedStatement.25=Error while reading binary stream:
-ByteArrayBuffer.0=ByteArrayBuffer has no NIO buffers
-ByteArrayBuffer.1=Unsupported character encoding '
-AssertionFailedException.0=ASSERT FAILS: Exception
-AssertionFailedException.1=\ that should not be thrown, was thrown
-NotUpdatable.0=Result Set not updatable.
-NotUpdatable.1=This result set must come from a statement
-NotUpdatable.2=that was created with a result set type of ResultSet.CONCUR_UPDATABLE,
-NotUpdatable.3=the query must select only one table, can not use functions and must
-NotUpdatable.4=select all primary keys from that table. See the JDBC 2.1 API Specification,
-NotUpdatable.5=section 5.6 for more details.
-NotUpdatableReason.0=Result Set not updatable (references more than one table).
-NotUpdatableReason.1=Result Set not updatable (references more than one database).
-NotUpdatableReason.2=Result Set not updatable (references no tables).
-NotUpdatableReason.3=Result Set not updatable (references computed values or doesn't reference any columns or tables).
-NotUpdatableReason.4=Result Set not updatable (references no primary keys).
-NotUpdatableReason.5=Result Set not updatable (referenced table has no primary keys).
-NotUpdatableReason.6=Result Set not updatable (references unknown primary key {0}).
-NotUpdatableReason.7=Result Set not updatable (does not reference all primary keys).
-
-JDBC4Connection.ClientInfoNotImplemented=Configured clientInfoProvider class ''{0}'' does not implement com.mysql.jdbc.JDBC4ClientInfoProvider.
-
-InvalidLoadBalanceStrategy=Invalid load balancing strategy ''{0}''.
-Connection.BadValueInServerVariables=Invalid value ''{1}'' for server variable named ''{0}'', falling back to sane default of ''{2}''.
-LoadBalancingConnectionProxy.badValueForRetriesAllDown=Bad value ''{0}'' for property "retriesAllDown".
-LoadBalancingConnectionProxy.badValueForLoadBalanceBlacklistTimeout=Bad value ''{0}'' for property "loadBalanceBlacklistTimeout".
-
-Connection.UnableToConnect=Could not create connection to database server.
-Connection.UnableToConnectWithRetries=Could not create connection to database server. \
-Attempted reconnect {0} times. Giving up.
-Connection.UnexpectedException=Unexpected exception encountered during query.
-Connection.UnhandledExceptionDuringShutdown=Unexpected exception during server shutdown.
-
-#
-# ConnectionProperty Categories
-#
-
-ConnectionProperties.categoryConnectionAuthentication=Connection/Authentication
-ConnectionProperties.categoryNetworking=Networking
-ConnectionProperties.categoryDebuggingProfiling=Debugging/Profiling
-ConnectionProperties.categorryHA=High Availability and Clustering
-ConnectionProperties.categoryMisc=Miscellaneous
-ConnectionProperties.categoryPerformance=Performance Extensions
-ConnectionProperties.categorySecurity=Security
-
-#
-# ConnectionProperty Descriptions
-#
-
-ConnectionProperties.loadDataLocal=Should the driver allow use of 'LOAD DATA LOCAL INFILE...' (defaults to 'true').
-ConnectionProperties.allowMultiQueries=Allow the use of ';' to delimit multiple queries during one statement (true/false), defaults to 'false'
-ConnectionProperties.allowNANandINF=Should the driver allow NaN or +/- INF values in PreparedStatement.setDouble()?
-ConnectionProperties.allowUrlInLoadLocal=Should the driver allow URLs in 'LOAD DATA LOCAL INFILE' statements?
-ConnectionProperties.alwaysSendSetIsolation=Should the driver always communicate with the database when Connection.setTransactionIsolation() is called? If set to false, the driver will only communicate with the database when the requested transaction isolation is different than the whichever is newer, the last value that was set via Connection.setTransactionIsolation(), or the value that was read from the server when the connection was established.
-ConnectionProperties.autoClosePstmtStreams=Should the driver automatically call .close() on streams/readers passed as arguments via set*() methods?
-ConnectionProperties.autoDeserialize=Should the driver automatically detect and de-serialize objects stored in BLOB fields?
-ConnectionProperties.autoGenerateTestcaseScript=Should the driver dump the SQL it is executing, including server-side prepared statements to STDERR?
-ConnectionProperties.autoReconnect=Should the driver try to re-establish stale and/or dead connections? If enabled the driver will throw an exception for a queries issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction. The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, investigate setting the MySQL server variable "wait_timeout" to some high value rather than the default of 8 hours.
-ConnectionProperties.autoReconnectForPools=Use a reconnection strategy appropriate for connection pools (defaults to 'false')
-ConnectionProperties.autoSlowLog=Instead of using slowQueryThreshold* to determine if a query is slow enough to be logged, maintain statistics that allow the driver to determine queries that are outside the 99th percentile?
-ConnectionProperties.blobsAreStrings=Should the driver always treat BLOBs as Strings - specifically to work around dubious metadata returned by the server for GROUP BY clauses?
-ConnectionProperties.functionsNeverReturnBlobs=Should the driver always treat data from functions returning BLOBs as Strings - specifically to work around dubious metadata returned by the server for GROUP BY clauses?
-ConnectionProperties.blobSendChunkSize=Chunk to use when sending BLOB/CLOBs via ServerPreparedStatements
-ConnectionProperties.cacheCallableStatements=Should the driver cache the parsing stage of CallableStatements
-ConnectionProperties.cachePrepStmts=Should the driver cache the parsing stage of PreparedStatements of client-side prepared statements, the "check" for suitability of server-side prepared and server-side prepared statements themselves?
-ConnectionProperties.cacheRSMetadata=Should the driver cache ResultSetMetaData for Statements and PreparedStatements? (Req. JDK-1.4+, true/false, default 'false')
-ConnectionProperties.cacheServerConfiguration=Should the driver cache the results of 'SHOW VARIABLES' and 'SHOW COLLATION' on a per-URL basis?
-ConnectionProperties.callableStmtCacheSize=If 'cacheCallableStmts' is enabled, how many callable statements should be cached?
-ConnectionProperties.capitalizeTypeNames=Capitalize type names in DatabaseMetaData? (usually only useful when using WebObjects, true/false, defaults to 'false')
-ConnectionProperties.characterEncoding=If 'useUnicode' is set to true, what character encoding should the driver use when dealing with strings? (defaults is to 'autodetect')
-ConnectionProperties.characterSetResults=Character set to tell the server to return results as.
-ConnectionProperties.clientInfoProvider=The name of a class that implements the com.mysql.jdbc.JDBC4ClientInfoProvider interface in order to support JDBC-4.0's Connection.get/setClientInfo() methods
-ConnectionProperties.clobberStreamingResults=This will cause a 'streaming' ResultSet to be automatically closed, and any outstanding data still streaming from the server to be discarded if another query is executed before all the data has been read from the server.
-ConnectionProperties.clobCharacterEncoding=The character encoding to use for sending and retrieving TEXT, MEDIUMTEXT and LONGTEXT values instead of the configured connection characterEncoding
-ConnectionProperties.compensateOnDuplicateKeyUpdateCounts=Should the driver compensate for the update counts of "ON DUPLICATE KEY" INSERT statements (2 = 1, 0 = 1) when using prepared statements?
-ConnectionProperties.connectionCollation=If set, tells the server to use this collation via 'set collation_connection'
-ConnectionProperties.connectionLifecycleInterceptors=A comma-delimited list of classes that implement "com.mysql.jdbc.ConnectionLifecycleInterceptor" that should notified of connection lifecycle events (creation, destruction, commit, rollback, setCatalog and setAutoCommit) and potentially alter the execution of these commands. ConnectionLifecycleInterceptors are "stackable", more than one interceptor may be specified via the configuration property as a comma-delimited list, with the interceptors executed in order from left to right.
-ConnectionProperties.connectTimeout=Timeout for socket connect (in milliseconds), with 0 being no timeout. Only works on JDK-1.4 or newer. Defaults to '0'.
-ConnectionProperties.continueBatchOnError=Should the driver continue processing batch commands if one statement fails. The JDBC spec allows either way (defaults to 'true').
-ConnectionProperties.createDatabaseIfNotExist=Creates the database given in the URL if it doesn't yet exist. Assumes the configured user has permissions to create databases.
-ConnectionProperties.defaultFetchSize=The driver will call setFetchSize(n) with this value on all newly-created Statements
-ConnectionProperties.useServerPrepStmts=Use server-side prepared statements if the server supports them?
-ConnectionProperties.dontTrackOpenResources=The JDBC specification requires the driver to automatically track and close resources, however if your application doesn't do a good job of explicitly calling close() on statements or result sets, this can cause memory leakage. Setting this property to true relaxes this constraint, and can be more memory efficient for some applications.
-ConnectionProperties.dumpQueriesOnException=Should the driver dump the contents of the query sent to the server in the message for SQLExceptions?
-ConnectionProperties.dynamicCalendars=Should the driver retrieve the default calendar when required, or cache it per connection/session?
-ConnectionProperties.eliseSetAutoCommit=If using MySQL-4.1 or newer, should the driver only issue 'set autocommit=n' queries when the server's state doesn't match the requested state by Connection.setAutoCommit(boolean)?
-ConnectionProperties.emptyStringsConvertToZero=Should the driver allow conversions from empty string fields to numeric values of '0'?
-ConnectionProperties.emulateLocators=Should the driver emulate java.sql.Blobs with locators? With this feature enabled, the driver will delay loading the actual Blob data until the one of the retrieval methods (getInputStream(), getBytes(), and so forth) on the blob data stream has been accessed. For this to work, you must use a column alias with the value of the column to the actual name of the Blob. The feature also has the following restrictions: The SELECT that created the result set must reference only one table, the table must have a primary key; the SELECT must alias the original blob column name, specified as a string, to an alternate name; the SELECT must cover all columns that make up the primary key.
-ConnectionProperties.emulateUnsupportedPstmts=Should the driver detect prepared statements that are not supported by the server, and replace them with client-side emulated versions?
-ConnectionProperties.enablePacketDebug=When enabled, a ring-buffer of 'packetDebugBufferSize' packets will be kept, and dumped when exceptions are thrown in key areas in the driver's code
-ConnectionProperties.enableQueryTimeouts=When enabled, query timeouts set via Statement.setQueryTimeout() use a shared java.util.Timer instance for scheduling. Even if the timeout doesn't expire before the query is processed, there will be memory used by the TimerTask for the given timeout which won't be reclaimed until the time the timeout would have expired if it hadn't been cancelled by the driver. High-load environments might want to consider disabling this functionality.
-ConnectionProperties.explainSlowQueries=If 'logSlowQueries' is enabled, should the driver automatically issue an 'EXPLAIN' on the server and send the results to the configured log at a WARN level?
-ConnectionProperties.failoverReadOnly=When failing over in autoReconnect mode, should the connection be set to 'read-only'?
-ConnectionProperties.gatherPerfMetrics=Should the driver gather performance metrics, and report them via the configured logger every 'reportMetricsIntervalMillis' milliseconds?
-ConnectionProperties.generateSimpleParameterMetadata=Should the driver generate simplified parameter metadata for PreparedStatements when no metadata is available either because the server couldn't support preparing the statement, or server-side prepared statements are disabled?
-ConnectionProperties.holdRSOpenOverStmtClose=Should the driver close result sets on Statement.close() as required by the JDBC specification?
-ConnectionProperties.ignoreNonTxTables=Ignore non-transactional table warning for rollback? (defaults to 'false').
-ConnectionProperties.initialTimeout=If autoReconnect is enabled, the initial time to wait between re-connect attempts (in seconds, defaults to '2').
-ConnectionProperties.interactiveClient=Set the CLIENT_INTERACTIVE flag, which tells MySQL to timeout connections based on INTERACTIVE_TIMEOUT instead of WAIT_TIMEOUT
-ConnectionProperties.jdbcCompliantTruncation=Should the driver throw java.sql.DataTruncation exceptions when data is truncated as is required by the JDBC specification when connected to a server that supports warnings (MySQL 4.1.0 and newer)? This property has no effect if the server sql-mode includes STRICT_TRANS_TABLES.
-ConnectionProperties.largeRowSizeThreshold=What size result set row should the JDBC driver consider "large", and thus use a more memory-efficient way of representing the row internally?
-ConnectionProperties.loadBalanceStrategy=If using a load-balanced connection to connect to SQL nodes in a MySQL Cluster/NDB configuration (by using the URL prefix "jdbc:mysql:loadbalance://"), which load balancing algorithm should the driver use: (1) "random" - the driver will pick a random host for each request. This tends to work better than round-robin, as the randomness will somewhat account for spreading loads where requests vary in response time, while round-robin can sometimes lead to overloaded nodes if there are variations in response times across the workload. (2) "bestResponseTime" - the driver will route the request to the host that had the best response time for the previous transaction.
-ConnectionProperties.loadBalanceBlacklistTimeout=Time in milliseconds between checks of servers which are unavailable.
-ConnectionProperties.localSocketAddress=Hostname or IP address given to explicitly configure the interface that the driver will bind the client side of the TCP/IP connection to when connecting.
-ConnectionProperties.locatorFetchBufferSize=If 'emulateLocators' is configured to 'true', what size buffer should be used when fetching BLOB data for getBinaryInputStream?
-ConnectionProperties.logger=The name of a class that implements \"{0}\" that will be used to log messages to. (default is \"{1}\", which logs to STDERR)
-ConnectionProperties.logSlowQueries=Should queries that take longer than 'slowQueryThresholdMillis' be logged?
-ConnectionProperties.logXaCommands=Should the driver log XA commands sent by MysqlXaConnection to the server, at the DEBUG level of logging?
-ConnectionProperties.maintainTimeStats=Should the driver maintain various internal timers to enable idle time calculations as well as more verbose error messages when the connection to the server fails? Setting this property to false removes at least two calls to System.getCurrentTimeMillis() per query.
-ConnectionProperties.maxQuerySizeToLog=Controls the maximum length/size of a query that will get logged when profiling or tracing
-ConnectionProperties.maxReconnects=Maximum number of reconnects to attempt if autoReconnect is true, default is '3'.
-ConnectionProperties.maxRows=The maximum number of rows to return (0, the default means return all rows).
-ConnectionProperties.allVersions=all versions
-ConnectionProperties.metadataCacheSize=The number of queries to cache ResultSetMetadata for if cacheResultSetMetaData is set to 'true' (default 50)
-ConnectionProperties.netTimeoutForStreamingResults=What value should the driver automatically set the server setting 'net_write_timeout' to when the streaming result sets feature is in use? (value has unit of seconds, the value '0' means the driver will not try and adjust this value)
-ConnectionProperties.noAccessToProcedureBodies=When determining procedure parameter types for CallableStatements, and the connected user can't access procedure bodies through "SHOW CREATE PROCEDURE" or select on mysql.proc should the driver instead create basic metadata (all parameters reported as INOUT VARCHARs) instead of throwing an exception?
-ConnectionProperties.noDatetimeStringSync=Don't ensure that ResultSet.getDatetimeType().toString().equals(ResultSet.getString())
-ConnectionProperties.noTzConversionForTimeType=Don't convert TIME values using the server timezone if 'useTimezone'='true'
-ConnectionProperties.nullCatalogMeansCurrent=When DatabaseMetadataMethods ask for a 'catalog' parameter, does the value null mean use the current catalog? (this is not JDBC-compliant, but follows legacy behavior from earlier versions of the driver)
-ConnectionProperties.nullNamePatternMatchesAll=Should DatabaseMetaData methods that accept *pattern parameters treat null the same as '%' (this is not JDBC-compliant, however older versions of the driver accepted this departure from the specification)
-ConnectionProperties.packetDebugBufferSize=The maximum number of packets to retain when 'enablePacketDebug' is true
-ConnectionProperties.padCharsWithSpace=If a result set column has the CHAR type and the value does not fill the amount of characters specified in the DDL for the column, should the driver pad the remaining characters with space (for ANSI compliance)?
-ConnectionProperties.paranoid=Take measures to prevent exposure sensitive information in error messages and clear data structures holding sensitive data when possible? (defaults to 'false')
-ConnectionProperties.pedantic=Follow the JDBC spec to the letter.
-ConnectionProperties.pinGlobalTxToPhysicalConnection=When using XAConnections, should the driver ensure that operations on a given XID are always routed to the same physical connection? This allows the XAConnection to support "XA START ... JOIN" after "XA END" has been called
-ConnectionProperties.populateInsertRowWithDefaultValues=When using ResultSets that are CONCUR_UPDATABLE, should the driver pre-populate the "insert" row with default values from the DDL for the table used in the query so those values are immediately available for ResultSet accessors? This functionality requires a call to the database for metadata each time a result set of this type is created. If disabled (the default), the default values will be populated by the an internal call to refreshRow() which pulls back default values and/or values changed by triggers.
-ConnectionProperties.prepStmtCacheSize=If prepared statement caching is enabled, how many prepared statements should be cached?
-ConnectionProperties.prepStmtCacheSqlLimit=If prepared statement caching is enabled, what's the largest SQL the driver will cache the parsing for?
-ConnectionProperties.processEscapeCodesForPrepStmts=Should the driver process escape codes in queries that are prepared?
-ConnectionProperties.profilerEventHandler=Name of a class that implements the interface com.mysql.jdbc.profiler.ProfilerEventHandler that will be used to handle profiling/tracing events.
-ConnectionProperties.profileSqlDeprecated=Deprecated, use 'profileSQL' instead. Trace queries and their execution/fetch times on STDERR (true/false) defaults to 'false'
-ConnectionProperties.profileSQL=Trace queries and their execution/fetch times to the configured logger (true/false) defaults to 'false'
-ConnectionProperties.connectionPropertiesTransform=An implementation of com.mysql.jdbc.ConnectionPropertiesTransform that the driver will use to modify URL properties passed to the driver before attempting a connection
-ConnectionProperties.queriesBeforeRetryMaster=Number of queries to issue before falling back to master when failed over (when using multi-host failover). Whichever condition is met first, 'queriesBeforeRetryMaster' or 'secondsBeforeRetryMaster' will cause an attempt to be made to reconnect to the master. Defaults to 50.
-ConnectionProperties.reconnectAtTxEnd=If autoReconnect is set to true, should the driver attempt reconnections at the end of every transaction?
-ConnectionProperties.relaxAutoCommit=If the version of MySQL the driver connects to does not support transactions, still allow calls to commit(), rollback() and setAutoCommit() (true/false, defaults to 'false')?
-ConnectionProperties.reportMetricsIntervalMillis=If 'gatherPerfMetrics' is enabled, how often should they be logged (in ms)?
-ConnectionProperties.requireSSL=Require SSL connection if useSSL=true? (defaults to 'false').
-ConnectionProperties.resourceId=A globally unique name that identifies the resource that this datasource or connection is connected to, used for XAResource.isSameRM() when the driver can't determine this value based on hostnames used in the URL
-ConnectionProperties.resultSetSizeThreshold=If the usage advisor is enabled, how many rows should a result set contain before the driver warns that it is suspiciously large?
-ConnectionProperties.retainStatementAfterResultSetClose=Should the driver retain the Statement reference in a ResultSet after ResultSet.close() has been called. This is not JDBC-compliant after JDBC-4.0.
-ConnectionProperties.retriesAllDown=When using loadbalancing, the number of times the driver should cycle through available hosts, attempting to connect. Between cycles, the driver will pause for 250ms if no servers are available.
-ConnectionProperties.rewriteBatchedStatements=Should the driver use multiqueries (irregardless of the setting of "allowMultiQueries") as well as rewriting of prepared statements for INSERT into multi-value inserts when executeBatch() is called? Notice that this has the potential for SQL injection if using plain java.sql.Statements and your code doesn't sanitize input correctly. Notice that for prepared statements, server-side prepared statements can not currently take advantage of this rewrite option, and that if you don't specify stream lengths when using PreparedStatement.set*Stream(), the driver won't be able to determine the optimum number of parameters per batch and you might receive an error from the driver that the resultant packet is too large. Statement.getGeneratedKeys() for these rewritten statements only works when the entire batch includes INSERT statements.
-ConnectionProperties.rollbackOnPooledClose=Should the driver issue a rollback() when the logical connection in a pool is closed?
-ConnectionProperties.roundRobinLoadBalance=When autoReconnect is enabled, and failoverReadonly is false, should we pick hosts to connect to on a round-robin basis?
-ConnectionProperties.runningCTS13=Enables workarounds for bugs in Sun's JDBC compliance testsuite version 1.3
-ConnectionProperties.secondsBeforeRetryMaster=How long should the driver wait, when failed over, before attempting
-ConnectionProperties.secondsBeforeRetryMaster.1=to reconnect to the master server? Whichever condition is met first,
-ConnectionProperties.secondsBeforeRetryMaster.2='queriesBeforeRetryMaster' or 'secondsBeforeRetryMaster' will cause an
-ConnectionProperties.secondsBeforeRetryMaster.3=attempt to be made to reconnect to the master. Time in seconds, defaults to 30
-ConnectionProperties.selfDestructOnPingSecondsLifetime=If set to a non-zero value, the driver will report close the connection and report failure when Connection.ping() or Connection.isValid(int) is called if the connnection's lifetime exceeds this value.
-ConnectionProperties.selfDestructOnPingMaxOperations==If set to a non-zero value, the driver will report close the connection and report failure when Connection.ping() or Connection.isValid(int) is called if the connnection's count of commands sent to the server exceeds this value.
-ConnectionProperties.serverTimezone=Override detection/mapping of timezone. Used when timezone from server doesn't map to Java timezone
-ConnectionProperties.sessionVariables=A comma-separated list of name/value pairs to be sent as SET SESSION ... to the server when the driver connects.
-ConnectionProperties.slowQueryThresholdMillis=If 'logSlowQueries' is enabled, how long should a query (in ms) before it is logged as 'slow'?
-ConnectionProperties.slowQueryThresholdNanos=If 'useNanosForElapsedTime' is set to true, and this property is set to a non-zero value, the driver will use this threshold (in nanosecond units) to determine if a query was slow.
-ConnectionProperties.socketFactory=The name of the class that the driver should use for creating socket connections to the server. This class must implement the interface 'com.mysql.jdbc.SocketFactory' and have public no-args constructor.
-ConnectionProperties.socketTimeout=Timeout on network socket operations (0, the default means no timeout).
-ConnectionProperties.statementInterceptors=A comma-delimited list of classes that implement "com.mysql.jdbc.StatementInterceptor" that should be placed "in between" query execution to influence the results. StatementInterceptors are "chainable", the results returned by the "current" interceptor will be passed on to the next in in the chain, from left-to-right order, as specified in this property.
-ConnectionProperties.strictFloatingPoint=Used only in older versions of compliance test
-ConnectionProperties.strictUpdates=Should the driver do strict checking (all primary keys selected) of updatable result sets (true, false, defaults to 'true')?
-ConnectionProperties.overrideSupportsIEF=Should the driver return "true" for DatabaseMetaData.supportsIntegrityEnhancementFacility() even if the database doesn't support it to workaround applications that require this method to return "true" to signal support of foreign keys, even though the SQL specification states that this facility contains much more than just foreign key support (one such application being OpenOffice)?
-ConnectionProperties.tcpNoDelay=If connecting using TCP/IP, should the driver set SO_TCP_NODELAY (disabling the Nagle Algorithm)?
-ConnectionProperties.tcpKeepAlive=If connecting using TCP/IP, should the driver set SO_KEEPALIVE?
-ConnectionProperties.tcpSoRcvBuf=If connecting using TCP/IP, should the driver set SO_RCV_BUF to the given value? The default value of '0', means use the platform default value for this property)
-ConnectionProperties.tcpSoSndBuf=If connecting using TCP/IP, shuold the driver set SO_SND_BUF to the given value? The default value of '0', means use the platform default value for this property)
-ConnectionProperties.tcpTrafficClass=If connecting using TCP/IP, should the driver set traffic class or type-of-service fields ?See the documentation for java.net.Socket.setTrafficClass() for more information.
-ConnectionProperties.tinyInt1isBit=Should the driver treat the datatype TINYINT(1) as the BIT type (because the server silently converts BIT -> TINYINT(1) when creating tables)?
-ConnectionProperties.traceProtocol=Should trace-level network protocol be logged?
-ConnectionProperties.treatUtilDateAsTimestamp=Should the driver treat java.util.Date as a TIMESTAMP for the purposes of PreparedStatement.setObject()?
-ConnectionProperties.transformedBitIsBoolean=If the driver converts TINYINT(1) to a different type, should it use BOOLEAN instead of BIT for future compatibility with MySQL-5.0, as MySQL-5.0 has a BIT type?
-ConnectionProperties.useCompression=Use zlib compression when communicating with the server (true/false)? Defaults to 'false'.
-ConnectionProperties.useConfigs=Load the comma-delimited list of configuration properties before parsing the URL or applying user-specified properties. These configurations are explained in the 'Configurations' of the documentation.
-ConnectionProperties.useCursorFetch=If connected to MySQL > 5.0.2, and setFetchSize() > 0 on a statement, should that statement use cursor-based fetching to retrieve rows?
-ConnectionProperties.useDynamicCharsetInfo=Should the driver use a per-connection cache of character set information queried from the server when necessary, or use a built-in static mapping that is more efficient, but isn't aware of custom character sets or character sets implemented after the release of the JDBC driver?
-ConnectionProperties.useFastIntParsing=Use internal String->Integer conversion routines to avoid excessive object creation?
-ConnectionProperties.useFastDateParsing=Use internal String->Date/Time/Timestamp conversion routines to avoid excessive object creation?
-ConnectionProperties.useHostsInPrivileges=Add '@hostname' to users in DatabaseMetaData.getColumn/TablePrivileges() (true/false), defaults to 'true'.
-ConnectionProperties.useInformationSchema=When connected to MySQL-5.0.7 or newer, should the driver use the INFORMATION_SCHEMA to derive information used by DatabaseMetaData?
-ConnectionProperties.useJDBCCompliantTimezoneShift=Should the driver use JDBC-compliant rules when converting TIME/TIMESTAMP/DATETIME values' timezone information for those JDBC arguments which take a java.util.Calendar argument? (Notice that this option is exclusive of the "useTimezone=true" configuration option.)
-ConnectionProperties.useLocalSessionState=Should the driver refer to the internal values of autocommit and transaction isolation that are set by Connection.setAutoCommit() and Connection.setTransactionIsolation() and transaction state as maintained by the protocol, rather than querying the database or blindly sending commands to the database for commit() or rollback() method calls?
-ConnectionProperties.useLocalTransactionState=Should the driver use the in-transaction state provided by the MySQL protocol to determine if a commit() or rollback() should actually be sent to the database?
-ConnectionProperties.useNanosForElapsedTime=For profiling/debugging functionality that measures elapsed time, should the driver try to use nanoseconds resolution if available (JDK >= 1.5)?
-ConnectionProperties.useOldAliasMetadataBehavior=Should the driver use the legacy behavior for "AS" clauses on columns and tables, and only return aliases (if any) for ResultSetMetaData.getColumnName() or ResultSetMetaData.getTableName() rather than the original column/table name? In 5.0.x, the default value was true.
-ConnectionProperties.useOldUtf8Behavior=Use the UTF-8 behavior the driver did when communicating with 4.0 and older servers
-ConnectionProperties.useOnlyServerErrorMessages=Don't prepend 'standard' SQLState error messages to error messages returned by the server.
-ConnectionProperties.useReadAheadInput=Use newer, optimized non-blocking, buffered input stream when reading from the server?
-ConnectionProperties.useSqlStateCodes=Use SQL Standard state codes instead of 'legacy' X/Open/SQL state codes (true/false), default is 'true'
-ConnectionProperties.useSSL=Use SSL when communicating with the server (true/false), defaults to 'false'
-ConnectionProperties.useSSPSCompatibleTimezoneShift=If migrating from an environment that was using server-side prepared statements, and the configuration property "useJDBCCompliantTimeZoneShift" set to "true", use compatible behavior when not using server-side prepared statements when sending TIMESTAMP values to the MySQL server.
-ConnectionProperties.useStreamLengthsInPrepStmts=Honor stream length parameter in PreparedStatement/ResultSet.setXXXStream() method calls (true/false, defaults to 'true')?
-ConnectionProperties.useTimezone=Convert time/date types between client and server timezones (true/false, defaults to 'false')?
-ConnectionProperties.ultraDevHack=Create PreparedStatements for prepareCall() when required, because UltraDev is broken and issues a prepareCall() for _all_ statements? (true/false, defaults to 'false')
-ConnectionProperties.useUnbufferedInput=Don't use BufferedInputStream for reading data from the server
-ConnectionProperties.useUnicode=Should the driver use Unicode character encodings when handling strings? Should only be used when the driver can't determine the character set mapping, or you are trying to 'force' the driver to use a character set that MySQL either doesn't natively support (such as UTF-8), true/false, defaults to 'true'
-ConnectionProperties.useUsageAdvisor=Should the driver issue 'usage' warnings advising proper and efficient usage of JDBC and MySQL Connector/J to the log (true/false, defaults to 'false')?
-ConnectionProperties.verifyServerCertificate=If "useSSL" is set to "true", should the driver verify the server's certificate? When using this feature, the keystore parameters should be specified by the "clientCertificateKeyStore*" properties, rather than system properties.
-ConnectionProperties.yearIsDateType=Should the JDBC driver treat the MySQL type "YEAR" as a java.sql.Date, or as a SHORT?
-ConnectionProperties.zeroDateTimeBehavior=What should happen when the driver encounters DATETIME values that are composed entirely of zeroes (used by MySQL to represent invalid dates)? Valid values are \"{0}\", \"{1}\" and \"{2}\".
-ConnectionProperties.useJvmCharsetConverters=Always use the character encoding routines built into the JVM, rather than using lookup tables for single-byte character sets?
-ConnectionProperties.useGmtMillisForDatetimes=Convert between session timezone and GMT before creating Date and Timestamp instances (value of "false" is legacy behavior, "true" leads to more JDBC-compliant behavior.
-ConnectionProperties.dumpMetadataOnColumnNotFound=Should the driver dump the field-level metadata of a result set into the exception message when ResultSet.findColumn() fails?
-ConnectionProperties.clientCertificateKeyStoreUrl=URL to the client certificate KeyStore (if not specified, use defaults)
-ConnectionProperties.trustCertificateKeyStoreUrl=URL to the trusted root certificate KeyStore (if not specified, use defaults)
-ConnectionProperties.clientCertificateKeyStoreType=KeyStore type for client certificates (NULL or empty means use default, standard keystore types supported by the JVM are "JKS" and "PKCS12", your environment may have more available depending on what security products are installed and available to the JVM.
-ConnectionProperties.clientCertificateKeyStorePassword=Password for the client certificates KeyStore
-ConnectionProperties.trustCertificateKeyStoreType=KeyStore type for trusted root certificates (NULL or empty means use default, standard keystore types supported by the JVM are "JKS" and "PKCS12", your environment may have more available depending on what security products are installed and available to the JVM.
-ConnectionProperties.trustCertificateKeyStorePassword=Password for the trusted root certificates KeyStore
-ConnectionProperties.Username=The user to connect as
-ConnectionProperties.Password=The password to use when connecting
-ConnectionProperties.useBlobToStoreUTF8OutsideBMP=Tells the driver to treat [MEDIUM/LONG]BLOB columns as [LONG]VARCHAR columns holding text encoded in UTF-8 that has characters outside the BMP (4-byte encodings), which MySQL server can't handle natively.
-ConnectionProperties.utf8OutsideBmpExcludedColumnNamePattern=When "useBlobToStoreUTF8OutsideBMP" is set to "true", column names matching the given regex will still be treated as BLOBs unless they match the regex specified for "utf8OutsideBmpIncludedColumnNamePattern". The regex must follow the patterns used for the java.util.regex package.
-ConnectionProperties.utf8OutsideBmpIncludedColumnNamePattern=Used to specify exclusion rules to "utf8OutsideBmpExcludedColumnNamePattern". The regex must follow the patterns used for the java.util.regex package.
-ConnectionProperties.useLegacyDatetimeCode=Use code for DATE/TIME/DATETIME/TIMESTAMP handling in result sets and statements that consistently handles timezone conversions from client to server and back again, or use the legacy code for these datatypes that has been in the driver for backwards-compatibility?
-ConnectionProperties.useColumnNamesInFindColumn=Prior to JDBC-4.0, the JDBC specification had a bug related to what could be given as a "column name" to ResultSet methods like findColumn(), or getters that took a String property. JDBC-4.0 clarified "column name" to mean the label, as given in an "AS" clause and returned by ResultSetMetaData.getColumnLabel(), and if no AS clause, the column name. Setting this property to "true" will give behavior that is congruent to JDBC-3.0 and earlier versions of the JDBC specification, but which because of the specification bug could give unexpected results. This property is preferred over "useOldAliasMetadataBehavior" unless you need the specific behavior that it provides with respect to ResultSetMetadata.
-ConnectionProperties.useAffectedRows=Don't set the CLIENT_FOUND_ROWS flag when connecting to the server (not JDBC-compliant, will break most applications that rely on "found" rows vs. "affected rows" for DML statements), but does cause "correct" update counts from "INSERT ... ON DUPLICATE KEY UPDATE" statements to be returned by the server.
-ConnectionProperties.passwordCharacterEncoding=What character encoding is used for passwords? Leaving this set to the default value (null), uses the platform character set, which works for ISO8859_1 (i.e. "latin1") passwords. For passwords in other character encodings, the encoding will have to be specified with this property, as it's not possible for the driver to auto-detect this.
-ConnectionProperties.exceptionInterceptors=Comma-delimited list of classes that implement com.mysql.jdbc.ExceptionInterceptor. These classes will be instantiated one per Connection instance, and all SQLExceptions thrown by the driver will be allowed to be intercepted by these interceptors, in a chained fashion, with the first class listed as the head of the chain.
-ConnectionProperties.maxAllowedPacket=Maximum allowed packet size to send to server. If not set, the value of system variable 'max_allowed_packet' will be used to initialize this upon connecting. This value will not take effect if set larger than the value of 'max_allowed_packet'.
-ConnectionProperties.queryTimeoutKillsConnection=If the timeout given in Statement.setQueryTimeout() expires, should the driver forcibly abort the Connection instead of attempting to abort the query?
-#
-# Error Messages for Connection Properties
-#
-
-ConnectionProperties.unableToInitDriverProperties=Unable to initialize driver properties due to
-ConnectionProperties.unsupportedCharacterEncoding=Unsupported character encoding ''{0}''.
-ConnectionProperties.errorNotExpected=Huh?
-ConnectionProperties.InternalPropertiesFailure=Internal properties failure
-
-TimeUtil.TooGenericTimezoneId=The server timezone value ''{0}'' represents more than one timezone. You must \
-configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a \
-more specifc timezone value if you want to utilize timezone support. The timezones that ''{0}'' maps to are: {1}.
-
-Connection.exceededConnectionLifetime=Ping or validation failed because configured connection lifetime exceeded.
-Connection.badLifecycleInterceptor=Unable to load connection lifecycle interceptor ''{0}''.
-MysqlIo.BadStatementInterceptor=Unable to load statement interceptor ''{0}''.
-Connection.BadExceptionInterceptor=Unable to load exception interceptor ''{0}''.
diff --git a/src/com/mysql/jdbc/Messages.java b/src/com/mysql/jdbc/Messages.java
deleted file mode 100644
index 60e7447c4..000000000
--- a/src/com/mysql/jdbc/Messages.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Support for localized messages.
- *
- * @author Mark Matthews
- * @version $Id$
- */
-public class Messages {
-
- private static final String BUNDLE_NAME = "com.mysql.jdbc.LocalizedErrorMessages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE;
-
- static {
- ResourceBundle temp = null;
-
- //
- // Overly-pedantic here, some appserver and JVM combos don't deal
- // well with the no-args version, others don't deal well with
- // the three-arg version, so we need to try both :(
- //
-
- try {
- temp = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault(),
- Messages.class.getClassLoader());
- } catch (Throwable t) {
- try {
- temp = ResourceBundle.getBundle(BUNDLE_NAME);
- } catch (Throwable t2) {
- RuntimeException rt = new RuntimeException(
- "Can't load resource bundle due to underlying exception "
- + t.toString());
- rt.initCause(t2);
-
- throw rt;
- }
- } finally {
- RESOURCE_BUNDLE = temp;
- }
- }
-
- /**
- * Returns the localized message for the given message key
- *
- * @param key
- * the message key
- * @return The localized message for the key
- */
- public static String getString(String key) {
- if (RESOURCE_BUNDLE == null) {
- throw new RuntimeException(
- "Localized messages from resource bundle '" + BUNDLE_NAME
- + "' not loaded during initialization of driver.");
- }
-
- try {
- if (key == null) {
- throw new IllegalArgumentException(
- "Message key can not be null");
- }
-
- String message = RESOURCE_BUNDLE.getString(key);
-
- if (message == null) {
- message = "Missing error message for key '" + key + "'";
- }
-
- return message;
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- public static String getString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
- /**
- * Dis-allow construction ...
- */
- private Messages() {
-
- // XXX Auto-generated constructor stub
- }
-}
diff --git a/src/com/mysql/jdbc/MiniAdmin.java b/src/com/mysql/jdbc/MiniAdmin.java
deleted file mode 100644
index 867fd4067..000000000
--- a/src/com/mysql/jdbc/MiniAdmin.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.Properties;
-
-/**
- * Utility functions for admin functionality from Java.
- *
- * @author Mark Matthews
- */
-public class MiniAdmin {
- // ~ Instance fields
- // --------------------------------------------------------
-
- private Connection conn;
-
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Create a new MiniAdmin using the given connection
- *
- * @param conn
- * the existing connection to use.
- *
- * @throws SQLException
- * if an error occurs
- */
- public MiniAdmin(java.sql.Connection conn) throws SQLException {
- if (conn == null) {
- throw SQLError.createSQLException(
- Messages.getString("MiniAdmin.0"), SQLError.SQL_STATE_GENERAL_ERROR, ((com.mysql.jdbc.ConnectionImpl)conn).getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (!(conn instanceof Connection)) {
- throw SQLError.createSQLException(Messages.getString("MiniAdmin.1"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, ((com.mysql.jdbc.ConnectionImpl)conn).getExceptionInterceptor());
- }
-
- this.conn = (Connection) conn;
- }
-
- /**
- * Create a new MiniAdmin, connecting using the given JDBC URL.
- *
- * @param jdbcUrl
- * the JDBC URL to use
- *
- * @throws SQLException
- * if an error occurs
- */
- public MiniAdmin(String jdbcUrl) throws SQLException {
- this(jdbcUrl, new Properties());
- }
-
- /**
- * Create a new MiniAdmin, connecting using the given JDBC URL and
- * properties
- *
- * @param jdbcUrl
- * the JDBC URL to use
- * @param props
- * the properties to use when connecting
- *
- * @throws SQLException
- * if an error occurs
- */
- public MiniAdmin(String jdbcUrl, Properties props) throws SQLException {
- this.conn = (Connection) (new Driver().connect(jdbcUrl, props));
- }
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * Shuts down the MySQL server at the other end of the connection that this
- * MiniAdmin was created from/for.
- *
- * @throws SQLException
- * if an error occurs
- */
- public void shutdown() throws SQLException {
- this.conn.shutdownServer();
- }
-}
diff --git a/src/com/mysql/jdbc/MysqlDataTruncation.java b/src/com/mysql/jdbc/MysqlDataTruncation.java
deleted file mode 100644
index 1168ef0ba..000000000
--- a/src/com/mysql/jdbc/MysqlDataTruncation.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008-2009 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.DataTruncation;
-
-/**
- * MySQL wrapper for DataTruncation until the server can support sending all
- * needed information.
- *
- * @author Mark Matthews
- *
- * @version $Id: MysqlDataTruncation.java,v 1.1.2.1 2005/05/13 18:58:38
- * mmatthews Exp $
- */
-public class MysqlDataTruncation extends DataTruncation {
-
- private String message;
-
- private int vendorErrorCode;
-
- /**
- * Creates a new MysqlDataTruncation exception/warning.
- *
- * @param message
- * the message from the server
- * @param index
- * of column or parameter
- * @param parameter
- * was a parameter?
- * @param read
- * was truncated on read?
- * @param dataSize
- * size requested
- * @param transferSize
- * size actually used
- */
- public MysqlDataTruncation(String message, int index, boolean parameter,
- boolean read, int dataSize, int transferSize, int vendorErrorCode) {
- super(index, parameter, read, dataSize, transferSize);
-
- this.message = message;
- this.vendorErrorCode = vendorErrorCode;
- }
-
- public int getErrorCode() {
- return this.vendorErrorCode;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Throwable#getMessage()
- */
- public String getMessage() {
- return super.getMessage() + ": " + this.message; //$NON-NLS-1$
- }
-}
diff --git a/src/com/mysql/jdbc/MysqlDefs.java b/src/com/mysql/jdbc/MysqlDefs.java
deleted file mode 100644
index 0c78b5efa..000000000
--- a/src/com/mysql/jdbc/MysqlDefs.java
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.Types;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * MysqlDefs contains many values that are needed for communication with the
- * MySQL server.
- *
- * @author Mark Matthews
- * @version $Id$
- */
-public final class MysqlDefs {
- // ~ Static fields/initializers
- // ---------------------------------------------
-
- static final int COM_BINLOG_DUMP = 18;
-
- static final int COM_CHANGE_USER = 17;
-
- static final int COM_CLOSE_STATEMENT = 25;
-
- static final int COM_CONNECT_OUT = 20;
-
- static final int COM_END = 29;
-
- static final int COM_EXECUTE = 23;
-
- static final int COM_FETCH = 28;
-
- static final int COM_LONG_DATA = 24;
-
- static final int COM_PREPARE = 22;
-
- static final int COM_REGISTER_SLAVE = 21;
-
- static final int COM_RESET_STMT = 26;
-
- static final int COM_SET_OPTION = 27;
-
- static final int COM_TABLE_DUMP = 19;
-
- static final int CONNECT = 11;
-
- static final int CREATE_DB = 5;
-
- static final int DEBUG = 13;
-
- static final int DELAYED_INSERT = 16;
-
- static final int DROP_DB = 6;
-
- static final int FIELD_LIST = 4;
-
- static final int FIELD_TYPE_BIT = 16;
-
- public static final int FIELD_TYPE_BLOB = 252;
-
- static final int FIELD_TYPE_DATE = 10;
-
- static final int FIELD_TYPE_DATETIME = 12;
-
- // Data Types
- static final int FIELD_TYPE_DECIMAL = 0;
-
- static final int FIELD_TYPE_DOUBLE = 5;
-
- static final int FIELD_TYPE_ENUM = 247;
-
- static final int FIELD_TYPE_FLOAT = 4;
-
- static final int FIELD_TYPE_GEOMETRY = 255;
-
- static final int FIELD_TYPE_INT24 = 9;
-
- static final int FIELD_TYPE_LONG = 3;
-
- static final int FIELD_TYPE_LONG_BLOB = 251;
-
- static final int FIELD_TYPE_LONGLONG = 8;
-
- static final int FIELD_TYPE_MEDIUM_BLOB = 250;
-
- static final int FIELD_TYPE_NEW_DECIMAL = 246;
-
- static final int FIELD_TYPE_NEWDATE = 14;
-
- static final int FIELD_TYPE_NULL = 6;
-
- static final int FIELD_TYPE_SET = 248;
-
- static final int FIELD_TYPE_SHORT = 2;
-
- static final int FIELD_TYPE_STRING = 254;
-
- static final int FIELD_TYPE_TIME = 11;
-
- static final int FIELD_TYPE_TIMESTAMP = 7;
-
- static final int FIELD_TYPE_TINY = 1;
-
- // Older data types
- static final int FIELD_TYPE_TINY_BLOB = 249;
-
- static final int FIELD_TYPE_VAR_STRING = 253;
-
- static final int FIELD_TYPE_VARCHAR = 15;
-
- // Newer data types
- static final int FIELD_TYPE_YEAR = 13;
-
- static final int INIT_DB = 2;
-
- static final long LENGTH_BLOB = 65535;
-
- static final long LENGTH_LONGBLOB = 4294967295L;
-
- static final long LENGTH_MEDIUMBLOB = 16777215;
-
- static final long LENGTH_TINYBLOB = 255;
-
- // Limitations
- static final int MAX_ROWS = 50000000; // From the MySQL FAQ
-
- /**
- * Used to indicate that the server sent no field-level character set
- * information, so the driver should use the connection-level character
- * encoding instead.
- */
- public static final int NO_CHARSET_INFO = -1;
-
- static final byte OPEN_CURSOR_FLAG = 1;
-
- static final int PING = 14;
-
- static final int PROCESS_INFO = 10;
-
- static final int PROCESS_KILL = 12;
-
- static final int QUERY = 3;
-
- static final int QUIT = 1;
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- static final int RELOAD = 7;
-
- static final int SHUTDOWN = 8;
-
- //
- // Constants defined from mysql
- //
- // DB Operations
- static final int SLEEP = 0;
-
- static final int STATISTICS = 9;
-
- static final int TIME = 15;
-
- /**
- * Maps the given MySQL type to the correct JDBC type.
- */
- static int mysqlToJavaType(int mysqlType) {
- int jdbcType;
-
- switch (mysqlType) {
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- jdbcType = Types.DECIMAL;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_TINY:
- jdbcType = Types.TINYINT;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_SHORT:
- jdbcType = Types.SMALLINT;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_LONG:
- jdbcType = Types.INTEGER;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_FLOAT:
- jdbcType = Types.REAL;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- jdbcType = Types.DOUBLE;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_NULL:
- jdbcType = Types.NULL;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- jdbcType = Types.TIMESTAMP;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- jdbcType = Types.BIGINT;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_INT24:
- jdbcType = Types.INTEGER;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_DATE:
- jdbcType = Types.DATE;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_TIME:
- jdbcType = Types.TIME;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_DATETIME:
- jdbcType = Types.TIMESTAMP;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_YEAR:
- jdbcType = Types.DATE;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_NEWDATE:
- jdbcType = Types.DATE;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_ENUM:
- jdbcType = Types.CHAR;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_SET:
- jdbcType = Types.CHAR;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- jdbcType = Types.VARBINARY;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- jdbcType = Types.LONGVARBINARY;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- jdbcType = Types.LONGVARBINARY;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_BLOB:
- jdbcType = Types.LONGVARBINARY;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- jdbcType = Types.VARCHAR;
-
- break;
-
- case MysqlDefs.FIELD_TYPE_STRING:
- jdbcType = Types.CHAR;
-
- break;
- case MysqlDefs.FIELD_TYPE_GEOMETRY:
- jdbcType = Types.BINARY;
-
- break;
- case MysqlDefs.FIELD_TYPE_BIT:
- jdbcType = Types.BIT;
-
- break;
- default:
- jdbcType = Types.VARCHAR;
- }
-
- return jdbcType;
- }
-
- /**
- * Maps the given MySQL type to the correct JDBC type.
- */
- static int mysqlToJavaType(String mysqlType) {
- if (mysqlType.equalsIgnoreCase("BIT")) {
- return mysqlToJavaType(FIELD_TYPE_BIT);
- } else if (mysqlType.equalsIgnoreCase("TINYINT")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_TINY);
- } else if (mysqlType.equalsIgnoreCase("SMALLINT")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_SHORT);
- } else if (mysqlType.equalsIgnoreCase("MEDIUMINT")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_INT24);
- } else if (mysqlType.equalsIgnoreCase("INT") || mysqlType.equalsIgnoreCase("INTEGER")) { //$NON-NLS-1$ //$NON-NLS-2$
- return mysqlToJavaType(FIELD_TYPE_LONG);
- } else if (mysqlType.equalsIgnoreCase("BIGINT")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_LONGLONG);
- } else if (mysqlType.equalsIgnoreCase("INT24")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_INT24);
- } else if (mysqlType.equalsIgnoreCase("REAL")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_DOUBLE);
- } else if (mysqlType.equalsIgnoreCase("FLOAT")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_FLOAT);
- } else if (mysqlType.equalsIgnoreCase("DECIMAL")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_DECIMAL);
- } else if (mysqlType.equalsIgnoreCase("NUMERIC")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_DECIMAL);
- } else if (mysqlType.equalsIgnoreCase("DOUBLE")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_DOUBLE);
- } else if (mysqlType.equalsIgnoreCase("CHAR")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_STRING);
- } else if (mysqlType.equalsIgnoreCase("VARCHAR")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_VAR_STRING);
- } else if (mysqlType.equalsIgnoreCase("DATE")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_DATE);
- } else if (mysqlType.equalsIgnoreCase("TIME")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_TIME);
- } else if (mysqlType.equalsIgnoreCase("YEAR")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_YEAR);
- } else if (mysqlType.equalsIgnoreCase("TIMESTAMP")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_TIMESTAMP);
- } else if (mysqlType.equalsIgnoreCase("DATETIME")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_DATETIME);
- } else if (mysqlType.equalsIgnoreCase("TINYBLOB")) { //$NON-NLS-1$
- return java.sql.Types.BINARY;
- } else if (mysqlType.equalsIgnoreCase("BLOB")) { //$NON-NLS-1$
- return java.sql.Types.LONGVARBINARY;
- } else if (mysqlType.equalsIgnoreCase("MEDIUMBLOB")) { //$NON-NLS-1$
- return java.sql.Types.LONGVARBINARY;
- } else if (mysqlType.equalsIgnoreCase("LONGBLOB")) { //$NON-NLS-1$
- return java.sql.Types.LONGVARBINARY;
- } else if (mysqlType.equalsIgnoreCase("TINYTEXT")) { //$NON-NLS-1$
- return java.sql.Types.VARCHAR;
- } else if (mysqlType.equalsIgnoreCase("TEXT")) { //$NON-NLS-1$
- return java.sql.Types.LONGVARCHAR;
- } else if (mysqlType.equalsIgnoreCase("MEDIUMTEXT")) { //$NON-NLS-1$
- return java.sql.Types.LONGVARCHAR;
- } else if (mysqlType.equalsIgnoreCase("LONGTEXT")) { //$NON-NLS-1$
- return java.sql.Types.LONGVARCHAR;
- } else if (mysqlType.equalsIgnoreCase("ENUM")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_ENUM);
- } else if (mysqlType.equalsIgnoreCase("SET")) { //$NON-NLS-1$
- return mysqlToJavaType(FIELD_TYPE_SET);
- } else if (mysqlType.equalsIgnoreCase("GEOMETRY")) {
- return mysqlToJavaType(FIELD_TYPE_GEOMETRY);
- } else if (mysqlType.equalsIgnoreCase("BINARY")) {
- return Types.BINARY; // no concrete type on the wire
- } else if (mysqlType.equalsIgnoreCase("VARBINARY")) {
- return Types.VARBINARY; // no concrete type on the wire
- } else if (mysqlType.equalsIgnoreCase("BIT")) {
- return mysqlToJavaType(FIELD_TYPE_BIT);
- }
-
- // Punt
- return java.sql.Types.OTHER;
- }
-
- /**
- * @param mysqlType
- * @return
- */
- public static String typeToName(int mysqlType) {
- switch (mysqlType) {
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- return "FIELD_TYPE_DECIMAL";
-
- case MysqlDefs.FIELD_TYPE_TINY:
- return "FIELD_TYPE_TINY";
-
- case MysqlDefs.FIELD_TYPE_SHORT:
- return "FIELD_TYPE_SHORT";
-
- case MysqlDefs.FIELD_TYPE_LONG:
- return "FIELD_TYPE_LONG";
-
- case MysqlDefs.FIELD_TYPE_FLOAT:
- return "FIELD_TYPE_FLOAT";
-
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- return "FIELD_TYPE_DOUBLE";
-
- case MysqlDefs.FIELD_TYPE_NULL:
- return "FIELD_TYPE_NULL";
-
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- return "FIELD_TYPE_TIMESTAMP";
-
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- return "FIELD_TYPE_LONGLONG";
-
- case MysqlDefs.FIELD_TYPE_INT24:
- return "FIELD_TYPE_INT24";
-
- case MysqlDefs.FIELD_TYPE_DATE:
- return "FIELD_TYPE_DATE";
-
- case MysqlDefs.FIELD_TYPE_TIME:
- return "FIELD_TYPE_TIME";
-
- case MysqlDefs.FIELD_TYPE_DATETIME:
- return "FIELD_TYPE_DATETIME";
-
- case MysqlDefs.FIELD_TYPE_YEAR:
- return "FIELD_TYPE_YEAR";
-
- case MysqlDefs.FIELD_TYPE_NEWDATE:
- return "FIELD_TYPE_NEWDATE";
-
- case MysqlDefs.FIELD_TYPE_ENUM:
- return "FIELD_TYPE_ENUM";
-
- case MysqlDefs.FIELD_TYPE_SET:
- return "FIELD_TYPE_SET";
-
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- return "FIELD_TYPE_TINY_BLOB";
-
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- return "FIELD_TYPE_MEDIUM_BLOB";
-
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- return "FIELD_TYPE_LONG_BLOB";
-
- case MysqlDefs.FIELD_TYPE_BLOB:
- return "FIELD_TYPE_BLOB";
-
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- return "FIELD_TYPE_VAR_STRING";
-
- case MysqlDefs.FIELD_TYPE_STRING:
- return "FIELD_TYPE_STRING";
-
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- return "FIELD_TYPE_VARCHAR";
-
- case MysqlDefs.FIELD_TYPE_GEOMETRY:
- return "FIELD_TYPE_GEOMETRY";
-
- default:
- return " Unknown MySQL Type # " + mysqlType;
- }
- }
-
- private static Map mysqlToJdbcTypesMap = new HashMap();
-
- static {
- mysqlToJdbcTypesMap.put("BIT", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_BIT)));
-
- mysqlToJdbcTypesMap.put("TINYINT", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_TINY)));
- mysqlToJdbcTypesMap.put("SMALLINT", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_SHORT)));
- mysqlToJdbcTypesMap.put("MEDIUMINT", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_INT24)));
- mysqlToJdbcTypesMap.put("INT", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_LONG)));
- mysqlToJdbcTypesMap.put("INTEGER", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_LONG)));
- mysqlToJdbcTypesMap.put("BIGINT", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_LONGLONG)));
- mysqlToJdbcTypesMap.put("INT24", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_INT24)));
- mysqlToJdbcTypesMap.put("REAL", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_DOUBLE)));
- mysqlToJdbcTypesMap.put("FLOAT", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_FLOAT)));
- mysqlToJdbcTypesMap.put("DECIMAL", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_DECIMAL)));
- mysqlToJdbcTypesMap.put("NUMERIC", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_DECIMAL)));
- mysqlToJdbcTypesMap.put("DOUBLE", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_DOUBLE)));
- mysqlToJdbcTypesMap.put("CHAR", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_STRING)));
- mysqlToJdbcTypesMap.put("VARCHAR", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_VAR_STRING)));
- mysqlToJdbcTypesMap.put("DATE", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_DATE)));
- mysqlToJdbcTypesMap.put("TIME", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_TIME)));
- mysqlToJdbcTypesMap.put("YEAR", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_YEAR)));
- mysqlToJdbcTypesMap.put("TIMESTAMP", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_TIMESTAMP)));
- mysqlToJdbcTypesMap.put("DATETIME", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_DATETIME)));
- mysqlToJdbcTypesMap.put("TINYBLOB", Constants.integerValueOf(java.sql.Types.BINARY));
- mysqlToJdbcTypesMap.put("BLOB", Constants.integerValueOf(
- java.sql.Types.LONGVARBINARY));
- mysqlToJdbcTypesMap.put("MEDIUMBLOB", Constants.integerValueOf(
- java.sql.Types.LONGVARBINARY));
- mysqlToJdbcTypesMap.put("LONGBLOB", Constants.integerValueOf(
- java.sql.Types.LONGVARBINARY));
- mysqlToJdbcTypesMap
- .put("TINYTEXT", Constants.integerValueOf(java.sql.Types.VARCHAR));
- mysqlToJdbcTypesMap
- .put("TEXT", Constants.integerValueOf(java.sql.Types.LONGVARCHAR));
- mysqlToJdbcTypesMap.put("MEDIUMTEXT", Constants.integerValueOf(
- java.sql.Types.LONGVARCHAR));
- mysqlToJdbcTypesMap.put("LONGTEXT", Constants.integerValueOf(
- java.sql.Types.LONGVARCHAR));
- mysqlToJdbcTypesMap.put("ENUM", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_ENUM)));
- mysqlToJdbcTypesMap.put("SET", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_SET)));
- mysqlToJdbcTypesMap.put("GEOMETRY", Constants.integerValueOf(
- mysqlToJavaType(FIELD_TYPE_GEOMETRY)));
- }
-
- static final void appendJdbcTypeMappingQuery(StringBuffer buf, String mysqlTypeColumnName) {
-
- buf.append("CASE ");
- Map typesMap = new HashMap();
- typesMap.putAll(mysqlToJdbcTypesMap);
- typesMap.put("BINARY", Constants.integerValueOf(Types.BINARY));
- typesMap.put("VARBINARY", Constants.integerValueOf(Types.VARBINARY));
-
- Iterator mysqlTypes = typesMap.keySet().iterator();
-
- while (mysqlTypes.hasNext()) {
- String mysqlTypeName = (String)mysqlTypes.next();
- buf.append(" WHEN ");
- buf.append(mysqlTypeColumnName);
- buf.append("='");
- buf.append(mysqlTypeName);
- buf.append("' THEN ");
- buf.append(typesMap.get(mysqlTypeName));
-
- if (mysqlTypeName.equalsIgnoreCase("DOUBLE") ||
- mysqlTypeName.equalsIgnoreCase("FLOAT") ||
- mysqlTypeName.equalsIgnoreCase("DECIMAL") ||
- mysqlTypeName.equalsIgnoreCase("NUMERIC")) {
- buf.append(" WHEN ");
- buf.append(mysqlTypeColumnName);
- buf.append("='");
- buf.append(mysqlTypeName);
- buf.append(" unsigned' THEN ");
- buf.append(typesMap.get(mysqlTypeName));
- }
- }
-
- buf.append(" ELSE ");
- buf.append(Types.OTHER);
- buf.append(" END ");
-
- }
-}
diff --git a/src/com/mysql/jdbc/MysqlErrorNumbers.java b/src/com/mysql/jdbc/MysqlErrorNumbers.java
deleted file mode 100644
index 80d5ac6a1..000000000
--- a/src/com/mysql/jdbc/MysqlErrorNumbers.java
+++ /dev/null
@@ -1,641 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-/**
- * Constants representing MySQL error numbers returned by the server in error
- * messages.
- *
- * @author Mark Matthews
- *
- * @version $Id: MysqlErrorNumbers.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews
- * Exp $
- */
-public final class MysqlErrorNumbers {
-
- public final static int ER_ABORTING_CONNECTION = 1152;
-
- public final static int ER_ACCESS_DENIED_ERROR = 1045;
-
- public final static int ER_ALTER_INFO = 1088;
-
- public final static int ER_AUTO_CONVERT = 1246;
-
- public final static int ER_BAD_DB_ERROR = 1049;
-
- public final static int ER_BAD_FIELD_ERROR = 1054;
-
- public final static int ER_BAD_FT_COLUMN = 1283;
-
- public final static int ER_BAD_HOST_ERROR = 1042;
-
- public final static int ER_BAD_NULL_ERROR = 1048;
-
- public final static int ER_BAD_SLAVE = 1200;
-
- public final static int ER_BAD_SLAVE_UNTIL_COND = 1277;
-
- public final static int ER_BAD_TABLE_ERROR = 1051;
-
- public final static int ER_BLOB_CANT_HAVE_DEFAULT = 1101;
-
- public final static int ER_BLOB_KEY_WITHOUT_LENGTH = 1170;
-
- public final static int ER_BLOB_USED_AS_KEY = 1073;
-
- public final static int ER_BLOBS_AND_NO_TERMINATED = 1084;
-
- public final static int ER_CANNOT_ADD_FOREIGN = 1215;
-
- public final static int ER_CANT_AGGREGATE_2COLLATIONS = 1267;
-
- public final static int ER_CANT_AGGREGATE_3COLLATIONS = 1270;
-
- public final static int ER_CANT_AGGREGATE_NCOLLATIONS = 1271;
-
- public final static int ER_CANT_CREATE_DB = 1006;
-
- public final static int ER_CANT_CREATE_FILE = 1004;
-
- public final static int ER_CANT_CREATE_TABLE = 1005;
-
- public final static int ER_CANT_CREATE_THREAD = 1135;
-
- public final static int ER_CANT_DELETE_FILE = 1011;
-
- public final static int ER_CANT_DO_THIS_DURING_AN_TRANSACTION = 1179;
-
- public final static int ER_CANT_DROP_FIELD_OR_KEY = 1091;
-
- public final static int ER_CANT_FIND_DL_ENTRY = 1127;
-
- public final static int ER_CANT_FIND_SYSTEM_REC = 1012;
-
- public final static int ER_CANT_FIND_UDF = 1122;
-
- public final static int ER_CANT_GET_STAT = 1013;
-
- public final static int ER_CANT_GET_WD = 1014;
-
- public final static int ER_CANT_INITIALIZE_UDF = 1123;
-
- public final static int ER_CANT_LOCK = 1015;
-
- public final static int ER_CANT_OPEN_FILE = 1016;
-
- public final static int ER_CANT_OPEN_LIBRARY = 1126;
-
- public final static int ER_CANT_READ_DIR = 1018;
-
- public final static int ER_CANT_REMOVE_ALL_FIELDS = 1090;
-
- public final static int ER_CANT_REOPEN_TABLE = 1137;
-
- public final static int ER_CANT_SET_WD = 1019;
-
- public final static int ER_CANT_UPDATE_WITH_READLOCK = 1223;
-
- public final static int ER_CANT_USE_OPTION_HERE = 1234;
-
- public final static int ER_CHECK_NO_SUCH_TABLE = 1177;
-
- public final static int ER_CHECK_NOT_IMPLEMENTED = 1178;
-
- public final static int ER_CHECKREAD = 1020;
-
- public final static int ER_COLLATION_CHARSET_MISMATCH = 1253;
-
- public final static int ER_COLUMNACCESS_DENIED_ERROR = 1143;
-
- public final static int ER_CON_COUNT_ERROR = 1040;
-
- public final static int ER_CONNECT_TO_MASTER = 1218;
-
- public final static int ER_CORRUPT_HELP_DB = 1244;
-
- public final static int ER_CRASHED_ON_REPAIR = 1195;
-
- public final static int ER_CRASHED_ON_USAGE = 1194;
-
- public final static int ER_CREATE_DB_WITH_READ_LOCK = 1209;
-
- public final static int ER_CUT_VALUE_GROUP_CONCAT = 1260;
-
- public final static int ER_CYCLIC_REFERENCE = 1245;
-
- public final static int ER_DB_CREATE_EXISTS = 1007;
-
- public final static int ER_DB_DROP_DELETE = 1009;
-
- public final static int ER_DB_DROP_EXISTS = 1008;
-
- public final static int ER_DB_DROP_RMDIR = 1010;
-
- public final static int ER_DBACCESS_DENIED_ERROR = 1044;
-
- public final static int ER_DELAYED_CANT_CHANGE_LOCK = 1150;
-
- public final static int ER_DELAYED_INSERT_TABLE_LOCKED = 1165;
-
- public final static int ER_DERIVED_MUST_HAVE_ALIAS = 1248;
-
- public final static int ER_DISK_FULL = 1021;
-
- public final static int ER_DROP_DB_WITH_READ_LOCK = 1208;
-
- public final static int ER_DROP_USER = 1268;
-
- public final static int ER_DUMP_NOT_IMPLEMENTED = 1185;
-
- public final static int ER_DUP_ARGUMENT = 1225;
-
- public final static int ER_DUP_ENTRY = 1062;
-
- public final static int ER_DUP_FIELDNAME = 1060;
-
- public final static int ER_DUP_KEY = 1022;
-
- public final static int ER_DUP_KEYNAME = 1061;
-
- public final static int ER_DUP_UNIQUE = 1169;
-
- public final static int ER_DUPLICATED_VALUE_IN_TYPE = 1291;
-
- public final static int ER_EMPTY_QUERY = 1065;
-
- public final static int ER_ERROR_DURING_CHECKPOINT = 1183;
-
- public final static int ER_ERROR_DURING_COMMIT = 1180;
-
- public final static int ER_ERROR_DURING_FLUSH_LOGS = 1182;
-
- public final static int ER_ERROR_DURING_ROLLBACK = 1181;
-
- public final static int ER_ERROR_MESSAGES = 298;
-
- public final static int ER_ERROR_ON_CLOSE = 1023;
-
- public final static int ER_ERROR_ON_READ = 1024;
-
- public final static int ER_ERROR_ON_RENAME = 1025;
-
- public final static int ER_ERROR_ON_WRITE = 1026;
-
- public final static int ER_ERROR_WHEN_EXECUTING_COMMAND = 1220;
-
- public final static int ER_FEATURE_DISABLED = 1289;
-
- public final static int ER_FIELD_SPECIFIED_TWICE = 1110;
-
- public final static int ER_FILE_EXISTS_ERROR = 1086;
-
- public final static int ER_FILE_NOT_FOUND = 1017;
-
- public final static int ER_FILE_USED = 1027;
-
- public final static int ER_FILSORT_ABORT = 1028;
-
- public final static int ER_FLUSH_MASTER_BINLOG_CLOSED = 1186;
-
- public final static int ER_FORCING_CLOSE = 1080;
-
- public final static int ER_FORM_NOT_FOUND = 1029;
-
- public final static int ER_FT_MATCHING_KEY_NOT_FOUND = 1191;
-
- public final static int ER_FUNCTION_NOT_DEFINED = 1128;
-
- public final static int ER_GET_ERRMSG = 1296;
-
- public final static int ER_GET_ERRNO = 1030;
-
- public final static int ER_GET_TEMPORARY_ERRMSG = 1297;
-
- public final static int ER_GLOBAL_VARIABLE = 1229;
-
- public final static int ER_GOT_SIGNAL = 1078;
-
- public final static int ER_GRANT_WRONG_HOST_OR_USER = 1145;
-
- public final static int ER_HANDSHAKE_ERROR = 1043;
-
- public final static int ER_HASHCHK = 1000;
-
- public final static int ER_HOST_IS_BLOCKED = 1129;
-
- public final static int ER_HOST_NOT_PRIVILEGED = 1130;
-
- public final static int ER_ILLEGAL_GRANT_FOR_TABLE = 1144;
-
- public final static int ER_ILLEGAL_HA = 1031;
-
- public final static int ER_ILLEGAL_REFERENCE = 1247;
-
- public final static int ER_INCORRECT_GLOBAL_LOCAL_VAR = 1238;
-
- public final static int ER_INDEX_REBUILD = 1187;
-
- public final static int ER_INSERT_INFO = 1092;
-
- public final static int ER_INVALID_DEFAULT = 1067;
-
- public final static int ER_INVALID_GROUP_FUNC_USE = 1111;
-
- public final static int ER_INVALID_ON_UPDATE = 1294;
-
- public final static int ER_INVALID_USE_OF_NULL = 1138;
-
- public final static int ER_IPSOCK_ERROR = 1081;
-
- public final static int ER_KEY_COLUMN_DOES_NOT_EXITS = 1072;
-
- public final static int ER_KEY_DOES_NOT_EXITS = 1176;
-
- public final static int ER_KEY_NOT_FOUND = 1032;
-
- public final static int ER_KEY_REF_DO_NOT_MATCH_TABLE_REF = 1240;
-
- public final static int ER_KILL_DENIED_ERROR = 1095;
-
- public final static int ER_LOAD_INFO = 1087;
-
- public final static int ER_LOCAL_VARIABLE = 1228;
-
- public final static int ER_LOCK_DEADLOCK = 1213;
-
- public final static int ER_LOCK_OR_ACTIVE_TRANSACTION = 1192;
-
- public final static int ER_LOCK_TABLE_FULL = 1206;
-
- public final static int ER_LOCK_WAIT_TIMEOUT = 1205;
-
- public final static int ER_MASTER = 1188;
-
- public final static int ER_MASTER_FATAL_ERROR_READING_BINLOG = 1236;
-
- public final static int ER_MASTER_INFO = 1201;
-
- public final static int ER_MASTER_NET_READ = 1189;
-
- public final static int ER_MASTER_NET_WRITE = 1190;
-
- public final static int ER_MISSING_SKIP_SLAVE = 1278;
-
- public final static int ER_MIX_OF_GROUP_FUNC_AND_FIELDS = 1140;
-
- public final static int ER_MIXING_NOT_ALLOWED = 1224;
-
- public final static int ER_MULTIPLE_PRI_KEY = 1068;
-
- public final static int ER_NET_ERROR_ON_WRITE = 1160;
-
- public final static int ER_NET_FCNTL_ERROR = 1155;
-
- public final static int ER_NET_PACKET_TOO_LARGE = 1153;
-
- public final static int ER_NET_PACKETS_OUT_OF_ORDER = 1156;
-
- public final static int ER_NET_READ_ERROR = 1158;
-
- public final static int ER_NET_READ_ERROR_FROM_PIPE = 1154;
-
- public final static int ER_NET_READ_INTERRUPTED = 1159;
-
- public final static int ER_NET_UNCOMPRESS_ERROR = 1157;
-
- public final static int ER_NET_WRITE_INTERRUPTED = 1161;
-
- public final static int ER_NEW_ABORTING_CONNECTION = 1184;
-
- public final static int ER_NISAMCHK = 1001;
-
- public final static int ER_NO = 1002;
-
- public final static int ER_NO_DB_ERROR = 1046;
-
- public final static int ER_NO_DEFAULT = 1230;
-
- public final static int ER_NO_PERMISSION_TO_CREATE_USER = 1211;
-
- public final static int ER_NO_RAID_COMPILED = 1174;
-
- public final static int ER_NO_REFERENCED_ROW = 1216;
-
- public final static int ER_NO_SUCH_INDEX = 1082;
-
- public final static int ER_NO_SUCH_TABLE = 1146;
-
- public final static int ER_NO_SUCH_THREAD = 1094;
-
- public final static int ER_NO_TABLES_USED = 1096;
-
- public final static int ER_NO_UNIQUE_LOGFILE = 1098;
-
- public final static int ER_NON_UNIQ_ERROR = 1052;
-
- public final static int ER_NON_UPDATABLE_TABLE = 1288;
-
- public final static int ER_NONEXISTING_GRANT = 1141;
-
- public final static int ER_NONEXISTING_TABLE_GRANT = 1147;
-
- public final static int ER_NONUNIQ_TABLE = 1066;
-
- public final static int ER_NORMAL_SHUTDOWN = 1077;
-
- public final static int ER_NOT_ALLOWED_COMMAND = 1148;
-
- public final static int ER_NOT_FORM_FILE = 1033;
-
- public final static int ER_NOT_KEYFILE = 1034;
-
- public final static int ER_NOT_SUPPORTED_AUTH_MODE = 1251;
-
- public final static int ER_NOT_SUPPORTED_YET = 1235;
-
- public final static int ER_NULL_COLUMN_IN_INDEX = 1121;
-
- public final static int ER_OLD_KEYFILE = 1035;
-
- public final static int ER_OPEN_AS_READONLY = 1036;
-
- public final static int ER_OPERAND_COLUMNS = 1241;
-
- public final static int ER_OPTION_PREVENTS_STATEMENT = 1290;
-
- public final static int ER_OUT_OF_RESOURCES = 1041;
-
- public final static int ER_OUT_OF_SORTMEMORY = 1038;
-
- public final static int ER_OUTOFMEMORY = 1037;
-
- public final static int ER_PARSE_ERROR = 1064;
-
- public final static int ER_PASSWORD_ANONYMOUS_USER = 1131;
-
- public final static int ER_PASSWORD_NO_MATCH = 1133;
-
- public final static int ER_PASSWORD_NOT_ALLOWED = 1132;
-
- public final static int ER_PRIMARY_CANT_HAVE_NULL = 1171;
-
- public final static int ER_QUERY_ON_MASTER = 1219;
-
- public final static int ER_READ_ONLY_TRANSACTION = 1207;
-
- public final static int ER_READY = 1076;
-
- public final static int ER_RECORD_FILE_FULL = 1114;
-
- public final static int ER_REGEXP_ERROR = 1139;
-
- public final static int ER_REQUIRES_PRIMARY_KEY = 1173;
-
- public final static int ER_REVOKE_GRANTS = 1269;
-
- public final static int ER_ROW_IS_REFERENCED = 1217;
-
- public final static int ER_SELECT_REDUCED = 1249;
-
- public final static int ER_SERVER_IS_IN_SECURE_AUTH_MODE = 1275;
-
- public final static int ER_SERVER_SHUTDOWN = 1053;
-
- public final static int ER_SET_CONSTANTS_ONLY = 1204;
-
- public final static int ER_SHUTDOWN_COMPLETE = 1079;
-
- public final static int ER_SLAVE_IGNORED_SSL_PARAMS = 1274;
-
- public final static int ER_SLAVE_IGNORED_TABLE = 1237;
-
- public final static int ER_SLAVE_MUST_STOP = 1198;
-
- public final static int ER_SLAVE_NOT_RUNNING = 1199;
-
- public final static int ER_SLAVE_THREAD = 1202;
-
- public final static int ER_SLAVE_WAS_NOT_RUNNING = 1255;
-
- public final static int ER_SLAVE_WAS_RUNNING = 1254;
-
- public final static int ER_SPATIAL_CANT_HAVE_NULL = 1252;
-
- public final static int ER_SPECIFIC_ACCESS_DENIED_ERROR = 1227;
-
- public final static int ER_STACK_OVERRUN = 1119;
-
- public final static int ER_SUBQUERY_NO_1_ROW = 1242;
-
- public final static int ER_SYNTAX_ERROR = 1149;
-
- public final static int ER_TABLE_CANT_HANDLE_AUTO_INCREMENT = 1164;
-
- public final static int ER_TABLE_CANT_HANDLE_BLOB = 1163;
-
- public final static int ER_TABLE_CANT_HANDLE_FT = 1214;
-
- public final static int ER_TABLE_EXISTS_ERROR = 1050;
-
- public final static int ER_TABLE_MUST_HAVE_COLUMNS = 1113;
-
- public final static int ER_TABLE_NOT_LOCKED = 1100;
-
- public final static int ER_TABLE_NOT_LOCKED_FOR_WRITE = 1099;
-
- public final static int ER_TABLEACCESS_DENIED_ERROR = 1142;
-
- public final static int ER_TABLENAME_NOT_ALLOWED_HERE = 1250;
-
- public final static int ER_TEXTFILE_NOT_READABLE = 1085;
-
- public final static int ER_TOO_BIG_FIELDLENGTH = 1074;
-
- public final static int ER_TOO_BIG_FOR_UNCOMPRESS = 1256;
-
- public final static int ER_TOO_BIG_ROWSIZE = 1118;
-
- public final static int ER_TOO_BIG_SELECT = 1104;
-
- public final static int ER_TOO_BIG_SET = 1097;
-
- public final static int ER_TOO_LONG_IDENT = 1059;
-
- public final static int ER_TOO_LONG_KEY = 1071;
-
- public final static int ER_TOO_LONG_STRING = 1162;
-
- public final static int ER_TOO_MANY_DELAYED_THREADS = 1151;
-
- public final static int ER_TOO_MANY_FIELDS = 1117;
-
- public final static int ER_TOO_MANY_KEY_PARTS = 1070;
-
- public final static int ER_TOO_MANY_KEYS = 1069;
-
- public final static int ER_TOO_MANY_ROWS = 1172;
-
- public final static int ER_TOO_MANY_TABLES = 1116;
-
- public final static int ER_TOO_MANY_USER_CONNECTIONS = 1203;
-
- public final static int ER_TOO_MUCH_AUTO_TIMESTAMP_COLS = 1293;
-
- public final static int ER_TRANS_CACHE_FULL = 1197;
-
- public final static int ER_TRUNCATED_WRONG_VALUE = 1292;
-
- public final static int ER_UDF_EXISTS = 1125;
-
- public final static int ER_UDF_NO_PATHS = 1124;
-
- public final static int ER_UNEXPECTED_EOF = 1039;
-
- public final static int ER_UNION_TABLES_IN_DIFFERENT_DIR = 1212;
-
- public final static int ER_UNKNOWN_CHARACTER_SET = 1115;
-
- public final static int ER_UNKNOWN_COLLATION = 1273;
-
- public final static int ER_UNKNOWN_COM_ERROR = 1047;
-
- public final static int ER_UNKNOWN_ERROR = 1105;
-
- public final static int ER_UNKNOWN_KEY_CACHE = 1284;
-
- public final static int ER_UNKNOWN_PROCEDURE = 1106;
-
- public final static int ER_UNKNOWN_STMT_HANDLER = 1243;
-
- public final static int ER_UNKNOWN_STORAGE_ENGINE = 1286;
-
- public final static int ER_UNKNOWN_SYSTEM_VARIABLE = 1193;
-
- public final static int ER_UNKNOWN_TABLE = 1109;
-
- public final static int ER_UNSUPPORTED_EXTENSION = 1112;
-
- public final static int ER_UNSUPPORTED_PS = 1295;
-
- public final static int ER_UNTIL_COND_IGNORED = 1279;
-
- public final static int ER_UPDATE_INFO = 1134;
-
- public final static int ER_UPDATE_TABLE_USED = 1093;
-
- public final static int ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE = 1175;
-
- public final static int ER_USER_LIMIT_REACHED = 1226;
-
- public final static int ER_VAR_CANT_BE_READ = 1233;
-
- public final static int ER_VARIABLE_IS_NOT_STRUCT = 1272;
-
- public final static int ER_WARN_DATA_OUT_OF_RANGE = 1264;
-
- public final static int ER_WARN_DATA_TRUNCATED = 1265;
-
- public final static int ER_WARN_DEPRECATED_SYNTAX = 1287;
-
- public final static int ER_WARN_FIELD_RESOLVED = 1276;
-
- public final static int ER_WARN_HOSTNAME_WONT_WORK = 1285;
-
- public final static int ER_WARN_NULL_TO_NOTNULL = 1263;
-
- public final static int ER_WARN_QC_RESIZE = 1282;
-
- public final static int ER_WARN_TOO_FEW_RECORDS = 1261;
-
- public final static int ER_WARN_TOO_MANY_RECORDS = 1262;
-
- public final static int ER_WARN_USING_OTHER_HANDLER = 1266;
-
- public final static int ER_WARNING_NOT_COMPLETE_ROLLBACK = 1196;
-
- public final static int ER_WRONG_ARGUMENTS = 1210;
-
- public final static int ER_WRONG_AUTO_KEY = 1075;
-
- public final static int ER_WRONG_COLUMN_NAME = 1166;
-
- public final static int ER_WRONG_DB_NAME = 1102;
-
- public final static int ER_WRONG_FIELD_SPEC = 1063;
-
- public final static int ER_WRONG_FIELD_TERMINATORS = 1083;
-
- public final static int ER_WRONG_FIELD_WITH_GROUP = 1055;
-
- public final static int ER_WRONG_FK_DEF = 1239;
-
- public final static int ER_WRONG_GROUP_FIELD = 1056;
-
- public final static int ER_WRONG_KEY_COLUMN = 1167;
-
- public final static int ER_WRONG_MRG_TABLE = 1168;
-
- public final static int ER_WRONG_NAME_FOR_CATALOG = 1281;
-
- public final static int ER_WRONG_NAME_FOR_INDEX = 1280;
-
- public final static int ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT = 1222;
-
- public final static int ER_WRONG_OUTER_JOIN = 1120;
-
- public final static int ER_WRONG_PARAMCOUNT_TO_PROCEDURE = 1107;
-
- public final static int ER_WRONG_PARAMETERS_TO_PROCEDURE = 1108;
-
- public final static int ER_WRONG_SUB_KEY = 1089;
-
- public final static int ER_WRONG_SUM_SELECT = 1057;
-
- public final static int ER_WRONG_TABLE_NAME = 1103;
-
- public final static int ER_WRONG_TYPE_FOR_VAR = 1232;
-
- public final static int ER_WRONG_USAGE = 1221;
-
- public final static int ER_WRONG_VALUE_COUNT = 1058;
-
- public final static int ER_WRONG_VALUE_COUNT_ON_ROW = 1136;
-
- public final static int ER_WRONG_VALUE_FOR_VAR = 1231;
-
- public final static int ER_XA_RMERR = 1401;
-
- public final static int ER_YES = 1003;
-
- public final static int ER_ZLIB_Z_BUF_ERROR = 1258;
-
- public final static int ER_ZLIB_Z_DATA_ERROR = 1259;
-
- public final static int ER_ZLIB_Z_MEM_ERROR = 1257;
-
- private MysqlErrorNumbers() {
- // prevent instantiation
- }
-}
diff --git a/src/com/mysql/jdbc/MysqlIO.java b/src/com/mysql/jdbc/MysqlIO.java
deleted file mode 100644
index 59530f81b..000000000
--- a/src/com/mysql/jdbc/MysqlIO.java
+++ /dev/null
@@ -1,4652 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.lang.ref.SoftReference;
-import java.math.BigInteger;
-import java.net.ConnectException;
-import java.net.MalformedURLException;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.URL;
-import java.security.NoSuchAlgorithmException;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-import java.util.zip.Deflater;
-
-import com.mysql.jdbc.exceptions.MySQLStatementCancelledException;
-import com.mysql.jdbc.exceptions.MySQLTimeoutException;
-import com.mysql.jdbc.profiler.ProfilerEvent;
-import com.mysql.jdbc.profiler.ProfilerEventHandler;
-import com.mysql.jdbc.profiler.ProfilerEventHandlerFactory;
-import com.mysql.jdbc.util.ReadAheadInputStream;
-import com.mysql.jdbc.util.ResultSetUtil;
-
-
-/**
- * This class is used by Connection for communicating with the MySQL server.
- *
- * @author Mark Matthews
- * @version $Id$
- *
- * @see java.sql.Connection
- */
-class MysqlIO {
- private static final int UTF8_CHARSET_INDEX = 33;
- private static final String CODE_PAGE_1252 = "Cp1252";
- protected static final int NULL_LENGTH = ~0;
- protected static final int COMP_HEADER_LENGTH = 3;
- protected static final int MIN_COMPRESS_LEN = 50;
- protected static final int HEADER_LENGTH = 4;
- protected static final int AUTH_411_OVERHEAD = 33;
- private static int maxBufferSize = 65535;
- private static final int CLIENT_COMPRESS = 32; /* Can use compression
- protcol */
- protected static final int CLIENT_CONNECT_WITH_DB = 8;
- private static final int CLIENT_FOUND_ROWS = 2;
- private static final int CLIENT_LOCAL_FILES = 128; /* Can use LOAD DATA
- LOCAL */
-
- /* Found instead of
- affected rows */
- private static final int CLIENT_LONG_FLAG = 4; /* Get all column flags */
- private static final int CLIENT_LONG_PASSWORD = 1; /* new more secure
- passwords */
- private static final int CLIENT_PROTOCOL_41 = 512; // for > 4.1.1
- private static final int CLIENT_INTERACTIVE = 1024;
- protected static final int CLIENT_SSL = 2048;
- private static final int CLIENT_TRANSACTIONS = 8192; // Client knows about transactions
- protected static final int CLIENT_RESERVED = 16384; // for 4.1.0 only
- protected static final int CLIENT_SECURE_CONNECTION = 32768;
- private static final int CLIENT_MULTI_QUERIES = 65536; // Enable/disable multiquery support
- private static final int CLIENT_MULTI_RESULTS = 131072; // Enable/disable multi-results
- private static final int SERVER_STATUS_IN_TRANS = 1;
- private static final int SERVER_STATUS_AUTOCOMMIT = 2; // Server in auto_commit mode
- static final int SERVER_MORE_RESULTS_EXISTS = 8; // Multi query - next query exists
- private static final int SERVER_QUERY_NO_GOOD_INDEX_USED = 16;
- private static final int SERVER_QUERY_NO_INDEX_USED = 32;
- private static final int SERVER_QUERY_WAS_SLOW = 2048;
- private static final int SERVER_STATUS_CURSOR_EXISTS = 64;
- private static final String FALSE_SCRAMBLE = "xxxxxxxx"; //$NON-NLS-1$
- protected static final int MAX_QUERY_SIZE_TO_LOG = 1024; // truncate logging of queries at 1K
- protected static final int MAX_QUERY_SIZE_TO_EXPLAIN = 1024 * 1024; // don't explain queries above 1MB
- protected static final int INITIAL_PACKET_SIZE = 1024;
- /**
- * We store the platform 'encoding' here, only used to avoid munging
- * filenames for LOAD DATA LOCAL INFILE...
- */
- private static String jvmPlatformCharset = null;
-
- /**
- * We need to have a 'marker' for all-zero datetimes so that ResultSet
- * can decide what to do based on connection setting
- */
- protected final static String ZERO_DATE_VALUE_MARKER = "0000-00-00";
- protected final static String ZERO_DATETIME_VALUE_MARKER = "0000-00-00 00:00:00";
-
- static {
- OutputStreamWriter outWriter = null;
-
- //
- // Use the I/O system to get the encoding (if possible), to avoid
- // security restrictions on System.getProperty("file.encoding") in
- // applets (why is that restricted?)
- //
- try {
- outWriter = new OutputStreamWriter(new ByteArrayOutputStream());
- jvmPlatformCharset = outWriter.getEncoding();
- } finally {
- try {
- if (outWriter != null) {
- outWriter.close();
- }
- } catch (IOException ioEx) {
- // ignore
- }
- }
- }
-
- /** Max number of bytes to dump when tracing the protocol */
- private final static int MAX_PACKET_DUMP_LENGTH = 1024;
- private boolean packetSequenceReset = false;
- protected int serverCharsetIndex;
-
- //
- // Use this when reading in rows to avoid thousands of new()
- // calls, because the byte arrays just get copied out of the
- // packet anyway
- //
- private Buffer reusablePacket = null;
- private Buffer sendPacket = null;
- private Buffer sharedSendPacket = null;
-
- /** Data to the server */
- protected BufferedOutputStream mysqlOutput = null;
- protected ConnectionImpl connection;
- private Deflater deflater = null;
- protected InputStream mysqlInput = null;
- private LinkedList packetDebugRingBuffer = null;
- private RowData streamingData = null;
-
- /** The connection to the server */
- protected Socket mysqlConnection = null;
- private SocketFactory socketFactory = null;
-
- //
- // Packet used for 'LOAD DATA LOCAL INFILE'
- //
- // We use a SoftReference, so that we don't penalize intermittent
- // use of this feature
- //
- private SoftReference loadFileBufRef;
-
- //
- // Used to send large packets to the server versions 4+
- // We use a SoftReference, so that we don't penalize intermittent
- // use of this feature
- //
- private SoftReference splitBufRef;
- protected String host = null;
- protected String seed;
- private String serverVersion = null;
- private String socketFactoryClassName = null;
- private byte[] packetHeaderBuf = new byte[4];
- private boolean colDecimalNeedsBump = false; // do we need to increment the colDecimal flag?
- private boolean hadWarnings = false;
- private boolean has41NewNewProt = false;
-
- /** Does the server support long column info? */
- private boolean hasLongColumnInfo = false;
- private boolean isInteractiveClient = false;
- private boolean logSlowQueries = false;
-
- /**
- * Does the character set of this connection match the character set of the
- * platform
- */
- private boolean platformDbCharsetMatches = true; // changed once we've connected.
- private boolean profileSql = false;
- private boolean queryBadIndexUsed = false;
- private boolean queryNoIndexUsed = false;
- private boolean serverQueryWasSlow = false;
-
- /** Should we use 4.1 protocol extensions? */
- private boolean use41Extensions = false;
- private boolean useCompression = false;
- private boolean useNewLargePackets = false;
- private boolean useNewUpdateCounts = false; // should we use the new larger update counts?
- private byte packetSequence = 0;
- private byte readPacketSequence = -1;
- private boolean checkPacketSequence = false;
- private byte protocolVersion = 0;
- private int maxAllowedPacket = 1024 * 1024;
- protected int maxThreeBytes = 255 * 255 * 255;
- protected int port = 3306;
- protected int serverCapabilities;
- private int serverMajorVersion = 0;
- private int serverMinorVersion = 0;
- private int oldServerStatus = 0;
- private int serverStatus = 0;
- private int serverSubMinorVersion = 0;
- private int warningCount = 0;
- protected long clientParam = 0;
- protected long lastPacketSentTimeMs = 0;
- protected long lastPacketReceivedTimeMs = 0;
- private boolean traceProtocol = false;
- private boolean enablePacketDebug = false;
- private Calendar sessionCalendar;
- private boolean useConnectWithDb;
- private boolean needToGrabQueryFromPacket;
- private boolean autoGenerateTestcaseScript;
- private long threadId;
- private boolean useNanosForElapsedTime;
- private long slowQueryThreshold;
- private String queryTimingUnits;
- private boolean useDirectRowUnpack = true;
- private int useBufferRowSizeThreshold;
- private int commandCount = 0;
- private List statementInterceptors;
- private ExceptionInterceptor exceptionInterceptor;
-
- /**
- * Constructor: Connect to the MySQL server and setup a stream connection.
- *
- * @param host the hostname to connect to
- * @param port the port number that the server is listening on
- * @param props the Properties from DriverManager.getConnection()
- * @param socketFactoryClassName the socket factory to use
- * @param conn the Connection that is creating us
- * @param socketTimeout the timeout to set for the socket (0 means no
- * timeout)
- *
- * @throws IOException if an IOException occurs during connect.
- * @throws SQLException if a database access error occurs.
- */
- public MysqlIO(String host, int port, Properties props,
- String socketFactoryClassName, ConnectionImpl conn,
- int socketTimeout, int useBufferRowSizeThreshold) throws IOException, SQLException {
- this.connection = conn;
-
- if (this.connection.getEnablePacketDebug()) {
- this.packetDebugRingBuffer = new LinkedList();
- }
- this.traceProtocol = this.connection.getTraceProtocol();
-
-
- this.useAutoSlowLog = this.connection.getAutoSlowLog();
-
- this.useBufferRowSizeThreshold = useBufferRowSizeThreshold;
- this.useDirectRowUnpack = this.connection.getUseDirectRowUnpack();
-
- this.logSlowQueries = this.connection.getLogSlowQueries();
-
- this.reusablePacket = new Buffer(INITIAL_PACKET_SIZE);
- this.sendPacket = new Buffer(INITIAL_PACKET_SIZE);
-
- this.port = port;
- this.host = host;
-
- this.socketFactoryClassName = socketFactoryClassName;
- this.socketFactory = createSocketFactory();
- this.exceptionInterceptor = this.connection.getExceptionInterceptor();
-
- try {
- this.mysqlConnection = this.socketFactory.connect(this.host,
- this.port, props);
-
-
- if (socketTimeout != 0) {
- try {
- this.mysqlConnection.setSoTimeout(socketTimeout);
- } catch (Exception ex) {
- /* Ignore if the platform does not support it */
- }
- }
-
- this.mysqlConnection = this.socketFactory.beforeHandshake();
-
- if (this.connection.getUseReadAheadInput()) {
- this.mysqlInput = new ReadAheadInputStream(this.mysqlConnection.getInputStream(), 16384,
- this.connection.getTraceProtocol(),
- this.connection.getLog());
- } else if (this.connection.useUnbufferedInput()) {
- this.mysqlInput = this.mysqlConnection.getInputStream();
- } else {
- this.mysqlInput = new BufferedInputStream(this.mysqlConnection.getInputStream(),
- 16384);
- }
-
- this.mysqlOutput = new BufferedOutputStream(this.mysqlConnection.getOutputStream(),
- 16384);
-
-
- this.isInteractiveClient = this.connection.getInteractiveClient();
- this.profileSql = this.connection.getProfileSql();
- this.sessionCalendar = Calendar.getInstance();
- this.autoGenerateTestcaseScript = this.connection.getAutoGenerateTestcaseScript();
-
- this.needToGrabQueryFromPacket = (this.profileSql ||
- this.logSlowQueries ||
- this.autoGenerateTestcaseScript);
-
- if (this.connection.getUseNanosForElapsedTime()
- && Util.nanoTimeAvailable()) {
- this.useNanosForElapsedTime = true;
-
- this.queryTimingUnits = Messages.getString("Nanoseconds");
- } else {
- this.queryTimingUnits = Messages.getString("Milliseconds");
- }
-
- if (this.connection.getLogSlowQueries()) {
- calculateSlowQueryThreshold();
- }
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection, 0, 0, ioEx, getExceptionInterceptor());
- }
- }
-
- /**
- * Does the server send back extra column info?
- *
- * @return true if so
- */
- public boolean hasLongColumnInfo() {
- return this.hasLongColumnInfo;
- }
-
- protected boolean isDataAvailable() throws SQLException {
- try {
- return this.mysqlInput.available() > 0;
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return Returns the lastPacketSentTimeMs.
- */
- protected long getLastPacketSentTimeMs() {
- return this.lastPacketSentTimeMs;
- }
-
- protected long getLastPacketReceivedTimeMs() {
- return this.lastPacketReceivedTimeMs;
- }
-
- /**
- * Build a result set. Delegates to buildResultSetWithRows() to build a
- * JDBC-version-specific ResultSet, given rows as byte data, and field
- * information.
- *
- * @param callingStatement DOCUMENT ME!
- * @param columnCount the number of columns in the result set
- * @param maxRows the maximum number of rows to read (-1 means all rows)
- * @param resultSetType (TYPE_FORWARD_ONLY, TYPE_SCROLL_????)
- * @param resultSetConcurrency the type of result set (CONCUR_UPDATABLE or
- * READ_ONLY)
- * @param streamResults should the result set be read all at once, or
- * streamed?
- * @param catalog the database name in use when the result set was created
- * @param isBinaryEncoded is this result set in native encoding?
- * @param unpackFieldInfo should we read MYSQL_FIELD info (if available)?
- *
- * @return a result set
- *
- * @throws SQLException if a database access error occurs
- */
- protected ResultSetImpl getResultSet(StatementImpl callingStatement,
- long columnCount, int maxRows, int resultSetType,
- int resultSetConcurrency, boolean streamResults, String catalog,
- boolean isBinaryEncoded, Field[] metadataFromCache)
- throws SQLException {
- Buffer packet; // The packet from the server
- Field[] fields = null;
-
- // Read in the column information
-
- if (metadataFromCache == null /* we want the metadata from the server */) {
- fields = new Field[(int) columnCount];
-
- for (int i = 0; i < columnCount; i++) {
- Buffer fieldPacket = null;
-
- fieldPacket = readPacket();
- fields[i] = unpackField(fieldPacket, false);
- }
- } else {
- for (int i = 0; i < columnCount; i++) {
- skipPacket();
- }
- }
-
- packet = reuseAndReadPacket(this.reusablePacket);
-
- readServerStatusForResultSets(packet);
-
- //
- // Handle cursor-based fetch first
- //
-
- if (this.connection.versionMeetsMinimum(5, 0, 2)
- && this.connection.getUseCursorFetch()
- && isBinaryEncoded
- && callingStatement != null
- && callingStatement.getFetchSize() != 0
- && callingStatement.getResultSetType() == ResultSet.TYPE_FORWARD_ONLY) {
- ServerPreparedStatement prepStmt = (com.mysql.jdbc.ServerPreparedStatement) callingStatement;
-
- boolean usingCursor = true;
-
- //
- // Server versions 5.0.5 or newer will only open
- // a cursor and set this flag if they can, otherwise
- // they punt and go back to mysql_store_results() behavior
- //
-
- if (this.connection.versionMeetsMinimum(5, 0, 5)) {
- usingCursor = (this.serverStatus &
- SERVER_STATUS_CURSOR_EXISTS) != 0;
- }
-
- if (usingCursor) {
- RowData rows = new RowDataCursor(
- this,
- prepStmt,
- fields);
-
- ResultSetImpl rs = buildResultSetWithRows(
- callingStatement,
- catalog,
- fields,
- rows, resultSetType, resultSetConcurrency, isBinaryEncoded);
-
- if (usingCursor) {
- rs.setFetchSize(callingStatement.getFetchSize());
- }
-
- return rs;
- }
- }
-
- RowData rowData = null;
-
- if (!streamResults) {
- rowData = readSingleRowSet(columnCount, maxRows,
- resultSetConcurrency, isBinaryEncoded,
- (metadataFromCache == null) ? fields : metadataFromCache);
- } else {
- rowData = new RowDataDynamic(this, (int) columnCount,
- (metadataFromCache == null) ? fields : metadataFromCache,
- isBinaryEncoded);
- this.streamingData = rowData;
- }
-
- ResultSetImpl rs = buildResultSetWithRows(callingStatement, catalog,
- (metadataFromCache == null) ? fields : metadataFromCache,
- rowData, resultSetType, resultSetConcurrency, isBinaryEncoded);
-
-
-
- return rs;
- }
-
- /**
- * Forcibly closes the underlying socket to MySQL.
- */
- protected final void forceClose() {
- try {
- if (this.mysqlInput != null) {
- this.mysqlInput.close();
- }
- } catch (IOException ioEx) {
- // we can't do anything constructive about this
- // Let the JVM clean it up later
- this.mysqlInput = null;
- }
-
- try {
- if (this.mysqlOutput != null) {
- this.mysqlOutput.close();
- }
- } catch (IOException ioEx) {
- // we can't do anything constructive about this
- // Let the JVM clean it up later
- this.mysqlOutput = null;
- }
-
- try {
- if (this.mysqlConnection != null) {
- this.mysqlConnection.close();
- }
- } catch (IOException ioEx) {
- // we can't do anything constructive about this
- // Let the JVM clean it up later
- this.mysqlConnection = null;
- }
- }
-
- /**
- * Reads and discards a single MySQL packet from the input stream.
- *
- * @throws SQLException if the network fails while skipping the
- * packet.
- */
- protected final void skipPacket() throws SQLException {
- try {
-
- int lengthRead = readFully(this.mysqlInput, this.packetHeaderBuf,
- 0, 4);
-
- if (lengthRead < 4) {
- forceClose();
- throw new IOException(Messages.getString("MysqlIO.1")); //$NON-NLS-1$
- }
-
- int packetLength = (this.packetHeaderBuf[0] & 0xff)
- + ((this.packetHeaderBuf[1] & 0xff) << 8)
- + ((this.packetHeaderBuf[2] & 0xff) << 16);
-
- if (this.traceProtocol) {
- StringBuffer traceMessageBuf = new StringBuffer();
-
- traceMessageBuf.append(Messages.getString("MysqlIO.2")); //$NON-NLS-1$
- traceMessageBuf.append(packetLength);
- traceMessageBuf.append(Messages.getString("MysqlIO.3")); //$NON-NLS-1$
- traceMessageBuf.append(StringUtils.dumpAsHex(
- this.packetHeaderBuf, 4));
-
- this.connection.getLog().logTrace(traceMessageBuf.toString());
- }
-
- byte multiPacketSeq = this.packetHeaderBuf[3];
-
- if (!this.packetSequenceReset) {
- if (this.enablePacketDebug && this.checkPacketSequence) {
- checkPacketSequencing(multiPacketSeq);
- }
- } else {
- this.packetSequenceReset = false;
- }
-
- this.readPacketSequence = multiPacketSeq;
-
- skipFully(this.mysqlInput, packetLength);
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- } catch (OutOfMemoryError oom) {
- try {
- this.connection.realClose(false, false, true, oom);
- } finally {
- throw oom;
- }
- }
- }
-
- /**
- * Read one packet from the MySQL server
- *
- * @return the packet from the server.
- *
- * @throws SQLException DOCUMENT ME!
- * @throws CommunicationsException DOCUMENT ME!
- */
- protected final Buffer readPacket() throws SQLException {
- try {
-
- int lengthRead = readFully(this.mysqlInput,
- this.packetHeaderBuf, 0, 4);
-
- if (lengthRead < 4) {
- forceClose();
- throw new IOException(Messages.getString("MysqlIO.1")); //$NON-NLS-1$
- }
-
- int packetLength = (this.packetHeaderBuf[0] & 0xff) +
- ((this.packetHeaderBuf[1] & 0xff) << 8) +
- ((this.packetHeaderBuf[2] & 0xff) << 16);
-
- if (packetLength > this.maxAllowedPacket) {
- throw new PacketTooBigException(packetLength, this.maxAllowedPacket);
- }
-
- if (this.traceProtocol) {
- StringBuffer traceMessageBuf = new StringBuffer();
-
- traceMessageBuf.append(Messages.getString("MysqlIO.2")); //$NON-NLS-1$
- traceMessageBuf.append(packetLength);
- traceMessageBuf.append(Messages.getString("MysqlIO.3")); //$NON-NLS-1$
- traceMessageBuf.append(StringUtils.dumpAsHex(
- this.packetHeaderBuf, 4));
-
- this.connection.getLog().logTrace(traceMessageBuf.toString());
- }
-
- byte multiPacketSeq = this.packetHeaderBuf[3];
-
- if (!this.packetSequenceReset) {
- if (this.enablePacketDebug && this.checkPacketSequence) {
- checkPacketSequencing(multiPacketSeq);
- }
- } else {
- this.packetSequenceReset = false;
- }
-
- this.readPacketSequence = multiPacketSeq;
-
- // Read data
- byte[] buffer = new byte[packetLength + 1];
- int numBytesRead = readFully(this.mysqlInput, buffer, 0,
- packetLength);
-
- if (numBytesRead != packetLength) {
- throw new IOException("Short read, expected " +
- packetLength + " bytes, only read " + numBytesRead);
- }
-
- buffer[packetLength] = 0;
-
- Buffer packet = new Buffer(buffer);
- packet.setBufLength(packetLength + 1);
-
- if (this.traceProtocol) {
- StringBuffer traceMessageBuf = new StringBuffer();
-
- traceMessageBuf.append(Messages.getString("MysqlIO.4")); //$NON-NLS-1$
- traceMessageBuf.append(getPacketDumpToLog(packet,
- packetLength));
-
- this.connection.getLog().logTrace(traceMessageBuf.toString());
- }
-
- if (this.enablePacketDebug) {
- enqueuePacketForDebugging(false, false, 0,
- this.packetHeaderBuf, packet);
- }
-
- if (this.connection.getMaintainTimeStats()) {
- this.lastPacketReceivedTimeMs = System.currentTimeMillis();
- }
-
- return packet;
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- } catch (OutOfMemoryError oom) {
- try {
- this.connection.realClose(false, false, true, oom);
- } finally {
- throw oom;
- }
- }
- }
-
- /**
- * Unpacks the Field information from the given packet. Understands pre 4.1
- * and post 4.1 server version field packet structures.
- *
- * @param packet the packet containing the field information
- * @param extractDefaultValues should default values be extracted?
- *
- * @return the unpacked field
- *
- * @throws SQLException DOCUMENT ME!
- */
- protected final Field unpackField(Buffer packet,
- boolean extractDefaultValues) throws SQLException {
- if (this.use41Extensions) {
- // we only store the position of the string and
- // materialize only if needed...
- if (this.has41NewNewProt) {
- // Not used yet, 5.0?
- int catalogNameStart = packet.getPosition() + 1;
- int catalogNameLength = packet.fastSkipLenString();
- catalogNameStart = adjustStartForFieldLength(catalogNameStart, catalogNameLength);
- }
-
- int databaseNameStart = packet.getPosition() + 1;
- int databaseNameLength = packet.fastSkipLenString();
- databaseNameStart = adjustStartForFieldLength(databaseNameStart, databaseNameLength);
-
- int tableNameStart = packet.getPosition() + 1;
- int tableNameLength = packet.fastSkipLenString();
- tableNameStart = adjustStartForFieldLength(tableNameStart, tableNameLength);
-
- // orgTableName is never used so skip
- int originalTableNameStart = packet.getPosition() + 1;
- int originalTableNameLength = packet.fastSkipLenString();
- originalTableNameStart = adjustStartForFieldLength(originalTableNameStart, originalTableNameLength);
-
- // we only store the position again...
- int nameStart = packet.getPosition() + 1;
- int nameLength = packet.fastSkipLenString();
-
- nameStart = adjustStartForFieldLength(nameStart, nameLength);
-
- // orgColName is not required so skip...
- int originalColumnNameStart = packet.getPosition() + 1;
- int originalColumnNameLength = packet.fastSkipLenString();
- originalColumnNameStart = adjustStartForFieldLength(originalColumnNameStart, originalColumnNameLength);
-
- packet.readByte();
-
- short charSetNumber = (short) packet.readInt();
-
- long colLength = 0;
-
- if (this.has41NewNewProt) {
- colLength = packet.readLong();
- } else {
- colLength = packet.readLongInt();
- }
-
- int colType = packet.readByte() & 0xff;
-
- short colFlag = 0;
-
- if (this.hasLongColumnInfo) {
- colFlag = (short) packet.readInt();
- } else {
- colFlag = (short) (packet.readByte() & 0xff);
- }
-
- int colDecimals = packet.readByte() & 0xff;
-
- int defaultValueStart = -1;
- int defaultValueLength = -1;
-
- if (extractDefaultValues) {
- defaultValueStart = packet.getPosition() + 1;
- defaultValueLength = packet.fastSkipLenString();
- }
-
- Field field = new Field(this.connection, packet.getByteBuffer(),
- databaseNameStart, databaseNameLength, tableNameStart,
- tableNameLength, originalTableNameStart,
- originalTableNameLength, nameStart, nameLength,
- originalColumnNameStart, originalColumnNameLength,
- colLength, colType, colFlag, colDecimals,
- defaultValueStart, defaultValueLength, charSetNumber);
-
- return field;
- }
-
- int tableNameStart = packet.getPosition() + 1;
- int tableNameLength = packet.fastSkipLenString();
- tableNameStart = adjustStartForFieldLength(tableNameStart, tableNameLength);
-
- int nameStart = packet.getPosition() + 1;
- int nameLength = packet.fastSkipLenString();
- nameStart = adjustStartForFieldLength(nameStart, nameLength);
-
- int colLength = packet.readnBytes();
- int colType = packet.readnBytes();
- packet.readByte(); // We know it's currently 2
-
- short colFlag = 0;
-
- if (this.hasLongColumnInfo) {
- colFlag = (short) (packet.readInt());
- } else {
- colFlag = (short) (packet.readByte() & 0xff);
- }
-
- int colDecimals = (packet.readByte() & 0xff);
-
- if (this.colDecimalNeedsBump) {
- colDecimals++;
- }
-
- Field field = new Field(this.connection, packet.getByteBuffer(),
- nameStart, nameLength, tableNameStart, tableNameLength,
- colLength, colType, colFlag, colDecimals);
-
- return field;
- }
-
- private int adjustStartForFieldLength(int nameStart, int nameLength) {
- if (nameLength < 251) {
- return nameStart;
- }
-
- if (nameLength >= 251 && nameLength < 65536) {
- return nameStart + 2;
- }
-
- if (nameLength >= 65536 && nameLength < 16777216) {
- return nameStart + 3;
- }
-
- return nameStart + 8;
- }
-
- protected boolean isSetNeededForAutoCommitMode(boolean autoCommitFlag) {
- if (this.use41Extensions && this.connection.getElideSetAutoCommits()) {
- boolean autoCommitModeOnServer = ((this.serverStatus &
- SERVER_STATUS_AUTOCOMMIT) != 0);
-
- if (!autoCommitFlag && versionMeetsMinimum(5, 0, 0)) {
- // Just to be safe, check if a transaction is in progress on the server....
- // if so, then we must be in autoCommit == false
- // therefore return the opposite of transaction status
- boolean inTransactionOnServer = ((this.serverStatus &
- SERVER_STATUS_IN_TRANS) != 0);
-
- return !inTransactionOnServer;
- }
-
- return autoCommitModeOnServer != autoCommitFlag;
- }
-
- return true;
- }
-
- protected boolean inTransactionOnServer() {
- return (this.serverStatus & SERVER_STATUS_IN_TRANS) != 0;
- }
-
- /**
- * Re-authenticates as the given user and password
- *
- * @param userName DOCUMENT ME!
- * @param password DOCUMENT ME!
- * @param database DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- protected void changeUser(String userName, String password, String database)
- throws SQLException {
- this.packetSequence = -1;
-
- int passwordLength = 16;
- int userLength = (userName != null) ? userName.length() : 0;
- int databaseLength = (database != null) ? database.length() : 0;
-
- int packLength = ((userLength + passwordLength + databaseLength) * 2) + 7 + HEADER_LENGTH + AUTH_411_OVERHEAD;
-
- if ((this.serverCapabilities & CLIENT_SECURE_CONNECTION) != 0) {
- Buffer changeUserPacket = new Buffer(packLength + 1);
- changeUserPacket.writeByte((byte) MysqlDefs.COM_CHANGE_USER);
-
- if (versionMeetsMinimum(4, 1, 1)) {
- secureAuth411(changeUserPacket, packLength, userName, password,
- database, false);
- } else {
- secureAuth(changeUserPacket, packLength, userName, password,
- database, false);
- }
- } else {
- // Passwords can be 16 chars long
- Buffer packet = new Buffer(packLength);
- packet.writeByte((byte) MysqlDefs.COM_CHANGE_USER);
-
- // User/Password data
- packet.writeString(userName);
-
- if (this.protocolVersion > 9) {
- packet.writeString(Util.newCrypt(password, this.seed));
- } else {
- packet.writeString(Util.oldCrypt(password, this.seed));
- }
-
- boolean localUseConnectWithDb = this.useConnectWithDb &&
- (database != null && database.length() > 0);
-
- if (localUseConnectWithDb) {
- packet.writeString(database);
- }
-
- send(packet, packet.getPosition());
- checkErrorPacket();
-
- if (!localUseConnectWithDb) {
- changeDatabaseTo(database);
- }
- }
- }
-
- /**
- * Checks for errors in the reply packet, and if none, returns the reply
- * packet, ready for reading
- *
- * @return a packet ready for reading.
- *
- * @throws SQLException is the packet is an error packet
- */
- protected Buffer checkErrorPacket() throws SQLException {
- return checkErrorPacket(-1);
- }
-
- /**
- * Determines if the database charset is the same as the platform charset
- */
- protected void checkForCharsetMismatch() {
- if (this.connection.getUseUnicode() &&
- (this.connection.getEncoding() != null)) {
- String encodingToCheck = jvmPlatformCharset;
-
- if (encodingToCheck == null) {
- encodingToCheck = System.getProperty("file.encoding"); //$NON-NLS-1$
- }
-
- if (encodingToCheck == null) {
- this.platformDbCharsetMatches = false;
- } else {
- this.platformDbCharsetMatches = encodingToCheck.equals(this.connection.getEncoding());
- }
- }
- }
-
- protected void clearInputStream() throws SQLException {
-
- try {
- int len = this.mysqlInput.available();
-
- while (len > 0) {
- this.mysqlInput.skip(len);
- len = this.mysqlInput.available();
- }
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- }
- }
-
- protected void resetReadPacketSequence() {
- this.readPacketSequence = 0;
- }
-
- protected void dumpPacketRingBuffer() throws SQLException {
- if ((this.packetDebugRingBuffer != null) &&
- this.connection.getEnablePacketDebug()) {
- StringBuffer dumpBuffer = new StringBuffer();
-
- dumpBuffer.append("Last " + this.packetDebugRingBuffer.size() +
- " packets received from server, from oldest->newest:\n");
- dumpBuffer.append("\n");
-
- for (Iterator ringBufIter = this.packetDebugRingBuffer.iterator();
- ringBufIter.hasNext();) {
- dumpBuffer.append((StringBuffer) ringBufIter.next());
- dumpBuffer.append("\n");
- }
-
- this.connection.getLog().logTrace(dumpBuffer.toString());
- }
- }
-
- /**
- * Runs an 'EXPLAIN' on the given query and dumps the results to the log
- *
- * @param querySQL DOCUMENT ME!
- * @param truncatedQuery DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- protected void explainSlowQuery(byte[] querySQL, String truncatedQuery)
- throws SQLException {
- if (StringUtils.startsWithIgnoreCaseAndWs(truncatedQuery, "SELECT")) { //$NON-NLS-1$
-
- PreparedStatement stmt = null;
- java.sql.ResultSet rs = null;
-
- try {
- stmt = (PreparedStatement) this.connection.clientPrepareStatement("EXPLAIN ?"); //$NON-NLS-1$
- stmt.setBytesNoEscapeNoQuotes(1, querySQL);
- rs = stmt.executeQuery();
-
- StringBuffer explainResults = new StringBuffer(Messages.getString(
- "MysqlIO.8") + truncatedQuery //$NON-NLS-1$
- +Messages.getString("MysqlIO.9")); //$NON-NLS-1$
-
- ResultSetUtil.appendResultSetSlashGStyle(explainResults, rs);
-
- this.connection.getLog().logWarn(explainResults.toString());
- } catch (SQLException sqlEx) {
- } finally {
- if (rs != null) {
- rs.close();
- }
-
- if (stmt != null) {
- stmt.close();
- }
- }
- } else {
- }
- }
-
- static int getMaxBuf() {
- return maxBufferSize;
- }
-
- /**
- * Get the major version of the MySQL server we are talking to.
- *
- * @return DOCUMENT ME!
- */
- final int getServerMajorVersion() {
- return this.serverMajorVersion;
- }
-
- /**
- * Get the minor version of the MySQL server we are talking to.
- *
- * @return DOCUMENT ME!
- */
- final int getServerMinorVersion() {
- return this.serverMinorVersion;
- }
-
- /**
- * Get the sub-minor version of the MySQL server we are talking to.
- *
- * @return DOCUMENT ME!
- */
- final int getServerSubMinorVersion() {
- return this.serverSubMinorVersion;
- }
-
- /**
- * Get the version string of the server we are talking to
- *
- * @return DOCUMENT ME!
- */
- String getServerVersion() {
- return this.serverVersion;
- }
-
- /**
- * Initialize communications with the MySQL server. Handles logging on, and
- * handling initial connection errors.
- *
- * @param user DOCUMENT ME!
- * @param password DOCUMENT ME!
- * @param database DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- * @throws CommunicationsException DOCUMENT ME!
- */
- void doHandshake(String user, String password, String database)
- throws SQLException {
- // Read the first packet
- this.checkPacketSequence = false;
- this.readPacketSequence = 0;
-
- Buffer buf = readPacket();
-
- // Get the protocol version
- this.protocolVersion = buf.readByte();
-
- if (this.protocolVersion == -1) {
- try {
- this.mysqlConnection.close();
- } catch (Exception e) {
- // ignore
- }
-
- int errno = 2000;
-
- errno = buf.readInt();
-
- String serverErrorMessage = buf.readString("ASCII", getExceptionInterceptor());
-
- StringBuffer errorBuf = new StringBuffer(Messages.getString(
- "MysqlIO.10")); //$NON-NLS-1$
- errorBuf.append(serverErrorMessage);
- errorBuf.append("\""); //$NON-NLS-1$
-
- String xOpen = SQLError.mysqlToSqlState(errno,
- this.connection.getUseSqlStateCodes());
-
- throw SQLError.createSQLException(SQLError.get(xOpen) + ", " //$NON-NLS-1$
- +errorBuf.toString(), xOpen, errno, getExceptionInterceptor());
- }
-
- this.serverVersion = buf.readString("ASCII", getExceptionInterceptor());
-
- // Parse the server version into major/minor/subminor
- int point = this.serverVersion.indexOf('.'); //$NON-NLS-1$
-
- if (point != -1) {
- try {
- int n = Integer.parseInt(this.serverVersion.substring(0, point));
- this.serverMajorVersion = n;
- } catch (NumberFormatException NFE1) {
- // ignore
- }
-
- String remaining = this.serverVersion.substring(point + 1,
- this.serverVersion.length());
- point = remaining.indexOf('.'); //$NON-NLS-1$
-
- if (point != -1) {
- try {
- int n = Integer.parseInt(remaining.substring(0, point));
- this.serverMinorVersion = n;
- } catch (NumberFormatException nfe) {
- // ignore
- }
-
- remaining = remaining.substring(point + 1, remaining.length());
-
- int pos = 0;
-
- while (pos < remaining.length()) {
- if ((remaining.charAt(pos) < '0') ||
- (remaining.charAt(pos) > '9')) {
- break;
- }
-
- pos++;
- }
-
- try {
- int n = Integer.parseInt(remaining.substring(0, pos));
- this.serverSubMinorVersion = n;
- } catch (NumberFormatException nfe) {
- // ignore
- }
- }
- }
-
- if (versionMeetsMinimum(4, 0, 8)) {
- this.maxThreeBytes = (256 * 256 * 256) - 1;
- this.useNewLargePackets = true;
- } else {
- this.maxThreeBytes = 255 * 255 * 255;
- this.useNewLargePackets = false;
- }
-
- this.colDecimalNeedsBump = versionMeetsMinimum(3, 23, 0);
- this.colDecimalNeedsBump = !versionMeetsMinimum(3, 23, 15); // guess? Not noted in changelog
- this.useNewUpdateCounts = versionMeetsMinimum(3, 22, 5);
-
- threadId = buf.readLong();
- this.seed = buf.readString("ASCII", getExceptionInterceptor());
-
- this.serverCapabilities = 0;
-
- if (buf.getPosition() < buf.getBufLength()) {
- this.serverCapabilities = buf.readInt();
- }
-
- if (versionMeetsMinimum(4, 1, 1)) {
- int position = buf.getPosition();
-
- /* New protocol with 16 bytes to describe server characteristics */
- this.serverCharsetIndex = buf.readByte() & 0xff;
- this.serverStatus = buf.readInt();
- checkTransactionState(0);
- buf.setPosition(position + 16);
-
- String seedPart2 = buf.readString("ASCII", getExceptionInterceptor());
- StringBuffer newSeed = new StringBuffer(20);
- newSeed.append(this.seed);
- newSeed.append(seedPart2);
- this.seed = newSeed.toString();
- }
-
- if (((this.serverCapabilities & CLIENT_COMPRESS) != 0) &&
- this.connection.getUseCompression()) {
- this.clientParam |= CLIENT_COMPRESS;
- }
-
- this.useConnectWithDb = (database != null) &&
- (database.length() > 0) &&
- !this.connection.getCreateDatabaseIfNotExist();
-
- if (this.useConnectWithDb) {
- this.clientParam |= CLIENT_CONNECT_WITH_DB;
- }
-
- if (((this.serverCapabilities & CLIENT_SSL) == 0) &&
- this.connection.getUseSSL()) {
- if (this.connection.getRequireSSL()) {
- this.connection.close();
- forceClose();
- throw SQLError.createSQLException(Messages.getString("MysqlIO.15"), //$NON-NLS-1$
- SQLError.SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE, getExceptionInterceptor());
- }
-
- this.connection.setUseSSL(false);
- }
-
- if ((this.serverCapabilities & CLIENT_LONG_FLAG) != 0) {
- // We understand other column flags, as well
- this.clientParam |= CLIENT_LONG_FLAG;
- this.hasLongColumnInfo = true;
- }
-
- // return FOUND rows
- if (!this.connection.getUseAffectedRows()) {
- this.clientParam |= CLIENT_FOUND_ROWS;
- }
-
- if (this.connection.getAllowLoadLocalInfile()) {
- this.clientParam |= CLIENT_LOCAL_FILES;
- }
-
- if (this.isInteractiveClient) {
- this.clientParam |= CLIENT_INTERACTIVE;
- }
-
- // Authenticate
- if (this.protocolVersion > 9) {
- this.clientParam |= CLIENT_LONG_PASSWORD; // for long passwords
- } else {
- this.clientParam &= ~CLIENT_LONG_PASSWORD;
- }
-
- //
- // 4.1 has some differences in the protocol
- //
- if (versionMeetsMinimum(4, 1, 0)) {
- if (versionMeetsMinimum(4, 1, 1)) {
- this.clientParam |= CLIENT_PROTOCOL_41;
- this.has41NewNewProt = true;
-
- // Need this to get server status values
- this.clientParam |= CLIENT_TRANSACTIONS;
-
- // We always allow multiple result sets
- this.clientParam |= CLIENT_MULTI_RESULTS;
-
- // We allow the user to configure whether
- // or not they want to support multiple queries
- // (by default, this is disabled).
- if (this.connection.getAllowMultiQueries()) {
- this.clientParam |= CLIENT_MULTI_QUERIES;
- }
- } else {
- this.clientParam |= CLIENT_RESERVED;
- this.has41NewNewProt = false;
- }
-
- this.use41Extensions = true;
- }
-
- int passwordLength = 16;
- int userLength = (user != null) ? user.length() : 0;
- int databaseLength = (database != null) ? database.length() : 0;
-
- int packLength = ((userLength + passwordLength + databaseLength) * 2) + 7 + HEADER_LENGTH + AUTH_411_OVERHEAD;
-
- Buffer packet = null;
-
- if (!this.connection.getUseSSL()) {
- if ((this.serverCapabilities & CLIENT_SECURE_CONNECTION) != 0) {
- this.clientParam |= CLIENT_SECURE_CONNECTION;
-
- if (versionMeetsMinimum(4, 1, 1)) {
- secureAuth411(null, packLength, user, password, database,
- true);
- } else {
- secureAuth(null, packLength, user, password, database, true);
- }
- } else {
- // Passwords can be 16 chars long
- packet = new Buffer(packLength);
-
- if ((this.clientParam & CLIENT_RESERVED) != 0) {
- if (versionMeetsMinimum(4, 1, 1)) {
- packet.writeLong(this.clientParam);
- packet.writeLong(this.maxThreeBytes);
-
- // charset, JDBC will connect as 'latin1',
- // and use 'SET NAMES' to change to the desired
- // charset after the connection is established.
- packet.writeByte((byte) 8);
-
- // Set of bytes reserved for future use.
- packet.writeBytesNoNull(new byte[23]);
- } else {
- packet.writeLong(this.clientParam);
- packet.writeLong(this.maxThreeBytes);
- }
- } else {
- packet.writeInt((int) this.clientParam);
- packet.writeLongInt(this.maxThreeBytes);
- }
-
- // User/Password data
- packet.writeString(user, CODE_PAGE_1252, this.connection);
-
- if (this.protocolVersion > 9) {
- packet.writeString(Util.newCrypt(password, this.seed), CODE_PAGE_1252, this.connection);
- } else {
- packet.writeString(Util.oldCrypt(password, this.seed), CODE_PAGE_1252, this.connection);
- }
-
- if (this.useConnectWithDb) {
- packet.writeString(database, CODE_PAGE_1252, this.connection);
- }
-
- send(packet, packet.getPosition());
- }
- } else {
- negotiateSSLConnection(user, password, database, packLength);
- }
-
- // Check for errors, not for 4.1.1 or newer,
- // as the new auth protocol doesn't work that way
- // (see secureAuth411() for more details...)
- if (!versionMeetsMinimum(4, 1, 1)) {
- checkErrorPacket();
- }
-
- //
- // Can't enable compression until after handshake
- //
- if (((this.serverCapabilities & CLIENT_COMPRESS) != 0) &&
- this.connection.getUseCompression()) {
- // The following matches with ZLIB's
- // compress()
- this.deflater = new Deflater();
- this.useCompression = true;
- this.mysqlInput = new CompressedInputStream(this.connection,
- this.mysqlInput);
- }
-
- if (!this.useConnectWithDb) {
- changeDatabaseTo(database);
- }
-
- try {
- this.mysqlConnection = this.socketFactory.afterHandshake();
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection, this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- }
- }
-
- private void changeDatabaseTo(String database) throws SQLException {
- if (database == null || database.length() == 0) {
- return;
- }
-
- try {
- sendCommand(MysqlDefs.INIT_DB, database, null, false, null, 0);
- } catch (Exception ex) {
- if (this.connection.getCreateDatabaseIfNotExist()) {
- sendCommand(MysqlDefs.QUERY, "CREATE DATABASE IF NOT EXISTS " +
- database,
- null, false, null, 0);
- sendCommand(MysqlDefs.INIT_DB, database, null, false, null, 0);
- } else {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ex, getExceptionInterceptor());
- }
- }
- }
-
- /**
- * Retrieve one row from the MySQL server. Note: this method is not
- * thread-safe, but it is only called from methods that are guarded by
- * synchronizing on this object.
- *
- * @param fields DOCUMENT ME!
- * @param columnCount DOCUMENT ME!
- * @param isBinaryEncoded DOCUMENT ME!
- * @param resultSetConcurrency DOCUMENT ME!
- * @param b
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- final ResultSetRow nextRow(Field[] fields, int columnCount,
- boolean isBinaryEncoded, int resultSetConcurrency,
- boolean useBufferRowIfPossible,
- boolean useBufferRowExplicit,
- boolean canReuseRowPacketForBufferRow, Buffer existingRowPacket)
- throws SQLException {
-
- if (this.useDirectRowUnpack && existingRowPacket == null
- && !isBinaryEncoded && !useBufferRowIfPossible
- && !useBufferRowExplicit) {
- return nextRowFast(fields, columnCount, isBinaryEncoded, resultSetConcurrency,
- useBufferRowIfPossible, useBufferRowExplicit, canReuseRowPacketForBufferRow);
- }
-
- Buffer rowPacket = null;
-
- if (existingRowPacket == null) {
- rowPacket = checkErrorPacket();
-
- if (!useBufferRowExplicit && useBufferRowIfPossible) {
- if (rowPacket.getBufLength() > this.useBufferRowSizeThreshold) {
- useBufferRowExplicit = true;
- }
- }
- } else {
- // We attempted to do nextRowFast(), but the packet was a
- // multipacket, so we couldn't unpack it directly
- rowPacket = existingRowPacket;
- checkErrorPacket(existingRowPacket);
- }
-
-
- if (!isBinaryEncoded) {
- //
- // Didn't read an error, so re-position to beginning
- // of packet in order to read result set data
- //
- rowPacket.setPosition(rowPacket.getPosition() - 1);
-
- if (!rowPacket.isLastDataPacket()) {
- if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE
- || (!useBufferRowIfPossible && !useBufferRowExplicit)) {
-
- byte[][] rowData = new byte[columnCount][];
-
- for (int i = 0; i < columnCount; i++) {
- rowData[i] = rowPacket.readLenByteArray(0);
- }
-
- return new ByteArrayRow(rowData, getExceptionInterceptor());
- }
-
- if (!canReuseRowPacketForBufferRow) {
- this.reusablePacket = new Buffer(rowPacket.getBufLength());
- }
-
- return new BufferRow(rowPacket, fields, false, getExceptionInterceptor());
-
- }
-
- readServerStatusForResultSets(rowPacket);
-
- return null;
- }
-
- //
- // Handle binary-encoded data for server-side
- // PreparedStatements...
- //
- if (!rowPacket.isLastDataPacket()) {
- if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE
- || (!useBufferRowIfPossible && !useBufferRowExplicit)) {
- return unpackBinaryResultSetRow(fields, rowPacket,
- resultSetConcurrency);
- }
-
- if (!canReuseRowPacketForBufferRow) {
- this.reusablePacket = new Buffer(rowPacket.getBufLength());
- }
-
- return new BufferRow(rowPacket, fields, true, getExceptionInterceptor());
- }
-
- rowPacket.setPosition(rowPacket.getPosition() - 1);
- readServerStatusForResultSets(rowPacket);
-
- return null;
- }
-
- final ResultSetRow nextRowFast(Field[] fields, int columnCount,
- boolean isBinaryEncoded, int resultSetConcurrency,
- boolean useBufferRowIfPossible,
- boolean useBufferRowExplicit, boolean canReuseRowPacket)
- throws SQLException {
- try {
- int lengthRead = readFully(this.mysqlInput, this.packetHeaderBuf,
- 0, 4);
-
- if (lengthRead < 4) {
- forceClose();
- throw new RuntimeException(Messages.getString("MysqlIO.43")); //$NON-NLS-1$
- }
-
- int packetLength = (this.packetHeaderBuf[0] & 0xff)
- + ((this.packetHeaderBuf[1] & 0xff) << 8)
- + ((this.packetHeaderBuf[2] & 0xff) << 16);
-
- // Have we stumbled upon a multi-packet?
- if (packetLength == this.maxThreeBytes) {
- reuseAndReadPacket(this.reusablePacket, packetLength);
-
- // Go back to "old" way which uses packets
- return nextRow(fields, columnCount, isBinaryEncoded, resultSetConcurrency,
- useBufferRowIfPossible, useBufferRowExplicit,
- canReuseRowPacket, this.reusablePacket);
- }
-
- // Does this go over the threshold where we should use a BufferRow?
-
- if (packetLength > this.useBufferRowSizeThreshold) {
- reuseAndReadPacket(this.reusablePacket, packetLength);
-
- // Go back to "old" way which uses packets
- return nextRow(fields, columnCount, isBinaryEncoded, resultSetConcurrency,
- true, true,
- false, this.reusablePacket);
- }
-
- int remaining = packetLength;
-
- boolean firstTime = true;
-
- byte[][] rowData = null;
-
- for (int i = 0; i < columnCount; i++) {
-
- int sw = this.mysqlInput.read() & 0xff;
- remaining--;
-
- if (firstTime) {
- if (sw == 255) {
- // error packet - we assemble it whole for "fidelity"
- // in case we ever need an entire packet in checkErrorPacket()
- // but we could've gotten away with just writing the error code
- // and message in it (for now).
- Buffer errorPacket = new Buffer(packetLength + HEADER_LENGTH);
- errorPacket.setPosition(0);
- errorPacket.writeByte(this.packetHeaderBuf[0]);
- errorPacket.writeByte(this.packetHeaderBuf[1]);
- errorPacket.writeByte(this.packetHeaderBuf[2]);
- errorPacket.writeByte((byte) 1);
- errorPacket.writeByte((byte)sw);
- readFully(this.mysqlInput, errorPacket.getByteBuffer(), 5, packetLength - 1);
- errorPacket.setPosition(4);
- checkErrorPacket(errorPacket);
- }
-
- if (sw == 254 && packetLength < 9) {
- if (this.use41Extensions) {
- this.warningCount = (this.mysqlInput.read() & 0xff)
- | ((this.mysqlInput.read() & 0xff) << 8);
- remaining -= 2;
-
- if (this.warningCount > 0) {
- this.hadWarnings = true; // this is a
- // 'latch', it's
- // reset by
- // sendCommand()
- }
-
- this.oldServerStatus = this.serverStatus;
-
- this.serverStatus = (this.mysqlInput.read() & 0xff)
- | ((this.mysqlInput.read() & 0xff) << 8);
- checkTransactionState(oldServerStatus);
-
- remaining -= 2;
-
- if (remaining > 0) {
- skipFully(this.mysqlInput, remaining);
- }
- }
-
- return null; // last data packet
- }
-
- rowData = new byte[columnCount][];
-
- firstTime = false;
- }
-
- int len = 0;
-
- switch (sw) {
- case 251:
- len = NULL_LENGTH;
- break;
-
- case 252:
- len = (this.mysqlInput.read() & 0xff)
- | ((this.mysqlInput.read() & 0xff) << 8);
- remaining -= 2;
- break;
-
- case 253:
- len = (this.mysqlInput.read() & 0xff)
- | ((this.mysqlInput.read() & 0xff) << 8)
- | ((this.mysqlInput.read() & 0xff) << 16);
-
- remaining -= 3;
- break;
-
- case 254:
- len = (int) ((this.mysqlInput.read() & 0xff)
- | ((long) (this.mysqlInput.read() & 0xff) << 8)
- | ((long) (this.mysqlInput.read() & 0xff) << 16)
- | ((long) (this.mysqlInput.read() & 0xff) << 24)
- | ((long) (this.mysqlInput.read() & 0xff) << 32)
- | ((long) (this.mysqlInput.read() & 0xff) << 40)
- | ((long) (this.mysqlInput.read() & 0xff) << 48)
- | ((long) (this.mysqlInput.read() & 0xff) << 56));
- remaining -= 8;
- break;
-
- default:
- len = sw;
- }
-
- if (len == NULL_LENGTH) {
- rowData[i] = null;
- } else if (len == 0) {
- rowData[i] = Constants.EMPTY_BYTE_ARRAY;
- } else {
- rowData[i] = new byte[len];
-
- int bytesRead = readFully(this.mysqlInput, rowData[i], 0,
- len);
-
- if (bytesRead != len) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs,
- new IOException(Messages.getString("MysqlIO.43")), getExceptionInterceptor());
- }
-
- remaining -= bytesRead;
- }
- }
-
- if (remaining > 0) {
- skipFully(this.mysqlInput, remaining);
- }
-
- return new ByteArrayRow(rowData, getExceptionInterceptor());
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- }
- }
-
- /**
- * Log-off of the MySQL server and close the socket.
- *
- * @throws SQLException DOCUMENT ME!
- */
- final void quit() throws SQLException {
- Buffer packet = new Buffer(6);
- this.packetSequence = -1;
- packet.writeByte((byte) MysqlDefs.QUIT);
- send(packet, packet.getPosition());
- forceClose();
- }
-
- /**
- * Returns the packet used for sending data (used by PreparedStatement)
- * Guarded by external synchronization on a mutex.
- *
- * @return A packet to send data with
- */
- Buffer getSharedSendPacket() {
- if (this.sharedSendPacket == null) {
- this.sharedSendPacket = new Buffer(INITIAL_PACKET_SIZE);
- }
-
- return this.sharedSendPacket;
- }
-
- void closeStreamer(RowData streamer) throws SQLException {
- if (this.streamingData == null) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.17") //$NON-NLS-1$
- +streamer + Messages.getString("MysqlIO.18"), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (streamer != this.streamingData) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.19") //$NON-NLS-1$
- +streamer + Messages.getString("MysqlIO.20") //$NON-NLS-1$
- +Messages.getString("MysqlIO.21") //$NON-NLS-1$
- +Messages.getString("MysqlIO.22"), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- this.streamingData = null;
- }
-
- boolean tackOnMoreStreamingResults(ResultSetImpl addingTo) throws SQLException {
- if ((this.serverStatus & SERVER_MORE_RESULTS_EXISTS) != 0) {
-
- boolean moreRowSetsExist = true;
- ResultSetImpl currentResultSet = addingTo;
- boolean firstTime = true;
-
- while (moreRowSetsExist) {
- if (!firstTime && currentResultSet.reallyResult()) {
- break;
- }
-
- firstTime = false;
-
- Buffer fieldPacket = checkErrorPacket();
- fieldPacket.setPosition(0);
-
- java.sql.Statement owningStatement = addingTo.getStatement();
-
- int maxRows = owningStatement.getMaxRows();
-
- // fixme for catalog, isBinary
-
- ResultSetImpl newResultSet = readResultsForQueryOrUpdate(
- (StatementImpl)owningStatement,
- maxRows, owningStatement.getResultSetType(),
- owningStatement.getResultSetConcurrency(),
- true, owningStatement.getConnection().getCatalog(), fieldPacket,
- addingTo.isBinaryEncoded,
- -1L, null);
-
- currentResultSet.setNextResultSet(newResultSet);
-
- currentResultSet = newResultSet;
-
- moreRowSetsExist = (this.serverStatus & MysqlIO.SERVER_MORE_RESULTS_EXISTS) != 0;
-
- if (!currentResultSet.reallyResult() && !moreRowSetsExist) {
- // special case, we can stop "streaming"
- return false;
- }
- }
-
- return true;
- }
-
- return false;
- }
-
- ResultSetImpl readAllResults(StatementImpl callingStatement, int maxRows,
- int resultSetType, int resultSetConcurrency, boolean streamResults,
- String catalog, Buffer resultPacket, boolean isBinaryEncoded,
- long preSentColumnCount, Field[] metadataFromCache)
- throws SQLException {
- resultPacket.setPosition(resultPacket.getPosition() - 1);
-
- ResultSetImpl topLevelResultSet = readResultsForQueryOrUpdate(callingStatement,
- maxRows, resultSetType, resultSetConcurrency, streamResults,
- catalog, resultPacket, isBinaryEncoded, preSentColumnCount,
- metadataFromCache);
-
- ResultSetImpl currentResultSet = topLevelResultSet;
-
- boolean checkForMoreResults = ((this.clientParam &
- CLIENT_MULTI_RESULTS) != 0);
-
- boolean serverHasMoreResults = (this.serverStatus &
- SERVER_MORE_RESULTS_EXISTS) != 0;
-
- //
- // TODO: We need to support streaming of multiple result sets
- //
- if (serverHasMoreResults && streamResults) {
- //clearInputStream();
-//
- //throw SQLError.createSQLException(Messages.getString("MysqlIO.23"), //$NON-NLS-1$
- //SQLError.SQL_STATE_DRIVER_NOT_CAPABLE);
- if (topLevelResultSet.getUpdateCount() != -1) {
- tackOnMoreStreamingResults(topLevelResultSet);
- }
-
- reclaimLargeReusablePacket();
-
- return topLevelResultSet;
- }
-
- boolean moreRowSetsExist = checkForMoreResults & serverHasMoreResults;
-
- while (moreRowSetsExist) {
- Buffer fieldPacket = checkErrorPacket();
- fieldPacket.setPosition(0);
-
- ResultSetImpl newResultSet = readResultsForQueryOrUpdate(callingStatement,
- maxRows, resultSetType, resultSetConcurrency,
- streamResults, catalog, fieldPacket, isBinaryEncoded,
- preSentColumnCount, metadataFromCache);
-
- currentResultSet.setNextResultSet(newResultSet);
-
- currentResultSet = newResultSet;
-
- moreRowSetsExist = (this.serverStatus & SERVER_MORE_RESULTS_EXISTS) != 0;
- }
-
- if (!streamResults) {
- clearInputStream();
- }
-
- reclaimLargeReusablePacket();
-
- return topLevelResultSet;
- }
-
- /**
- * Sets the buffer size to max-buf
- */
- void resetMaxBuf() {
- this.maxAllowedPacket = this.connection.getMaxAllowedPacket();
- }
-
- /**
- * Send a command to the MySQL server If data is to be sent with command,
- * it should be put in extraData.
- *
- * Raw packets can be sent by setting queryPacket to something other
- * than null.
- *
- * @param command the MySQL protocol 'command' from MysqlDefs
- * @param extraData any 'string' data for the command
- * @param queryPacket a packet pre-loaded with data for the protocol (i.e.
- * from a client-side prepared statement).
- * @param skipCheck do not call checkErrorPacket() if true
- * @param extraDataCharEncoding the character encoding of the extraData
- * parameter.
- *
- * @return the response packet from the server
- *
- * @throws SQLException if an I/O error or SQL error occurs
- */
-
- final Buffer sendCommand(int command, String extraData, Buffer queryPacket,
- boolean skipCheck, String extraDataCharEncoding, int timeoutMillis)
- throws SQLException {
- this.commandCount++;
-
- //
- // We cache these locally, per-command, as the checks
- // for them are in very 'hot' sections of the I/O code
- // and we save 10-15% in overall performance by doing this...
- //
- this.enablePacketDebug = this.connection.getEnablePacketDebug();
- this.readPacketSequence = 0;
-
- int oldTimeout = 0;
-
- if (timeoutMillis != 0) {
- try {
- oldTimeout = this.mysqlConnection.getSoTimeout();
- this.mysqlConnection.setSoTimeout(timeoutMillis);
- } catch (SocketException e) {
- throw SQLError.createCommunicationsException(this.connection, lastPacketSentTimeMs,
- lastPacketReceivedTimeMs, e, getExceptionInterceptor());
- }
- }
-
- try {
-
- checkForOutstandingStreamingData();
-
- // Clear serverStatus...this value is guarded by an
- // external mutex, as you can only ever be processing
- // one command at a time
- this.oldServerStatus = this.serverStatus;
- this.serverStatus = 0;
- this.hadWarnings = false;
- this.warningCount = 0;
-
- this.queryNoIndexUsed = false;
- this.queryBadIndexUsed = false;
- this.serverQueryWasSlow = false;
-
- //
- // Compressed input stream needs cleared at beginning
- // of each command execution...
- //
- if (this.useCompression) {
- int bytesLeft = this.mysqlInput.available();
-
- if (bytesLeft > 0) {
- this.mysqlInput.skip(bytesLeft);
- }
- }
-
- try {
- clearInputStream();
-
- //
- // PreparedStatements construct their own packets,
- // for efficiency's sake.
- //
- // If this is a generic query, we need to re-use
- // the sending packet.
- //
- if (queryPacket == null) {
- int packLength = HEADER_LENGTH + COMP_HEADER_LENGTH + 1 +
- ((extraData != null) ? extraData.length() : 0) + 2;
-
- if (this.sendPacket == null) {
- this.sendPacket = new Buffer(packLength);
- }
-
- this.packetSequence = -1;
- this.readPacketSequence = 0;
- this.checkPacketSequence = true;
- this.sendPacket.clear();
-
- this.sendPacket.writeByte((byte) command);
-
- if ((command == MysqlDefs.INIT_DB) ||
- (command == MysqlDefs.CREATE_DB) ||
- (command == MysqlDefs.DROP_DB) ||
- (command == MysqlDefs.QUERY) ||
- (command == MysqlDefs.COM_PREPARE)) {
- if (extraDataCharEncoding == null) {
- this.sendPacket.writeStringNoNull(extraData);
- } else {
- this.sendPacket.writeStringNoNull(extraData,
- extraDataCharEncoding,
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), this.connection);
- }
- } else if (command == MysqlDefs.PROCESS_KILL) {
- long id = Long.parseLong(extraData);
- this.sendPacket.writeLong(id);
- }
-
- send(this.sendPacket, this.sendPacket.getPosition());
- } else {
- this.packetSequence = -1;
- send(queryPacket, queryPacket.getPosition()); // packet passed by PreparedStatement
- }
- } catch (SQLException sqlEx) {
- // don't wrap SQLExceptions
- throw sqlEx;
- } catch (Exception ex) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ex, getExceptionInterceptor());
- }
-
- Buffer returnPacket = null;
-
- if (!skipCheck) {
- if ((command == MysqlDefs.COM_EXECUTE) ||
- (command == MysqlDefs.COM_RESET_STMT)) {
- this.readPacketSequence = 0;
- this.packetSequenceReset = true;
- }
-
- returnPacket = checkErrorPacket(command);
- }
-
- return returnPacket;
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- } finally {
- if (timeoutMillis != 0) {
- try {
- this.mysqlConnection.setSoTimeout(oldTimeout);
- } catch (SocketException e) {
- throw SQLError.createCommunicationsException(this.connection, lastPacketSentTimeMs,
- lastPacketReceivedTimeMs, e, getExceptionInterceptor());
- }
- }
- }
- }
-
- private int statementExecutionDepth = 0;
- private boolean useAutoSlowLog;
-
- /**
- * Send a query stored in a packet directly to the server.
- *
- * @param callingStatement DOCUMENT ME!
- * @param resultSetConcurrency DOCUMENT ME!
- * @param characterEncoding DOCUMENT ME!
- * @param queryPacket DOCUMENT ME!
- * @param maxRows DOCUMENT ME!
- * @param conn DOCUMENT ME!
- * @param resultSetType DOCUMENT ME!
- * @param resultSetConcurrency DOCUMENT ME!
- * @param streamResults DOCUMENT ME!
- * @param catalog DOCUMENT ME!
- * @param unpackFieldInfo should we read MYSQL_FIELD info (if available)?
- *
- * @return DOCUMENT ME!
- *
- * @throws Exception DOCUMENT ME!
- */
- final ResultSetInternalMethods sqlQueryDirect(StatementImpl callingStatement, String query,
- String characterEncoding, Buffer queryPacket, int maxRows,
- int resultSetType, int resultSetConcurrency,
- boolean streamResults, String catalog, Field[] cachedMetadata)
- throws Exception {
- this.statementExecutionDepth++;
-
- try {
- if (this.statementInterceptors != null) {
- ResultSetInternalMethods interceptedResults =
- invokeStatementInterceptorsPre(query, callingStatement);
-
- if (interceptedResults != null) {
- return interceptedResults;
- }
- }
-
- long queryStartTime = 0;
- long queryEndTime = 0;
-
- if (query != null) {
-
- // We don't know exactly how many bytes we're going to get
- // from the query. Since we're dealing with Unicode, the
- // max is 2, so pad it (2 * query) + space for headers
- int packLength = HEADER_LENGTH + 1 + (query.length() * 2) + 2;
-
- String statementComment = this.connection.getStatementComment();
-
- byte[] commentAsBytes = null;
-
- if (statementComment != null) {
- commentAsBytes = StringUtils.getBytes(statementComment, null,
- characterEncoding, this.connection
- .getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), getExceptionInterceptor());
-
- packLength += commentAsBytes.length;
- packLength += 6; // for /*[space] [space]*/
- }
-
- if (this.sendPacket == null) {
- this.sendPacket = new Buffer(packLength);
- } else {
- this.sendPacket.clear();
- }
-
- this.sendPacket.writeByte((byte) MysqlDefs.QUERY);
-
- if (commentAsBytes != null) {
- this.sendPacket.writeBytesNoNull(Constants.SLASH_STAR_SPACE_AS_BYTES);
- this.sendPacket.writeBytesNoNull(commentAsBytes);
- this.sendPacket.writeBytesNoNull(Constants.SPACE_STAR_SLASH_SPACE_AS_BYTES);
- }
-
- if (characterEncoding != null) {
- if (this.platformDbCharsetMatches) {
- this.sendPacket.writeStringNoNull(query, characterEncoding,
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(),
- this.connection);
- } else {
- if (StringUtils.startsWithIgnoreCaseAndWs(query, "LOAD DATA")) { //$NON-NLS-1$
- this.sendPacket.writeBytesNoNull(query.getBytes());
- } else {
- this.sendPacket.writeStringNoNull(query,
- characterEncoding,
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(),
- this.connection);
- }
- }
- } else {
- this.sendPacket.writeStringNoNull(query);
- }
-
- queryPacket = this.sendPacket;
- }
-
- byte[] queryBuf = null;
- int oldPacketPosition = 0;
-
- if (needToGrabQueryFromPacket) {
- queryBuf = queryPacket.getByteBuffer();
-
- // save the packet position
- oldPacketPosition = queryPacket.getPosition();
-
- queryStartTime = getCurrentTimeNanosOrMillis();
- }
-
- if (this.autoGenerateTestcaseScript) {
- String testcaseQuery = null;
-
- if (query != null) {
- testcaseQuery = query;
- } else {
- testcaseQuery = new String(queryBuf, 5,
- (oldPacketPosition - 5));
- }
-
- StringBuffer debugBuf = new StringBuffer(testcaseQuery.length() + 32);
- this.connection.generateConnectionCommentBlock(debugBuf);
- debugBuf.append(testcaseQuery);
- debugBuf.append(';');
- this.connection.dumpTestcaseQuery(debugBuf.toString());
- }
-
- // Send query command and sql query string
- Buffer resultPacket = sendCommand(MysqlDefs.QUERY, null, queryPacket,
- false, null, 0);
-
- long fetchBeginTime = 0;
- long fetchEndTime = 0;
-
- String profileQueryToLog = null;
-
- boolean queryWasSlow = false;
-
- if (this.profileSql || this.logSlowQueries) {
- queryEndTime = System.currentTimeMillis();
-
- boolean shouldExtractQuery = false;
-
- if (this.profileSql) {
- shouldExtractQuery = true;
- } else if (this.logSlowQueries) {
- long queryTime = queryEndTime - queryStartTime;
-
- boolean logSlow = false;
-
- if (this.useAutoSlowLog) {
- logSlow = queryTime > this.connection.getSlowQueryThresholdMillis();
- } else {
- logSlow = this.connection.isAbonormallyLongQuery(queryTime);
-
- this.connection.reportQueryTime(queryTime);
- }
-
- if (logSlow) {
- shouldExtractQuery = true;
- queryWasSlow = true;
- }
- }
-
- if (shouldExtractQuery) {
- // Extract the actual query from the network packet
- boolean truncated = false;
-
- int extractPosition = oldPacketPosition;
-
- if (oldPacketPosition > this.connection.getMaxQuerySizeToLog()) {
- extractPosition = this.connection.getMaxQuerySizeToLog() + 5;
- truncated = true;
- }
-
- profileQueryToLog = new String(queryBuf, 5,
- (extractPosition - 5));
-
- if (truncated) {
- profileQueryToLog += Messages.getString("MysqlIO.25"); //$NON-NLS-1$
- }
- }
-
- fetchBeginTime = queryEndTime;
- }
-
- ResultSetInternalMethods rs = readAllResults(callingStatement, maxRows, resultSetType,
- resultSetConcurrency, streamResults, catalog, resultPacket,
- false, -1L, cachedMetadata);
-
- if (queryWasSlow && !this.serverQueryWasSlow /* don't log slow queries twice */) {
- StringBuffer mesgBuf = new StringBuffer(48 +
- profileQueryToLog.length());
-
- mesgBuf.append(Messages.getString("MysqlIO.SlowQuery",
- new Object[] {new Long(this.slowQueryThreshold),
- queryTimingUnits,
- new Long(queryEndTime - queryStartTime)}));
- mesgBuf.append(profileQueryToLog);
-
- ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);
-
- eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_SLOW_QUERY,
- "", catalog, this.connection.getId(), //$NON-NLS-1$
- (callingStatement != null) ? callingStatement.getId() : 999,
- ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
- (int) (queryEndTime - queryStartTime), queryTimingUnits, null,
- new Throwable(), mesgBuf.toString()));
-
- if (this.connection.getExplainSlowQueries()) {
- if (oldPacketPosition < MAX_QUERY_SIZE_TO_EXPLAIN) {
- explainSlowQuery(queryPacket.getBytes(5,
- (oldPacketPosition - 5)), profileQueryToLog);
- } else {
- this.connection.getLog().logWarn(Messages.getString(
- "MysqlIO.28") //$NON-NLS-1$
- +MAX_QUERY_SIZE_TO_EXPLAIN +
- Messages.getString("MysqlIO.29")); //$NON-NLS-1$
- }
- }
- }
-
- if (this.logSlowQueries) {
-
- ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);
-
- if (this.queryBadIndexUsed) {
- eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
- this.connection.getId(),
- (callingStatement != null) ? callingStatement.getId()
- : 999, ((ResultSetImpl)rs).resultId,
- System.currentTimeMillis(),
- (queryEndTime - queryStartTime), this.queryTimingUnits,
- null,
- new Throwable(),
- Messages.getString("MysqlIO.33") //$NON-NLS-1$
- +profileQueryToLog));
- }
-
- if (this.queryNoIndexUsed) {
- eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
- this.connection.getId(),
- (callingStatement != null) ? callingStatement.getId()
- : 999, ((ResultSetImpl)rs).resultId,
- System.currentTimeMillis(),
- (queryEndTime - queryStartTime), this.queryTimingUnits,
- null,
- new Throwable(),
- Messages.getString("MysqlIO.35") //$NON-NLS-1$
- +profileQueryToLog));
- }
-
- if (this.serverQueryWasSlow) {
- eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_SLOW_QUERY, "", catalog, //$NON-NLS-1$
- this.connection.getId(),
- (callingStatement != null) ? callingStatement.getId()
- : 999, ((ResultSetImpl)rs).resultId,
- System.currentTimeMillis(),
- (queryEndTime - queryStartTime), this.queryTimingUnits,
- null,
- new Throwable(),
- Messages.getString("MysqlIO.ServerSlowQuery") //$NON-NLS-1$
- +profileQueryToLog));
- }
- }
-
- if (this.profileSql) {
- fetchEndTime = getCurrentTimeNanosOrMillis();
-
- ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);
-
- eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_QUERY,
- "", catalog, this.connection.getId(), //$NON-NLS-1$
- (callingStatement != null) ? callingStatement.getId() : 999,
- ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
- (queryEndTime - queryStartTime), this.queryTimingUnits,
- null,
- new Throwable(), profileQueryToLog));
-
- eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_FETCH,
- "", catalog, this.connection.getId(), //$NON-NLS-1$
- (callingStatement != null) ? callingStatement.getId() : 999,
- ((ResultSetImpl)rs).resultId, System.currentTimeMillis(),
- (fetchEndTime - fetchBeginTime), this.queryTimingUnits,
- null,
- new Throwable(), null));
- }
-
- if (this.hadWarnings) {
- scanForAndThrowDataTruncation();
- }
-
- if (this.statementInterceptors != null) {
- ResultSetInternalMethods interceptedResults = invokeStatementInterceptorsPost(
- query, callingStatement, rs);
-
- if (interceptedResults != null) {
- rs = interceptedResults;
- }
- }
-
- return rs;
- } catch (SQLException sqlEx) {
- if (callingStatement != null) {
- synchronized (callingStatement.cancelTimeoutMutex) {
- if (callingStatement.wasCancelled) {
- SQLException cause = null;
-
- if (callingStatement.wasCancelledByTimeout) {
- cause = new MySQLTimeoutException();
- } else {
- cause = new MySQLStatementCancelledException();
- }
-
- callingStatement.resetCancelledState();
-
- throw cause;
- }
- }
- }
-
- throw sqlEx;
- } finally {
- this.statementExecutionDepth--;
- }
- }
-
- private ResultSetInternalMethods invokeStatementInterceptorsPre(String sql,
- Statement interceptedStatement) throws SQLException {
- ResultSetInternalMethods previousResultSet = null;
-
- Iterator interceptors = this.statementInterceptors.iterator();
-
- while (interceptors.hasNext()) {
- StatementInterceptor interceptor = ((StatementInterceptor) interceptors
- .next());
-
- boolean executeTopLevelOnly = interceptor.executeTopLevelOnly();
- boolean shouldExecute = (executeTopLevelOnly && this.statementExecutionDepth == 1)
- || (!executeTopLevelOnly);
-
- if (shouldExecute) {
- String sqlToInterceptor = sql;
-
- if (interceptedStatement instanceof PreparedStatement) {
- sqlToInterceptor = ((PreparedStatement) interceptedStatement)
- .asSql();
- }
-
- ResultSetInternalMethods interceptedResultSet = interceptor
- .preProcess(sqlToInterceptor, interceptedStatement,
- this.connection);
-
- if (interceptedResultSet != null) {
- previousResultSet = interceptedResultSet;
- }
- }
- }
-
- return previousResultSet;
- }
-
- private ResultSetInternalMethods invokeStatementInterceptorsPost(
- String sql, Statement interceptedStatement,
- ResultSetInternalMethods originalResultSet) throws SQLException {
- Iterator interceptors = this.statementInterceptors.iterator();
-
- while (interceptors.hasNext()) {
- StatementInterceptor interceptor = ((StatementInterceptor) interceptors
- .next());
-
- boolean executeTopLevelOnly = interceptor.executeTopLevelOnly();
- boolean shouldExecute = (executeTopLevelOnly && this.statementExecutionDepth == 1)
- || (!executeTopLevelOnly);
-
- if (shouldExecute) {
- String sqlToInterceptor = sql;
-
- if (interceptedStatement instanceof PreparedStatement) {
- sqlToInterceptor = ((PreparedStatement) interceptedStatement)
- .asSql();
- }
-
- ResultSetInternalMethods interceptedResultSet = interceptor
- .postProcess(sqlToInterceptor, interceptedStatement,
- originalResultSet, this.connection);
-
- if (interceptedResultSet != null) {
- originalResultSet = interceptedResultSet;
- }
- }
- }
-
- return originalResultSet;
- }
-
- private void calculateSlowQueryThreshold() {
- this.slowQueryThreshold = this.connection.getSlowQueryThresholdMillis();
-
- if (this.connection.getUseNanosForElapsedTime()) {
- long nanosThreshold = this.connection.getSlowQueryThresholdNanos();
-
- if (nanosThreshold != 0) {
- this.slowQueryThreshold = nanosThreshold;
- } else {
- this.slowQueryThreshold *= 1000000; // 1 million millis in a nano
- }
- }
- }
-
- protected long getCurrentTimeNanosOrMillis() {
- if (this.useNanosForElapsedTime) {
- return Util.getCurrentTimeNanosOrMillis();
- }
-
- return System.currentTimeMillis();
- }
-
- /**
- * Returns the host this IO is connected to
- *
- * @return DOCUMENT ME!
- */
- String getHost() {
- return this.host;
- }
-
- /**
- * Is the version of the MySQL server we are connected to the given
- * version?
- *
- * @param major the major version
- * @param minor the minor version
- * @param subminor the subminor version
- *
- * @return true if the version of the MySQL server we are connected is the
- * given version
- */
- boolean isVersion(int major, int minor, int subminor) {
- return ((major == getServerMajorVersion()) &&
- (minor == getServerMinorVersion()) &&
- (subminor == getServerSubMinorVersion()));
- }
-
- /**
- * Does the version of the MySQL server we are connected to meet the given
- * minimums?
- *
- * @param major DOCUMENT ME!
- * @param minor DOCUMENT ME!
- * @param subminor DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- boolean versionMeetsMinimum(int major, int minor, int subminor) {
- if (getServerMajorVersion() >= major) {
- if (getServerMajorVersion() == major) {
- if (getServerMinorVersion() >= minor) {
- if (getServerMinorVersion() == minor) {
- return (getServerSubMinorVersion() >= subminor);
- }
-
- // newer than major.minor
- return true;
- }
-
- // older than major.minor
- return false;
- }
-
- // newer than major
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns the hex dump of the given packet, truncated to
- * MAX_PACKET_DUMP_LENGTH if packetLength exceeds that value.
- *
- * @param packetToDump the packet to dump in hex
- * @param packetLength the number of bytes to dump
- *
- * @return the hex dump of the given packet
- */
- private final static String getPacketDumpToLog(Buffer packetToDump,
- int packetLength) {
- if (packetLength < MAX_PACKET_DUMP_LENGTH) {
- return packetToDump.dump(packetLength);
- }
-
- StringBuffer packetDumpBuf = new StringBuffer(MAX_PACKET_DUMP_LENGTH * 4);
- packetDumpBuf.append(packetToDump.dump(MAX_PACKET_DUMP_LENGTH));
- packetDumpBuf.append(Messages.getString("MysqlIO.36")); //$NON-NLS-1$
- packetDumpBuf.append(MAX_PACKET_DUMP_LENGTH);
- packetDumpBuf.append(Messages.getString("MysqlIO.37")); //$NON-NLS-1$
-
- return packetDumpBuf.toString();
- }
-
- private final int readFully(InputStream in, byte[] b, int off, int len)
- throws IOException {
- if (len < 0) {
- throw new IndexOutOfBoundsException();
- }
-
- int n = 0;
-
- while (n < len) {
- int count = in.read(b, off + n, len - n);
-
- if (count < 0) {
- throw new EOFException(Messages.getString("MysqlIO.EOF",
- new Object[] {new Integer(len), new Integer(n)}));
- }
-
- n += count;
- }
-
- return n;
- }
-
- private final long skipFully(InputStream in, long len) throws IOException {
- if (len < 0) {
- throw new IOException("Negative skip length not allowed");
- }
-
- long n = 0;
-
- while (n < len) {
- long count = in.skip(len - n);
-
- if (count < 0) {
- throw new EOFException(Messages.getString("MysqlIO.EOF",
- new Object[] {new Long(len), new Long(n)}));
- }
-
- n += count;
- }
-
- return n;
- }
-
- /**
- * Reads one result set off of the wire, if the result is actually an
- * update count, creates an update-count only result set.
- *
- * @param callingStatement DOCUMENT ME!
- * @param maxRows the maximum rows to return in the result set.
- * @param resultSetType scrollability
- * @param resultSetConcurrency updatability
- * @param streamResults should the driver leave the results on the wire,
- * and read them only when needed?
- * @param catalog the catalog in use
- * @param resultPacket the first packet of information in the result set
- * @param isBinaryEncoded is this result set from a prepared statement?
- * @param preSentColumnCount do we already know the number of columns?
- * @param unpackFieldInfo should we unpack the field information?
- *
- * @return a result set that either represents the rows, or an update count
- *
- * @throws SQLException if an error occurs while reading the rows
- */
- protected final ResultSetImpl readResultsForQueryOrUpdate(
- StatementImpl callingStatement, int maxRows, int resultSetType,
- int resultSetConcurrency, boolean streamResults, String catalog,
- Buffer resultPacket, boolean isBinaryEncoded, long preSentColumnCount,
- Field[] metadataFromCache) throws SQLException {
- long columnCount = resultPacket.readFieldLength();
-
- if (columnCount == 0) {
- return buildResultSetWithUpdates(callingStatement, resultPacket);
- } else if (columnCount == Buffer.NULL_LENGTH) {
- String charEncoding = null;
-
- if (this.connection.getUseUnicode()) {
- charEncoding = this.connection.getEncoding();
- }
-
- String fileName = null;
-
- if (this.platformDbCharsetMatches) {
- fileName = ((charEncoding != null)
- ? resultPacket.readString(charEncoding, getExceptionInterceptor())
- : resultPacket.readString());
- } else {
- fileName = resultPacket.readString();
- }
-
- return sendFileToServer(callingStatement, fileName);
- } else {
- com.mysql.jdbc.ResultSetImpl results = getResultSet(callingStatement,
- columnCount, maxRows, resultSetType, resultSetConcurrency,
- streamResults, catalog, isBinaryEncoded,
- metadataFromCache);
-
- return results;
- }
- }
-
- private int alignPacketSize(int a, int l) {
- return ((((a) + (l)) - 1) & ~((l) - 1));
- }
-
- private com.mysql.jdbc.ResultSetImpl buildResultSetWithRows(
- StatementImpl callingStatement, String catalog,
- com.mysql.jdbc.Field[] fields, RowData rows, int resultSetType,
- int resultSetConcurrency, boolean isBinaryEncoded)
- throws SQLException {
- ResultSetImpl rs = null;
-
- switch (resultSetConcurrency) {
- case java.sql.ResultSet.CONCUR_READ_ONLY:
- rs = com.mysql.jdbc.ResultSetImpl.getInstance(catalog, fields, rows,
- this.connection, callingStatement, false);
-
- if (isBinaryEncoded) {
- rs.setBinaryEncoded();
- }
-
- break;
-
- case java.sql.ResultSet.CONCUR_UPDATABLE:
- rs = com.mysql.jdbc.ResultSetImpl.getInstance(catalog, fields, rows,
- this.connection, callingStatement, true);
-
- break;
-
- default:
- return com.mysql.jdbc.ResultSetImpl.getInstance(catalog, fields, rows,
- this.connection, callingStatement, false);
- }
-
- rs.setResultSetType(resultSetType);
- rs.setResultSetConcurrency(resultSetConcurrency);
-
- return rs;
- }
-
- private com.mysql.jdbc.ResultSetImpl buildResultSetWithUpdates(
- StatementImpl callingStatement, Buffer resultPacket)
- throws SQLException {
- long updateCount = -1;
- long updateID = -1;
- String info = null;
-
- try {
- if (this.useNewUpdateCounts) {
- updateCount = resultPacket.newReadLength();
- updateID = resultPacket.newReadLength();
- } else {
- updateCount = resultPacket.readLength();
- updateID = resultPacket.readLength();
- }
-
- if (this.use41Extensions) {
- // oldStatus set in sendCommand()
- this.serverStatus = resultPacket.readInt();
-
- checkTransactionState(oldServerStatus);
-
- this.warningCount = resultPacket.readInt();
-
- if (this.warningCount > 0) {
- this.hadWarnings = true; // this is a 'latch', it's reset by sendCommand()
- }
-
- resultPacket.readByte(); // advance pointer
-
- setServerSlowQueryFlags();
- }
-
- if (this.connection.isReadInfoMsgEnabled()) {
- info = resultPacket.readString(this.connection.getErrorMessageEncoding(), getExceptionInterceptor());
- }
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(SQLError.get(
- SQLError.SQL_STATE_GENERAL_ERROR), SQLError.SQL_STATE_GENERAL_ERROR, -1, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
-
- ResultSetInternalMethods updateRs = com.mysql.jdbc.ResultSetImpl.getInstance(updateCount,
- updateID, this.connection, callingStatement);
-
- if (info != null) {
- ((com.mysql.jdbc.ResultSetImpl)updateRs).setServerInfo(info);
- }
-
- return (com.mysql.jdbc.ResultSetImpl)updateRs;
- }
-
- private void setServerSlowQueryFlags() {
- if (this.profileSql) {
- this.queryNoIndexUsed = (this.serverStatus &
- SERVER_QUERY_NO_GOOD_INDEX_USED) != 0;
- this.queryBadIndexUsed = (this.serverStatus &
- SERVER_QUERY_NO_INDEX_USED) != 0;
- this.serverQueryWasSlow = (this.serverStatus &
- SERVER_QUERY_WAS_SLOW) != 0;
- }
- }
-
- private void checkForOutstandingStreamingData() throws SQLException {
- if (this.streamingData != null) {
- boolean shouldClobber = this.connection.getClobberStreamingResults();
-
- if (!shouldClobber) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.39") //$NON-NLS-1$
- +this.streamingData +
- Messages.getString("MysqlIO.40") //$NON-NLS-1$
- +Messages.getString("MysqlIO.41") //$NON-NLS-1$
- +Messages.getString("MysqlIO.42"), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- // Close the result set
- this.streamingData.getOwner().realClose(false);
-
- // clear any pending data....
- clearInputStream();
- }
- }
-
- private Buffer compressPacket(Buffer packet, int offset, int packetLen,
- int headerLength) throws SQLException {
- packet.writeLongInt(packetLen - headerLength);
- packet.writeByte((byte) 0); // wrapped packet has 0 packet seq.
-
- int lengthToWrite = 0;
- int compressedLength = 0;
- byte[] bytesToCompress = packet.getByteBuffer();
- byte[] compressedBytes = null;
- int offsetWrite = 0;
-
- if (packetLen < MIN_COMPRESS_LEN) {
- lengthToWrite = packetLen;
- compressedBytes = packet.getByteBuffer();
- compressedLength = 0;
- offsetWrite = offset;
- } else {
- compressedBytes = new byte[bytesToCompress.length * 2];
-
- this.deflater.reset();
- this.deflater.setInput(bytesToCompress, offset, packetLen);
- this.deflater.finish();
-
- int compLen = this.deflater.deflate(compressedBytes);
-
- if (compLen > packetLen) {
- lengthToWrite = packetLen;
- compressedBytes = packet.getByteBuffer();
- compressedLength = 0;
- offsetWrite = offset;
- } else {
- lengthToWrite = compLen;
- headerLength += COMP_HEADER_LENGTH;
- compressedLength = packetLen;
- }
- }
-
- Buffer compressedPacket = new Buffer(packetLen + headerLength);
-
- compressedPacket.setPosition(0);
- compressedPacket.writeLongInt(lengthToWrite);
- compressedPacket.writeByte(this.packetSequence);
- compressedPacket.writeLongInt(compressedLength);
- compressedPacket.writeBytesNoNull(compressedBytes, offsetWrite,
- lengthToWrite);
-
- return compressedPacket;
- }
-
- private final void readServerStatusForResultSets(Buffer rowPacket)
- throws SQLException {
- if (this.use41Extensions) {
- rowPacket.readByte(); // skips the 'last packet' flag
-
- this.warningCount = rowPacket.readInt();
-
- if (this.warningCount > 0) {
- this.hadWarnings = true; // this is a 'latch', it's reset by sendCommand()
- }
-
- this.oldServerStatus = this.serverStatus;
- this.serverStatus = rowPacket.readInt();
- checkTransactionState(oldServerStatus);
-
- setServerSlowQueryFlags();
- }
- }
-
- private SocketFactory createSocketFactory() throws SQLException {
- try {
- if (this.socketFactoryClassName == null) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.75"), //$NON-NLS-1$
- SQLError.SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE, getExceptionInterceptor());
- }
-
- return (SocketFactory) (Class.forName(this.socketFactoryClassName)
- .newInstance());
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(Messages.getString("MysqlIO.76") //$NON-NLS-1$
- +this.socketFactoryClassName +
- Messages.getString("MysqlIO.77"),
- SQLError.SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE, getExceptionInterceptor());
-
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- private void enqueuePacketForDebugging(boolean isPacketBeingSent,
- boolean isPacketReused, int sendLength, byte[] header, Buffer packet)
- throws SQLException {
- if ((this.packetDebugRingBuffer.size() + 1) > this.connection.getPacketDebugBufferSize()) {
- this.packetDebugRingBuffer.removeFirst();
- }
-
- StringBuffer packetDump = null;
-
- if (!isPacketBeingSent) {
- int bytesToDump = Math.min(MAX_PACKET_DUMP_LENGTH,
- packet.getBufLength());
-
- Buffer packetToDump = new Buffer(4 + bytesToDump);
-
- packetToDump.setPosition(0);
- packetToDump.writeBytesNoNull(header);
- packetToDump.writeBytesNoNull(packet.getBytes(0, bytesToDump));
-
- String packetPayload = packetToDump.dump(bytesToDump);
-
- packetDump = new StringBuffer(96 + packetPayload.length());
-
- packetDump.append("Server ");
-
- if (isPacketReused) {
- packetDump.append("(re-used)");
- } else {
- packetDump.append("(new)");
- }
-
- packetDump.append(" ");
- packetDump.append(packet.toSuperString());
- packetDump.append(" --------------------> Client\n");
- packetDump.append("\nPacket payload:\n\n");
- packetDump.append(packetPayload);
-
- if (bytesToDump == MAX_PACKET_DUMP_LENGTH) {
- packetDump.append("\nNote: Packet of " + packet.getBufLength() +
- " bytes truncated to " + MAX_PACKET_DUMP_LENGTH +
- " bytes.\n");
- }
- } else {
- int bytesToDump = Math.min(MAX_PACKET_DUMP_LENGTH, sendLength);
-
- String packetPayload = packet.dump(bytesToDump);
-
- packetDump = new StringBuffer(64 + 4 + packetPayload.length());
-
- packetDump.append("Client ");
- packetDump.append(packet.toSuperString());
- packetDump.append("--------------------> Server\n");
- packetDump.append("\nPacket payload:\n\n");
- packetDump.append(packetPayload);
-
- if (bytesToDump == MAX_PACKET_DUMP_LENGTH) {
- packetDump.append("\nNote: Packet of " + sendLength +
- " bytes truncated to " + MAX_PACKET_DUMP_LENGTH +
- " bytes.\n");
- }
- }
-
- this.packetDebugRingBuffer.addLast(packetDump);
- }
-
- private RowData readSingleRowSet(long columnCount, int maxRows,
- int resultSetConcurrency, boolean isBinaryEncoded, Field[] fields)
- throws SQLException {
- RowData rowData;
- ArrayList rows = new ArrayList();
-
- boolean useBufferRowExplicit = useBufferRowExplicit(fields);
-
- // Now read the data
- ResultSetRow row = nextRow(fields, (int) columnCount, isBinaryEncoded,
- resultSetConcurrency, false, useBufferRowExplicit, false, null);
-
- int rowCount = 0;
-
- if (row != null) {
- rows.add(row);
- rowCount = 1;
- }
-
- while (row != null) {
- row = nextRow(fields, (int) columnCount, isBinaryEncoded,
- resultSetConcurrency, false, useBufferRowExplicit, false, null);
-
- if (row != null) {
- if ((maxRows == -1) || (rowCount < maxRows)) {
- rows.add(row);
- rowCount++;
- }
- }
- }
-
- rowData = new RowDataStatic(rows);
-
- return rowData;
- }
-
- public static boolean useBufferRowExplicit(Field[] fields) {
- if (fields == null) {
- return false;
- }
-
- for (int i = 0; i < fields.length; i++) {
- switch (fields[i].getSQLType()) {
- case Types.BLOB:
- case Types.CLOB:
- case Types.LONGVARBINARY:
- case Types.LONGVARCHAR:
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Don't hold on to overly-large packets
- */
- private void reclaimLargeReusablePacket() {
- if ((this.reusablePacket != null) &&
- (this.reusablePacket.getCapacity() > 1048576)) {
- this.reusablePacket = new Buffer(INITIAL_PACKET_SIZE);
- }
- }
-
- /**
- * Re-use a packet to read from the MySQL server
- *
- * @param reuse DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- * @throws SQLException DOCUMENT ME!
- */
- private final Buffer reuseAndReadPacket(Buffer reuse) throws SQLException {
- return reuseAndReadPacket(reuse, -1);
- }
-
- private final Buffer reuseAndReadPacket(Buffer reuse, int existingPacketLength)
- throws SQLException {
-
- try {
- reuse.setWasMultiPacket(false);
- int packetLength = 0;
-
- if (existingPacketLength == -1) {
- int lengthRead = readFully(this.mysqlInput,
- this.packetHeaderBuf, 0, 4);
-
- if (lengthRead < 4) {
- forceClose();
- throw new IOException(Messages.getString("MysqlIO.43")); //$NON-NLS-1$
- }
-
- packetLength = (this.packetHeaderBuf[0] & 0xff) +
- ((this.packetHeaderBuf[1] & 0xff) << 8) +
- ((this.packetHeaderBuf[2] & 0xff) << 16);
- } else {
- packetLength = existingPacketLength;
- }
-
- if (this.traceProtocol) {
- StringBuffer traceMessageBuf = new StringBuffer();
-
- traceMessageBuf.append(Messages.getString("MysqlIO.44")); //$NON-NLS-1$
- traceMessageBuf.append(packetLength);
- traceMessageBuf.append(Messages.getString("MysqlIO.45")); //$NON-NLS-1$
- traceMessageBuf.append(StringUtils.dumpAsHex(
- this.packetHeaderBuf, 4));
-
- this.connection.getLog().logTrace(traceMessageBuf.toString());
- }
-
- byte multiPacketSeq = this.packetHeaderBuf[3];
-
- if (!this.packetSequenceReset) {
- if (this.enablePacketDebug && this.checkPacketSequence) {
- checkPacketSequencing(multiPacketSeq);
- }
- } else {
- this.packetSequenceReset = false;
- }
-
- this.readPacketSequence = multiPacketSeq;
-
- // Set the Buffer to it's original state
- reuse.setPosition(0);
-
- // Do we need to re-alloc the byte buffer?
- //
- // Note: We actually check the length of the buffer,
- // rather than getBufLength(), because getBufLength() is not
- // necesarily the actual length of the byte array
- // used as the buffer
- if (reuse.getByteBuffer().length <= packetLength) {
- reuse.setByteBuffer(new byte[packetLength + 1]);
- }
-
- // Set the new length
- reuse.setBufLength(packetLength);
-
- // Read the data from the server
- int numBytesRead = readFully(this.mysqlInput,
- reuse.getByteBuffer(), 0, packetLength);
-
- if (numBytesRead != packetLength) {
- throw new IOException("Short read, expected " +
- packetLength + " bytes, only read " + numBytesRead);
- }
-
- if (this.traceProtocol) {
- StringBuffer traceMessageBuf = new StringBuffer();
-
- traceMessageBuf.append(Messages.getString("MysqlIO.46")); //$NON-NLS-1$
- traceMessageBuf.append(getPacketDumpToLog(reuse,
- packetLength));
-
- this.connection.getLog().logTrace(traceMessageBuf.toString());
- }
-
- if (this.enablePacketDebug) {
- enqueuePacketForDebugging(false, true, 0,
- this.packetHeaderBuf, reuse);
- }
-
- boolean isMultiPacket = false;
-
- if (packetLength == this.maxThreeBytes) {
- reuse.setPosition(this.maxThreeBytes);
-
- int packetEndPoint = packetLength;
-
- // it's multi-packet
- isMultiPacket = true;
-
- packetLength = readRemainingMultiPackets(reuse, multiPacketSeq,
- packetEndPoint);
- }
-
- if (!isMultiPacket) {
- reuse.getByteBuffer()[packetLength] = 0; // Null-termination
- }
-
- if (this.connection.getMaintainTimeStats()) {
- this.lastPacketReceivedTimeMs = System.currentTimeMillis();
- }
-
- return reuse;
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- } catch (OutOfMemoryError oom) {
- try {
- // _Try_ this
- clearInputStream();
- } finally {
- try {
- this.connection.realClose(false, false, true, oom);
- } finally {
- throw oom;
- }
- }
- }
-
- }
-
- private int readRemainingMultiPackets(Buffer reuse, byte multiPacketSeq,
- int packetEndPoint) throws IOException, SQLException {
- int lengthRead;
- int packetLength;
- lengthRead = readFully(this.mysqlInput,
- this.packetHeaderBuf, 0, 4);
-
- if (lengthRead < 4) {
- forceClose();
- throw new IOException(Messages.getString("MysqlIO.47")); //$NON-NLS-1$
- }
-
- packetLength = (this.packetHeaderBuf[0] & 0xff) +
- ((this.packetHeaderBuf[1] & 0xff) << 8) +
- ((this.packetHeaderBuf[2] & 0xff) << 16);
-
- Buffer multiPacket = new Buffer(packetLength);
- boolean firstMultiPkt = true;
-
- while (true) {
- if (!firstMultiPkt) {
- lengthRead = readFully(this.mysqlInput,
- this.packetHeaderBuf, 0, 4);
-
- if (lengthRead < 4) {
- forceClose();
- throw new IOException(Messages.getString(
- "MysqlIO.48")); //$NON-NLS-1$
- }
-
- packetLength = (this.packetHeaderBuf[0] & 0xff) +
- ((this.packetHeaderBuf[1] & 0xff) << 8) +
- ((this.packetHeaderBuf[2] & 0xff) << 16);
- } else {
- firstMultiPkt = false;
- }
-
- if (!this.useNewLargePackets && (packetLength == 1)) {
- clearInputStream();
-
- break;
- } else if (packetLength < this.maxThreeBytes) {
- byte newPacketSeq = this.packetHeaderBuf[3];
-
- if (newPacketSeq != (multiPacketSeq + 1)) {
- throw new IOException(Messages.getString(
- "MysqlIO.49")); //$NON-NLS-1$
- }
-
- multiPacketSeq = newPacketSeq;
-
- // Set the Buffer to it's original state
- multiPacket.setPosition(0);
-
- // Set the new length
- multiPacket.setBufLength(packetLength);
-
- // Read the data from the server
- byte[] byteBuf = multiPacket.getByteBuffer();
- int lengthToWrite = packetLength;
-
- int bytesRead = readFully(this.mysqlInput, byteBuf,
- 0, packetLength);
-
- if (bytesRead != lengthToWrite) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs,
- SQLError.createSQLException(Messages.getString(
- "MysqlIO.50") //$NON-NLS-1$
- +lengthToWrite +
- Messages.getString("MysqlIO.51") +
- bytesRead //$NON-NLS-1$
- +".", getExceptionInterceptor()), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- reuse.writeBytesNoNull(byteBuf, 0, lengthToWrite);
-
- packetEndPoint += lengthToWrite;
-
- break; // end of multipacket sequence
- }
-
- byte newPacketSeq = this.packetHeaderBuf[3];
-
- if (newPacketSeq != (multiPacketSeq + 1)) {
- throw new IOException(Messages.getString(
- "MysqlIO.53")); //$NON-NLS-1$
- }
-
- multiPacketSeq = newPacketSeq;
-
- // Set the Buffer to it's original state
- multiPacket.setPosition(0);
-
- // Set the new length
- multiPacket.setBufLength(packetLength);
-
- // Read the data from the server
- byte[] byteBuf = multiPacket.getByteBuffer();
- int lengthToWrite = packetLength;
-
- int bytesRead = readFully(this.mysqlInput, byteBuf, 0,
- packetLength);
-
- if (bytesRead != lengthToWrite) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs,
- SQLError.createSQLException(Messages.getString(
- "MysqlIO.54") //$NON-NLS-1$
- +lengthToWrite +
- Messages.getString("MysqlIO.55") //$NON-NLS-1$
- +bytesRead + ".", getExceptionInterceptor()), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- reuse.writeBytesNoNull(byteBuf, 0, lengthToWrite);
-
- packetEndPoint += lengthToWrite;
- }
-
- reuse.setPosition(0);
- reuse.setWasMultiPacket(true);
- return packetLength;
- }
-
- /**
- * @param multiPacketSeq
- * @throws CommunicationsException
- */
- private void checkPacketSequencing(byte multiPacketSeq)
- throws SQLException {
- if ((multiPacketSeq == -128) && (this.readPacketSequence != 127)) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs,
- new IOException("Packets out of order, expected packet # -128, but received packet # " +
- multiPacketSeq), getExceptionInterceptor());
- }
-
- if ((this.readPacketSequence == -1) && (multiPacketSeq != 0)) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs,
- new IOException("Packets out of order, expected packet # -1, but received packet # " +
- multiPacketSeq), getExceptionInterceptor());
- }
-
- if ((multiPacketSeq != -128) && (this.readPacketSequence != -1) &&
- (multiPacketSeq != (this.readPacketSequence + 1))) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs,
- new IOException("Packets out of order, expected packet # " +
- (this.readPacketSequence + 1) + ", but received packet # " +
- multiPacketSeq), getExceptionInterceptor());
- }
- }
-
- void enableMultiQueries() throws SQLException {
- Buffer buf = getSharedSendPacket();
-
- buf.clear();
- buf.writeByte((byte)MysqlDefs.COM_SET_OPTION);
- buf.writeInt(0);
- sendCommand(MysqlDefs.COM_SET_OPTION, null, buf, false, null, 0);
- }
-
- void disableMultiQueries() throws SQLException {
- Buffer buf = getSharedSendPacket();
-
- buf.clear();
- buf.writeByte((byte)MysqlDefs.COM_SET_OPTION);
- buf.writeInt(1);
- sendCommand(MysqlDefs.COM_SET_OPTION, null, buf, false, null, 0);
- }
-
- private final void send(Buffer packet, int packetLen)
- throws SQLException {
- try {
- if (this.maxAllowedPacket > 0 && packetLen > this.maxAllowedPacket) {
- throw new PacketTooBigException(packetLen, this.maxAllowedPacket);
- }
-
- if ((this.serverMajorVersion >= 4) &&
- (packetLen >= this.maxThreeBytes)) {
- sendSplitPackets(packet);
- } else {
- this.packetSequence++;
-
- Buffer packetToSend = packet;
-
- packetToSend.setPosition(0);
-
- if (this.useCompression) {
- int originalPacketLen = packetLen;
-
- packetToSend = compressPacket(packet, 0, packetLen,
- HEADER_LENGTH);
- packetLen = packetToSend.getPosition();
-
- if (this.traceProtocol) {
- StringBuffer traceMessageBuf = new StringBuffer();
-
- traceMessageBuf.append(Messages.getString("MysqlIO.57")); //$NON-NLS-1$
- traceMessageBuf.append(getPacketDumpToLog(
- packetToSend, packetLen));
- traceMessageBuf.append(Messages.getString("MysqlIO.58")); //$NON-NLS-1$
- traceMessageBuf.append(getPacketDumpToLog(packet,
- originalPacketLen));
-
- this.connection.getLog().logTrace(traceMessageBuf.toString());
- }
- } else {
- packetToSend.writeLongInt(packetLen - HEADER_LENGTH);
- packetToSend.writeByte(this.packetSequence);
-
- if (this.traceProtocol) {
- StringBuffer traceMessageBuf = new StringBuffer();
-
- traceMessageBuf.append(Messages.getString("MysqlIO.59")); //$NON-NLS-1$
- traceMessageBuf.append(packetToSend.dump(packetLen));
-
- this.connection.getLog().logTrace(traceMessageBuf.toString());
- }
- }
-
-
- this.mysqlOutput.write(packetToSend.getByteBuffer(), 0,
- packetLen);
- this.mysqlOutput.flush();
- }
-
- if (this.enablePacketDebug) {
- enqueuePacketForDebugging(true, false, packetLen + 5,
- this.packetHeaderBuf, packet);
- }
-
- //
- // Don't hold on to large packets
- //
- if (packet == this.sharedSendPacket) {
- reclaimLargeSharedSendPacket();
- }
-
- if (this.connection.getMaintainTimeStats()) {
- this.lastPacketSentTimeMs = System.currentTimeMillis();
- }
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- }
- }
-
- /**
- * Reads and sends a file to the server for LOAD DATA LOCAL INFILE
- *
- * @param callingStatement DOCUMENT ME!
- * @param fileName the file name to send.
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- private final ResultSetImpl sendFileToServer(StatementImpl callingStatement,
- String fileName) throws SQLException {
-
- Buffer filePacket = (this.loadFileBufRef == null) ? null
- : (Buffer) (this.loadFileBufRef.get());
-
- int bigPacketLength = Math.min(this.connection.getMaxAllowedPacket() -
- (HEADER_LENGTH * 3),
- alignPacketSize(this.connection.getMaxAllowedPacket() - 16, 4096) -
- (HEADER_LENGTH * 3));
-
- int oneMeg = 1024 * 1024;
-
- int smallerPacketSizeAligned = Math.min(oneMeg - (HEADER_LENGTH * 3),
- alignPacketSize(oneMeg - 16, 4096) - (HEADER_LENGTH * 3));
-
- int packetLength = Math.min(smallerPacketSizeAligned, bigPacketLength);
-
- if (filePacket == null) {
- try {
- filePacket = new Buffer((packetLength + HEADER_LENGTH));
- this.loadFileBufRef = new SoftReference(filePacket);
- } catch (OutOfMemoryError oom) {
- throw SQLError.createSQLException("Could not allocate packet of " + packetLength
- + " bytes required for LOAD DATA LOCAL INFILE operation."
- + " Try increasing max heap allocation for JVM or decreasing server variable "
- + "'max_allowed_packet'", SQLError.SQL_STATE_MEMORY_ALLOCATION_FAILURE, getExceptionInterceptor());
-
- }
- }
-
- filePacket.clear();
- send(filePacket, 0);
-
- byte[] fileBuf = new byte[packetLength];
-
- BufferedInputStream fileIn = null;
-
- try {
- if (!this.connection.getAllowLoadLocalInfile()) {
- throw SQLError.createSQLException(
- Messages.getString("MysqlIO.LoadDataLocalNotAllowed"),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
-
- InputStream hookedStream = null;
-
- if (callingStatement != null) {
- hookedStream = callingStatement.getLocalInfileInputStream();
- }
-
- if (hookedStream != null) {
- fileIn = new BufferedInputStream(hookedStream);
- } else if (!this.connection.getAllowUrlInLocalInfile()) {
- fileIn = new BufferedInputStream(new FileInputStream(fileName));
- } else {
- // First look for ':'
- if (fileName.indexOf(':') != -1) {
- try {
- URL urlFromFileName = new URL(fileName);
- fileIn = new BufferedInputStream(urlFromFileName.openStream());
- } catch (MalformedURLException badUrlEx) {
- // we fall back to trying this as a file input stream
- fileIn = new BufferedInputStream(new FileInputStream(
- fileName));
- }
- } else {
- fileIn = new BufferedInputStream(new FileInputStream(
- fileName));
- }
- }
-
- int bytesRead = 0;
-
- while ((bytesRead = fileIn.read(fileBuf)) != -1) {
- filePacket.clear();
- filePacket.writeBytesNoNull(fileBuf, 0, bytesRead);
- send(filePacket, filePacket.getPosition());
- }
- } catch (IOException ioEx) {
- StringBuffer messageBuf = new StringBuffer(Messages.getString(
- "MysqlIO.60")); //$NON-NLS-1$
-
- if (!this.connection.getParanoid()) {
- messageBuf.append("'"); //$NON-NLS-1$
-
- if (fileName != null) {
- messageBuf.append(fileName);
- }
-
- messageBuf.append("'"); //$NON-NLS-1$
- }
-
- messageBuf.append(Messages.getString("MysqlIO.63")); //$NON-NLS-1$
-
- if (!this.connection.getParanoid()) {
- messageBuf.append(Messages.getString("MysqlIO.64")); //$NON-NLS-1$
- messageBuf.append(Util.stackTraceToString(ioEx));
- }
-
- throw SQLError.createSQLException(messageBuf.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- } finally {
- if (fileIn != null) {
- try {
- fileIn.close();
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(Messages.getString("MysqlIO.65"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
-
- fileIn = null;
- } else {
- // file open failed, but server needs one packet
- filePacket.clear();
- send(filePacket, filePacket.getPosition());
- checkErrorPacket(); // to clear response off of queue
- }
- }
-
- // send empty packet to mark EOF
- filePacket.clear();
- send(filePacket, filePacket.getPosition());
-
- Buffer resultPacket = checkErrorPacket();
-
- return buildResultSetWithUpdates(callingStatement, resultPacket);
- }
-
- /**
- * Checks for errors in the reply packet, and if none, returns the reply
- * packet, ready for reading
- *
- * @param command the command being issued (if used)
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException if an error packet was received
- * @throws CommunicationsException DOCUMENT ME!
- */
- private Buffer checkErrorPacket(int command) throws SQLException {
- int statusCode = 0;
- Buffer resultPacket = null;
- this.serverStatus = 0;
-
- try {
- // Check return value, if we get a java.io.EOFException,
- // the server has gone away. We'll pass it on up the
- // exception chain and let someone higher up decide
- // what to do (barf, reconnect, etc).
- resultPacket = reuseAndReadPacket(this.reusablePacket);
- } catch (SQLException sqlEx) {
- // Don't wrap SQL Exceptions
- throw sqlEx;
- } catch (Exception fallThru) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, fallThru, getExceptionInterceptor());
- }
-
- checkErrorPacket(resultPacket);
-
- return resultPacket;
- }
-
- private void checkErrorPacket(Buffer resultPacket) throws SQLException {
-
- int statusCode = resultPacket.readByte();
-
- // Error handling
- if (statusCode == (byte) 0xff) {
- String serverErrorMessage;
- int errno = 2000;
-
- if (this.protocolVersion > 9) {
- errno = resultPacket.readInt();
-
- String xOpen = null;
-
- serverErrorMessage =
- resultPacket.readString(this.connection.getErrorMessageEncoding(), getExceptionInterceptor());
-
- if (serverErrorMessage.charAt(0) == '#') { //$NON-NLS-1$
-
- // we have an SQLState
- if (serverErrorMessage.length() > 6) {
- xOpen = serverErrorMessage.substring(1, 6);
- serverErrorMessage = serverErrorMessage.substring(6);
-
- if (xOpen.equals("HY000")) { //$NON-NLS-1$
- xOpen = SQLError.mysqlToSqlState(errno,
- this.connection.getUseSqlStateCodes());
- }
- } else {
- xOpen = SQLError.mysqlToSqlState(errno,
- this.connection.getUseSqlStateCodes());
- }
- } else {
- xOpen = SQLError.mysqlToSqlState(errno,
- this.connection.getUseSqlStateCodes());
- }
-
- clearInputStream();
-
- StringBuffer errorBuf = new StringBuffer();
-
- String xOpenErrorMessage = SQLError.get(xOpen);
-
- if (!this.connection.getUseOnlyServerErrorMessages()) {
- if (xOpenErrorMessage != null) {
- errorBuf.append(xOpenErrorMessage);
- errorBuf.append(Messages.getString("MysqlIO.68")); //$NON-NLS-1$
- }
- }
-
- errorBuf.append(serverErrorMessage);
-
- if (!this.connection.getUseOnlyServerErrorMessages()) {
- if (xOpenErrorMessage != null) {
- errorBuf.append("\""); //$NON-NLS-1$
- }
- }
-
- appendInnodbStatusInformation(xOpen, errorBuf);
-
- if (xOpen != null && xOpen.startsWith("22")) {
- throw new MysqlDataTruncation(errorBuf.toString(), 0, true, false, 0, 0, errno);
- } else {
- throw SQLError.createSQLException(errorBuf.toString(), xOpen, errno, getExceptionInterceptor());
- }
- }
-
- serverErrorMessage = resultPacket.readString(
- this.connection.getErrorMessageEncoding(), getExceptionInterceptor());
- clearInputStream();
-
- if (serverErrorMessage.indexOf(Messages.getString("MysqlIO.70")) != -1) { //$NON-NLS-1$
- throw SQLError.createSQLException(SQLError.get(
- SQLError.SQL_STATE_COLUMN_NOT_FOUND) +
- ", " //$NON-NLS-1$
- +serverErrorMessage, SQLError.SQL_STATE_COLUMN_NOT_FOUND,
- -1, getExceptionInterceptor());
- }
-
- StringBuffer errorBuf = new StringBuffer(Messages.getString(
- "MysqlIO.72")); //$NON-NLS-1$
- errorBuf.append(serverErrorMessage);
- errorBuf.append("\""); //$NON-NLS-1$
-
- throw SQLError.createSQLException(SQLError.get(
- SQLError.SQL_STATE_GENERAL_ERROR) + ", " //$NON-NLS-1$
- +errorBuf.toString(), SQLError.SQL_STATE_GENERAL_ERROR, -1, getExceptionInterceptor());
- }
- }
-
- private void appendInnodbStatusInformation(String xOpen,
- StringBuffer errorBuf) throws SQLException {
- if (this.connection.getIncludeInnodbStatusInDeadlockExceptions()
- && xOpen != null
- && (xOpen.startsWith("40") || xOpen.startsWith("41"))
- && this.streamingData == null) {
- ResultSet rs = null;
-
- try {
- rs = sqlQueryDirect(null, "SHOW ENGINE INNODB STATUS",
- this.connection.getEncoding(), null, -1,
- ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_READ_ONLY, false, this.connection
- .getCatalog(), null);
-
- if (rs.next()) {
- errorBuf.append("\n\n");
- errorBuf.append(rs.getString("Status"));
- } else {
- errorBuf.append("\n\n");
- errorBuf.append(Messages
- .getString("MysqlIO.NoInnoDBStatusFound"));
- }
- } catch (Exception ex) {
- errorBuf.append("\n\n");
- errorBuf.append(Messages
- .getString("MysqlIO.InnoDBStatusFailed"));
- errorBuf.append("\n\n");
- errorBuf.append(Util.stackTraceToString(ex));
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
- }
- }
-
- /**
- * Sends a large packet to the server as a series of smaller packets
- *
- * @param packet DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- * @throws CommunicationsException DOCUMENT ME!
- */
- private final void sendSplitPackets(Buffer packet)
- throws SQLException {
- try {
- //
- // Big packets are handled by splitting them in packets of MAX_THREE_BYTES
- // length. The last packet is always a packet that is < MAX_THREE_BYTES.
- // (The last packet may even have a length of 0)
- //
- //
- // NB: Guarded by execSQL. If the driver changes architecture, this
- // will need to be synchronized in some other way
- //
- Buffer headerPacket = (this.splitBufRef == null) ? null
- : (Buffer) (this.splitBufRef.get());
-
- //
- // Store this packet in a soft reference...It can be re-used if not GC'd (so clients
- // that use it frequently won't have to re-alloc the 16M buffer), but we don't
- // penalize infrequent users of large packets by keeping 16M allocated all of the time
- //
- if (headerPacket == null) {
- headerPacket = new Buffer((this.maxThreeBytes +
- HEADER_LENGTH));
- this.splitBufRef = new SoftReference(headerPacket);
- }
-
- int len = packet.getPosition();
- int splitSize = this.maxThreeBytes;
- int originalPacketPos = HEADER_LENGTH;
- byte[] origPacketBytes = packet.getByteBuffer();
- byte[] headerPacketBytes = headerPacket.getByteBuffer();
-
- while (len >= this.maxThreeBytes) {
- this.packetSequence++;
-
- headerPacket.setPosition(0);
- headerPacket.writeLongInt(splitSize);
-
- headerPacket.writeByte(this.packetSequence);
- System.arraycopy(origPacketBytes, originalPacketPos,
- headerPacketBytes, 4, splitSize);
-
- int packetLen = splitSize + HEADER_LENGTH;
-
- //
- // Swap a compressed packet in, if we're using
- // compression...
- //
- if (!this.useCompression) {
- this.mysqlOutput.write(headerPacketBytes, 0,
- splitSize + HEADER_LENGTH);
- this.mysqlOutput.flush();
- } else {
- Buffer packetToSend;
-
- headerPacket.setPosition(0);
- packetToSend = compressPacket(headerPacket, HEADER_LENGTH,
- splitSize, HEADER_LENGTH);
- packetLen = packetToSend.getPosition();
-
- this.mysqlOutput.write(packetToSend.getByteBuffer(), 0,
- packetLen);
- this.mysqlOutput.flush();
- }
-
- originalPacketPos += splitSize;
- len -= splitSize;
- }
-
- //
- // Write last packet
- //
- headerPacket.clear();
- headerPacket.setPosition(0);
- headerPacket.writeLongInt(len - HEADER_LENGTH);
- this.packetSequence++;
- headerPacket.writeByte(this.packetSequence);
-
- if (len != 0) {
- System.arraycopy(origPacketBytes, originalPacketPos,
- headerPacketBytes, 4, len - HEADER_LENGTH);
- }
-
- int packetLen = len - HEADER_LENGTH;
-
- //
- // Swap a compressed packet in, if we're using
- // compression...
- //
- if (!this.useCompression) {
- this.mysqlOutput.write(headerPacket.getByteBuffer(), 0, len);
- this.mysqlOutput.flush();
- } else {
- Buffer packetToSend;
-
- headerPacket.setPosition(0);
- packetToSend = compressPacket(headerPacket, HEADER_LENGTH,
- packetLen, HEADER_LENGTH);
- packetLen = packetToSend.getPosition();
-
- this.mysqlOutput.write(packetToSend.getByteBuffer(), 0,
- packetLen);
- this.mysqlOutput.flush();
- }
- } catch (IOException ioEx) {
- throw SQLError.createCommunicationsException(this.connection,
- this.lastPacketSentTimeMs, this.lastPacketReceivedTimeMs, ioEx, getExceptionInterceptor());
- }
- }
-
- private void reclaimLargeSharedSendPacket() {
- if ((this.sharedSendPacket != null) &&
- (this.sharedSendPacket.getCapacity() > 1048576)) {
- this.sharedSendPacket = new Buffer(INITIAL_PACKET_SIZE);
- }
- }
-
- boolean hadWarnings() {
- return this.hadWarnings;
- }
-
- void scanForAndThrowDataTruncation() throws SQLException {
- if ((this.streamingData == null) && versionMeetsMinimum(4, 1, 0) &&
- this.connection.getJdbcCompliantTruncation() && this.warningCount > 0) {
- SQLError.convertShowWarningsToSQLWarnings(this.connection,
- this.warningCount, true);
- }
- }
-
- /**
- * Secure authentication for 4.1 and newer servers.
- *
- * @param packet DOCUMENT ME!
- * @param packLength
- * @param user
- * @param password
- * @param database DOCUMENT ME!
- * @param writeClientParams
- *
- * @throws SQLException
- */
- private void secureAuth(Buffer packet, int packLength, String user,
- String password, String database, boolean writeClientParams)
- throws SQLException {
- // Passwords can be 16 chars long
- if (packet == null) {
- packet = new Buffer(packLength);
- }
-
- if (writeClientParams) {
- if (this.use41Extensions) {
- if (versionMeetsMinimum(4, 1, 1)) {
- packet.writeLong(this.clientParam);
- packet.writeLong(this.maxThreeBytes);
-
- // charset, JDBC will connect as 'latin1',
- // and use 'SET NAMES' to change to the desired
- // charset after the connection is established.
- packet.writeByte((byte) 8);
-
- // Set of bytes reserved for future use.
- packet.writeBytesNoNull(new byte[23]);
- } else {
- packet.writeLong(this.clientParam);
- packet.writeLong(this.maxThreeBytes);
- }
- } else {
- packet.writeInt((int) this.clientParam);
- packet.writeLongInt(this.maxThreeBytes);
- }
- }
-
- // User/Password data
- packet.writeString(user, CODE_PAGE_1252, this.connection);
-
- if (password.length() != 0) {
- /* Prepare false scramble */
- packet.writeString(FALSE_SCRAMBLE, CODE_PAGE_1252, this.connection);
- } else {
- /* For empty password*/
- packet.writeString("", CODE_PAGE_1252, this.connection); //$NON-NLS-1$
- }
-
- if (this.useConnectWithDb) {
- packet.writeString(database, CODE_PAGE_1252, this.connection);
- }
-
- send(packet, packet.getPosition());
-
- //
- // Don't continue stages if password is empty
- //
- if (password.length() > 0) {
- Buffer b = readPacket();
-
- b.setPosition(0);
-
- byte[] replyAsBytes = b.getByteBuffer();
-
- if ((replyAsBytes.length == 25) && (replyAsBytes[0] != 0)) {
- // Old passwords will have '*' at the first byte of hash */
- if (replyAsBytes[0] != '*') {
- try {
- /* Build full password hash as it is required to decode scramble */
- byte[] buff = Security.passwordHashStage1(password);
-
- /* Store copy as we'll need it later */
- byte[] passwordHash = new byte[buff.length];
- System.arraycopy(buff, 0, passwordHash, 0, buff.length);
-
- /* Finally hash complete password using hash we got from server */
- passwordHash = Security.passwordHashStage2(passwordHash,
- replyAsBytes);
-
- byte[] packetDataAfterSalt = new byte[replyAsBytes.length -
- 5];
-
- System.arraycopy(replyAsBytes, 4, packetDataAfterSalt,
- 0, replyAsBytes.length - 5);
-
- byte[] mysqlScrambleBuff = new byte[20];
-
- /* Decypt and store scramble 4 = hash for stage2 */
- Security.passwordCrypt(packetDataAfterSalt,
- mysqlScrambleBuff, passwordHash, 20);
-
- /* Encode scramble with password. Recycle buffer */
- Security.passwordCrypt(mysqlScrambleBuff, buff, buff, 20);
-
- Buffer packet2 = new Buffer(25);
- packet2.writeBytesNoNull(buff);
-
- this.packetSequence++;
-
- send(packet2, 24);
- } catch (NoSuchAlgorithmException nse) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.91") //$NON-NLS-1$
- +Messages.getString("MysqlIO.92"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- } else {
- try {
- /* Create password to decode scramble */
- byte[] passwordHash = Security.createKeyFromOldPassword(password);
-
- /* Decypt and store scramble 4 = hash for stage2 */
- byte[] netReadPos4 = new byte[replyAsBytes.length - 5];
-
- System.arraycopy(replyAsBytes, 4, netReadPos4, 0,
- replyAsBytes.length - 5);
-
- byte[] mysqlScrambleBuff = new byte[20];
-
- /* Decypt and store scramble 4 = hash for stage2 */
- Security.passwordCrypt(netReadPos4, mysqlScrambleBuff,
- passwordHash, 20);
-
- /* Finally scramble decoded scramble with password */
- String scrambledPassword = Util.scramble(new String(
- mysqlScrambleBuff), password);
-
- Buffer packet2 = new Buffer(packLength);
- packet2.writeString(scrambledPassword, CODE_PAGE_1252, this.connection);
- this.packetSequence++;
-
- send(packet2, 24);
- } catch (NoSuchAlgorithmException nse) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.93") //$NON-NLS-1$
- +Messages.getString("MysqlIO.94"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
- }
- }
- }
-
- /**
- * Secure authentication for 4.1.1 and newer servers.
- *
- * @param packet DOCUMENT ME!
- * @param packLength
- * @param user
- * @param password
- * @param database DOCUMENT ME!
- * @param writeClientParams
- *
- * @throws SQLException
- */
- void secureAuth411(Buffer packet, int packLength, String user,
- String password, String database, boolean writeClientParams)
- throws SQLException {
- // SERVER: public_seed=create_random_string()
- // send(public_seed)
- //
- // CLIENT: recv(public_seed)
- // hash_stage1=sha1("password")
- // hash_stage2=sha1(hash_stage1)
- // reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
- //
- // // this three steps are done in scramble()
- //
- // send(reply)
- //
- //
- // SERVER: recv(reply)
- // hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
- // candidate_hash2=sha1(hash_stage1)
- // check(candidate_hash2==hash_stage2)
- // Passwords can be 16 chars long
- if (packet == null) {
- packet = new Buffer(packLength);
- }
-
- if (writeClientParams) {
- if (this.use41Extensions) {
- if (versionMeetsMinimum(4, 1, 1)) {
- packet.writeLong(this.clientParam);
- packet.writeLong(this.maxThreeBytes);
-
- // charset, JDBC will connect as 'utf8',
- // and use 'SET NAMES' to change to the desired
- // charset after the connection is established.
- packet.writeByte((byte) UTF8_CHARSET_INDEX);
-
- // Set of bytes reserved for future use.
- packet.writeBytesNoNull(new byte[23]);
- } else {
- packet.writeLong(this.clientParam);
- packet.writeLong(this.maxThreeBytes);
- }
- } else {
- packet.writeInt((int) this.clientParam);
- packet.writeLongInt(this.maxThreeBytes);
- }
- }
-
- // User/Password data
- packet.writeString(user, "utf-8", this.connection);
-
- if (password.length() != 0) {
- packet.writeByte((byte) 0x14);
-
- try {
- packet.writeBytesNoNull(Security.scramble411(password, this.seed, this.connection));
- } catch (NoSuchAlgorithmException nse) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.95") //$NON-NLS-1$
- +Messages.getString("MysqlIO.96"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- } catch (UnsupportedEncodingException e) {
- throw SQLError.createSQLException(Messages.getString("MysqlIO.95") //$NON-NLS-1$
- +Messages.getString("MysqlIO.96"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- } else {
- /* For empty password*/
- packet.writeByte((byte) 0);
- }
-
- if (this.useConnectWithDb) {
- packet.writeString(database, "utf-8", this.connection);
- }
-
- send(packet, packet.getPosition());
-
- byte savePacketSequence = this.packetSequence++;
-
- Buffer reply = checkErrorPacket();
-
- if (reply.isLastDataPacket()) {
- /*
- By sending this very specific reply server asks us to send scrambled
- password in old format. The reply contains scramble_323.
- */
- this.packetSequence = ++savePacketSequence;
- packet.clear();
-
- String seed323 = this.seed.substring(0, 8);
- packet.writeString(Util.newCrypt(password, seed323));
- send(packet, packet.getPosition());
-
- /* Read what server thinks about out new auth message report */
- checkErrorPacket();
- }
- }
-
- /**
- * Un-packs binary-encoded result set data for one row
- *
- * @param fields
- * @param binaryData
- * @param resultSetConcurrency DOCUMENT ME!
- *
- * @return byte[][]
- *
- * @throws SQLException DOCUMENT ME!
- */
- private final ResultSetRow unpackBinaryResultSetRow(Field[] fields,
- Buffer binaryData, int resultSetConcurrency) throws SQLException {
- int numFields = fields.length;
-
- byte[][] unpackedRowData = new byte[numFields][];
-
- //
- // Unpack the null bitmask, first
- //
-
- /* Reserve place for null-marker bytes */
- int nullCount = (numFields + 9) / 8;
-
- byte[] nullBitMask = new byte[nullCount];
-
- for (int i = 0; i < nullCount; i++) {
- nullBitMask[i] = binaryData.readByte();
- }
-
- int nullMaskPos = 0;
- int bit = 4; // first two bits are reserved for future use
-
- //
- // TODO: Benchmark if moving check for updatable result
- // sets out of loop is worthwhile?
- //
-
- for (int i = 0; i < numFields; i++) {
- if ((nullBitMask[nullMaskPos] & bit) != 0) {
- unpackedRowData[i] = null;
- } else {
- if (resultSetConcurrency != ResultSetInternalMethods.CONCUR_UPDATABLE) {
- extractNativeEncodedColumn(binaryData, fields, i,
- unpackedRowData);
- } else {
- unpackNativeEncodedColumn(binaryData, fields, i,
- unpackedRowData);
- }
- }
-
- if (((bit <<= 1) & 255) == 0) {
- bit = 1; /* To next byte */
-
- nullMaskPos++;
- }
- }
-
- return new ByteArrayRow(unpackedRowData, getExceptionInterceptor());
- }
-
-
- private final void extractNativeEncodedColumn(Buffer binaryData,
- Field[] fields, int columnIndex, byte[][] unpackedRowData) throws SQLException {
- Field curField = fields[columnIndex];
-
- switch (curField.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_NULL:
- break; // for dummy binds
-
- case MysqlDefs.FIELD_TYPE_TINY:
-
- unpackedRowData[columnIndex] = new byte[] {binaryData.readByte()};
- break;
-
- case MysqlDefs.FIELD_TYPE_SHORT:
- case MysqlDefs.FIELD_TYPE_YEAR:
-
- unpackedRowData[columnIndex] = binaryData.getBytes(2);
- break;
- case MysqlDefs.FIELD_TYPE_LONG:
- case MysqlDefs.FIELD_TYPE_INT24:
-
- unpackedRowData[columnIndex] = binaryData.getBytes(4);
- break;
- case MysqlDefs.FIELD_TYPE_LONGLONG:
-
- unpackedRowData[columnIndex] = binaryData.getBytes(8);
- break;
- case MysqlDefs.FIELD_TYPE_FLOAT:
-
- unpackedRowData[columnIndex] = binaryData.getBytes(4);
- break;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
-
- unpackedRowData[columnIndex] = binaryData.getBytes(8);
- break;
- case MysqlDefs.FIELD_TYPE_TIME:
-
- int length = (int) binaryData.readFieldLength();
-
- unpackedRowData[columnIndex] = binaryData.getBytes(length);
-
- break;
- case MysqlDefs.FIELD_TYPE_DATE:
-
- length = (int) binaryData.readFieldLength();
-
- unpackedRowData[columnIndex] = binaryData.getBytes(length);
-
- break;
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- length = (int) binaryData.readFieldLength();
-
- unpackedRowData[columnIndex] = binaryData.getBytes(length);
- break;
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- case MysqlDefs.FIELD_TYPE_BLOB:
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- case MysqlDefs.FIELD_TYPE_STRING:
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- case MysqlDefs.FIELD_TYPE_GEOMETRY:
- unpackedRowData[columnIndex] = binaryData.readLenByteArray(0);
-
- break;
- case MysqlDefs.FIELD_TYPE_BIT:
- unpackedRowData[columnIndex] = binaryData.readLenByteArray(0);
-
- break;
- default:
- throw SQLError.createSQLException(Messages.getString("MysqlIO.97") //$NON-NLS-1$
- +curField.getMysqlType() +
- Messages.getString("MysqlIO.98") + columnIndex +
- Messages.getString("MysqlIO.99") //$NON-NLS-1$ //$NON-NLS-2$
- + fields.length + Messages.getString("MysqlIO.100"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- private final void unpackNativeEncodedColumn(Buffer binaryData,
- Field[] fields, int columnIndex, byte[][] unpackedRowData)
- throws SQLException {
- Field curField = fields[columnIndex];
-
- switch (curField.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_NULL:
- break; // for dummy binds
-
- case MysqlDefs.FIELD_TYPE_TINY:
-
- byte tinyVal = binaryData.readByte();
-
- if (!curField.isUnsigned()) {
- unpackedRowData[columnIndex] = String.valueOf(tinyVal)
- .getBytes();
- } else {
- short unsignedTinyVal = (short) (tinyVal & 0xff);
-
- unpackedRowData[columnIndex] = String.valueOf(unsignedTinyVal)
- .getBytes();
- }
-
- break;
-
- case MysqlDefs.FIELD_TYPE_SHORT:
- case MysqlDefs.FIELD_TYPE_YEAR:
-
- short shortVal = (short) binaryData.readInt();
-
- if (!curField.isUnsigned()) {
- unpackedRowData[columnIndex] = String.valueOf(shortVal)
- .getBytes();
- } else {
- int unsignedShortVal = shortVal & 0xffff;
-
- unpackedRowData[columnIndex] = String.valueOf(unsignedShortVal)
- .getBytes();
- }
-
- break;
-
- case MysqlDefs.FIELD_TYPE_LONG:
- case MysqlDefs.FIELD_TYPE_INT24:
-
- int intVal = (int) binaryData.readLong();
-
- if (!curField.isUnsigned()) {
- unpackedRowData[columnIndex] = String.valueOf(intVal)
- .getBytes();
- } else {
- long longVal = intVal & 0xffffffffL;
-
- unpackedRowData[columnIndex] = String.valueOf(longVal)
- .getBytes();
- }
-
- break;
-
- case MysqlDefs.FIELD_TYPE_LONGLONG:
-
- long longVal = binaryData.readLongLong();
-
- if (!curField.isUnsigned()) {
- unpackedRowData[columnIndex] = String.valueOf(longVal)
- .getBytes();
- } else {
- BigInteger asBigInteger = ResultSetImpl.convertLongToUlong(longVal);
-
- unpackedRowData[columnIndex] = asBigInteger.toString()
- .getBytes();
- }
-
- break;
-
- case MysqlDefs.FIELD_TYPE_FLOAT:
-
- float floatVal = Float.intBitsToFloat(binaryData.readIntAsLong());
-
- unpackedRowData[columnIndex] = String.valueOf(floatVal).getBytes();
-
- break;
-
- case MysqlDefs.FIELD_TYPE_DOUBLE:
-
- double doubleVal = Double.longBitsToDouble(binaryData.readLongLong());
-
- unpackedRowData[columnIndex] = String.valueOf(doubleVal).getBytes();
-
- break;
-
- case MysqlDefs.FIELD_TYPE_TIME:
-
- int length = (int) binaryData.readFieldLength();
-
- int hour = 0;
- int minute = 0;
- int seconds = 0;
-
- if (length != 0) {
- binaryData.readByte(); // skip tm->neg
- binaryData.readLong(); // skip daysPart
- hour = binaryData.readByte();
- minute = binaryData.readByte();
- seconds = binaryData.readByte();
-
- if (length > 8) {
- binaryData.readLong(); // ignore 'secondsPart'
- }
- }
-
-
- byte[] timeAsBytes = new byte[8];
-
- timeAsBytes[0] = (byte) Character.forDigit(hour / 10, 10);
- timeAsBytes[1] = (byte) Character.forDigit(hour % 10, 10);
-
- timeAsBytes[2] = (byte) ':';
-
- timeAsBytes[3] = (byte) Character.forDigit(minute / 10,
- 10);
- timeAsBytes[4] = (byte) Character.forDigit(minute % 10,
- 10);
-
- timeAsBytes[5] = (byte) ':';
-
- timeAsBytes[6] = (byte) Character.forDigit(seconds / 10,
- 10);
- timeAsBytes[7] = (byte) Character.forDigit(seconds % 10,
- 10);
-
- unpackedRowData[columnIndex] = timeAsBytes;
-
-
- break;
-
- case MysqlDefs.FIELD_TYPE_DATE:
- length = (int) binaryData.readFieldLength();
-
- int year = 0;
- int month = 0;
- int day = 0;
-
- hour = 0;
- minute = 0;
- seconds = 0;
-
- if (length != 0) {
- year = binaryData.readInt();
- month = binaryData.readByte();
- day = binaryData.readByte();
- }
-
- if ((year == 0) && (month == 0) && (day == 0)) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL.equals(
- this.connection.getZeroDateTimeBehavior())) {
- unpackedRowData[columnIndex] = null;
-
- break;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION.equals(
- this.connection.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '0000-00-00' can not be represented as java.sql.Date",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- year = 1;
- month = 1;
- day = 1;
- }
-
-
- byte[] dateAsBytes = new byte[10];
-
- dateAsBytes[0] = (byte) Character.forDigit(year / 1000,
- 10);
-
- int after1000 = year % 1000;
-
- dateAsBytes[1] = (byte) Character.forDigit(after1000 / 100,
- 10);
-
- int after100 = after1000 % 100;
-
- dateAsBytes[2] = (byte) Character.forDigit(after100 / 10,
- 10);
- dateAsBytes[3] = (byte) Character.forDigit(after100 % 10,
- 10);
-
- dateAsBytes[4] = (byte) '-';
-
- dateAsBytes[5] = (byte) Character.forDigit(month / 10,
- 10);
- dateAsBytes[6] = (byte) Character.forDigit(month % 10,
- 10);
-
- dateAsBytes[7] = (byte) '-';
-
- dateAsBytes[8] = (byte) Character.forDigit(day / 10, 10);
- dateAsBytes[9] = (byte) Character.forDigit(day % 10, 10);
-
- unpackedRowData[columnIndex] = dateAsBytes;
-
-
- break;
-
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- length = (int) binaryData.readFieldLength();
-
- year = 0;
- month = 0;
- day = 0;
-
- hour = 0;
- minute = 0;
- seconds = 0;
-
- int nanos = 0;
-
- if (length != 0) {
- year = binaryData.readInt();
- month = binaryData.readByte();
- day = binaryData.readByte();
-
- if (length > 4) {
- hour = binaryData.readByte();
- minute = binaryData.readByte();
- seconds = binaryData.readByte();
- }
-
- //if (length > 7) {
- // nanos = (int)binaryData.readLong();
- //}
- }
-
- if ((year == 0) && (month == 0) && (day == 0)) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL.equals(
- this.connection.getZeroDateTimeBehavior())) {
- unpackedRowData[columnIndex] = null;
-
- break;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION.equals(
- this.connection.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '0000-00-00' can not be represented as java.sql.Timestamp",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- year = 1;
- month = 1;
- day = 1;
- }
-
-
- int stringLength = 19;
-
- byte[] nanosAsBytes = Integer.toString(nanos).getBytes();
-
- stringLength += (1 + nanosAsBytes.length); // '.' + # of digits
-
- byte[] datetimeAsBytes = new byte[stringLength];
-
- datetimeAsBytes[0] = (byte) Character.forDigit(year / 1000,
- 10);
-
- after1000 = year % 1000;
-
- datetimeAsBytes[1] = (byte) Character.forDigit(after1000 / 100,
- 10);
-
- after100 = after1000 % 100;
-
- datetimeAsBytes[2] = (byte) Character.forDigit(after100 / 10,
- 10);
- datetimeAsBytes[3] = (byte) Character.forDigit(after100 % 10,
- 10);
-
- datetimeAsBytes[4] = (byte) '-';
-
- datetimeAsBytes[5] = (byte) Character.forDigit(month / 10,
- 10);
- datetimeAsBytes[6] = (byte) Character.forDigit(month % 10,
- 10);
-
- datetimeAsBytes[7] = (byte) '-';
-
- datetimeAsBytes[8] = (byte) Character.forDigit(day / 10,
- 10);
- datetimeAsBytes[9] = (byte) Character.forDigit(day % 10,
- 10);
-
- datetimeAsBytes[10] = (byte) ' ';
-
- datetimeAsBytes[11] = (byte) Character.forDigit(hour / 10,
- 10);
- datetimeAsBytes[12] = (byte) Character.forDigit(hour % 10,
- 10);
-
- datetimeAsBytes[13] = (byte) ':';
-
- datetimeAsBytes[14] = (byte) Character.forDigit(minute / 10,
- 10);
- datetimeAsBytes[15] = (byte) Character.forDigit(minute % 10,
- 10);
-
- datetimeAsBytes[16] = (byte) ':';
-
- datetimeAsBytes[17] = (byte) Character.forDigit(seconds / 10,
- 10);
- datetimeAsBytes[18] = (byte) Character.forDigit(seconds % 10,
- 10);
-
- datetimeAsBytes[19] = (byte) '.';
-
- int nanosOffset = 20;
-
- for (int j = 0; j < nanosAsBytes.length; j++) {
- datetimeAsBytes[nanosOffset + j] = nanosAsBytes[j];
- }
-
- unpackedRowData[columnIndex] = datetimeAsBytes;
-
-
- break;
-
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- case MysqlDefs.FIELD_TYPE_BLOB:
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- case MysqlDefs.FIELD_TYPE_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- case MysqlDefs.FIELD_TYPE_BIT:
- unpackedRowData[columnIndex] = binaryData.readLenByteArray(0);
-
- break;
-
- default:
- throw SQLError.createSQLException(Messages.getString("MysqlIO.97") //$NON-NLS-1$
- +curField.getMysqlType() +
- Messages.getString("MysqlIO.98") + columnIndex +
- Messages.getString("MysqlIO.99") //$NON-NLS-1$ //$NON-NLS-2$
- + fields.length + Messages.getString("MysqlIO.100"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- /**
- * Negotiates the SSL communications channel used when connecting
- * to a MySQL server that understands SSL.
- *
- * @param user
- * @param password
- * @param database
- * @param packLength
- * @throws SQLException
- * @throws CommunicationsException
- */
- private void negotiateSSLConnection(String user, String password,
- String database, int packLength)
- throws SQLException {
- if (!ExportControlled.enabled()) {
- throw new ConnectionFeatureNotAvailableException(this.connection,
- this.lastPacketSentTimeMs, null);
- }
-
- boolean doSecureAuth = false;
-
- if ((this.serverCapabilities & CLIENT_SECURE_CONNECTION) != 0) {
- this.clientParam |= CLIENT_SECURE_CONNECTION;
- doSecureAuth = true;
- }
-
- this.clientParam |= CLIENT_SSL;
-
- Buffer packet = new Buffer(packLength);
-
- if (this.use41Extensions) {
- packet.writeLong(this.clientParam);
- } else {
- packet.writeInt((int) this.clientParam);
- }
-
- send(packet, packet.getPosition());
-
- ExportControlled.transformSocketToSSLSocket(this);
-
- packet.clear();
-
- if (doSecureAuth) {
- if (versionMeetsMinimum(4, 1, 1)) {
- secureAuth411(null, packLength, user, password, database, true);
- } else {
- secureAuth411(null, packLength, user, password, database, true);
- }
- } else {
- if (this.use41Extensions) {
- packet.writeLong(this.clientParam);
- packet.writeLong(this.maxThreeBytes);
- } else {
- packet.writeInt((int) this.clientParam);
- packet.writeLongInt(this.maxThreeBytes);
- }
-
- // User/Password data
- packet.writeString(user);
-
- if (this.protocolVersion > 9) {
- packet.writeString(Util.newCrypt(password, this.seed));
- } else {
- packet.writeString(Util.oldCrypt(password, this.seed));
- }
-
- if (((this.serverCapabilities & CLIENT_CONNECT_WITH_DB) != 0) &&
- (database != null) && (database.length() > 0)) {
- packet.writeString(database);
- }
-
- send(packet, packet.getPosition());
- }
- }
-
- protected int getServerStatus() {
- return this.serverStatus;
- }
-
- protected List fetchRowsViaCursor(List fetchedRows, long statementId,
- Field[] columnTypes, int fetchSize, boolean useBufferRowExplicit) throws SQLException {
-
- if (fetchedRows == null) {
- fetchedRows = new ArrayList(fetchSize);
- } else {
- fetchedRows.clear();
- }
-
- this.sharedSendPacket.clear();
-
- this.sharedSendPacket.writeByte((byte) MysqlDefs.COM_FETCH);
- this.sharedSendPacket.writeLong(statementId);
- this.sharedSendPacket.writeLong(fetchSize);
-
- sendCommand(MysqlDefs.COM_FETCH, null, this.sharedSendPacket, true,
- null, 0);
-
- ResultSetRow row = null;
-
- while ((row = nextRow(columnTypes, columnTypes.length, true,
- ResultSet.CONCUR_READ_ONLY, false, useBufferRowExplicit, false, null)) != null) {
- fetchedRows.add(row);
- }
-
- return fetchedRows;
- }
-
- protected long getThreadId() {
- return this.threadId;
- }
-
- protected boolean useNanosForElapsedTime() {
- return this.useNanosForElapsedTime;
- }
-
- protected long getSlowQueryThreshold() {
- return this.slowQueryThreshold;
- }
-
- protected String getQueryTimingUnits() {
- return this.queryTimingUnits;
- }
-
- protected int getCommandCount() {
- return this.commandCount;
- }
-
- private void checkTransactionState(int oldStatus) throws SQLException {
- boolean previouslyInTrans = ((oldStatus & SERVER_STATUS_IN_TRANS) != 0);
- boolean currentlyInTrans = ((this.serverStatus & SERVER_STATUS_IN_TRANS) != 0);
-
- if (previouslyInTrans && !currentlyInTrans) {
- this.connection.transactionCompleted();
- } else if (!previouslyInTrans && currentlyInTrans) {
- this.connection.transactionBegun();
- }
- }
-
- protected void setStatementInterceptors(List statementInterceptors) {
- this.statementInterceptors = statementInterceptors;
- }
-
- protected ExceptionInterceptor getExceptionInterceptor() {
- return this.exceptionInterceptor;
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/MysqlParameterMetadata.java b/src/com/mysql/jdbc/MysqlParameterMetadata.java
deleted file mode 100644
index c5c216f1d..000000000
--- a/src/com/mysql/jdbc/MysqlParameterMetadata.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.ParameterMetaData;
-import java.sql.SQLException;
-import java.sql.Types;
-
-public class MysqlParameterMetadata implements ParameterMetaData {
- boolean returnSimpleMetadata = false;
-
- ResultSetMetaData metadata = null;
-
- int parameterCount = 0;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- MysqlParameterMetadata(Field[] fieldInfo, int parameterCount, ExceptionInterceptor exceptionInterceptor) {
- this.metadata = new ResultSetMetaData(fieldInfo, false, exceptionInterceptor);
-
- this.parameterCount = parameterCount;
- this.exceptionInterceptor = exceptionInterceptor;
- }
-
- /**
- * Used for "fake" basic metadata for client-side prepared statements when
- * we don't know the parameter types.
- *
- * @param parameterCount
- */
- MysqlParameterMetadata(int count) {
- this.parameterCount = count;
- this.returnSimpleMetadata = true;
- }
-
- public int getParameterCount() throws SQLException {
- return this.parameterCount;
- }
-
- public int isNullable(int arg0) throws SQLException {
- checkAvailable();
-
- return this.metadata.isNullable(arg0);
- }
-
- private void checkAvailable() throws SQLException {
- if (this.metadata == null || this.metadata.fields == null) {
- throw SQLError.createSQLException(
- "Parameter metadata not available for the given statement",
- SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, this.exceptionInterceptor);
- }
- }
-
- public boolean isSigned(int arg0) throws SQLException {
- if (this.returnSimpleMetadata) {
- checkBounds(arg0);
-
- return false;
- }
-
- checkAvailable();
-
- return (this.metadata.isSigned(arg0));
- }
-
- public int getPrecision(int arg0) throws SQLException {
- if (this.returnSimpleMetadata) {
- checkBounds(arg0);
-
- return 0;
- }
-
- checkAvailable();
-
- return (this.metadata.getPrecision(arg0));
- }
-
- public int getScale(int arg0) throws SQLException {
- if (this.returnSimpleMetadata) {
- checkBounds(arg0);
-
- return 0;
- }
-
- checkAvailable();
-
- return (this.metadata.getScale(arg0));
- }
-
- public int getParameterType(int arg0) throws SQLException {
- if (this.returnSimpleMetadata) {
- checkBounds(arg0);
-
- return Types.VARCHAR;
- }
-
- checkAvailable();
-
- return (this.metadata.getColumnType(arg0));
- }
-
- public String getParameterTypeName(int arg0) throws SQLException {
- if (this.returnSimpleMetadata) {
- checkBounds(arg0);
-
- return "VARCHAR";
- }
-
- checkAvailable();
-
- return (this.metadata.getColumnTypeName(arg0));
- }
-
- public String getParameterClassName(int arg0) throws SQLException {
- if (this.returnSimpleMetadata) {
- checkBounds(arg0);
-
- return "java.lang.String";
- }
-
- checkAvailable();
-
- return (this.metadata.getColumnClassName(arg0));
- }
-
- public int getParameterMode(int arg0) throws SQLException {
- return parameterModeIn;
- }
-
- private void checkBounds(int paramNumber) throws SQLException {
- if (paramNumber < 1) {
- throw SQLError.createSQLException("Parameter index of '"
- + paramNumber + "' is invalid.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
-
- if (paramNumber > this.parameterCount) {
- throw SQLError.createSQLException("Parameter index of '"
- + paramNumber
- + "' is greater than number of parameters, which is '"
- + this.parameterCount + "'.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
-
- }
- }
-
- /**
- * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
- * for an object that does. Returns false otherwise. If this implements the interface then return true,
- * else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
- * object. If this does not implement the interface and is not a wrapper, return false.
- * This method should be implemented as a low-cost operation compared to unwrap so that
- * callers can use this method to avoid expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument should succeed.
- *
- * @param interfaces a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly wraps an object that does.
- * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
- * for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class iface) throws SQLException {
-
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to non-standard methods,
- * or standard methods not exposed by the proxy.
- * The result may be either the object found to implement the interface or a proxy for that object.
- * If the receiver implements the interface then that is the object. If the receiver is a wrapper
- * and the wrapped object implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped object. If the receiver is not a
- * wrapper and does not implement the interface, then an SQLException is thrown.
- *
- * @param iface A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the actual implementing object.
- * @throws java.sql.SQLException If no object found that implements the interface
- * @since 1.6
- */
- public Object unwrap(Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return Util.cast(iface, this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-}
diff --git a/src/com/mysql/jdbc/MysqlSavepoint.java b/src/com/mysql/jdbc/MysqlSavepoint.java
deleted file mode 100644
index adc1ba855..000000000
--- a/src/com/mysql/jdbc/MysqlSavepoint.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.rmi.server.UID;
-import java.sql.SQLException;
-import java.sql.Savepoint;
-
-/**
- * Represents SQL SAVEPOINTS in MySQL.
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public class MysqlSavepoint implements Savepoint {
- private static String getUniqueId() {
- // no need to re-invent the wheel here...
- String uidStr = new UID().toString();
-
- int uidLength = uidStr.length();
-
- StringBuffer safeString = new StringBuffer(uidLength);
-
- for (int i = 0; i < uidLength; i++) {
- char c = uidStr.charAt(i);
-
- if (Character.isLetter(c) || Character.isDigit(c)) {
- safeString.append(c);
- } else {
- safeString.append('_');
- }
- }
-
- return safeString.toString();
- }
-
- private String savepointName;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- /**
- * Creates an unnamed savepoint.
- *
- * @param conn
- *
- * @throws SQLException
- * if an error occurs
- */
- MysqlSavepoint(ExceptionInterceptor exceptionInterceptor) throws SQLException {
- this(getUniqueId(), exceptionInterceptor);
- }
-
- /**
- * Creates a named savepoint
- *
- * @param name
- * the name of the savepoint.
- *
- * @throws SQLException
- * if name == null or is empty.
- */
- MysqlSavepoint(String name, ExceptionInterceptor exceptionInterceptor) throws SQLException {
- if (name == null || name.length() == 0) {
- throw SQLError.createSQLException("Savepoint name can not be NULL or empty",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- this.savepointName = name;
-
- this.exceptionInterceptor = exceptionInterceptor;
- }
-
- /**
- * @see java.sql.Savepoint#getSavepointId()
- */
- public int getSavepointId() throws SQLException {
- throw SQLError.createSQLException("Only named savepoints are supported.",
- SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, exceptionInterceptor);
- }
-
- /**
- * @see java.sql.Savepoint#getSavepointName()
- */
- public String getSavepointName() throws SQLException {
- return this.savepointName;
- }
-}
diff --git a/src/com/mysql/jdbc/NamedPipeSocketFactory.java b/src/com/mysql/jdbc/NamedPipeSocketFactory.java
deleted file mode 100644
index 0f021f912..000000000
--- a/src/com/mysql/jdbc/NamedPipeSocketFactory.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.RandomAccessFile;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.Properties;
-
-/**
- * A socket factory for named pipes (on Windows)
- *
- * @author Mark Matthews
- */
-public class NamedPipeSocketFactory implements SocketFactory {
- /**
- * A socket that encapsulates named pipes on Windows
- */
- class NamedPipeSocket extends Socket {
- private boolean isClosed = false;
-
- private RandomAccessFile namedPipeFile;
-
- NamedPipeSocket(String filePath) throws IOException {
- if ((filePath == null) || (filePath.length() == 0)) {
- throw new IOException(Messages
- .getString("NamedPipeSocketFactory.4")); //$NON-NLS-1$
- }
-
- this.namedPipeFile = new RandomAccessFile(filePath, "rw"); //$NON-NLS-1$
- }
-
- /**
- * @see java.net.Socket#close()
- */
- public synchronized void close() throws IOException {
- this.namedPipeFile.close();
- this.isClosed = true;
- }
-
- /**
- * @see java.net.Socket#getInputStream()
- */
- public InputStream getInputStream() throws IOException {
- return new RandomAccessFileInputStream(this.namedPipeFile);
- }
-
- /**
- * @see java.net.Socket#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- return new RandomAccessFileOutputStream(this.namedPipeFile);
- }
-
- /**
- * @see java.net.Socket#isClosed()
- */
- public boolean isClosed() {
- return this.isClosed;
- }
- }
-
- /**
- * Enables OutputStream-type functionality for a RandomAccessFile
- */
- class RandomAccessFileInputStream extends InputStream {
- RandomAccessFile raFile;
-
- RandomAccessFileInputStream(RandomAccessFile file) {
- this.raFile = file;
- }
-
- /**
- * @see java.io.InputStream#available()
- */
- public int available() throws IOException {
- return -1;
- }
-
- /**
- * @see java.io.InputStream#close()
- */
- public void close() throws IOException {
- this.raFile.close();
- }
-
- /**
- * @see java.io.InputStream#read()
- */
- public int read() throws IOException {
- return this.raFile.read();
- }
-
- /**
- * @see java.io.InputStream#read(byte[])
- */
- public int read(byte[] b) throws IOException {
- return this.raFile.read(b);
- }
-
- /**
- * @see java.io.InputStream#read(byte[], int, int)
- */
- public int read(byte[] b, int off, int len) throws IOException {
- return this.raFile.read(b, off, len);
- }
- }
-
- /**
- * Enables OutputStream-type functionality for a RandomAccessFile
- */
- class RandomAccessFileOutputStream extends OutputStream {
- RandomAccessFile raFile;
-
- RandomAccessFileOutputStream(RandomAccessFile file) {
- this.raFile = file;
- }
-
- /**
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- this.raFile.close();
- }
-
- /**
- * @see java.io.OutputStream#write(byte[])
- */
- public void write(byte[] b) throws IOException {
- this.raFile.write(b);
- }
-
- /**
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len) throws IOException {
- this.raFile.write(b, off, len);
- }
-
- /**
- * @see java.io.OutputStream#write(int)
- */
- public void write(int b) throws IOException {
- }
- }
-
- private static final String NAMED_PIPE_PROP_NAME = "namedPipePath"; //$NON-NLS-1$
-
- private Socket namedPipeSocket;
-
- /**
- * Constructor for NamedPipeSocketFactory.
- */
- public NamedPipeSocketFactory() {
- super();
- }
-
- /**
- * @see com.mysql.jdbc.SocketFactory#afterHandshake()
- */
- public Socket afterHandshake() throws SocketException, IOException {
- return this.namedPipeSocket;
- }
-
- /**
- * @see com.mysql.jdbc.SocketFactory#beforeHandshake()
- */
- public Socket beforeHandshake() throws SocketException, IOException {
- return this.namedPipeSocket;
- }
-
- /**
- * @see com.mysql.jdbc.SocketFactory#connect(String, Properties)
- */
- public Socket connect(String host, int portNumber /* ignored */,
- Properties props) throws SocketException, IOException {
- String namedPipePath = props.getProperty(NAMED_PIPE_PROP_NAME);
-
- if (namedPipePath == null) {
- namedPipePath = "\\\\.\\pipe\\MySQL"; //$NON-NLS-1$
- } else if (namedPipePath.length() == 0) {
- throw new SocketException(Messages
- .getString("NamedPipeSocketFactory.2") //$NON-NLS-1$
- + NAMED_PIPE_PROP_NAME
- + Messages.getString("NamedPipeSocketFactory.3")); //$NON-NLS-1$
- }
-
- this.namedPipeSocket = new NamedPipeSocket(namedPipePath);
-
- return this.namedPipeSocket;
- }
-}
diff --git a/src/com/mysql/jdbc/NonRegisteringDriver.java b/src/com/mysql/jdbc/NonRegisteringDriver.java
deleted file mode 100644
index ff3566ee7..000000000
--- a/src/com/mysql/jdbc/NonRegisteringDriver.java
+++ /dev/null
@@ -1,791 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-/**
- * The Java SQL framework allows for multiple database drivers. Each driver
- * should supply a class that implements the Driver interface
- *
- *
- * The DriverManager will try to load as many drivers as it can find and then
- * for any given connection request, it will ask each driver in turn to try to
- * connect to the target URL.
- *
- *
- *
- * It is strongly recommended that each Driver class should be small and
- * standalone so that the Driver class can be loaded and queried without
- * bringing in vast quantities of supporting code.
- *
- *
- *
- * When a Driver class is loaded, it should create an instance of itself and
- * register it with the DriverManager. This means that a user can load and
- * register a driver by doing Class.forName("foo.bah.Driver")
- *
- *
- * @author Mark Matthews
- * @version $Id: NonRegisteringDriver.java,v 1.1.2.1 2005/05/13 18:58:38
- * mmatthews Exp $
- *
- * @see org.gjt.mm.mysql.Connection
- * @see java.sql.Driver
- */
-public class NonRegisteringDriver implements java.sql.Driver {
- private static final String REPLICATION_URL_PREFIX = "jdbc:mysql:replication://";
-
- private static final String URL_PREFIX = "jdbc:mysql://";
-
- private static final String MXJ_URL_PREFIX = "jdbc:mysql:mxj://";
-
- private static final String LOADBALANCE_URL_PREFIX = "jdbc:mysql:loadbalance://";
-
- /**
- * Key used to retreive the database value from the properties instance
- * passed to the driver.
- */
- public static final String DBNAME_PROPERTY_KEY = "DBNAME";
-
- /** Should the driver generate debugging output? */
- public static final boolean DEBUG = false;
-
- /** Index for hostname coming out of parseHostPortPair(). */
- public final static int HOST_NAME_INDEX = 0;
-
- /**
- * Key used to retreive the hostname value from the properties instance
- * passed to the driver.
- */
- public static final String HOST_PROPERTY_KEY = "HOST";
-
- public static final String NUM_HOSTS_PROPERTY_KEY = "NUM_HOSTS";
-
- /**
- * Key used to retreive the password value from the properties instance
- * passed to the driver.
- */
- public static final String PASSWORD_PROPERTY_KEY = "password";
-
- /** Index for port # coming out of parseHostPortPair(). */
- public final static int PORT_NUMBER_INDEX = 1;
-
- /**
- * Key used to retreive the port number value from the properties instance
- * passed to the driver.
- */
- public static final String PORT_PROPERTY_KEY = "PORT";
-
- public static final String PROPERTIES_TRANSFORM_KEY = "propertiesTransform";
-
- /** Should the driver generate method-call traces? */
- public static final boolean TRACE = false;
-
- public static final String USE_CONFIG_PROPERTY_KEY = "useConfigs";
-
- /**
- * Key used to retreive the username value from the properties instance
- * passed to the driver.
- */
- public static final String USER_PROPERTY_KEY = "user";
-
- /**
- * Gets the drivers major version number
- *
- * @return the drivers major version number
- */
- static int getMajorVersionInternal() {
- return safeIntParse("@MYSQL_CJ_MAJOR_VERSION@"); //$NON-NLS-1$
- }
-
- /**
- * Get the drivers minor version number
- *
- * @return the drivers minor version number
- */
- static int getMinorVersionInternal() {
- return safeIntParse("@MYSQL_CJ_MINOR_VERSION@"); //$NON-NLS-1$
- }
-
- /**
- * Parses hostPortPair in the form of [host][:port] into an array, with the
- * element of index HOST_NAME_INDEX being the host (or null if not
- * specified), and the element of index PORT_NUMBER_INDEX being the port (or
- * null if not specified).
- *
- * @param hostPortPair
- * host and port in form of of [host][:port]
- *
- * @return array containing host and port as Strings
- *
- * @throws SQLException
- * if a parse error occurs
- */
- protected static String[] parseHostPortPair(String hostPortPair)
- throws SQLException {
- int portIndex = hostPortPair.indexOf(":"); //$NON-NLS-1$
-
- String[] splitValues = new String[2];
-
- String hostname = null;
-
- if (portIndex != -1) {
- if ((portIndex + 1) < hostPortPair.length()) {
- String portAsString = hostPortPair.substring(portIndex + 1);
- hostname = hostPortPair.substring(0, portIndex);
-
- splitValues[HOST_NAME_INDEX] = hostname;
-
- splitValues[PORT_NUMBER_INDEX] = portAsString;
- } else {
- throw SQLError.createSQLException(Messages
- .getString("NonRegisteringDriver.37"), //$NON-NLS-1$
- SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
- }
- } else {
- splitValues[HOST_NAME_INDEX] = hostPortPair;
- splitValues[PORT_NUMBER_INDEX] = null;
- }
-
- return splitValues;
- }
-
- private static int safeIntParse(String intAsString) {
- try {
- return Integer.parseInt(intAsString);
- } catch (NumberFormatException nfe) {
- return 0;
- }
- }
-
- /**
- * Construct a new driver and register it with DriverManager
- *
- * @throws SQLException
- * if a database error occurs.
- */
- public NonRegisteringDriver() throws SQLException {
- // Required for Class.forName().newInstance()
- }
-
- /**
- * Typically, drivers will return true if they understand the subprotocol
- * specified in the URL and false if they don't. This driver's protocols
- * start with jdbc:mysql:
- *
- * @param url
- * the URL of the driver
- *
- * @return true if this driver accepts the given URL
- *
- * @exception SQLException
- * if a database-access error occurs
- *
- * @see java.sql.Driver#acceptsURL
- */
- public boolean acceptsURL(String url) throws SQLException {
- return (parseURL(url, null) != null);
- }
-
- //
- // return the database name property
- //
-
- /**
- * Try to make a database connection to the given URL. The driver should
- * return "null" if it realizes it is the wrong kind of driver to connect to
- * the given URL. This will be common, as when the JDBC driverManager is
- * asked to connect to a given URL, it passes the URL to each loaded driver
- * in turn.
- *
- *
- * The driver should raise an SQLException if it is the right driver to
- * connect to the given URL, but has trouble connecting to the database.
- *
- *
- *
- * The java.util.Properties argument can be used to pass arbitrary string
- * tag/value pairs as connection arguments.
- *
- *
- *
- * My protocol takes the form:
- *
- *
- *
- * jdbc:mysql://host:port/database
- *
- *
- *
- *
- *
- * @param url
- * the URL of the database to connect to
- * @param info
- * a list of arbitrary tag/value pairs as connection arguments
- *
- * @return a connection to the URL or null if it isnt us
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see java.sql.Driver#connect
- */
- public java.sql.Connection connect(String url, Properties info)
- throws SQLException {
- if (url != null) {
- if (StringUtils.startsWithIgnoreCase(url, LOADBALANCE_URL_PREFIX)) {
- return connectLoadBalanced(url, info);
- } else if (StringUtils.startsWithIgnoreCase(url,
- REPLICATION_URL_PREFIX)) {
- return connectReplicationConnection(url, info);
- }
- }
-
- Properties props = null;
-
- if ((props = parseURL(url, info)) == null) {
- return null;
- }
-
- try {
- Connection newConn = com.mysql.jdbc.ConnectionImpl.getInstance(
- host(props), port(props), props, database(props), url);
-
- return newConn;
- } catch (SQLException sqlEx) {
- // Don't wrap SQLExceptions, throw
- // them un-changed.
- throw sqlEx;
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(Messages
- .getString("NonRegisteringDriver.17") //$NON-NLS-1$
- + ex.toString()
- + Messages.getString("NonRegisteringDriver.18"), //$NON-NLS-1$
- SQLError.SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE, null);
-
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- private java.sql.Connection connectLoadBalanced(String url, Properties info)
- throws SQLException {
- Properties parsedProps = parseURL(url, info);
-
- // People tend to drop this in, it doesn't make sense
- parsedProps.remove("roundRobinLoadBalance");
-
- if (parsedProps == null) {
- return null;
- }
-
- int numHosts = Integer.parseInt(parsedProps.getProperty(NUM_HOSTS_PROPERTY_KEY));
-
- List hostList = new ArrayList();
-
- for (int i = 0; i < numHosts; i++) {
- int index = i + 1;
-
- hostList.add(parsedProps.getProperty(HOST_PROPERTY_KEY + "." + index) + ":"
- + parsedProps.getProperty(PORT_PROPERTY_KEY + "." + index));
- }
-
- LoadBalancingConnectionProxy proxyBal = new LoadBalancingConnectionProxy(
- hostList, parsedProps);
-
- return (java.sql.Connection) java.lang.reflect.Proxy.newProxyInstance(this
- .getClass().getClassLoader(),
- new Class[] { java.sql.Connection.class }, proxyBal);
- }
-
- protected java.sql.Connection connectReplicationConnection(String url, Properties info)
- throws SQLException {
- Properties parsedProps = parseURL(url, info);
-
- if (parsedProps == null) {
- return null;
- }
-
- Properties masterProps = (Properties) parsedProps.clone();
- Properties slavesProps = (Properties) parsedProps.clone();
-
- // Marker used for further testing later on, also when
- // debugging
- slavesProps.setProperty("com.mysql.jdbc.ReplicationConnection.isSlave",
- "true");
-
- int numHosts = Integer.parseInt(parsedProps.getProperty(NUM_HOSTS_PROPERTY_KEY));
-
- if (numHosts < 2) {
- throw SQLError
- .createSQLException(
- "Must specify at least one slave host to connect to for master/slave replication load-balancing functionality",
- SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
- }
-
- for (int i = 1; i < numHosts; i++) {
- int index = i + 1;
-
- masterProps.remove(HOST_PROPERTY_KEY + "." + index);
- masterProps.remove(PORT_PROPERTY_KEY + "." + index);
-
- slavesProps.setProperty(HOST_PROPERTY_KEY + "." + i, parsedProps.getProperty(HOST_PROPERTY_KEY + "." + index));
- slavesProps.setProperty(PORT_PROPERTY_KEY + "." + i, parsedProps.getProperty(PORT_PROPERTY_KEY + "." + index));
- }
-
- masterProps.setProperty(NUM_HOSTS_PROPERTY_KEY, "1");
- slavesProps.remove(HOST_PROPERTY_KEY + "." + numHosts);
- slavesProps.remove(PORT_PROPERTY_KEY + "." + numHosts);
- slavesProps.setProperty(NUM_HOSTS_PROPERTY_KEY, String.valueOf(numHosts - 1));
- slavesProps.setProperty(HOST_PROPERTY_KEY, slavesProps.getProperty(HOST_PROPERTY_KEY + ".1"));
- slavesProps.setProperty(PORT_PROPERTY_KEY, slavesProps.getProperty(PORT_PROPERTY_KEY + ".1"));
-
- return new ReplicationConnection(masterProps, slavesProps);
- }
-
- /**
- * Returns the database property from props
- *
- * @param props
- * the Properties to look for the database property.
- *
- * @return the database name.
- */
- public String database(Properties props) {
- return props.getProperty(DBNAME_PROPERTY_KEY); //$NON-NLS-1$
- }
-
- /**
- * Gets the drivers major version number
- *
- * @return the drivers major version number
- */
- public int getMajorVersion() {
- return getMajorVersionInternal();
- }
-
- /**
- * Get the drivers minor version number
- *
- * @return the drivers minor version number
- */
- public int getMinorVersion() {
- return getMinorVersionInternal();
- }
-
- /**
- * The getPropertyInfo method is intended to allow a generic GUI tool to
- * discover what properties it should prompt a human for in order to get
- * enough information to connect to a database.
- *
- *
- * Note that depending on the values the human has supplied so far,
- * additional values may become necessary, so it may be necessary to iterate
- * through several calls to getPropertyInfo
- *
- *
- * @param url
- * the Url of the database to connect to
- * @param info
- * a proposed list of tag/value pairs that will be sent on
- * connect open.
- *
- * @return An array of DriverPropertyInfo objects describing possible
- * properties. This array may be an empty array if no properties are
- * required
- *
- * @exception SQLException
- * if a database-access error occurs
- *
- * @see java.sql.Driver#getPropertyInfo
- */
- public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
- throws SQLException {
- if (info == null) {
- info = new Properties();
- }
-
- if ((url != null) && url.startsWith(URL_PREFIX)) { //$NON-NLS-1$
- info = parseURL(url, info);
- }
-
- DriverPropertyInfo hostProp = new DriverPropertyInfo(HOST_PROPERTY_KEY, //$NON-NLS-1$
- info.getProperty(HOST_PROPERTY_KEY)); //$NON-NLS-1$
- hostProp.required = true;
- hostProp.description = Messages.getString("NonRegisteringDriver.3"); //$NON-NLS-1$
-
- DriverPropertyInfo portProp = new DriverPropertyInfo(PORT_PROPERTY_KEY, //$NON-NLS-1$
- info.getProperty(PORT_PROPERTY_KEY, "3306")); //$NON-NLS-1$ //$NON-NLS-2$
- portProp.required = false;
- portProp.description = Messages.getString("NonRegisteringDriver.7"); //$NON-NLS-1$
-
- DriverPropertyInfo dbProp = new DriverPropertyInfo(DBNAME_PROPERTY_KEY, //$NON-NLS-1$
- info.getProperty(DBNAME_PROPERTY_KEY)); //$NON-NLS-1$
- dbProp.required = false;
- dbProp.description = "Database name"; //$NON-NLS-1$
-
- DriverPropertyInfo userProp = new DriverPropertyInfo(USER_PROPERTY_KEY, //$NON-NLS-1$
- info.getProperty(USER_PROPERTY_KEY)); //$NON-NLS-1$
- userProp.required = true;
- userProp.description = Messages.getString("NonRegisteringDriver.13"); //$NON-NLS-1$
-
- DriverPropertyInfo passwordProp = new DriverPropertyInfo(
- PASSWORD_PROPERTY_KEY, //$NON-NLS-1$
- info.getProperty(PASSWORD_PROPERTY_KEY)); //$NON-NLS-1$
- passwordProp.required = true;
- passwordProp.description = Messages
- .getString("NonRegisteringDriver.16"); //$NON-NLS-1$
-
- DriverPropertyInfo[] dpi = ConnectionPropertiesImpl
- .exposeAsDriverPropertyInfo(info, 5);
-
- dpi[0] = hostProp;
- dpi[1] = portProp;
- dpi[2] = dbProp;
- dpi[3] = userProp;
- dpi[4] = passwordProp;
-
- return dpi;
- }
-
- //
- // return the value of any property this driver knows about
- //
-
- /**
- * Returns the hostname property
- *
- * @param props
- * the java.util.Properties instance to retrieve the hostname
- * from.
- *
- * @return the hostname
- */
- public String host(Properties props) {
- return props.getProperty(HOST_PROPERTY_KEY, "localhost"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Report whether the driver is a genuine JDBC compliant driver. A driver
- * may only report "true" here if it passes the JDBC compliance tests,
- * otherwise it is required to return false. JDBC compliance requires full
- * support for the JDBC API and full support for SQL 92 Entry Level.
- *
- *
- * MySQL is not SQL92 compliant
- *
- *
- * @return is this driver JDBC compliant?
- */
- public boolean jdbcCompliant() {
- return false;
- }
-
- public Properties parseURL(String url, Properties defaults)
- throws java.sql.SQLException {
- Properties urlProps = (defaults != null) ? new Properties(defaults)
- : new Properties();
-
- if (url == null) {
- return null;
- }
-
- if (!StringUtils.startsWithIgnoreCase(url, URL_PREFIX)
- && !StringUtils.startsWithIgnoreCase(url, MXJ_URL_PREFIX)
- && !StringUtils.startsWithIgnoreCase(url,
- LOADBALANCE_URL_PREFIX)
- && !StringUtils.startsWithIgnoreCase(url,
- REPLICATION_URL_PREFIX)) { //$NON-NLS-1$
-
- return null;
- }
-
- int beginningOfSlashes = url.indexOf("//");
-
- if (StringUtils.startsWithIgnoreCase(url, MXJ_URL_PREFIX)) {
-
- urlProps
- .setProperty("socketFactory",
- "com.mysql.management.driverlaunched.ServerLauncherSocketFactory");
- }
-
- /*
- * Parse parameters after the ? in the URL and remove them from the
- * original URL.
- */
- int index = url.indexOf("?"); //$NON-NLS-1$
-
- if (index != -1) {
- String paramString = url.substring(index + 1, url.length());
- url = url.substring(0, index);
-
- StringTokenizer queryParams = new StringTokenizer(paramString, "&"); //$NON-NLS-1$
-
- while (queryParams.hasMoreTokens()) {
- String parameterValuePair = queryParams.nextToken();
-
- int indexOfEquals = StringUtils.indexOfIgnoreCase(0,
- parameterValuePair, "=");
-
- String parameter = null;
- String value = null;
-
- if (indexOfEquals != -1) {
- parameter = parameterValuePair.substring(0, indexOfEquals);
-
- if (indexOfEquals + 1 < parameterValuePair.length()) {
- value = parameterValuePair.substring(indexOfEquals + 1);
- }
- }
-
- if ((value != null && value.length() > 0)
- && (parameter != null && parameter.length() > 0)) {
- try {
- urlProps.put(parameter, URLDecoder.decode(value,
- "UTF-8"));
- } catch (UnsupportedEncodingException badEncoding) {
- // punt
- urlProps.put(parameter, URLDecoder.decode(value));
- } catch (NoSuchMethodError nsme) {
- // punt again
- urlProps.put(parameter, URLDecoder.decode(value));
- }
- }
- }
- }
-
- url = url.substring(beginningOfSlashes + 2);
-
- String hostStuff = null;
-
- int slashIndex = url.indexOf("/"); //$NON-NLS-1$
-
- if (slashIndex != -1) {
- hostStuff = url.substring(0, slashIndex);
-
- if ((slashIndex + 1) < url.length()) {
- urlProps.put(DBNAME_PROPERTY_KEY, //$NON-NLS-1$
- url.substring((slashIndex + 1), url.length()));
- }
- } else {
- hostStuff = url;
- }
-
- int numHosts = 0;
-
- if ((hostStuff != null) && (hostStuff.trim().length() > 0)) {
- StringTokenizer st = new StringTokenizer(hostStuff, ",");
-
- while (st.hasMoreTokens()) {
- numHosts++;
-
- String[] hostPortPair = parseHostPortPair(st.nextToken());
-
- if (hostPortPair[HOST_NAME_INDEX] != null && hostPortPair[HOST_NAME_INDEX].trim().length() > 0) {
- urlProps.setProperty(HOST_PROPERTY_KEY + "." + numHosts, hostPortPair[HOST_NAME_INDEX]);
- } else {
- urlProps.setProperty(HOST_PROPERTY_KEY + "." + numHosts, "localhost");
- }
-
- if (hostPortPair[PORT_NUMBER_INDEX] != null) {
- urlProps.setProperty(PORT_PROPERTY_KEY + "." + numHosts, hostPortPair[PORT_NUMBER_INDEX]);
- } else {
- urlProps.setProperty(PORT_PROPERTY_KEY + "." + numHosts, "3306");
- }
- }
- } else {
- numHosts = 1;
- urlProps.setProperty(HOST_PROPERTY_KEY + ".1", "localhost");
- urlProps.setProperty(PORT_PROPERTY_KEY + ".1", "3306");
- }
-
- urlProps.setProperty(NUM_HOSTS_PROPERTY_KEY, String.valueOf(numHosts));
- urlProps.setProperty(HOST_PROPERTY_KEY, urlProps.getProperty(HOST_PROPERTY_KEY + ".1"));
- urlProps.setProperty(PORT_PROPERTY_KEY, urlProps.getProperty(PORT_PROPERTY_KEY + ".1"));
-
- String propertiesTransformClassName = urlProps
- .getProperty(PROPERTIES_TRANSFORM_KEY);
-
- if (propertiesTransformClassName != null) {
- try {
- ConnectionPropertiesTransform propTransformer = (ConnectionPropertiesTransform) Class
- .forName(propertiesTransformClassName).newInstance();
-
- urlProps = propTransformer.transformProperties(urlProps);
- } catch (InstantiationException e) {
- throw SQLError.createSQLException(
- "Unable to create properties transform instance '"
- + propertiesTransformClassName
- + "' due to underlying exception: "
- + e.toString(),
- SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
- } catch (IllegalAccessException e) {
- throw SQLError.createSQLException(
- "Unable to create properties transform instance '"
- + propertiesTransformClassName
- + "' due to underlying exception: "
- + e.toString(),
- SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
- } catch (ClassNotFoundException e) {
- throw SQLError.createSQLException(
- "Unable to create properties transform instance '"
- + propertiesTransformClassName
- + "' due to underlying exception: "
- + e.toString(),
- SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
- }
- }
-
- if (Util.isColdFusion() &&
- urlProps.getProperty("autoConfigureForColdFusion", "true").equalsIgnoreCase("true")) {
- String configs = urlProps.getProperty(USE_CONFIG_PROPERTY_KEY);
-
- StringBuffer newConfigs = new StringBuffer();
-
- if (configs != null) {
- newConfigs.append(configs);
- newConfigs.append(",");
- }
-
- newConfigs.append("coldFusion");
-
- urlProps.setProperty(USE_CONFIG_PROPERTY_KEY, newConfigs.toString());
- }
-
- // If we use a config, it actually should get overridden by anything in
- // the URL or passed-in properties
-
- String configNames = null;
-
- if (defaults != null) {
- configNames = defaults.getProperty(USE_CONFIG_PROPERTY_KEY);
- }
-
- if (configNames == null) {
- configNames = urlProps.getProperty(USE_CONFIG_PROPERTY_KEY);
- }
-
- if (configNames != null) {
- List splitNames = StringUtils.split(configNames, ",", true);
-
- Properties configProps = new Properties();
-
- Iterator namesIter = splitNames.iterator();
-
- while (namesIter.hasNext()) {
- String configName = (String) namesIter.next();
-
- try {
- InputStream configAsStream = getClass()
- .getResourceAsStream(
- "configs/" + configName + ".properties");
-
- if (configAsStream == null) {
- throw SQLError
- .createSQLException(
- "Can't find configuration template named '"
- + configName + "'",
- SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
- }
- configProps.load(configAsStream);
- } catch (IOException ioEx) {
- SQLException sqlEx = SQLError.createSQLException(
- "Unable to load configuration template '"
- + configName
- + "' due to underlying IOException: "
- + ioEx,
- SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
- sqlEx.initCause(ioEx);
-
- throw sqlEx;
- }
- }
-
- Iterator propsIter = urlProps.keySet().iterator();
-
- while (propsIter.hasNext()) {
- String key = propsIter.next().toString();
- String property = urlProps.getProperty(key);
- configProps.setProperty(key, property);
- }
-
- urlProps = configProps;
- }
-
- // Properties passed in should override ones in URL
-
- if (defaults != null) {
- Iterator propsIter = defaults.keySet().iterator();
-
- while (propsIter.hasNext()) {
- String key = propsIter.next().toString();
- if (!key.equals(NUM_HOSTS_PROPERTY_KEY)) {
- String property = defaults.getProperty(key);
- urlProps.setProperty(key, property);
- }
- }
- }
-
- return urlProps;
- }
-
- /**
- * Returns the port number property
- *
- * @param props
- * the properties to get the port number from
- *
- * @return the port number
- */
- public int port(Properties props) {
- return Integer.parseInt(props.getProperty(PORT_PROPERTY_KEY, "3306")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Returns the given property from props
- *
- * @param name
- * the property name
- * @param props
- * the property instance to look in
- *
- * @return the property value, or null if not found.
- */
- public String property(String name, Properties props) {
- return props.getProperty(name);
- }
-}
diff --git a/src/com/mysql/jdbc/NonRegisteringReplicationDriver.java b/src/com/mysql/jdbc/NonRegisteringReplicationDriver.java
deleted file mode 100644
index 7ee30c30f..000000000
--- a/src/com/mysql/jdbc/NonRegisteringReplicationDriver.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-/**
- * Driver that opens two connections, one two a replication master, and another
- * to one or more slaves, and decides to use master when the connection is not
- * read-only, and use slave(s) when the connection is read-only.
- *
- * @version $Id: NonRegisteringReplicationDriver.java,v 1.1.2.1 2005/05/13
- * 18:58:37 mmatthews Exp $
- */
-public class NonRegisteringReplicationDriver extends NonRegisteringDriver {
- public NonRegisteringReplicationDriver() throws SQLException {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Driver#connect(java.lang.String, java.util.Properties)
- */
- public Connection connect(String url, Properties info) throws SQLException {
- return connectReplicationConnection(url, info);
- }
-}
diff --git a/src/com/mysql/jdbc/NotImplemented.java b/src/com/mysql/jdbc/NotImplemented.java
deleted file mode 100644
index 062d846f3..000000000
--- a/src/com/mysql/jdbc/NotImplemented.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-/**
- * Thrown from methods not required to be implemented.
- *
- * @author Mark Matthews
- */
-public class NotImplemented extends java.sql.SQLException {
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Creates a new NotImplemented object.
- */
- public NotImplemented() {
- super(
- Messages.getString("NotImplemented.0"), SQLError.SQL_STATE_DRIVER_NOT_CAPABLE); //$NON-NLS-1$
- }
-}
diff --git a/src/com/mysql/jdbc/NotUpdatable.java b/src/com/mysql/jdbc/NotUpdatable.java
deleted file mode 100644
index ca336c708..000000000
--- a/src/com/mysql/jdbc/NotUpdatable.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-/**
- * Thrown when a result sate is not updatable
- *
- * @author Mark Matthews
- */
-public class NotUpdatable extends SQLException {
-
- private static final long serialVersionUID = 8084742846039782258L;
-
- /**
- * The message to use when result set is not updatable.
- *
- * The same message is used in the warnings generated by Updatabale result
- * set.
- */
- public static final String NOT_UPDATEABLE_MESSAGE = Messages
- .getString("NotUpdatable.0") //$NON-NLS-1$
- + Messages.getString("NotUpdatable.1") //$NON-NLS-1$
- + Messages.getString("NotUpdatable.2") //$NON-NLS-1$
- + Messages.getString("NotUpdatable.3") //$NON-NLS-1$
- + Messages.getString("NotUpdatable.4") //$NON-NLS-1$
- + Messages.getString("NotUpdatable.5"); //$NON-NLS-1$
-
- /**
- * Creates a new NotUpdatable exception.
- */
- public NotUpdatable() {
- this(NOT_UPDATEABLE_MESSAGE);
- }
-
- /**
- * Append the given reason to the not updatable message if the reason is not
- * null.
- */
- public NotUpdatable(String reason) {
- super(reason
- + Messages.getString("NotUpdatable.1")
- + Messages.getString("NotUpdatable.2")
- + Messages.getString("NotUpdatable.3")
- + Messages.getString("NotUpdatable.4")
- + Messages.getString("NotUpdatable.5"),
- SQLError.SQL_STATE_GENERAL_ERROR);
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/OperationNotSupportedException.java b/src/com/mysql/jdbc/OperationNotSupportedException.java
deleted file mode 100644
index 2ca70e4b9..000000000
--- a/src/com/mysql/jdbc/OperationNotSupportedException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright 2004-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-class OperationNotSupportedException extends SQLException {
- OperationNotSupportedException() {
- super(
- Messages.getString("RowDataDynamic.10"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/OutputStreamWatcher.java b/src/com/mysql/jdbc/OutputStreamWatcher.java
deleted file mode 100644
index 01e1bc096..000000000
--- a/src/com/mysql/jdbc/OutputStreamWatcher.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-/**
- * Objects that want to be notified of lifecycle events on a
- * WatchableOutputStream should implement this interface, and register
- * themselves with setWatcher() on the WatchableOutputStream instance.
- *
- * @author Mark Matthews
- */
-interface OutputStreamWatcher {
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * Called when the OutputStream being watched has .close() called
- */
- void streamClosed(WatchableOutputStream out);
-}
diff --git a/src/com/mysql/jdbc/PacketTooBigException.java b/src/com/mysql/jdbc/PacketTooBigException.java
deleted file mode 100644
index d1a7cd748..000000000
--- a/src/com/mysql/jdbc/PacketTooBigException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-/**
- * Thrown when a packet that is too big for the server is created.
- *
- * @author Mark Matthews
- */
-public class PacketTooBigException extends SQLException {
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Creates a new PacketTooBigException object.
- *
- * @param packetSize
- * the size of the packet that was going to be sent
- * @param maximumPacketSize
- * the maximum size the server will accept
- */
- public PacketTooBigException(long packetSize, long maximumPacketSize) {
- super(
- Messages.getString("PacketTooBigException.0") + packetSize + Messages.getString("PacketTooBigException.1") //$NON-NLS-1$ //$NON-NLS-2$
- + maximumPacketSize
- + Messages.getString("PacketTooBigException.2") //$NON-NLS-1$
- + Messages.getString("PacketTooBigException.3") //$NON-NLS-1$
- + Messages.getString("PacketTooBigException.4"), SQLError.SQL_STATE_GENERAL_ERROR); //$NON-NLS-1$
- }
-}
diff --git a/src/com/mysql/jdbc/ParameterBindings.java b/src/com/mysql/jdbc/ParameterBindings.java
deleted file mode 100644
index 9a033967a..000000000
--- a/src/com/mysql/jdbc/ParameterBindings.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-/**
- * Interface to allow PreparedStatement implementations to expose
- * their parameter bindings to StatementInterceptors.
- *
- * @version $Id: $
- */
-public interface ParameterBindings {
-
- public abstract Array getArray(int parameterIndex) throws SQLException;
-
- public abstract InputStream getAsciiStream(int parameterIndex) throws SQLException;
-
- public abstract BigDecimal getBigDecimal(int parameterIndex) throws SQLException;
-
- public abstract InputStream getBinaryStream(int parameterIndex) throws SQLException;
-
- public abstract java.sql.Blob getBlob(int parameterIndex) throws SQLException;
-
- public abstract boolean getBoolean(int parameterIndex) throws SQLException;
-
- public abstract byte getByte(int parameterIndex) throws SQLException;
-
- public abstract byte[] getBytes(int parameterIndex) throws SQLException;
-
- public abstract Reader getCharacterStream(int parameterIndex) throws SQLException;
-
- public abstract Clob getClob(int parameterIndex) throws SQLException;
-
- public abstract Date getDate(int parameterIndex) throws SQLException;
-
- public abstract double getDouble(int parameterIndex) throws SQLException;
-
- public abstract float getFloat(int parameterIndex) throws SQLException;
-
- public abstract int getInt(int parameterIndex) throws SQLException;
-
- public abstract long getLong(int parameterIndex) throws SQLException;
-
- public abstract Reader getNCharacterStream(int parameterIndex) throws SQLException;
-
- public abstract Reader getNClob(int parameterIndex) throws SQLException;
-
- public abstract Object getObject(int parameterIndex) throws SQLException;
-
- public abstract Ref getRef(int parameterIndex) throws SQLException;
-
- public abstract short getShort(int parameterIndex) throws SQLException;
-
- public abstract String getString(int parameterIndex) throws SQLException;
-
- public abstract Time getTime(int parameterIndex) throws SQLException;
-
- public abstract Timestamp getTimestamp(int parameterIndex) throws SQLException;
-
- public abstract URL getURL(int parameterIndex) throws SQLException;
-
- public abstract boolean isNull(int parameterIndex) throws SQLException;
-}
diff --git a/src/com/mysql/jdbc/PingTarget.java b/src/com/mysql/jdbc/PingTarget.java
deleted file mode 100644
index f9eb3646e..000000000
--- a/src/com/mysql/jdbc/PingTarget.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-public interface PingTarget {
- public void doPing() throws SQLException;
-}
diff --git a/src/com/mysql/jdbc/PreparedStatement.java b/src/com/mysql/jdbc/PreparedStatement.java
deleted file mode 100644
index c71f1d2cd..000000000
--- a/src/com/mysql/jdbc/PreparedStatement.java
+++ /dev/null
@@ -1,5598 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Constructor;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-import java.sql.Array;
-import java.sql.Clob;
-import java.sql.DatabaseMetaData;
-import java.sql.Date;
-import java.sql.ParameterMetaData;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import com.mysql.jdbc.exceptions.DeadlockTimeoutRollbackMarker;
-import com.mysql.jdbc.exceptions.MySQLStatementCancelledException;
-import com.mysql.jdbc.exceptions.MySQLTimeoutException;
-import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException;
-import com.mysql.jdbc.profiler.ProfilerEvent;
-
-/**
- * A SQL Statement is pre-compiled and stored in a PreparedStatement object.
- * This object can then be used to efficiently execute this statement multiple
- * times.
- *
- *
- * Note: The setXXX methods for setting IN parameter values must specify
- * types that are compatible with the defined SQL type of the input parameter.
- * For instance, if the IN parameter has SQL type Integer, then setInt should be
- * used.
- *
- *
- *
- * If arbitrary parameter type conversions are required, then the setObject
- * method should be used with a target SQL type.
- *
- *
- * @author Mark Matthews
- * @version $Id: PreparedStatement.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews
- * Exp $
- *
- * @see java.sql.ResultSet
- * @see java.sql.PreparedStatement
- */
-public class PreparedStatement extends com.mysql.jdbc.StatementImpl implements
- java.sql.PreparedStatement {
- private static final Constructor JDBC_4_PSTMT_2_ARG_CTOR;
- private static final Constructor JDBC_4_PSTMT_3_ARG_CTOR;
- private static final Constructor JDBC_4_PSTMT_4_ARG_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_PSTMT_2_ARG_CTOR = Class.forName(
- "com.mysql.jdbc.JDBC4PreparedStatement")
- .getConstructor(
- new Class[] { ConnectionImpl.class, String.class });
- JDBC_4_PSTMT_3_ARG_CTOR = Class.forName(
- "com.mysql.jdbc.JDBC4PreparedStatement")
- .getConstructor(
- new Class[] { ConnectionImpl.class, String.class,
- String.class });
- JDBC_4_PSTMT_4_ARG_CTOR = Class.forName(
- "com.mysql.jdbc.JDBC4PreparedStatement")
- .getConstructor(
- new Class[] { ConnectionImpl.class, String.class,
- String.class, ParseInfo.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_PSTMT_2_ARG_CTOR = null;
- JDBC_4_PSTMT_3_ARG_CTOR = null;
- JDBC_4_PSTMT_4_ARG_CTOR = null;
- }
- }
-
- class BatchParams {
- boolean[] isNull = null;
-
- boolean[] isStream = null;
-
- InputStream[] parameterStreams = null;
-
- byte[][] parameterStrings = null;
-
- int[] streamLengths = null;
-
- BatchParams(byte[][] strings, InputStream[] streams,
- boolean[] isStreamFlags, int[] lengths, boolean[] isNullFlags) {
- //
- // Make copies
- //
- this.parameterStrings = new byte[strings.length][];
- this.parameterStreams = new InputStream[streams.length];
- this.isStream = new boolean[isStreamFlags.length];
- this.streamLengths = new int[lengths.length];
- this.isNull = new boolean[isNullFlags.length];
- System.arraycopy(strings, 0, this.parameterStrings, 0,
- strings.length);
- System.arraycopy(streams, 0, this.parameterStreams, 0,
- streams.length);
- System.arraycopy(isStreamFlags, 0, this.isStream, 0,
- isStreamFlags.length);
- System.arraycopy(lengths, 0, this.streamLengths, 0, lengths.length);
- System
- .arraycopy(isNullFlags, 0, this.isNull, 0,
- isNullFlags.length);
- }
- }
-
- class EndPoint {
- int begin;
-
- int end;
-
- EndPoint(int b, int e) {
- this.begin = b;
- this.end = e;
- }
- }
-
- class ParseInfo {
- char firstStmtChar = 0;
-
- boolean foundLimitClause = false;
-
- boolean foundLoadData = false;
-
- long lastUsed = 0;
-
- int statementLength = 0;
-
- int statementStartPos = 0;
-
- boolean canRewriteAsMultiValueInsert = false;
-
- byte[][] staticSql = null;
-
- boolean isOnDuplicateKeyUpdate = false;
-
- int locationOfOnDuplicateKeyUpdate = -1;
-
- String valuesClause;
-
- boolean parametersInDuplicateKeyClause = false;
-
- /**
- * Represents the "parsed" state of a client-side
- * prepared statement, with the statement broken up into
- * it's static and dynamic (where parameters are bound)
- * parts.
- */
- ParseInfo(String sql, ConnectionImpl conn,
- java.sql.DatabaseMetaData dbmd, String encoding,
- SingleByteCharsetConverter converter) throws SQLException {
- this(sql, conn, dbmd, encoding, converter, true);
- }
-
- public ParseInfo(String sql, ConnectionImpl conn,
- java.sql.DatabaseMetaData dbmd, String encoding,
- SingleByteCharsetConverter converter, boolean buildRewriteInfo) throws SQLException {
- try {
- if (sql == null) {
- throw SQLError.createSQLException(Messages
- .getString("PreparedStatement.61"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- this.locationOfOnDuplicateKeyUpdate = getOnDuplicateKeyLocation(sql);
- this.isOnDuplicateKeyUpdate = this.locationOfOnDuplicateKeyUpdate != -1;
-
- this.lastUsed = System.currentTimeMillis();
-
- String quotedIdentifierString = dbmd.getIdentifierQuoteString();
-
- char quotedIdentifierChar = 0;
-
- if ((quotedIdentifierString != null)
- && !quotedIdentifierString.equals(" ") //$NON-NLS-1$
- && (quotedIdentifierString.length() > 0)) {
- quotedIdentifierChar = quotedIdentifierString.charAt(0);
- }
-
- this.statementLength = sql.length();
-
- ArrayList endpointList = new ArrayList();
- boolean inQuotes = false;
- char quoteChar = 0;
- boolean inQuotedId = false;
- int lastParmEnd = 0;
- int i;
-
- int stopLookingForLimitClause = this.statementLength - 5;
-
- this.foundLimitClause = false;
-
- boolean noBackslashEscapes = connection.isNoBackslashEscapesSet();
-
- // we're not trying to be real pedantic here, but we'd like to
- // skip comments at the beginning of statements, as frameworks
- // such as Hibernate use them to aid in debugging
-
- statementStartPos = findStartOfStatement(sql);
-
- for (i = statementStartPos; i < this.statementLength; ++i) {
- char c = sql.charAt(i);
-
- if ((this.firstStmtChar == 0) && Character.isLetter(c)) {
- // Determine what kind of statement we're doing (_S_elect,
- // _I_nsert, etc.)
- this.firstStmtChar = Character.toUpperCase(c);
- }
-
- if (!noBackslashEscapes &&
- c == '\\' && i < (this.statementLength - 1)) {
- i++;
- continue; // next character is escaped
- }
-
- // are we in a quoted identifier?
- // (only valid when the id is not inside a 'string')
- if (!inQuotes && (quotedIdentifierChar != 0)
- && (c == quotedIdentifierChar)) {
- inQuotedId = !inQuotedId;
- } else if (!inQuotedId) {
- // only respect quotes when not in a quoted identifier
-
- if (inQuotes) {
- if (((c == '\'') || (c == '"')) && c == quoteChar) {
- if (i < (this.statementLength - 1) && sql.charAt(i + 1) == quoteChar) {
- i++;
- continue; // inline quote escape
- }
-
- inQuotes = !inQuotes;
- quoteChar = 0;
- } else if (((c == '\'') || (c == '"')) && c == quoteChar) {
- inQuotes = !inQuotes;
- quoteChar = 0;
- }
- } else {
- if (c == '#'
- || (c == '-' && (i + 1) < this.statementLength && sql
- .charAt(i + 1) == '-')) {
- // run out to end of statement, or newline,
- // whichever comes first
- int endOfStmt = this.statementLength - 1;
-
- for (; i < endOfStmt; i++) {
- c = sql.charAt(i);
-
- if (c == '\r' || c == '\n') {
- break;
- }
- }
-
- continue;
- } else if (c == '/' && (i + 1) < this.statementLength) {
- // Comment?
- char cNext = sql.charAt(i + 1);
-
- if (cNext == '*') {
- i+= 2;
-
- for (int j = i; j < this.statementLength; j++) {
- i++;
- cNext = sql.charAt(j);
-
- if (cNext == '*' && (j + 1) < this.statementLength) {
- if (sql.charAt(j + 1) == '/') {
- i++;
-
- if (i < this.statementLength) {
- c = sql.charAt(i);
- }
-
- break; // comment done
- }
- }
- }
- }
- } else if ((c == '\'') || (c == '"')) {
- inQuotes = true;
- quoteChar = c;
- }
- }
- }
-
- if ((c == '?') && !inQuotes && !inQuotedId) {
- endpointList.add(new int[] { lastParmEnd, i });
- lastParmEnd = i + 1;
-
- if (isOnDuplicateKeyUpdate && i > locationOfOnDuplicateKeyUpdate) {
- parametersInDuplicateKeyClause = true;
- }
- }
-
- if (!inQuotes && (i < stopLookingForLimitClause)) {
- if ((c == 'L') || (c == 'l')) {
- char posI1 = sql.charAt(i + 1);
-
- if ((posI1 == 'I') || (posI1 == 'i')) {
- char posM = sql.charAt(i + 2);
-
- if ((posM == 'M') || (posM == 'm')) {
- char posI2 = sql.charAt(i + 3);
-
- if ((posI2 == 'I') || (posI2 == 'i')) {
- char posT = sql.charAt(i + 4);
-
- if ((posT == 'T') || (posT == 't')) {
- foundLimitClause = true;
- }
- }
- }
- }
- }
- }
- }
-
- if (this.firstStmtChar == 'L') {
- if (StringUtils.startsWithIgnoreCaseAndWs(sql, "LOAD DATA")) { //$NON-NLS-1$
- this.foundLoadData = true;
- } else {
- this.foundLoadData = false;
- }
- } else {
- this.foundLoadData = false;
- }
-
- endpointList.add(new int[] { lastParmEnd, this.statementLength });
- this.staticSql = new byte[endpointList.size()][];
- char[] asCharArray = sql.toCharArray();
-
- for (i = 0; i < this.staticSql.length; i++) {
- int[] ep = (int[]) endpointList.get(i);
- int end = ep[1];
- int begin = ep[0];
- int len = end - begin;
-
- if (this.foundLoadData) {
- String temp = new String(asCharArray, begin, len);
- this.staticSql[i] = temp.getBytes();
- } else if (encoding == null) {
- byte[] buf = new byte[len];
-
- for (int j = 0; j < len; j++) {
- buf[j] = (byte) sql.charAt(begin + j);
- }
-
- this.staticSql[i] = buf;
- } else {
- if (converter != null) {
- this.staticSql[i] = StringUtils.getBytes(sql,
- converter, encoding, connection
- .getServerCharacterEncoding(), begin,
- len, connection.parserKnowsUnicode(), getExceptionInterceptor());
- } else {
- String temp = new String(asCharArray, begin, len);
-
- this.staticSql[i] = StringUtils.getBytes(temp,
- encoding, connection
- .getServerCharacterEncoding(),
- connection.parserKnowsUnicode(), conn, getExceptionInterceptor());
- }
- }
- }
- } catch (StringIndexOutOfBoundsException oobEx) {
- SQLException sqlEx = new SQLException("Parse error for " + sql);
- sqlEx.initCause(oobEx);
-
- throw sqlEx;
- }
-
-
- if (buildRewriteInfo) {
- this.canRewriteAsMultiValueInsert = PreparedStatement
- .canRewrite(sql, this.isOnDuplicateKeyUpdate,
- this.locationOfOnDuplicateKeyUpdate,
- this.statementStartPos) && !this.parametersInDuplicateKeyClause;
-
- if (this.canRewriteAsMultiValueInsert
- && conn.getRewriteBatchedStatements()) {
- buildRewriteBatchedParams(sql, conn, dbmd, encoding,
- converter);
- }
- }
- }
-
- private ParseInfo batchHead;
-
- private ParseInfo batchValues;
-
- private ParseInfo batchODKUClause;
-
- private void buildRewriteBatchedParams(String sql, ConnectionImpl conn,
- DatabaseMetaData metadata, String encoding,
- SingleByteCharsetConverter converter) throws SQLException {
- this.valuesClause = extractValuesClause(sql);
- String odkuClause = isOnDuplicateKeyUpdate ? sql
- .substring(locationOfOnDuplicateKeyUpdate) : null;
-
- String headSql = null;
-
- if (isOnDuplicateKeyUpdate) {
- headSql = sql.substring(0, locationOfOnDuplicateKeyUpdate);
- } else {
- headSql = sql;
- }
-
- this.batchHead = new ParseInfo(headSql, conn, metadata, encoding,
- converter, false);
- this.batchValues = new ParseInfo("," + this.valuesClause, conn,
- metadata, encoding, converter, false);
- this.batchODKUClause = null;
-
- if (odkuClause != null && odkuClause.length() > 0) {
- this.batchODKUClause = new ParseInfo("," + this.valuesClause
- + " " + odkuClause, conn, metadata, encoding,
- converter, false);
- }
- }
-
- private String extractValuesClause(String sql) throws SQLException {
- String quoteCharStr = connection.getMetaData()
- .getIdentifierQuoteString();
-
- int indexOfValues = -1;
- int valuesSearchStart = statementStartPos;
-
- while (indexOfValues == -1) {
- if (quoteCharStr.length() > 0) {
- indexOfValues = StringUtils.indexOfIgnoreCaseRespectQuotes(
- valuesSearchStart,
- originalSql, "VALUES ", quoteCharStr.charAt(0), false);
- } else {
- indexOfValues = StringUtils.indexOfIgnoreCase(valuesSearchStart,
- originalSql,
- "VALUES ");
- }
- /* check if the char immediately preceding VALUES may be part of the table name */
- if (indexOfValues > 0) {
- char c = originalSql.charAt(indexOfValues - 1);
- switch(c) {
- case ' ':
- case ')':
- case '`':
- case '\t':
- case '\n':
- break;
- default:
- valuesSearchStart = indexOfValues + 7;
- indexOfValues = -1;
- break;
- }
- } else {
- break;
- }
- }
-
- if (indexOfValues == -1) {
- return null;
- }
-
- int indexOfFirstParen = sql.indexOf('(', indexOfValues + 7);
-
- if (indexOfFirstParen == -1) {
- return null;
- }
-
- int endOfValuesClause = sql.lastIndexOf(')');
-
- if (endOfValuesClause == -1) {
- return null;
- }
-
- if (isOnDuplicateKeyUpdate) {
- endOfValuesClause = this.locationOfOnDuplicateKeyUpdate - 1;
- }
-
- return sql.substring(indexOfFirstParen, endOfValuesClause + 1);
- }
-
- /**
- * Returns a ParseInfo for a multi-value INSERT for a batch of size numBatch (without parsing!).
- */
- synchronized ParseInfo getParseInfoForBatch(int numBatch) {
- AppendingBatchVisitor apv = new AppendingBatchVisitor();
- buildInfoForBatch(numBatch, apv);
-
- ParseInfo batchParseInfo = new ParseInfo(apv.getStaticSqlStrings(),
- this.firstStmtChar, this.foundLimitClause,
- this.foundLoadData, this.isOnDuplicateKeyUpdate,
- this.locationOfOnDuplicateKeyUpdate, this.statementLength,
- this.statementStartPos);
-
- return batchParseInfo;
- }
-
- /**
- * Returns a preparable SQL string for the number of batched parameters, used by server-side prepared statements
- * when re-writing batch INSERTs.
- */
-
- String getSqlForBatch(int numBatch) throws UnsupportedEncodingException {
- ParseInfo batchInfo = getParseInfoForBatch(numBatch);
- int size = 0;
- final byte[][] sqlStrings = batchInfo.staticSql;
- final int sqlStringsLength = sqlStrings.length;
-
- for (int i = 0; i < sqlStringsLength; i++) {
- size += sqlStrings[i].length;
- size++; // for the '?'
- }
-
- StringBuffer buf = new StringBuffer(size);
-
- for (int i = 0; i < sqlStringsLength - 1; i++) {
- buf.append(new String(sqlStrings[i], charEncoding));
- buf.append("?");
- }
-
- buf.append(new String(sqlStrings[sqlStringsLength - 1]));
-
- return buf.toString();
- }
-
- /**
- * Builds a ParseInfo for the given batch size, without parsing. We use
- * a visitor pattern here, because the if {}s make computing a size for the
- * resultant byte[][] make this too complex, and we don't necessarily want to
- * use a List for this, because the size can be dynamic, and thus we'll not be
- * able to guess a good initial size for an array-based list, and it's not
- * efficient to convert a LinkedList to an array.
- */
- private void buildInfoForBatch(int numBatch, BatchVisitor visitor) {
- final byte[][] headStaticSql = this.batchHead.staticSql;
- final int headStaticSqlLength = headStaticSql.length;
-
- if (headStaticSqlLength > 1) {
- for (int i = 0; i < headStaticSqlLength - 1; i++) {
- visitor.append(headStaticSql[i]).increment();
- }
- }
-
- // merge end of head, with beginning of a value clause
- byte[] endOfHead = headStaticSql[headStaticSqlLength - 1];
- final byte[][] valuesStaticSql = this.batchValues.staticSql;
- byte[] beginOfValues = valuesStaticSql[0];
-
- visitor.merge(endOfHead, beginOfValues).increment();
-
- int numValueRepeats = numBatch - 1; // first one is in the "head"
-
- if (this.batchODKUClause != null) {
- numValueRepeats--; // Last one is in the ODKU clause
- }
-
- final int valuesStaticSqlLength = valuesStaticSql.length;
- byte[] endOfValues = valuesStaticSql[valuesStaticSqlLength - 1];
-
- for (int i = 0; i < numValueRepeats; i++) {
- for (int j = 1; j < valuesStaticSqlLength - 1; j++) {
- visitor.append(valuesStaticSql[j]).increment();
- }
- visitor.merge(endOfValues, beginOfValues).increment();
- }
-
- if (this.batchODKUClause != null) {
- final byte[][] batchOdkuStaticSql = this.batchODKUClause.staticSql;
- byte[] beginOfOdku = batchOdkuStaticSql[0];
- visitor.decrement().merge(endOfValues, beginOfOdku).increment();
-
- final int batchOdkuStaticSqlLength = batchOdkuStaticSql.length;
-
- if (numBatch > 1) {
- for (int i = 1; i < batchOdkuStaticSqlLength; i++) {
- visitor.append(batchOdkuStaticSql[i])
- .increment();
- }
- } else {
- visitor.decrement().append(batchOdkuStaticSql[(batchOdkuStaticSqlLength - 1)]);
- }
- } else {
- // Everything after the values clause, but not ODKU, which today is nothing
- // but a syntax error, but we should still not mangle the SQL!
- visitor.decrement().append(this.staticSql[this.staticSql.length - 1]);
- }
- }
-
- private ParseInfo(byte[][] staticSql, char firstStmtChar,
- boolean foundLimitClause, boolean foundLoadData,
- boolean isOnDuplicateKeyUpdate,
- int locationOfOnDuplicateKeyUpdate, int statementLength,
- int statementStartPos) {
- this.firstStmtChar = firstStmtChar;
- this.foundLimitClause = foundLimitClause;
- this.foundLoadData = foundLoadData;
- this.isOnDuplicateKeyUpdate = isOnDuplicateKeyUpdate;
- this.locationOfOnDuplicateKeyUpdate = locationOfOnDuplicateKeyUpdate;
- this.statementLength = statementLength;
- this.statementStartPos = statementStartPos;
- this.staticSql = staticSql;
- }
- }
-
- interface BatchVisitor {
- abstract BatchVisitor increment();
-
- abstract BatchVisitor decrement();
-
- abstract BatchVisitor append(byte[] values);
-
- abstract BatchVisitor merge(byte[] begin, byte[] end);
- }
-
- class AppendingBatchVisitor implements BatchVisitor {
- LinkedList statementComponents = new LinkedList();
-
- public BatchVisitor append(byte[] values) {
- statementComponents.addLast(values);
-
- return this;
- }
-
- public BatchVisitor increment() {
- // no-op
- return this;
- }
-
- public BatchVisitor decrement() {
- statementComponents.removeLast();
-
- return this;
- }
-
- public BatchVisitor merge(byte[] front, byte[] back) {
- int mergedLength = front.length + back.length;
- byte[] merged = new byte[mergedLength];
- System.arraycopy(front, 0, merged, 0, front.length);
- System.arraycopy(back, 0, merged, front.length, back.length);
- statementComponents.addLast(merged);
- return this;
- }
-
- public byte[][] getStaticSqlStrings() {
- byte[][] asBytes = new byte[this.statementComponents.size()][];
- this.statementComponents.toArray(asBytes);
-
- return asBytes;
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer();
- Iterator iter = this.statementComponents.iterator();
- while (iter.hasNext()) {
- buf.append(new String((byte[]) iter.next()));
- }
-
- return buf.toString();
- }
-
- }
-
- private final static byte[] HEX_DIGITS = new byte[] { (byte) '0',
- (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5',
- (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'A',
- (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F' };
-
- /**
- * Reads length bytes from reader into buf. Blocks until enough input is
- * available
- *
- * @param reader
- * DOCUMENT ME!
- * @param buf
- * DOCUMENT ME!
- * @param length
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws IOException
- * DOCUMENT ME!
- */
- protected static int readFully(Reader reader, char[] buf, int length)
- throws IOException {
- int numCharsRead = 0;
-
- while (numCharsRead < length) {
- int count = reader.read(buf, numCharsRead, length - numCharsRead);
-
- if (count < 0) {
- break;
- }
-
- numCharsRead += count;
- }
-
- return numCharsRead;
- }
-
- /**
- * Does the batch (if any) contain "plain" statements added by
- * Statement.addBatch(String)?
- *
- * If so, we can't re-write it to use multi-value or multi-queries.
- */
- protected boolean batchHasPlainStatements = false;
-
- private java.sql.DatabaseMetaData dbmd = null;
-
- /**
- * What is the first character of the prepared statement (used to check for
- * SELECT vs. INSERT/UPDATE/DELETE)
- */
- protected char firstCharOfStmt = 0;
-
- /** Does the SQL for this statement contain a 'limit' clause? */
- protected boolean hasLimitClause = false;
-
- /** Is this query a LOAD DATA query? */
- protected boolean isLoadDataQuery = false;
-
- private boolean[] isNull = null;
-
- private boolean[] isStream = null;
-
- protected int numberOfExecutions = 0;
-
- /** The SQL that was passed in to 'prepare' */
- protected String originalSql = null;
-
- /** The number of parameters in this PreparedStatement */
- protected int parameterCount;
-
- protected MysqlParameterMetadata parameterMetaData;
-
- private InputStream[] parameterStreams = null;
-
- private byte[][] parameterValues = null;
-
- /**
- * Only used by statement interceptors at the moment to
- * provide introspection of bound values
- */
- protected int[] parameterTypes = null;
-
- protected ParseInfo parseInfo;
-
- private java.sql.ResultSetMetaData pstmtResultMetaData;
-
- private byte[][] staticSqlStrings = null;
-
- private byte[] streamConvertBuf = new byte[4096];
-
- private int[] streamLengths = null;
-
- private SimpleDateFormat tsdf = null;
-
- /**
- * Are we using a version of MySQL where we can use 'true' boolean values?
- */
- protected boolean useTrueBoolean = false;
-
- protected boolean usingAnsiMode;
-
- protected String batchedValuesClause;
-
- private boolean doPingInstead;
- private SimpleDateFormat ddf;
- private SimpleDateFormat tdf;
-
- private boolean compensateForOnDuplicateKeyUpdate = false;
-
- /** Charset encoder used to escape if needed, such as Yen sign in SJIS */
- private CharsetEncoder charsetEncoder;
-
- /** Command index of currently executing batch command. */
- private int batchCommandIndex = -1;
-
- /**
- * Creates a prepared statement instance -- We need to provide factory-style
- * methods so we can support both JDBC3 (and older) and JDBC4 runtimes,
- * otherwise the class verifier complains when it tries to load JDBC4-only
- * interface classes that are present in JDBC4 method signatures.
- */
-
- protected static PreparedStatement getInstance(ConnectionImpl conn,
- String catalog) throws SQLException {
- if (!Util.isJdbc4()) {
- return new PreparedStatement(conn, catalog);
- }
-
- return (PreparedStatement) Util.handleNewInstance(
- JDBC_4_PSTMT_2_ARG_CTOR, new Object[] { conn, catalog }, conn.getExceptionInterceptor());
- }
-
- /**
- * Creates a prepared statement instance -- We need to provide factory-style
- * methods so we can support both JDBC3 (and older) and JDBC4 runtimes,
- * otherwise the class verifier complains when it tries to load JDBC4-only
- * interface classes that are present in JDBC4 method signatures.
- */
-
- protected static PreparedStatement getInstance(ConnectionImpl conn, String sql,
- String catalog) throws SQLException {
- if (!Util.isJdbc4()) {
- return new PreparedStatement(conn, sql, catalog);
- }
-
- return (PreparedStatement) Util.handleNewInstance(
- JDBC_4_PSTMT_3_ARG_CTOR, new Object[] { conn, sql, catalog }, conn.getExceptionInterceptor());
- }
-
- /**
- * Creates a prepared statement instance -- We need to provide factory-style
- * methods so we can support both JDBC3 (and older) and JDBC4 runtimes,
- * otherwise the class verifier complains when it tries to load JDBC4-only
- * interface classes that are present in JDBC4 method signatures.
- */
-
- protected static PreparedStatement getInstance(ConnectionImpl conn, String sql,
- String catalog, ParseInfo cachedParseInfo) throws SQLException {
- if (!Util.isJdbc4()) {
- return new PreparedStatement(conn, sql, catalog, cachedParseInfo);
- }
-
- return (PreparedStatement) Util.handleNewInstance(
- JDBC_4_PSTMT_4_ARG_CTOR, new Object[] { conn, sql, catalog,
- cachedParseInfo }, conn.getExceptionInterceptor());
- }
-
- /**
- * Constructor used by server-side prepared statements
- *
- * @param conn
- * the connection that created us
- * @param catalog
- * the catalog in use when we were created
- *
- * @throws SQLException
- * if an error occurs
- */
- public PreparedStatement(ConnectionImpl conn, String catalog)
- throws SQLException {
- super(conn, catalog);
-
- this.compensateForOnDuplicateKeyUpdate = this.connection.getCompensateOnDuplicateKeyUpdateCounts();
- }
-
- /**
- * Constructor for the PreparedStatement class.
- *
- * @param conn
- * the connection creating this statement
- * @param sql
- * the SQL for this statement
- * @param catalog
- * the catalog/database this statement should be issued against
- *
- * @throws SQLException
- * if a database error occurs.
- */
- public PreparedStatement(ConnectionImpl conn, String sql, String catalog)
- throws SQLException {
- super(conn, catalog);
-
- if (sql == null) {
- throw SQLError.createSQLException(Messages.getString("PreparedStatement.0"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- this.originalSql = sql;
-
- if (this.originalSql.startsWith(PING_MARKER)) {
- this.doPingInstead = true;
- } else {
- this.doPingInstead = false;
- }
-
- this.dbmd = this.connection.getMetaData();
-
- this.useTrueBoolean = this.connection.versionMeetsMinimum(3, 21, 23);
-
- this.parseInfo = new ParseInfo(sql, this.connection, this.dbmd,
- this.charEncoding, this.charConverter);
-
- initializeFromParseInfo();
-
- this.compensateForOnDuplicateKeyUpdate = this.connection.getCompensateOnDuplicateKeyUpdateCounts();
-
- if (conn.getRequiresEscapingEncoder())
- charsetEncoder = Charset.forName(conn.getEncoding()).newEncoder();
- }
-
- /**
- * Creates a new PreparedStatement object.
- *
- * @param conn
- * the connection creating this statement
- * @param sql
- * the SQL for this statement
- * @param catalog
- * the catalog/database this statement should be issued against
- * @param cachedParseInfo
- * already created parseInfo.
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public PreparedStatement(ConnectionImpl conn, String sql, String catalog,
- ParseInfo cachedParseInfo) throws SQLException {
- super(conn, catalog);
-
- if (sql == null) {
- throw SQLError.createSQLException(Messages.getString("PreparedStatement.1"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- this.originalSql = sql;
-
- this.dbmd = this.connection.getMetaData();
-
- this.useTrueBoolean = this.connection.versionMeetsMinimum(3, 21, 23);
-
- this.parseInfo = cachedParseInfo;
-
- this.usingAnsiMode = !this.connection.useAnsiQuotedIdentifiers();
-
- initializeFromParseInfo();
-
- this.compensateForOnDuplicateKeyUpdate = this.connection.getCompensateOnDuplicateKeyUpdateCounts();
-
- if (conn.getRequiresEscapingEncoder())
- charsetEncoder = Charset.forName(conn.getEncoding()).newEncoder();
- }
-
- /**
- * JDBC 2.0 Add a set of parameters to the batch.
- *
- * @exception SQLException
- * if a database-access error occurs.
- *
- * @see StatementImpl#addBatch
- */
- public void addBatch() throws SQLException {
- if (this.batchedArgs == null) {
- this.batchedArgs = new ArrayList();
- }
-
- for (int i = 0; i < this.parameterValues.length; i++) {
- checkAllParametersSet(this.parameterValues[i],
- this.parameterStreams[i], i);
- }
-
- this.batchedArgs.add(new BatchParams(this.parameterValues,
- this.parameterStreams, this.isStream, this.streamLengths,
- this.isNull));
- }
-
- public synchronized void addBatch(String sql) throws SQLException {
- this.batchHasPlainStatements = true;
-
- super.addBatch(sql);
- }
-
- protected String asSql() throws SQLException {
- return asSql(false);
- }
-
- protected String asSql(boolean quoteStreamsAndUnknowns) throws SQLException {
- if (this.isClosed) {
- return "statement has been closed, no further internal information available";
- }
-
- StringBuffer buf = new StringBuffer();
-
- try {
- int realParameterCount = this.parameterCount + getParameterIndexOffset();
- Object batchArg = null;
- if (batchCommandIndex != -1)
- batchArg = batchedArgs.get(batchCommandIndex);
-
- for (int i = 0; i < realParameterCount; ++i) {
- if (this.charEncoding != null) {
- buf.append(new String(this.staticSqlStrings[i],
- this.charEncoding));
- } else {
- buf.append(new String(this.staticSqlStrings[i]));
- }
-
- byte val[] = null;
- if (batchArg != null && batchArg instanceof String) {
- buf.append((String)batchArg);
- continue;
- }
- if (batchCommandIndex == -1)
- val = parameterValues[i];
- else
- val = ((BatchParams)batchArg).parameterStrings[i];
-
- boolean isStreamParam = false;
- if (batchCommandIndex == -1)
- isStreamParam = isStream[i];
- else
- isStreamParam = ((BatchParams)batchArg).isStream[i];
-
- if ((val == null) && !isStreamParam) {
- if (quoteStreamsAndUnknowns) {
- buf.append("'");
- }
-
- buf.append("** NOT SPECIFIED **"); //$NON-NLS-1$
-
- if (quoteStreamsAndUnknowns) {
- buf.append("'");
- }
- } else if (isStreamParam) {
- if (quoteStreamsAndUnknowns) {
- buf.append("'");
- }
-
- buf.append("** STREAM DATA **"); //$NON-NLS-1$
-
- if (quoteStreamsAndUnknowns) {
- buf.append("'");
- }
- } else {
- if (this.charConverter != null) {
- buf.append(this.charConverter.toString(val));
- } else {
- if (this.charEncoding != null) {
- buf.append(new String(val, this.charEncoding));
- } else {
- buf.append(StringUtils.toAsciiString(val));
- }
- }
- }
- }
-
- if (this.charEncoding != null) {
- buf.append(new String(
- this.staticSqlStrings[this.parameterCount + getParameterIndexOffset()],
- this.charEncoding));
- } else {
- buf
- .append(StringUtils
- .toAsciiString(this.staticSqlStrings[this.parameterCount + getParameterIndexOffset()]));
- }
- } catch (UnsupportedEncodingException uue) {
- throw new RuntimeException(Messages
- .getString("PreparedStatement.32") //$NON-NLS-1$
- + this.charEncoding
- + Messages.getString("PreparedStatement.33")); //$NON-NLS-1$
- }
-
- return buf.toString();
- }
-
- public synchronized void clearBatch() throws SQLException {
- this.batchHasPlainStatements = false;
-
- super.clearBatch();
- }
-
- /**
- * In general, parameter values remain in force for repeated used of a
- * Statement. Setting a parameter value automatically clears its previous
- * value. However, in some cases, it is useful to immediately release the
- * resources used by the current parameter values; this can be done by
- * calling clearParameters
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public synchronized void clearParameters() throws SQLException {
- checkClosed();
-
- for (int i = 0; i < this.parameterValues.length; i++) {
- this.parameterValues[i] = null;
- this.parameterStreams[i] = null;
- this.isStream[i] = false;
- this.isNull[i] = false;
- this.parameterTypes[i] = Types.NULL;
- }
- }
-
- /**
- * Closes this prepared statement and releases all resources.
- *
- * @throws SQLException
- * if database error occurs.
- */
- public synchronized void close() throws SQLException {
- realClose(true, true);
- }
-
- private final void escapeblockFast(byte[] buf, Buffer packet, int size)
- throws SQLException {
- int lastwritten = 0;
-
- for (int i = 0; i < size; i++) {
- byte b = buf[i];
-
- if (b == '\0') {
- // write stuff not yet written
- if (i > lastwritten) {
- packet.writeBytesNoNull(buf, lastwritten, i - lastwritten);
- }
-
- // write escape
- packet.writeByte((byte) '\\');
- packet.writeByte((byte) '0');
- lastwritten = i + 1;
- } else {
- if ((b == '\\') || (b == '\'')
- || (!this.usingAnsiMode && b == '"')) {
- // write stuff not yet written
- if (i > lastwritten) {
- packet.writeBytesNoNull(buf, lastwritten, i
- - lastwritten);
- }
-
- // write escape
- packet.writeByte((byte) '\\');
- lastwritten = i; // not i+1 as b wasn't written.
- }
- }
- }
-
- // write out remaining stuff from buffer
- if (lastwritten < size) {
- packet.writeBytesNoNull(buf, lastwritten, size - lastwritten);
- }
- }
-
- private final void escapeblockFast(byte[] buf,
- ByteArrayOutputStream bytesOut, int size) {
- int lastwritten = 0;
-
- for (int i = 0; i < size; i++) {
- byte b = buf[i];
-
- if (b == '\0') {
- // write stuff not yet written
- if (i > lastwritten) {
- bytesOut.write(buf, lastwritten, i - lastwritten);
- }
-
- // write escape
- bytesOut.write('\\');
- bytesOut.write('0');
- lastwritten = i + 1;
- } else {
- if ((b == '\\') || (b == '\'')
- || (!this.usingAnsiMode && b == '"')) {
- // write stuff not yet written
- if (i > lastwritten) {
- bytesOut.write(buf, lastwritten, i - lastwritten);
- }
-
- // write escape
- bytesOut.write('\\');
- lastwritten = i; // not i+1 as b wasn't written.
- }
- }
- }
-
- // write out remaining stuff from buffer
- if (lastwritten < size) {
- bytesOut.write(buf, lastwritten, size - lastwritten);
- }
- }
-
- /**
- * Check to see if the statement is safe for read-only slaves after failover.
- *
- * @return true if safe for read-only.
- * @throws SQLException
- */
- protected boolean checkReadOnlySafeStatement() throws SQLException {
- return ((!this.connection.isReadOnly()) || (this.firstCharOfStmt == 'S'));
- }
-
- /**
- * Some prepared statements return multiple results; the execute method
- * handles these complex statements as well as the simpler form of
- * statements handled by executeQuery and executeUpdate
- *
- * @return true if the next result is a ResultSet; false if it is an update
- * count or there are no more results
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public boolean execute() throws SQLException {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- if(!checkReadOnlySafeStatement()) {
- throw SQLError.createSQLException(Messages.getString("PreparedStatement.20") //$NON-NLS-1$
- + Messages.getString("PreparedStatement.21"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- ResultSetInternalMethods rs = null;
-
- CachedResultSetMetaData cachedMetadata = null;
-
- synchronized (locallyScopedConn.getMutex()) {
- lastQueryIsOnDupKeyUpdate = false;
- if (retrieveGeneratedKeys)
- lastQueryIsOnDupKeyUpdate = containsOnDuplicateKeyUpdateInSQL();
- boolean doStreaming = createStreamingResultSet();
-
- clearWarnings();
-
- // Adjust net_write_timeout to a higher value if we're
- // streaming result sets. More often than not, someone runs into
- // an issue where they blow net_write_timeout when using this
- // feature, and if they're willing to hold a result set open
- // for 30 seconds or more, one more round-trip isn't going to hurt
- //
- // This is reset by RowDataDynamic.close().
-
- if (doStreaming
- && this.connection.getNetTimeoutForStreamingResults() > 0) {
- executeSimpleNonQuery(locallyScopedConn,
- "SET net_write_timeout="
- + this.connection
- .getNetTimeoutForStreamingResults());
- }
-
- this.batchedGeneratedKeys = null;
-
- Buffer sendPacket = fillSendPacket();
-
- String oldCatalog = null;
-
- if (!locallyScopedConn.getCatalog().equals(this.currentCatalog)) {
- oldCatalog = locallyScopedConn.getCatalog();
- locallyScopedConn.setCatalog(this.currentCatalog);
- }
-
- //
- // Check if we have cached metadata for this query...
- //
- if (locallyScopedConn.getCacheResultSetMetadata()) {
- cachedMetadata = locallyScopedConn.getCachedMetaData(this.originalSql);
- }
-
- Field[] metadataFromCache = null;
-
- if (cachedMetadata != null) {
- metadataFromCache = cachedMetadata.fields;
- }
-
- boolean oldInfoMsgState = false;
-
- if (this.retrieveGeneratedKeys) {
- oldInfoMsgState = locallyScopedConn.isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
- }
-
- // If there isn't a limit clause in the SQL
- // then limit the number of rows to return in
- // an efficient manner. Only do this if
- // setMaxRows() hasn't been used on any Statements
- // generated from the current Connection (saves
- // a query, and network traffic).
- //
- // Only apply max_rows to selects
- //
- if (locallyScopedConn.useMaxRows()) {
- int rowLimit = -1;
-
- if (this.firstCharOfStmt == 'S') {
- if (this.hasLimitClause) {
- rowLimit = this.maxRows;
- } else {
- if (this.maxRows <= 0) {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- } else {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT="
- + this.maxRows);
- }
- }
- } else {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- }
-
- // Finally, execute the query
- rs = executeInternal(rowLimit, sendPacket,
- doStreaming,
- (this.firstCharOfStmt == 'S'), metadataFromCache, false);
- } else {
- rs = executeInternal(-1, sendPacket,
- doStreaming,
- (this.firstCharOfStmt == 'S'), metadataFromCache, false);
- }
-
- if (cachedMetadata != null) {
- locallyScopedConn.initializeResultsMetadataFromCache(this.originalSql,
- cachedMetadata, this.results);
- } else {
- if (rs.reallyResult() && locallyScopedConn.getCacheResultSetMetadata()) {
- locallyScopedConn.initializeResultsMetadataFromCache(this.originalSql,
- null /* will be created */, rs);
- }
- }
-
- if (this.retrieveGeneratedKeys) {
- locallyScopedConn.setReadInfoMsgEnabled(oldInfoMsgState);
- rs.setFirstCharOfQuery(this.firstCharOfStmt);
- }
-
- if (oldCatalog != null) {
- locallyScopedConn.setCatalog(oldCatalog);
- }
-
- if (rs != null) {
- this.lastInsertId = rs.getUpdateID();
-
- this.results = rs;
- }
- }
-
- return ((rs != null) && rs.reallyResult());
- }
-
- /**
- * JDBC 2.0 Submit a batch of commands to the database for execution. This
- * method is optional.
- *
- * @return an array of update counts containing one element for each command
- * in the batch. The array is ordered according to the order in
- * which commands were inserted into the batch
- *
- * @exception SQLException
- * if a database-access error occurs, or the driver does not
- * support batch statements
- * @throws java.sql.BatchUpdateException
- * DOCUMENT ME!
- */
- public int[] executeBatch() throws SQLException {
- checkClosed();
-
- if (this.connection.isReadOnly()) {
- throw new SQLException(Messages.getString("PreparedStatement.25") //$NON-NLS-1$
- + Messages.getString("PreparedStatement.26"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
- }
-
- synchronized (this.connection.getMutex()) {
- if (this.batchedArgs == null || this.batchedArgs.size() == 0) {
- return new int[0];
- }
-
- // we timeout the entire batch, not individual statements
- int batchTimeout = this.timeoutInMillis;
- this.timeoutInMillis = 0;
-
- resetCancelledState();
-
- try {
- clearWarnings();
-
- if (!this.batchHasPlainStatements
- && this.connection.getRewriteBatchedStatements()) {
-
-
- if (canRewriteAsMultiValueInsertAtSqlLevel()) {
- return executeBatchedInserts(batchTimeout);
- }
-
- if (this.connection.versionMeetsMinimum(4, 1, 0)
- && !this.batchHasPlainStatements
- && this.batchedArgs != null
- && this.batchedArgs.size() > 3 /* cost of option setting rt-wise */) {
- return executePreparedBatchAsMultiStatement(batchTimeout);
- }
- }
-
- return executeBatchSerially(batchTimeout);
- } finally {
- clearBatch();
- }
- }
- }
-
- public boolean canRewriteAsMultiValueInsertAtSqlLevel() throws SQLException {
- return this.parseInfo.canRewriteAsMultiValueInsert;
- }
-
- protected int getLocationOfOnDuplicateKeyUpdate() {
- return this.parseInfo.locationOfOnDuplicateKeyUpdate;
- }
-
- /**
- * Rewrites the already prepared statement into a multi-statement
- * query of 'statementsPerBatch' values and executes the entire batch
- * using this new statement.
- *
- * @return update counts in the same fashion as executeBatch()
- *
- * @throws SQLException
- */
-
- protected int[] executePreparedBatchAsMultiStatement(int batchTimeout) throws SQLException {
- synchronized (this.connection.getMutex()) {
- // This is kind of an abuse, but it gets the job done
- if (this.batchedValuesClause == null) {
- this.batchedValuesClause = this.originalSql + ";";
- }
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- boolean multiQueriesEnabled = locallyScopedConn.getAllowMultiQueries();
- CancelTask timeoutTask = null;
-
- try {
- clearWarnings();
-
- int numBatchedArgs = this.batchedArgs.size();
-
- if (this.retrieveGeneratedKeys) {
- this.batchedGeneratedKeys = new ArrayList(numBatchedArgs);
- }
-
- int numValuesPerBatch = computeBatchSize(numBatchedArgs);
-
- if (numBatchedArgs < numValuesPerBatch) {
- numValuesPerBatch = numBatchedArgs;
- }
-
- java.sql.PreparedStatement batchedStatement = null;
-
- int batchedParamIndex = 1;
- int numberToExecuteAsMultiValue = 0;
- int batchCounter = 0;
- int updateCountCounter = 0;
- int[] updateCounts = new int[numBatchedArgs];
- SQLException sqlEx = null;
-
- try {
- if (!multiQueriesEnabled) {
- locallyScopedConn.getIO().enableMultiQueries();
- }
-
- if (this.retrieveGeneratedKeys) {
- batchedStatement = locallyScopedConn.prepareStatement(
- generateMultiStatementForBatch(numValuesPerBatch),
- RETURN_GENERATED_KEYS);
- } else {
- batchedStatement = locallyScopedConn
- .prepareStatement(generateMultiStatementForBatch(numValuesPerBatch));
- }
-
- if (locallyScopedConn.getEnableQueryTimeouts() &&
- batchTimeout != 0
- && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask((StatementImpl)batchedStatement);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- batchTimeout);
- }
-
- if (numBatchedArgs < numValuesPerBatch) {
- numberToExecuteAsMultiValue = numBatchedArgs;
- } else {
- numberToExecuteAsMultiValue = numBatchedArgs / numValuesPerBatch;
- }
-
- int numberArgsToExecute = numberToExecuteAsMultiValue * numValuesPerBatch;
-
- for (int i = 0; i < numberArgsToExecute; i++) {
- if (i != 0 && i % numValuesPerBatch == 0) {
- try {
- batchedStatement.execute();
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(batchCounter, numValuesPerBatch,
- updateCounts, ex);
- }
-
- updateCountCounter = processMultiCountsAndKeys(
- (StatementImpl)batchedStatement, updateCountCounter,
- updateCounts);
-
- batchedStatement.clearParameters();
- batchedParamIndex = 1;
- }
-
- batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
- batchedParamIndex, this.batchedArgs
- .get(batchCounter++));
- }
-
- try {
- batchedStatement.execute();
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(batchCounter - 1, numValuesPerBatch,
- updateCounts, ex);
- }
-
- updateCountCounter = processMultiCountsAndKeys(
- (StatementImpl)batchedStatement, updateCountCounter,
- updateCounts);
-
- batchedStatement.clearParameters();
-
- numValuesPerBatch = numBatchedArgs - batchCounter;
- } finally {
- if (batchedStatement != null) {
- batchedStatement.close();
- }
- }
-
- try {
- if (numValuesPerBatch > 0) {
-
- if (this.retrieveGeneratedKeys) {
- batchedStatement = locallyScopedConn.prepareStatement(
- generateMultiStatementForBatch(numValuesPerBatch),
- RETURN_GENERATED_KEYS);
- } else {
- batchedStatement = locallyScopedConn.prepareStatement(
- generateMultiStatementForBatch(numValuesPerBatch));
- }
-
- if (timeoutTask != null) {
- timeoutTask.toCancel = (StatementImpl)batchedStatement;
- }
-
- batchedParamIndex = 1;
-
- while (batchCounter < numBatchedArgs) {
- batchedParamIndex = setOneBatchedParameterSet(batchedStatement,
- batchedParamIndex, this.batchedArgs
- .get(batchCounter++));
- }
-
- try {
- batchedStatement.execute();
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(batchCounter - 1, numValuesPerBatch,
- updateCounts, ex);
- }
-
- updateCountCounter = processMultiCountsAndKeys(
- (StatementImpl)batchedStatement, updateCountCounter,
- updateCounts);
-
- batchedStatement.clearParameters();
- }
-
- if (timeoutTask != null) {
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask.cancel();
- timeoutTask = null;
- }
-
- if (sqlEx != null) {
- throw new java.sql.BatchUpdateException(sqlEx
- .getMessage(), sqlEx.getSQLState(), sqlEx
- .getErrorCode(), updateCounts);
- }
-
- return updateCounts;
- } finally {
- if (batchedStatement != null) {
- batchedStatement.close();
- }
- }
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- resetCancelledState();
-
- if (!multiQueriesEnabled) {
- locallyScopedConn.getIO().disableMultiQueries();
- }
-
- clearBatch();
- }
- }
- }
-
- private String generateMultiStatementForBatch(int numBatches) {
- StringBuffer newStatementSql = new StringBuffer((this.originalSql
- .length() + 1) * numBatches);
-
- newStatementSql.append(this.originalSql);
-
- for (int i = 0; i < numBatches - 1; i++) {
- newStatementSql.append(';');
- newStatementSql.append(this.originalSql);
- }
-
- return newStatementSql.toString();
- }
-
- /**
- * Rewrites the already prepared statement into a multi-value insert
- * statement of 'statementsPerBatch' values and executes the entire batch
- * using this new statement.
- *
- * @return update counts in the same fashion as executeBatch()
- *
- * @throws SQLException
- */
- protected int[] executeBatchedInserts(int batchTimeout) throws SQLException {
- String valuesClause = getValuesClause();
-
- Connection locallyScopedConn = this.connection;
-
- if (valuesClause == null) {
- return executeBatchSerially(batchTimeout);
- }
-
- int numBatchedArgs = this.batchedArgs.size();
-
- if (this.retrieveGeneratedKeys) {
- this.batchedGeneratedKeys = new ArrayList(numBatchedArgs);
- }
-
- int numValuesPerBatch = computeBatchSize(numBatchedArgs);
-
- if (numBatchedArgs < numValuesPerBatch) {
- numValuesPerBatch = numBatchedArgs;
- }
-
- java.sql.PreparedStatement batchedStatement = null;
-
- int batchedParamIndex = 1;
- int updateCountRunningTotal = 0;
- int numberToExecuteAsMultiValue = 0;
- int batchCounter = 0;
- CancelTask timeoutTask = null;
- SQLException sqlEx = null;
-
- int[] updateCounts = new int[numBatchedArgs];
-
- for (int i = 0; i < this.batchedArgs.size(); i++) {
- updateCounts[i] = 1;
- }
-
- try {
- try {
- batchedStatement = /* FIXME -if we ever care about folks proxying our ConnectionImpl */
- prepareBatchedInsertSQL((ConnectionImpl) locallyScopedConn, numValuesPerBatch);
-
- if (this.connection.getEnableQueryTimeouts()
- && batchTimeout != 0
- && this.connection.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(
- (StatementImpl) batchedStatement);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- batchTimeout);
- }
-
- if (numBatchedArgs < numValuesPerBatch) {
- numberToExecuteAsMultiValue = numBatchedArgs;
- } else {
- numberToExecuteAsMultiValue = numBatchedArgs
- / numValuesPerBatch;
- }
-
- int numberArgsToExecute = numberToExecuteAsMultiValue
- * numValuesPerBatch;
-
- for (int i = 0; i < numberArgsToExecute; i++) {
- if (i != 0 && i % numValuesPerBatch == 0) {
- try {
- updateCountRunningTotal += batchedStatement
- .executeUpdate();
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(batchCounter - 1,
- numValuesPerBatch, updateCounts, ex);
- }
-
- getBatchedGeneratedKeys(batchedStatement);
- batchedStatement.clearParameters();
- batchedParamIndex = 1;
-
- }
-
- batchedParamIndex = setOneBatchedParameterSet(
- batchedStatement, batchedParamIndex,
- this.batchedArgs.get(batchCounter++));
- }
-
- try {
- updateCountRunningTotal += batchedStatement.executeUpdate();
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(batchCounter - 1,
- numValuesPerBatch, updateCounts, ex);
- }
-
- getBatchedGeneratedKeys(batchedStatement);
-
- numValuesPerBatch = numBatchedArgs - batchCounter;
- } finally {
- if (batchedStatement != null) {
- batchedStatement.close();
- }
- }
-
- try {
- if (numValuesPerBatch > 0) {
- batchedStatement =
- prepareBatchedInsertSQL((ConnectionImpl) locallyScopedConn,
- numValuesPerBatch);
-
- if (timeoutTask != null) {
- timeoutTask.toCancel = (StatementImpl) batchedStatement;
- }
-
- batchedParamIndex = 1;
-
- while (batchCounter < numBatchedArgs) {
- batchedParamIndex = setOneBatchedParameterSet(
- batchedStatement, batchedParamIndex,
- this.batchedArgs.get(batchCounter++));
- }
-
- try {
- updateCountRunningTotal += batchedStatement.executeUpdate();
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(batchCounter - 1,
- numValuesPerBatch, updateCounts, ex);
- }
-
- getBatchedGeneratedKeys(batchedStatement);
- }
-
- if (sqlEx != null) {
- throw new java.sql.BatchUpdateException(sqlEx
- .getMessage(), sqlEx.getSQLState(), sqlEx
- .getErrorCode(), updateCounts);
- }
-
- return updateCounts;
- } finally {
- if (batchedStatement != null) {
- batchedStatement.close();
- }
- }
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- resetCancelledState();
- }
- }
-
- protected String getValuesClause() throws SQLException {
- return this.parseInfo.valuesClause;
- }
-
- /**
- * Computes the optimum number of batched parameter lists to send
- * without overflowing max_allowed_packet.
- *
- * @param numBatchedArgs
- * @return
- * @throws SQLException
- */
- protected int computeBatchSize(int numBatchedArgs) throws SQLException {
- long[] combinedValues = computeMaxParameterSetSizeAndBatchSize(numBatchedArgs);
-
- long maxSizeOfParameterSet = combinedValues[0];
- long sizeOfEntireBatch = combinedValues[1];
-
- int maxAllowedPacket = this.connection.getMaxAllowedPacket();
-
- if (sizeOfEntireBatch < maxAllowedPacket - this.originalSql.length()) {
- return numBatchedArgs;
- }
-
- return (int)Math.max(1, (maxAllowedPacket - this.originalSql.length()) / maxSizeOfParameterSet);
- }
-
- /**
- * Computes the maximum parameter set size, and entire batch size given
- * the number of arguments in the batch.
- * @throws SQLException
- */
- protected long[] computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs) throws SQLException {
- long sizeOfEntireBatch = 0;
- long maxSizeOfParameterSet = 0;
-
- for (int i = 0; i < numBatchedArgs; i++) {
- BatchParams paramArg = (BatchParams) this.batchedArgs
- .get(i);
-
- boolean[] isNullBatch = paramArg.isNull;
- boolean[] isStreamBatch = paramArg.isStream;
-
- long sizeOfParameterSet = 0;
-
- for (int j = 0; j < isNullBatch.length; j++) {
- if (!isNullBatch[j]) {
-
- if (isStreamBatch[j]) {
- int streamLength = paramArg.streamLengths[j];
-
- if (streamLength != -1) {
- sizeOfParameterSet += streamLength * 2; // for safety in escaping
- } else {
- int paramLength = paramArg.parameterStrings[j].length;
- sizeOfParameterSet += paramLength;
- }
- } else {
- sizeOfParameterSet += paramArg.parameterStrings[j].length;
- }
- } else {
- sizeOfParameterSet += 4; // for NULL literal in SQL
- }
- }
-
- //
- // Account for static part of values clause
- // This is a little naiive, because the ?s will be replaced
- // but it gives us some padding, and is less housekeeping
- // to ignore them. We're looking for a "fuzzy" value here
- // anyway
- //
-
- if (getValuesClause() != null) {
- sizeOfParameterSet += getValuesClause().length() + 1;
- } else {
- sizeOfParameterSet += this.originalSql.length() + 1;
- }
-
- sizeOfEntireBatch += sizeOfParameterSet;
-
- if (sizeOfParameterSet > maxSizeOfParameterSet) {
- maxSizeOfParameterSet = sizeOfParameterSet;
- }
- }
-
- return new long[] {maxSizeOfParameterSet, sizeOfEntireBatch};
- }
-
-
- /**
- * Executes the current batch of statements by executing them one-by-one.
- *
- * @return a list of update counts
- * @throws SQLException
- * if an error occurs
- */
- protected int[] executeBatchSerially(int batchTimeout) throws SQLException {
-
- Connection locallyScopedConn = this.connection;
-
- if (locallyScopedConn == null) {
- checkClosed();
- }
-
- int[] updateCounts = null;
-
- if (this.batchedArgs != null) {
- int nbrCommands = this.batchedArgs.size();
- updateCounts = new int[nbrCommands];
-
- for (int i = 0; i < nbrCommands; i++) {
- updateCounts[i] = -3;
- }
-
- SQLException sqlEx = null;
-
- CancelTask timeoutTask = null;
-
- try {
- if (this.connection.getEnableQueryTimeouts() &&
- batchTimeout != 0
- && this.connection.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- batchTimeout);
- }
-
- if (this.retrieveGeneratedKeys) {
- this.batchedGeneratedKeys = new ArrayList(nbrCommands);
- }
-
- for (batchCommandIndex = 0; batchCommandIndex < nbrCommands; batchCommandIndex++) {
- Object arg = this.batchedArgs.get(batchCommandIndex);
-
- if (arg instanceof String) {
- updateCounts[batchCommandIndex] = executeUpdate((String) arg);
- } else {
- BatchParams paramArg = (BatchParams) arg;
-
- try {
- updateCounts[batchCommandIndex] = executeUpdate(
- paramArg.parameterStrings,
- paramArg.parameterStreams, paramArg.isStream,
- paramArg.streamLengths, paramArg.isNull, true);
-
- if (this.retrieveGeneratedKeys) {
- java.sql.ResultSet rs = null;
-
- try {
- if (containsOnDuplicateKeyUpdateInSQL())
- rs = getGeneratedKeysInternal(1);
- else
- rs = getGeneratedKeysInternal();
-
- while (rs.next()) {
- this.batchedGeneratedKeys
- .add(new ByteArrayRow(new byte[][] { rs.getBytes(1) }, getExceptionInterceptor()));
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
- }
- } catch (SQLException ex) {
- updateCounts[batchCommandIndex] = EXECUTE_FAILED;
-
- if (this.continueBatchOnError &&
- !(ex instanceof MySQLTimeoutException) &&
- !(ex instanceof MySQLStatementCancelledException) &&
- !hasDeadlockOrTimeoutRolledBackTx(ex)) {
- sqlEx = ex;
- } else {
- int[] newUpdateCounts = new int[batchCommandIndex];
- System.arraycopy(updateCounts, 0,
- newUpdateCounts, 0, batchCommandIndex);
-
- throw new java.sql.BatchUpdateException(ex
- .getMessage(), ex.getSQLState(), ex
- .getErrorCode(), newUpdateCounts);
- }
- }
- }
- }
-
- if (sqlEx != null) {
- throw new java.sql.BatchUpdateException(sqlEx.getMessage(),
- sqlEx.getSQLState(), sqlEx.getErrorCode(), updateCounts);
- }
- } finally {
- batchCommandIndex = -1;
-
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- resetCancelledState();
- }
- }
-
- return (updateCounts != null) ? updateCounts : new int[0];
-
- }
-
- /**
- * Actually execute the prepared statement. This is here so server-side
- * PreparedStatements can re-use most of the code from this class.
- *
- * @param maxRowsToRetrieve
- * the max number of rows to return
- * @param sendPacket
- * the packet to send
- * @param createStreamingResultSet
- * should a 'streaming' result set be created?
- * @param queryIsSelectOnly
- * is this query doing a SELECT?
- * @param unpackFields
- * DOCUMENT ME!
- *
- * @return the results as a ResultSet
- *
- * @throws SQLException
- * if an error occurs.
- */
- protected ResultSetInternalMethods executeInternal(int maxRowsToRetrieve,
- Buffer sendPacket, boolean createStreamingResultSet,
- boolean queryIsSelectOnly, Field[] metadataFromCache,
- boolean isBatch)
- throws SQLException {
- try {
-
- resetCancelledState();
-
- ConnectionImpl locallyScopedConnection = this.connection;
-
- this.numberOfExecutions++;
-
- if (this.doPingInstead) {
- doPingInstead();
-
- return this.results;
- }
-
- ResultSetInternalMethods rs;
-
- CancelTask timeoutTask = null;
-
- try {
- if (locallyScopedConnection.getEnableQueryTimeouts() &&
- this.timeoutInMillis != 0
- && locallyScopedConnection.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- this.timeoutInMillis);
- }
-
- rs = locallyScopedConnection.execSQL(this, null, maxRowsToRetrieve, sendPacket,
- this.resultSetType, this.resultSetConcurrency,
- createStreamingResultSet, this.currentCatalog,
- metadataFromCache, isBatch);
-
- if (timeoutTask != null) {
- timeoutTask.cancel();
-
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask = null;
- }
-
- synchronized (this.cancelTimeoutMutex) {
- if (this.wasCancelled) {
- SQLException cause = null;
-
- if (this.wasCancelledByTimeout) {
- cause = new MySQLTimeoutException();
- } else {
- cause = new MySQLStatementCancelledException();
- }
-
- resetCancelledState();
-
- throw cause;
- }
- }
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
- }
-
- return rs;
- } catch (NullPointerException npe) {
- checkClosed(); // we can't synchronize ourselves against async connection-close
- // due to deadlock issues, so this is the next best thing for
- // this particular corner case.
-
- throw npe;
- }
- }
-
- /**
- * A Prepared SQL query is executed and its ResultSet is returned
- *
- * @return a ResultSet that contains the data produced by the query - never
- * null
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public java.sql.ResultSet executeQuery() throws SQLException {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- checkForDml(this.originalSql, this.firstCharOfStmt);
-
- CachedResultSetMetaData cachedMetadata = null;
-
- // We need to execute this all together
- // So synchronize on the Connection's mutex (because
- // even queries going through there synchronize
- // on the same mutex.
- synchronized (locallyScopedConn.getMutex()) {
- clearWarnings();
-
- boolean doStreaming = createStreamingResultSet();
-
- this.batchedGeneratedKeys = null;
-
- // Adjust net_write_timeout to a higher value if we're
- // streaming result sets. More often than not, someone runs into
- // an issue where they blow net_write_timeout when using this
- // feature, and if they're willing to hold a result set open
- // for 30 seconds or more, one more round-trip isn't going to hurt
- //
- // This is reset by RowDataDynamic.close().
-
- if (doStreaming
- && this.connection.getNetTimeoutForStreamingResults() > 0) {
- locallyScopedConn.execSQL(this, "SET net_write_timeout="
- + this.connection.getNetTimeoutForStreamingResults(),
- -1, null, ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_READ_ONLY, false, this.currentCatalog,
- null, false);
- }
-
- Buffer sendPacket = fillSendPacket();
-
- if (this.results != null) {
- if (!this.connection.getHoldResultsOpenOverStatementClose()) {
- if (!this.holdResultsOpenOverClose) {
- this.results.realClose(false);
- }
- }
- }
-
- String oldCatalog = null;
-
- if (!locallyScopedConn.getCatalog().equals(this.currentCatalog)) {
- oldCatalog = locallyScopedConn.getCatalog();
- locallyScopedConn.setCatalog(this.currentCatalog);
- }
-
- //
- // Check if we have cached metadata for this query...
- //
- if (locallyScopedConn.getCacheResultSetMetadata()) {
- cachedMetadata = locallyScopedConn.getCachedMetaData(this.originalSql);
- }
-
- Field[] metadataFromCache = null;
-
- if (cachedMetadata != null) {
- metadataFromCache = cachedMetadata.fields;
- }
-
- if (locallyScopedConn.useMaxRows()) {
- // If there isn't a limit clause in the SQL
- // then limit the number of rows to return in
- // an efficient manner. Only do this if
- // setMaxRows() hasn't been used on any Statements
- // generated from the current Connection (saves
- // a query, and network traffic).
- if (this.hasLimitClause) {
- this.results = executeInternal(this.maxRows, sendPacket,
- createStreamingResultSet(), true,
- metadataFromCache, false);
- } else {
- if (this.maxRows <= 0) {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- } else {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=" + this.maxRows);
- }
-
- this.results = executeInternal(-1, sendPacket,
- doStreaming, true,
- metadataFromCache, false);
-
- if (oldCatalog != null) {
- this.connection.setCatalog(oldCatalog);
- }
- }
- } else {
- this.results = executeInternal(-1, sendPacket,
- doStreaming, true,
- metadataFromCache, false);
- }
-
- if (oldCatalog != null) {
- locallyScopedConn.setCatalog(oldCatalog);
- }
-
- if (cachedMetadata != null) {
- locallyScopedConn.initializeResultsMetadataFromCache(this.originalSql,
- cachedMetadata, this.results);
- } else {
- if (locallyScopedConn.getCacheResultSetMetadata()) {
- locallyScopedConn.initializeResultsMetadataFromCache(this.originalSql,
- null /* will be created */, this.results);
- }
- }
- }
-
- this.lastInsertId = this.results.getUpdateID();
-
- return this.results;
- }
-
- /**
- * Execute a SQL INSERT, UPDATE or DELETE statement. In addition, SQL
- * statements that return nothing such as SQL DDL statements can be
- * executed.
- *
- * @return either the row count for INSERT, UPDATE or DELETE; or 0 for SQL
- * statements that return nothing.
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public int executeUpdate() throws SQLException {
- return executeUpdate(true, false);
- }
-
- /*
- * We need this variant, because ServerPreparedStatement calls this for
- * batched updates, which will end up clobbering the warnings and generated
- * keys we need to gather for the batch.
- */
- protected int executeUpdate(
- boolean clearBatchedGeneratedKeysAndWarnings, boolean isBatch) throws SQLException {
- if (clearBatchedGeneratedKeysAndWarnings) {
- clearWarnings();
- this.batchedGeneratedKeys = null;
- }
-
- return executeUpdate(this.parameterValues, this.parameterStreams,
- this.isStream, this.streamLengths, this.isNull, isBatch);
- }
-
- /**
- * Added to allow batch-updates
- *
- * @param batchedParameterStrings
- * string values used in single statement
- * @param batchedParameterStreams
- * stream values used in single statement
- * @param batchedIsStream
- * flags for streams used in single statement
- * @param batchedStreamLengths
- * lengths of streams to be read.
- * @param batchedIsNull
- * flags for parameters that are null
- *
- * @return the update count
- *
- * @throws SQLException
- * if a database error occurs
- */
- protected int executeUpdate(byte[][] batchedParameterStrings,
- InputStream[] batchedParameterStreams, boolean[] batchedIsStream,
- int[] batchedStreamLengths, boolean[] batchedIsNull, boolean isReallyBatch)
- throws SQLException {
-
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- if (locallyScopedConn.isReadOnly()) {
- throw SQLError.createSQLException(Messages.getString("PreparedStatement.34") //$NON-NLS-1$
- + Messages.getString("PreparedStatement.35"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- if ((this.firstCharOfStmt == 'S')
- && isSelectQuery()) { //$NON-NLS-1$
- throw SQLError.createSQLException(Messages.getString("PreparedStatement.37"), //$NON-NLS-1$
- "01S03", getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (this.results != null) {
- if (!locallyScopedConn.getHoldResultsOpenOverStatementClose()) {
- this.results.realClose(false);
- }
- }
-
- ResultSetInternalMethods rs = null;
-
- // The checking and changing of catalogs
- // must happen in sequence, so synchronize
- // on the same mutex that _conn is using
- synchronized (locallyScopedConn.getMutex()) {
- Buffer sendPacket = fillSendPacket(batchedParameterStrings,
- batchedParameterStreams, batchedIsStream,
- batchedStreamLengths);
-
- String oldCatalog = null;
-
- if (!locallyScopedConn.getCatalog().equals(this.currentCatalog)) {
- oldCatalog = locallyScopedConn.getCatalog();
- locallyScopedConn.setCatalog(this.currentCatalog);
- }
-
- //
- // Only apply max_rows to selects
- //
- if (locallyScopedConn.useMaxRows()) {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- }
-
- boolean oldInfoMsgState = false;
-
- if (this.retrieveGeneratedKeys) {
- oldInfoMsgState = locallyScopedConn.isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
- }
-
- rs = executeInternal(-1, sendPacket, false, false, null,
- isReallyBatch);
-
- if (this.retrieveGeneratedKeys) {
- locallyScopedConn.setReadInfoMsgEnabled(oldInfoMsgState);
- rs.setFirstCharOfQuery(this.firstCharOfStmt);
- }
-
- if (oldCatalog != null) {
- locallyScopedConn.setCatalog(oldCatalog);
- }
- }
-
- this.results = rs;
-
- this.updateCount = rs.getUpdateCount();
-
- if (containsOnDuplicateKeyUpdateInSQL() &&
- this.compensateForOnDuplicateKeyUpdate) {
- if (this.updateCount == 2 || this.updateCount == 0) {
- this.updateCount = 1;
- }
- }
-
- int truncatedUpdateCount = 0;
-
- if (this.updateCount > Integer.MAX_VALUE) {
- truncatedUpdateCount = Integer.MAX_VALUE;
- } else {
- truncatedUpdateCount = (int) this.updateCount;
- }
-
- this.lastInsertId = rs.getUpdateID();
-
- return truncatedUpdateCount;
- }
-
- protected boolean containsOnDuplicateKeyUpdateInSQL() {
- return this.parseInfo.isOnDuplicateKeyUpdate;
- }
-
-
-
- /**
- * Creates the packet that contains the query to be sent to the server.
- *
- * @return A Buffer filled with the query representing the
- * PreparedStatement.
- *
- * @throws SQLException
- * if an error occurs.
- */
- protected Buffer fillSendPacket() throws SQLException {
- return fillSendPacket(this.parameterValues, this.parameterStreams,
- this.isStream, this.streamLengths);
- }
-
- /**
- * Creates the packet that contains the query to be sent to the server.
- *
- * @param batchedParameterStrings
- * the parameters as strings
- * @param batchedParameterStreams
- * the parameters as streams
- * @param batchedIsStream
- * is the given parameter a stream?
- * @param batchedStreamLengths
- * the lengths of the streams (if appropriate)
- *
- * @return a Buffer filled with the query that represents this statement
- *
- * @throws SQLException
- * if an error occurs.
- */
- protected Buffer fillSendPacket(byte[][] batchedParameterStrings,
- InputStream[] batchedParameterStreams, boolean[] batchedIsStream,
- int[] batchedStreamLengths) throws SQLException {
- Buffer sendPacket = this.connection.getIO().getSharedSendPacket();
-
- sendPacket.clear();
-
- sendPacket.writeByte((byte) MysqlDefs.QUERY);
-
- boolean useStreamLengths = this.connection
- .getUseStreamLengthsInPrepStmts();
-
- //
- // Try and get this allocation as close as possible
- // for BLOBs
- //
- int ensurePacketSize = 0;
-
- String statementComment = this.connection.getStatementComment();
-
- byte[] commentAsBytes = null;
-
- if (statementComment != null) {
- if (this.charConverter != null) {
- commentAsBytes = this.charConverter.toBytes(statementComment);
- } else {
- commentAsBytes = StringUtils.getBytes(statementComment, this.charConverter,
- this.charEncoding, this.connection
- .getServerCharacterEncoding(), this.connection
- .parserKnowsUnicode(), getExceptionInterceptor());
- }
-
- ensurePacketSize += commentAsBytes.length;
- ensurePacketSize += 6; // for /*[space] [space]*/
- }
-
- for (int i = 0; i < batchedParameterStrings.length; i++) {
- if (batchedIsStream[i] && useStreamLengths) {
- ensurePacketSize += batchedStreamLengths[i];
- }
- }
-
- if (ensurePacketSize != 0) {
- sendPacket.ensureCapacity(ensurePacketSize);
- }
-
- if (commentAsBytes != null) {
- sendPacket.writeBytesNoNull(Constants.SLASH_STAR_SPACE_AS_BYTES);
- sendPacket.writeBytesNoNull(commentAsBytes);
- sendPacket.writeBytesNoNull(Constants.SPACE_STAR_SLASH_SPACE_AS_BYTES);
- }
-
- for (int i = 0; i < batchedParameterStrings.length; i++) {
- checkAllParametersSet(batchedParameterStrings[i],
- batchedParameterStreams[i], i);
-
- sendPacket.writeBytesNoNull(this.staticSqlStrings[i]);
-
- if (batchedIsStream[i]) {
- streamToBytes(sendPacket, batchedParameterStreams[i], true,
- batchedStreamLengths[i], useStreamLengths);
- } else {
- sendPacket.writeBytesNoNull(batchedParameterStrings[i]);
- }
- }
-
- sendPacket
- .writeBytesNoNull(this.staticSqlStrings[batchedParameterStrings.length]);
-
- return sendPacket;
- }
-
- private void checkAllParametersSet(byte[] parameterString,
- InputStream parameterStream, int columnIndex) throws SQLException {
- if ((parameterString == null)
- && parameterStream == null) {
- System.out.println(toString());
- throw SQLError.createSQLException(Messages
- .getString("PreparedStatement.40") //$NON-NLS-1$
- + (columnIndex + 1), SQLError.SQL_STATE_WRONG_NO_OF_PARAMETERS, getExceptionInterceptor());
- }
- }
-
- /**
- * Returns a preparaed statement for the number of batched parameters, used when re-writing batch INSERTs.
- */
- protected PreparedStatement prepareBatchedInsertSQL(ConnectionImpl localConn, int numBatches) throws SQLException {
- PreparedStatement pstmt = new PreparedStatement(localConn, "batch statement, no sql available", this.currentCatalog, this.parseInfo.getParseInfoForBatch(numBatches));
- pstmt.setRetrieveGeneratedKeys(this.retrieveGeneratedKeys);
-
- return pstmt;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param parameterIndex
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public byte[] getBytesRepresentation(int parameterIndex)
- throws SQLException {
- if (this.isStream[parameterIndex]) {
- return streamToBytes(this.parameterStreams[parameterIndex], false,
- this.streamLengths[parameterIndex], this.connection
- .getUseStreamLengthsInPrepStmts());
- }
-
- byte[] parameterVal = this.parameterValues[parameterIndex];
-
- if (parameterVal == null) {
- return null;
- }
-
- if ((parameterVal[0] == '\'')
- && (parameterVal[parameterVal.length - 1] == '\'')) {
- byte[] valNoQuotes = new byte[parameterVal.length - 2];
- System.arraycopy(parameterVal, 1, valNoQuotes, 0,
- parameterVal.length - 2);
-
- return valNoQuotes;
- }
-
- return parameterVal;
- }
-
- /**
- * Get bytes representation for a parameter in a statement batch.
- * @param parameterIndex
- * @param commandIndex
- * @return
- * @throws SQLException
- */
- protected byte[] getBytesRepresentationForBatch(int parameterIndex, int commandIndex)
- throws SQLException {
- Object batchedArg = batchedArgs.get(commandIndex);
- if (batchedArg instanceof String) {
- try {
- return ((String)batchedArg).getBytes(charEncoding);
-
- } catch (UnsupportedEncodingException uue) {
- throw new RuntimeException(Messages
- .getString("PreparedStatement.32") //$NON-NLS-1$
- + this.charEncoding
- + Messages.getString("PreparedStatement.33")); //$NON-NLS-1$
- }
- }
-
- BatchParams params = (BatchParams)batchedArg;
- if (params.isStream[parameterIndex])
- return streamToBytes(params.parameterStreams[parameterIndex], false,
- params.streamLengths[parameterIndex],
- connection.getUseStreamLengthsInPrepStmts());
- byte parameterVal[] = params.parameterStrings[parameterIndex];
- if (parameterVal == null)
- return null;
-
- if ((parameterVal[0] == '\'')
- && (parameterVal[parameterVal.length - 1] == '\'')) {
- byte[] valNoQuotes = new byte[parameterVal.length - 2];
- System.arraycopy(parameterVal, 1, valNoQuotes, 0,
- parameterVal.length - 2);
-
- return valNoQuotes;
- }
-
- return parameterVal;
- }
-
- // --------------------------JDBC 2.0-----------------------------
-
- private final String getDateTimePattern(String dt, boolean toTime)
- throws Exception {
- //
- // Special case
- //
- int dtLength = (dt != null) ? dt.length() : 0;
-
- if ((dtLength >= 8) && (dtLength <= 10)) {
- int dashCount = 0;
- boolean isDateOnly = true;
-
- for (int i = 0; i < dtLength; i++) {
- char c = dt.charAt(i);
-
- if (!Character.isDigit(c) && (c != '-')) {
- isDateOnly = false;
-
- break;
- }
-
- if (c == '-') {
- dashCount++;
- }
- }
-
- if (isDateOnly && (dashCount == 2)) {
- return "yyyy-MM-dd"; //$NON-NLS-1$
- }
- }
-
- //
- // Special case - time-only
- //
- boolean colonsOnly = true;
-
- for (int i = 0; i < dtLength; i++) {
- char c = dt.charAt(i);
-
- if (!Character.isDigit(c) && (c != ':')) {
- colonsOnly = false;
-
- break;
- }
- }
-
- if (colonsOnly) {
- return "HH:mm:ss"; //$NON-NLS-1$
- }
-
- int n;
- int z;
- int count;
- int maxvecs;
- char c;
- char separator;
- StringReader reader = new StringReader(dt + " "); //$NON-NLS-1$
- ArrayList vec = new ArrayList();
- ArrayList vecRemovelist = new ArrayList();
- Object[] nv = new Object[3];
- Object[] v;
- nv[0] = Constants.characterValueOf('y');
- nv[1] = new StringBuffer();
- nv[2] = Constants.integerValueOf(0);
- vec.add(nv);
-
- if (toTime) {
- nv = new Object[3];
- nv[0] = Constants.characterValueOf('h');
- nv[1] = new StringBuffer();
- nv[2] = Constants.integerValueOf(0);
- vec.add(nv);
- }
-
- while ((z = reader.read()) != -1) {
- separator = (char) z;
- maxvecs = vec.size();
-
- for (count = 0; count < maxvecs; count++) {
- v = (Object[]) vec.get(count);
- n = ((Integer) v[2]).intValue();
- c = getSuccessor(((Character) v[0]).charValue(), n);
-
- if (!Character.isLetterOrDigit(separator)) {
- if ((c == ((Character) v[0]).charValue()) && (c != 'S')) {
- vecRemovelist.add(v);
- } else {
- ((StringBuffer) v[1]).append(separator);
-
- if ((c == 'X') || (c == 'Y')) {
- v[2] = Constants.integerValueOf(4);
- }
- }
- } else {
- if (c == 'X') {
- c = 'y';
- nv = new Object[3];
- nv[1] = (new StringBuffer(((StringBuffer) v[1])
- .toString())).append('M');
- nv[0] = Constants.characterValueOf('M');
- nv[2] = Constants.integerValueOf(1);
- vec.add(nv);
- } else if (c == 'Y') {
- c = 'M';
- nv = new Object[3];
- nv[1] = (new StringBuffer(((StringBuffer) v[1])
- .toString())).append('d');
- nv[0] = Constants.characterValueOf('d');
- nv[2] = Constants.integerValueOf(1);
- vec.add(nv);
- }
-
- ((StringBuffer) v[1]).append(c);
-
- if (c == ((Character) v[0]).charValue()) {
- v[2] = Constants.integerValueOf(n + 1);
- } else {
- v[0] = Constants.characterValueOf(c);
- v[2] = Constants.integerValueOf(1);
- }
- }
- }
-
- int size = vecRemovelist.size();
-
- for (int i = 0; i < size; i++) {
- v = (Object[]) vecRemovelist.get(i);
- vec.remove(v);
- }
-
- vecRemovelist.clear();
- }
-
- int size = vec.size();
-
- for (int i = 0; i < size; i++) {
- v = (Object[]) vec.get(i);
- c = ((Character) v[0]).charValue();
- n = ((Integer) v[2]).intValue();
-
- boolean bk = getSuccessor(c, n) != c;
- boolean atEnd = (((c == 's') || (c == 'm') || ((c == 'h') && toTime)) && bk);
- boolean finishesAtDate = (bk && (c == 'd') && !toTime);
- boolean containsEnd = (((StringBuffer) v[1]).toString()
- .indexOf('W') != -1);
-
- if ((!atEnd && !finishesAtDate) || (containsEnd)) {
- vecRemovelist.add(v);
- }
- }
-
- size = vecRemovelist.size();
-
- for (int i = 0; i < size; i++) {
- vec.remove(vecRemovelist.get(i));
- }
-
- vecRemovelist.clear();
- v = (Object[]) vec.get(0); // might throw exception
-
- StringBuffer format = (StringBuffer) v[1];
- format.setLength(format.length() - 1);
-
- return format.toString();
- }
-
- /**
- * The number, types and properties of a ResultSet's columns are provided by
- * the getMetaData method.
- *
- * @return the description of a ResultSet's columns
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.ResultSetMetaData getMetaData()
- throws SQLException {
-
- //
- // We could just tack on a LIMIT 0 here no matter what the
- // statement, and check if a result set was returned or not,
- // but I'm not comfortable with that, myself, so we take
- // the "safer" road, and only allow metadata for _actual_
- // SELECTS (but not SHOWs).
- //
- // CALL's are trapped further up and you end up with a
- // CallableStatement anyway.
- //
-
- if (!isSelectQuery()) {
- return null;
- }
-
- PreparedStatement mdStmt = null;
- java.sql.ResultSet mdRs = null;
-
- if (this.pstmtResultMetaData == null) {
- try {
- mdStmt = new PreparedStatement(this.connection,
- this.originalSql, this.currentCatalog, this.parseInfo);
-
- mdStmt.setMaxRows(0);
-
- int paramCount = this.parameterValues.length;
-
- for (int i = 1; i <= paramCount; i++) {
- mdStmt.setString(i, ""); //$NON-NLS-1$
- }
-
- boolean hadResults = mdStmt.execute();
-
- if (hadResults) {
- mdRs = mdStmt.getResultSet();
-
- this.pstmtResultMetaData = mdRs.getMetaData();
- } else {
- this.pstmtResultMetaData = new ResultSetMetaData(
- new Field[0],
- this.connection.getUseOldAliasMetadataBehavior(), getExceptionInterceptor());
- }
- } finally {
- SQLException sqlExRethrow = null;
-
- if (mdRs != null) {
- try {
- mdRs.close();
- } catch (SQLException sqlEx) {
- sqlExRethrow = sqlEx;
- }
-
- mdRs = null;
- }
-
- if (mdStmt != null) {
- try {
- mdStmt.close();
- } catch (SQLException sqlEx) {
- sqlExRethrow = sqlEx;
- }
-
- mdStmt = null;
- }
-
- if (sqlExRethrow != null) {
- throw sqlExRethrow;
- }
- }
- }
-
- return this.pstmtResultMetaData;
- }
-
- protected boolean isSelectQuery() {
- return StringUtils.startsWithIgnoreCaseAndWs(
- StringUtils.stripComments(this.originalSql,
- "'\"", "'\"", true, false, true, true),
- "SELECT");
- }
-
- /**
- * @see PreparedStatement#getParameterMetaData()
- */
- public ParameterMetaData getParameterMetaData()
- throws SQLException {
- if (this.parameterMetaData == null) {
- if (this.connection.getGenerateSimpleParameterMetadata()) {
- this.parameterMetaData = new MysqlParameterMetadata(this.parameterCount);
- } else {
- this.parameterMetaData = new MysqlParameterMetadata(
- null, this.parameterCount, getExceptionInterceptor());
- }
- }
-
- return this.parameterMetaData;
-}
-
- ParseInfo getParseInfo() {
- return this.parseInfo;
- }
-
- private final char getSuccessor(char c, int n) {
- return ((c == 'y') && (n == 2)) ? 'X'
- : (((c == 'y') && (n < 4)) ? 'y'
- : ((c == 'y') ? 'M'
- : (((c == 'M') && (n == 2)) ? 'Y'
- : (((c == 'M') && (n < 3)) ? 'M'
- : ((c == 'M') ? 'd'
- : (((c == 'd') && (n < 2)) ? 'd'
- : ((c == 'd') ? 'H'
- : (((c == 'H') && (n < 2)) ? 'H'
- : ((c == 'H') ? 'm'
- : (((c == 'm') && (n < 2)) ? 'm'
- : ((c == 'm') ? 's'
- : (((c == 's') && (n < 2)) ? 's'
- : 'W'))))))))))));
- }
-
- /**
- * Used to escape binary data with hex for mb charsets
- *
- * @param buf
- * @param packet
- * @param size
- * @throws SQLException
- */
- private final void hexEscapeBlock(byte[] buf, Buffer packet, int size)
- throws SQLException {
- for (int i = 0; i < size; i++) {
- byte b = buf[i];
- int lowBits = (b & 0xff) / 16;
- int highBits = (b & 0xff) % 16;
-
- packet.writeByte(HEX_DIGITS[lowBits]);
- packet.writeByte(HEX_DIGITS[highBits]);
- }
- }
-
- private void initializeFromParseInfo() throws SQLException {
- this.staticSqlStrings = this.parseInfo.staticSql;
- this.hasLimitClause = this.parseInfo.foundLimitClause;
- this.isLoadDataQuery = this.parseInfo.foundLoadData;
- this.firstCharOfStmt = this.parseInfo.firstStmtChar;
-
- this.parameterCount = this.staticSqlStrings.length - 1;
-
- this.parameterValues = new byte[this.parameterCount][];
- this.parameterStreams = new InputStream[this.parameterCount];
- this.isStream = new boolean[this.parameterCount];
- this.streamLengths = new int[this.parameterCount];
- this.isNull = new boolean[this.parameterCount];
- this.parameterTypes = new int[this.parameterCount];
-
- clearParameters();
-
- for (int j = 0; j < this.parameterCount; j++) {
- this.isStream[j] = false;
- }
- }
-
- boolean isNull(int paramIndex) {
- return this.isNull[paramIndex];
- }
-
- private final int readblock(InputStream i, byte[] b) throws SQLException {
- try {
- return i.read(b);
- } catch (Throwable ex) {
- SQLException sqlEx = SQLError.createSQLException(Messages.getString("PreparedStatement.56") //$NON-NLS-1$
- + ex.getClass().getName(), SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- private final int readblock(InputStream i, byte[] b, int length)
- throws SQLException {
- try {
- int lengthToRead = length;
-
- if (lengthToRead > b.length) {
- lengthToRead = b.length;
- }
-
- return i.read(b, 0, lengthToRead);
- } catch (Throwable ex) {
- SQLException sqlEx = SQLError.createSQLException(Messages.getString("PreparedStatement.56") //$NON-NLS-1$
- + ex.getClass().getName(), SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- /**
- * Closes this statement, releasing all resources
- *
- * @param calledExplicitly
- * was this called by close()?
- *
- * @throws SQLException
- * if an error occurs
- */
- protected void realClose(boolean calledExplicitly,
- boolean closeOpenResults) throws SQLException {
- if (this.useUsageAdvisor) {
- if (this.numberOfExecutions <= 1) {
- String message = Messages.getString("PreparedStatement.43"); //$NON-NLS-1$
-
- this.eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN, "", this.currentCatalog, //$NON-NLS-1$
- this.connectionId, this.getId(), -1, System
- .currentTimeMillis(), 0, Constants.MILLIS_I18N,
- null,
- this.pointOfOrigin, message));
- }
- }
-
- super.realClose(calledExplicitly, closeOpenResults);
-
- this.dbmd = null;
- this.originalSql = null;
- this.staticSqlStrings = null;
- this.parameterValues = null;
- this.parameterStreams = null;
- this.isStream = null;
- this.streamLengths = null;
- this.isNull = null;
- this.streamConvertBuf = null;
- this.parameterTypes = null;
- }
-
- /**
- * JDBC 2.0 Set an Array parameter.
- *
- * @param i
- * the first parameter is 1, the second is 2, ...
- * @param x
- * an object representing an SQL array
- *
- * @throws SQLException
- * because this method is not implemented.
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- public void setArray(int i, Array x) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * When a very large ASCII value is input to a LONGVARCHAR parameter, it may
- * be more practical to send it via a java.io.InputStream. JDBC will read
- * the data from the stream as needed, until it reaches end-of-file. The
- * JDBC driver will do any necessary conversion from ASCII to the database
- * char format.
- *
- *
- * Note: This stream object can either be a standard Java stream
- * object or your own subclass that implements the standard interface.
- *
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- * @param length
- * the number of bytes in the stream
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setAsciiStream(int parameterIndex, InputStream x,
- int length) throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.VARCHAR);
- } else {
- setBinaryStream(parameterIndex, x, length);
- }
- }
-
- /**
- * Set a parameter to a java.math.BigDecimal value. The driver converts this
- * to a SQL NUMERIC value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setBigDecimal(int parameterIndex, BigDecimal x)
- throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.DECIMAL);
- } else {
- setInternal(parameterIndex, StringUtils
- .fixDecimalExponent(StringUtils.consistentToString(x)));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DECIMAL;
- }
- }
-
- /**
- * When a very large binary value is input to a LONGVARBINARY parameter, it
- * may be more practical to send it via a java.io.InputStream. JDBC will
- * read the data from the stream as needed, until it reaches end-of-file.
- *
- *
- * Note: This stream object can either be a standard Java stream
- * object or your own subclass that implements the standard interface.
- *
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- * @param length
- * the number of bytes to read from the stream (ignored)
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public void setBinaryStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- int parameterIndexOffset = getParameterIndexOffset();
-
- if ((parameterIndex < 1)
- || (parameterIndex > this.staticSqlStrings.length)) {
- throw SQLError.createSQLException(
- Messages.getString("PreparedStatement.2") //$NON-NLS-1$
- + parameterIndex
- + Messages.getString("PreparedStatement.3") + this.staticSqlStrings.length + Messages.getString("PreparedStatement.4"), //$NON-NLS-1$ //$NON-NLS-2$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- } else if (parameterIndexOffset == -1 && parameterIndex == 1) {
- throw SQLError.createSQLException("Can't set IN parameter for return value of stored function call.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
-
- this.parameterStreams[parameterIndex - 1 + parameterIndexOffset] = x;
- this.isStream[parameterIndex - 1 + parameterIndexOffset] = true;
- this.streamLengths[parameterIndex - 1 + parameterIndexOffset] = length;
- this.isNull[parameterIndex - 1 + parameterIndexOffset] = false;
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.BLOB;
- }
- }
-
- public void setBlob(int parameterIndex, InputStream inputStream, long length)
- throws SQLException {
- setBinaryStream(parameterIndex, inputStream, (int)length);
- }
-
- /**
- * JDBC 2.0 Set a BLOB parameter.
- *
- * @param i
- * the first parameter is 1, the second is 2, ...
- * @param x
- * an object representing a BLOB
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void setBlob(int i, java.sql.Blob x) throws SQLException {
- if (x == null) {
- setNull(i, Types.BLOB);
- } else {
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
-
- bytesOut.write('\'');
- escapeblockFast(x.getBytes(1, (int) x.length()), bytesOut, (int) x
- .length());
- bytesOut.write('\'');
-
- setInternal(i, bytesOut.toByteArray());
-
- this.parameterTypes[i - 1 + getParameterIndexOffset()] = Types.BLOB;
- }
- }
-
- /**
- * Set a parameter to a Java boolean value. The driver converts this to a
- * SQL BIT value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public void setBoolean(int parameterIndex, boolean x) throws SQLException {
- if (this.useTrueBoolean) {
- setInternal(parameterIndex, x ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- setInternal(parameterIndex, x ? "'t'" : "'f'"); //$NON-NLS-1$ //$NON-NLS-2$
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.BOOLEAN;
- }
- }
-
- /**
- * Set a parameter to a Java byte value. The driver converts this to a SQL
- * TINYINT value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setByte(int parameterIndex, byte x) throws SQLException {
- setInternal(parameterIndex, String.valueOf(x));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.TINYINT;
- }
-
- /**
- * Set a parameter to a Java array of bytes. The driver converts this to a
- * SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative
- * to the driver's limits on VARBINARYs) when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setBytes(int parameterIndex, byte[] x) throws SQLException {
- setBytes(parameterIndex, x, true, true);
-
- if (x != null) {
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.BINARY;
- }
- }
-
- protected void setBytes(int parameterIndex, byte[] x,
- boolean checkForIntroducer, boolean escapeForMBChars)
- throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- String connectionEncoding = this.connection.getEncoding();
-
- if (this.connection.isNoBackslashEscapesSet()
- || (escapeForMBChars
- && this.connection.getUseUnicode()
- && connectionEncoding != null
- && CharsetMapping.isMultibyteCharset(connectionEncoding))) {
-
- // Send as hex
-
- ByteArrayOutputStream bOut = new ByteArrayOutputStream(
- (x.length * 2) + 3);
- bOut.write('x');
- bOut.write('\'');
-
- for (int i = 0; i < x.length; i++) {
- int lowBits = (x[i] & 0xff) / 16;
- int highBits = (x[i] & 0xff) % 16;
-
- bOut.write(HEX_DIGITS[lowBits]);
- bOut.write(HEX_DIGITS[highBits]);
- }
-
- bOut.write('\'');
-
- setInternal(parameterIndex, bOut.toByteArray());
-
- return;
- }
-
- // escape them
- int numBytes = x.length;
-
- int pad = 2;
-
- boolean needsIntroducer = checkForIntroducer
- && this.connection.versionMeetsMinimum(4, 1, 0);
-
- if (needsIntroducer) {
- pad += 7;
- }
-
- ByteArrayOutputStream bOut = new ByteArrayOutputStream(numBytes
- + pad);
-
- if (needsIntroducer) {
- bOut.write('_');
- bOut.write('b');
- bOut.write('i');
- bOut.write('n');
- bOut.write('a');
- bOut.write('r');
- bOut.write('y');
- }
- bOut.write('\'');
-
- for (int i = 0; i < numBytes; ++i) {
- byte b = x[i];
-
- switch (b) {
- case 0: /* Must be escaped for 'mysql' */
- bOut.write('\\');
- bOut.write('0');
-
- break;
-
- case '\n': /* Must be escaped for logs */
- bOut.write('\\');
- bOut.write('n');
-
- break;
-
- case '\r':
- bOut.write('\\');
- bOut.write('r');
-
- break;
-
- case '\\':
- bOut.write('\\');
- bOut.write('\\');
-
- break;
-
- case '\'':
- bOut.write('\\');
- bOut.write('\'');
-
- break;
-
- case '"': /* Better safe than sorry */
- bOut.write('\\');
- bOut.write('"');
-
- break;
-
- case '\032': /* This gives problems on Win32 */
- bOut.write('\\');
- bOut.write('Z');
-
- break;
-
- default:
- bOut.write(b);
- }
- }
-
- bOut.write('\'');
-
- setInternal(parameterIndex, bOut.toByteArray());
- }
- }
-
- /**
- * Used by updatable result sets for refreshRow() because the parameter has
- * already been escaped for updater or inserter prepared statements.
- *
- * @param parameterIndex
- * the parameter to set.
- * @param parameterAsBytes
- * the parameter as a string.
- *
- * @throws SQLException
- * if an error occurs
- */
- protected void setBytesNoEscape(int parameterIndex, byte[] parameterAsBytes)
- throws SQLException {
- byte[] parameterWithQuotes = new byte[parameterAsBytes.length + 2];
- parameterWithQuotes[0] = '\'';
- System.arraycopy(parameterAsBytes, 0, parameterWithQuotes, 1,
- parameterAsBytes.length);
- parameterWithQuotes[parameterAsBytes.length + 1] = '\'';
-
- setInternal(parameterIndex, parameterWithQuotes);
- }
-
- protected void setBytesNoEscapeNoQuotes(int parameterIndex,
- byte[] parameterAsBytes) throws SQLException {
- setInternal(parameterIndex, parameterAsBytes);
- }
-
- /**
- * JDBC 2.0 When a very large UNICODE value is input to a LONGVARCHAR
- * parameter, it may be more practical to send it via a java.io.Reader. JDBC
- * will read the data from the stream as needed, until it reaches
- * end-of-file. The JDBC driver will do any necessary conversion from
- * UNICODE to the database char format.
- *
- *
- * Note: This stream object can either be a standard Java stream
- * object or your own subclass that implements the standard interface.
- *
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param reader
- * the java reader which contains the UNICODE data
- * @param length
- * the number of characters in the stream
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public void setCharacterStream(int parameterIndex, java.io.Reader reader,
- int length) throws SQLException {
- try {
- if (reader == null) {
- setNull(parameterIndex, Types.LONGVARCHAR);
- } else {
- char[] c = null;
- int len = 0;
-
- boolean useLength = this.connection
- .getUseStreamLengthsInPrepStmts();
-
- String forcedEncoding = this.connection.getClobCharacterEncoding();
-
- if (useLength && (length != -1)) {
- c = new char[length];
-
- int numCharsRead = readFully(reader, c, length); // blocks
- // until
- // all
- // read
-
- if (forcedEncoding == null) {
- setString(parameterIndex, new String(c, 0, numCharsRead));
- } else {
- try {
- setBytes(parameterIndex, new String(c,
- 0,
- numCharsRead).getBytes(forcedEncoding));
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException("Unsupported character encoding " +
- forcedEncoding, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
- } else {
- c = new char[4096];
-
- StringBuffer buf = new StringBuffer();
-
- while ((len = reader.read(c)) != -1) {
- buf.append(c, 0, len);
- }
-
- if (forcedEncoding == null) {
- setString(parameterIndex, buf.toString());
- } else {
- try {
- setBytes(parameterIndex,
- buf.toString().getBytes(forcedEncoding));
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException("Unsupported character encoding " +
- forcedEncoding, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
- }
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.CLOB;
- }
- } catch (java.io.IOException ioEx) {
- throw SQLError.createSQLException(ioEx.toString(),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- /**
- * JDBC 2.0 Set a CLOB parameter.
- *
- * @param i
- * the first parameter is 1, the second is 2, ...
- * @param x
- * an object representing a CLOB
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void setClob(int i, Clob x) throws SQLException {
- if (x == null) {
- setNull(i, Types.CLOB);
- } else {
-
- String forcedEncoding = this.connection.getClobCharacterEncoding();
-
- if (forcedEncoding == null) {
- setString(i, x.getSubString(1L, (int) x.length()));
- } else {
- try {
- setBytes(i, x.getSubString(1L,
- (int)x.length()).getBytes(forcedEncoding));
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException("Unsupported character encoding " +
- forcedEncoding, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- this.parameterTypes[i - 1 + getParameterIndexOffset()] = Types.CLOB;
- }
- }
-
- /**
- * Set a parameter to a java.sql.Date value. The driver converts this to a
- * SQL DATE value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception java.sql.SQLException
- * if a database access error occurs
- */
- public void setDate(int parameterIndex, java.sql.Date x)
- throws java.sql.SQLException {
- setDate(parameterIndex, x, null);
- }
-
- /**
- * Set a parameter to a java.sql.Date value. The driver converts this to a
- * SQL DATE value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- * @param cal
- * the calendar to interpret the date with
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public void setDate(int parameterIndex, java.sql.Date x, Calendar cal)
- throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.DATE);
- } else {
- checkClosed();
-
- if (!this.useLegacyDatetimeCode) {
- newSetDateInternal(parameterIndex, x, cal);
- } else {
- // FIXME: Have instance version of this, problem as it's
- // not thread-safe :(
- SimpleDateFormat dateFormatter = new SimpleDateFormat(
- "''yyyy-MM-dd''", Locale.US); //$NON-NLS-1$
- setInternal(parameterIndex, dateFormatter.format(x));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DATE;
- }
- }
- }
-
- /**
- * Set a parameter to a Java double value. The driver converts this to a SQL
- * DOUBLE value when it sends it to the database
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setDouble(int parameterIndex, double x) throws SQLException {
-
- if (!this.connection.getAllowNanAndInf()
- && (x == Double.POSITIVE_INFINITY
- || x == Double.NEGATIVE_INFINITY || Double.isNaN(x))) {
- throw SQLError.createSQLException("'" + x
- + "' is not a valid numeric or approximate numeric value",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
-
- }
-
- setInternal(parameterIndex, StringUtils.fixDecimalExponent(String
- .valueOf(x)));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DOUBLE;
- }
-
- /**
- * Set a parameter to a Java float value. The driver converts this to a SQL
- * FLOAT value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setFloat(int parameterIndex, float x) throws SQLException {
- setInternal(parameterIndex, StringUtils.fixDecimalExponent(String
- .valueOf(x)));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.FLOAT;
- }
-
- /**
- * Set a parameter to a Java int value. The driver converts this to a SQL
- * INTEGER value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setInt(int parameterIndex, int x) throws SQLException {
- setInternal(parameterIndex, String.valueOf(x));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.INTEGER;
- }
-
- protected final void setInternal(int paramIndex, byte[] val)
- throws SQLException {
- if (this.isClosed) {
- throw SQLError.createSQLException(Messages.getString("PreparedStatement.48"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- int parameterIndexOffset = getParameterIndexOffset();
-
- checkBounds(paramIndex, parameterIndexOffset);
-
- this.isStream[paramIndex - 1 + parameterIndexOffset] = false;
- this.isNull[paramIndex - 1 + parameterIndexOffset] = false;
- this.parameterStreams[paramIndex - 1 + parameterIndexOffset] = null;
- this.parameterValues[paramIndex - 1 + parameterIndexOffset] = val;
- }
-
- private void checkBounds(int paramIndex, int parameterIndexOffset)
- throws SQLException {
- if ((paramIndex < 1)) {
- throw SQLError.createSQLException(
- Messages.getString("PreparedStatement.49") //$NON-NLS-1$
- + paramIndex
- + Messages.getString("PreparedStatement.50"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- } else if (paramIndex > this.parameterCount) {
- throw SQLError.createSQLException(
- Messages.getString("PreparedStatement.51") //$NON-NLS-1$
- + paramIndex
- + Messages.getString("PreparedStatement.52") + (this.parameterValues.length) + Messages.getString("PreparedStatement.53"), //$NON-NLS-1$ //$NON-NLS-2$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- } else if (parameterIndexOffset == -1 && paramIndex == 1) {
- throw SQLError.createSQLException("Can't set IN parameter for return value of stored function call.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- protected final void setInternal(int paramIndex, String val)
- throws SQLException {
- checkClosed();
-
- byte[] parameterAsBytes = null;
-
- if (this.charConverter != null) {
- parameterAsBytes = this.charConverter.toBytes(val);
- } else {
- parameterAsBytes = StringUtils.getBytes(val, this.charConverter,
- this.charEncoding, this.connection
- .getServerCharacterEncoding(), this.connection
- .parserKnowsUnicode(), getExceptionInterceptor());
- }
-
- setInternal(paramIndex, parameterAsBytes);
- }
-
- /**
- * Set a parameter to a Java long value. The driver converts this to a SQL
- * BIGINT value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setLong(int parameterIndex, long x) throws SQLException {
- setInternal(parameterIndex, String.valueOf(x));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.BIGINT;
- }
-
- /**
- * Set a parameter to SQL NULL
- *
- *
- * Note: You must specify the parameters SQL type (although MySQL
- * ignores it)
- *
- *
- * @param parameterIndex
- * the first parameter is 1, etc...
- * @param sqlType
- * the SQL type code defined in java.sql.Types
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setNull(int parameterIndex, int sqlType) throws SQLException {
- setInternal(parameterIndex, "null"); //$NON-NLS-1$
- this.isNull[parameterIndex - 1 + getParameterIndexOffset()] = true;
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.NULL;
- }
-
- /**
- * Set a parameter to SQL NULL.
- *
- *
- * Note: You must specify the parameter's SQL type.
- *
- * The given Java object will be converted to the targetSqlType before being
- * sent to the database.
- *
- *
- *
- * note that this method may be used to pass database-specific abstract data
- * types. This is done by using a Driver-specific Java type and using a
- * targetSqlType of java.sql.Types.OTHER
- *
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param parameterObj
- * the object containing the input parameter value
- * @param targetSqlType
- * The SQL type to be send to the database
- * @param scale
- * For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types
- * this is the number of digits after the decimal. For all other
- * types this value will be ignored.
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public void setObject(int parameterIndex, Object parameterObj,
- int targetSqlType, int scale) throws SQLException {
- if (parameterObj == null) {
- setNull(parameterIndex, java.sql.Types.OTHER);
- } else {
- try {
- switch (targetSqlType) {
- case Types.BOOLEAN:
- /*
- From Table-B5 in the JDBC-3.0 Spec
-
- T S I B R F D D N B B C V L
- I M N I E L O E U I O H A O
- N A T G A O U C M T O A R N
- Y L E I L A B I E L R C G
- I L G N T L M R E H V
- N I E T E A I A A A
- T N R L C N R R
- T C
- H
- A
- R
- -----------------------------------
- Boolean x x x x x x x x x x x x x x
- */
-
- if (parameterObj instanceof Boolean) {
- setBoolean(parameterIndex, ((Boolean)parameterObj).booleanValue());
-
- break;
- } else if (parameterObj instanceof String) {
- setBoolean(parameterIndex, "true".equalsIgnoreCase((String)parameterObj) ||
- !"0".equalsIgnoreCase((String)parameterObj));
-
- break;
- } else if (parameterObj instanceof Number) {
- int intValue = ((Number)parameterObj).intValue();
-
- setBoolean(parameterIndex, intValue != 0);
-
- break;
- } else {
- throw SQLError.createSQLException("No conversion from " + parameterObj.getClass().getName() +
- " to Types.BOOLEAN possible.", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
-
- case Types.BIT:
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.REAL:
- case Types.FLOAT:
- case Types.DOUBLE:
- case Types.DECIMAL:
- case Types.NUMERIC:
-
- setNumericObject(parameterIndex, parameterObj, targetSqlType, scale);
-
- break;
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- if (parameterObj instanceof BigDecimal) {
- setString(
- parameterIndex,
- (StringUtils
- .fixDecimalExponent(StringUtils
- .consistentToString((BigDecimal) parameterObj))));
- } else {
- setString(parameterIndex, parameterObj.toString());
- }
-
- break;
-
- case Types.CLOB:
-
- if (parameterObj instanceof java.sql.Clob) {
- setClob(parameterIndex, (java.sql.Clob) parameterObj);
- } else {
- setString(parameterIndex, parameterObj.toString());
- }
-
- break;
-
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.BLOB:
-
- if (parameterObj instanceof byte[]) {
- setBytes(parameterIndex, (byte[]) parameterObj);
- } else if (parameterObj instanceof java.sql.Blob) {
- setBlob(parameterIndex, (java.sql.Blob) parameterObj);
- } else {
- setBytes(parameterIndex, StringUtils.getBytes(
- parameterObj.toString(), this.charConverter,
- this.charEncoding, this.connection
- .getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), getExceptionInterceptor()));
- }
-
- break;
-
- case Types.DATE:
- case Types.TIMESTAMP:
-
- java.util.Date parameterAsDate;
-
- if (parameterObj instanceof String) {
- ParsePosition pp = new ParsePosition(0);
- java.text.DateFormat sdf = new java.text.SimpleDateFormat(
- getDateTimePattern((String) parameterObj, false), Locale.US);
- parameterAsDate = sdf.parse((String) parameterObj, pp);
- } else {
- parameterAsDate = (java.util.Date) parameterObj;
- }
-
- switch (targetSqlType) {
- case Types.DATE:
-
- if (parameterAsDate instanceof java.sql.Date) {
- setDate(parameterIndex,
- (java.sql.Date) parameterAsDate);
- } else {
- setDate(parameterIndex, new java.sql.Date(
- parameterAsDate.getTime()));
- }
-
- break;
-
- case Types.TIMESTAMP:
-
- if (parameterAsDate instanceof java.sql.Timestamp) {
- setTimestamp(parameterIndex,
- (java.sql.Timestamp) parameterAsDate);
- } else {
- setTimestamp(parameterIndex,
- new java.sql.Timestamp(parameterAsDate
- .getTime()));
- }
-
- break;
- }
-
- break;
-
- case Types.TIME:
-
- if (parameterObj instanceof String) {
- java.text.DateFormat sdf = new java.text.SimpleDateFormat(
- getDateTimePattern((String) parameterObj, true), Locale.US);
- setTime(parameterIndex, new java.sql.Time(sdf.parse(
- (String) parameterObj).getTime()));
- } else if (parameterObj instanceof Timestamp) {
- Timestamp xT = (Timestamp) parameterObj;
- setTime(parameterIndex, new java.sql.Time(xT.getTime()));
- } else {
- setTime(parameterIndex, (java.sql.Time) parameterObj);
- }
-
- break;
-
- case Types.OTHER:
- setSerializableObject(parameterIndex, parameterObj);
-
- break;
-
- default:
- throw SQLError.createSQLException(Messages
- .getString("PreparedStatement.16"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- } catch (Exception ex) {
- if (ex instanceof SQLException) {
- throw (SQLException) ex;
- }
-
- SQLException sqlEx = SQLError.createSQLException(
- Messages.getString("PreparedStatement.17") //$NON-NLS-1$
- + parameterObj.getClass().toString()
- + Messages.getString("PreparedStatement.18") //$NON-NLS-1$
- + ex.getClass().getName()
- + Messages.getString("PreparedStatement.19") + ex.getMessage(), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
-
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
- }
-
- protected int setOneBatchedParameterSet(
- java.sql.PreparedStatement batchedStatement, int batchedParamIndex,
- Object paramSet) throws SQLException {
- BatchParams paramArg = (BatchParams)paramSet;
-
- boolean[] isNullBatch = paramArg.isNull;
- boolean[] isStreamBatch = paramArg.isStream;
-
- for (int j = 0; j < isNullBatch.length; j++) {
- if (isNullBatch[j]) {
- batchedStatement.setNull(batchedParamIndex++, Types.NULL);
- } else {
- if (isStreamBatch[j]) {
- batchedStatement.setBinaryStream(batchedParamIndex++,
- paramArg.parameterStreams[j],
- paramArg.streamLengths[j]);
- } else {
- ((com.mysql.jdbc.PreparedStatement) batchedStatement)
- .setBytesNoEscapeNoQuotes(batchedParamIndex++,
- paramArg.parameterStrings[j]);
- }
- }
- }
-
- return batchedParamIndex;
- }
-
- /**
- * JDBC 2.0 Set a REF(<structured-type>) parameter.
- *
- * @param i
- * the first parameter is 1, the second is 2, ...
- * @param x
- * an object representing data of an SQL REF Type
- *
- * @throws SQLException
- * if a database error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- public void setRef(int i, Ref x) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * Sets the concurrency for result sets generated by this statement
- *
- * @param concurrencyFlag
- * DOCUMENT ME!
- */
- void setResultSetConcurrency(int concurrencyFlag) {
- this.resultSetConcurrency = concurrencyFlag;
- }
-
- /**
- * Sets the result set type for result sets generated by this statement
- *
- * @param typeFlag
- * DOCUMENT ME!
- */
- void setResultSetType(int typeFlag) {
- this.resultSetType = typeFlag;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param retrieveGeneratedKeys
- */
- protected void setRetrieveGeneratedKeys(boolean retrieveGeneratedKeys) {
- this.retrieveGeneratedKeys = retrieveGeneratedKeys;
- }
-
-
-
- /**
- * Sets the value for the placeholder as a serialized Java object (used by
- * various forms of setObject()
- *
- * @param parameterIndex
- * DOCUMENT ME!
- * @param parameterObj
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- private final void setSerializableObject(int parameterIndex,
- Object parameterObj) throws SQLException {
- try {
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- ObjectOutputStream objectOut = new ObjectOutputStream(bytesOut);
- objectOut.writeObject(parameterObj);
- objectOut.flush();
- objectOut.close();
- bytesOut.flush();
- bytesOut.close();
-
- byte[] buf = bytesOut.toByteArray();
- ByteArrayInputStream bytesIn = new ByteArrayInputStream(buf);
- setBinaryStream(parameterIndex, bytesIn, buf.length);
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.BINARY;
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(Messages.getString("PreparedStatement.54") //$NON-NLS-1$
- + ex.getClass().getName(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- /**
- * Set a parameter to a Java short value. The driver converts this to a SQL
- * SMALLINT value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setShort(int parameterIndex, short x) throws SQLException {
- setInternal(parameterIndex, String.valueOf(x));
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.SMALLINT;
- }
-
- /**
- * Set a parameter to a Java String value. The driver converts this to a SQL
- * VARCHAR or LONGVARCHAR value (depending on the arguments size relative to
- * the driver's limits on VARCHARs) when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setString(int parameterIndex, String x) throws SQLException {
- // if the passed string is null, then set this column to null
- if (x == null) {
- setNull(parameterIndex, Types.CHAR);
- } else {
- checkClosed();
-
- int stringLength = x.length();
-
- if (this.connection.isNoBackslashEscapesSet()) {
- // Scan for any nasty chars
-
- boolean needsHexEscape = isEscapeNeededForString(x,
- stringLength);
-
- if (!needsHexEscape) {
- byte[] parameterAsBytes = null;
-
- StringBuffer quotedString = new StringBuffer(x.length() + 2);
- quotedString.append('\'');
- quotedString.append(x);
- quotedString.append('\'');
-
- if (!this.isLoadDataQuery) {
- parameterAsBytes = StringUtils.getBytes(quotedString.toString(),
- this.charConverter, this.charEncoding,
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), getExceptionInterceptor());
- } else {
- // Send with platform character encoding
- parameterAsBytes = quotedString.toString().getBytes();
- }
-
- setInternal(parameterIndex, parameterAsBytes);
- } else {
- byte[] parameterAsBytes = null;
-
- if (!this.isLoadDataQuery) {
- parameterAsBytes = StringUtils.getBytes(x,
- this.charConverter, this.charEncoding,
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), getExceptionInterceptor());
- } else {
- // Send with platform character encoding
- parameterAsBytes = x.getBytes();
- }
-
- setBytes(parameterIndex, parameterAsBytes);
- }
-
- return;
- }
-
- String parameterAsString = x;
- boolean needsQuoted = true;
-
- if (this.isLoadDataQuery || isEscapeNeededForString(x, stringLength)) {
- needsQuoted = false; // saves an allocation later
-
- StringBuffer buf = new StringBuffer((int) (x.length() * 1.1));
-
- buf.append('\'');
-
- //
- // Note: buf.append(char) is _faster_ than
- // appending in blocks, because the block
- // append requires a System.arraycopy()....
- // go figure...
- //
-
- for (int i = 0; i < stringLength; ++i) {
- char c = x.charAt(i);
-
- switch (c) {
- case 0: /* Must be escaped for 'mysql' */
- buf.append('\\');
- buf.append('0');
-
- break;
-
- case '\n': /* Must be escaped for logs */
- buf.append('\\');
- buf.append('n');
-
- break;
-
- case '\r':
- buf.append('\\');
- buf.append('r');
-
- break;
-
- case '\\':
- buf.append('\\');
- buf.append('\\');
-
- break;
-
- case '\'':
- buf.append('\\');
- buf.append('\'');
-
- break;
-
- case '"': /* Better safe than sorry */
- if (this.usingAnsiMode) {
- buf.append('\\');
- }
-
- buf.append('"');
-
- break;
-
- case '\032': /* This gives problems on Win32 */
- buf.append('\\');
- buf.append('Z');
-
- break;
-
- case '\u00a5':
- case '\u20a9':
- // escape characters interpreted as backslash by mysql
- if(charsetEncoder != null) {
- CharBuffer cbuf = CharBuffer.allocate(1);
- ByteBuffer bbuf = ByteBuffer.allocate(1);
- cbuf.put(c);
- cbuf.position(0);
- charsetEncoder.encode(cbuf, bbuf, true);
- if(bbuf.get(0) == '\\') {
- buf.append('\\');
- }
- }
- // fall through
-
- default:
- buf.append(c);
- }
- }
-
- buf.append('\'');
-
- parameterAsString = buf.toString();
- }
-
- byte[] parameterAsBytes = null;
-
- if (!this.isLoadDataQuery) {
- if (needsQuoted) {
- parameterAsBytes = StringUtils.getBytesWrapped(parameterAsString,
- '\'', '\'', this.charConverter, this.charEncoding, this.connection
- .getServerCharacterEncoding(), this.connection
- .parserKnowsUnicode(), getExceptionInterceptor());
- } else {
- parameterAsBytes = StringUtils.getBytes(parameterAsString,
- this.charConverter, this.charEncoding, this.connection
- .getServerCharacterEncoding(), this.connection
- .parserKnowsUnicode(), getExceptionInterceptor());
- }
- } else {
- // Send with platform character encoding
- parameterAsBytes = parameterAsString.getBytes();
- }
-
- setInternal(parameterIndex, parameterAsBytes);
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.VARCHAR;
- }
- }
-
- private boolean isEscapeNeededForString(String x, int stringLength) {
- boolean needsHexEscape = false;
-
- for (int i = 0; i < stringLength; ++i) {
- char c = x.charAt(i);
-
- switch (c) {
- case 0: /* Must be escaped for 'mysql' */
-
- needsHexEscape = true;
- break;
-
- case '\n': /* Must be escaped for logs */
- needsHexEscape = true;
-
- break;
-
- case '\r':
- needsHexEscape = true;
- break;
-
- case '\\':
- needsHexEscape = true;
-
- break;
-
- case '\'':
- needsHexEscape = true;
-
- break;
-
- case '"': /* Better safe than sorry */
- needsHexEscape = true;
-
- break;
-
- case '\032': /* This gives problems on Win32 */
- needsHexEscape = true;
- break;
- }
-
- if (needsHexEscape) {
- break; // no need to scan more
- }
- }
- return needsHexEscape;
- }
-
- /**
- * Set a parameter to a java.sql.Time value. The driver converts this to a
- * SQL TIME value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- * @param cal
- * the cal specifying the timezone
- *
- * @throws SQLException
- * if a database-access error occurs.
- */
- public void setTime(int parameterIndex, java.sql.Time x, Calendar cal)
- throws SQLException {
- setTimeInternal(parameterIndex, x, cal, cal.getTimeZone(), true);
- }
-
- /**
- * Set a parameter to a java.sql.Time value. The driver converts this to a
- * SQL TIME value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...));
- * @param x
- * the parameter value
- *
- * @throws java.sql.SQLException
- * if a database access error occurs
- */
- public void setTime(int parameterIndex, Time x)
- throws java.sql.SQLException {
- setTimeInternal(parameterIndex, x, null, Util.getDefaultTimeZone(), false);
- }
-
- /**
- * Set a parameter to a java.sql.Time value. The driver converts this to a
- * SQL TIME value when it sends it to the database, using the given
- * timezone.
- *
- * @param parameterIndex
- * the first parameter is 1...));
- * @param x
- * the parameter value
- * @param tz
- * the timezone to use
- *
- * @throws java.sql.SQLException
- * if a database access error occurs
- */
- private void setTimeInternal(int parameterIndex, Time x, Calendar targetCalendar,
- TimeZone tz,
- boolean rollForward) throws java.sql.SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.TIME);
- } else {
- checkClosed();
-
- if (!this.useLegacyDatetimeCode) {
- newSetTimeInternal(parameterIndex, x, targetCalendar);
- } else {
- Calendar sessionCalendar = getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- x = TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- x, tz, this.connection
- .getServerTimezoneTZ(), rollForward);
- }
-
- setInternal(parameterIndex, "'" + x.toString() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.TIME;
- }
- }
-
- /**
- * Set a parameter to a java.sql.Timestamp value. The driver converts this
- * to a SQL TIMESTAMP value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- * @param cal
- * the calendar specifying the timezone to use
- *
- * @throws SQLException
- * if a database-access error occurs.
- */
- public void setTimestamp(int parameterIndex, java.sql.Timestamp x,
- Calendar cal) throws SQLException {
- setTimestampInternal(parameterIndex, x, cal, cal.getTimeZone(), true);
- }
-
- /**
- * Set a parameter to a java.sql.Timestamp value. The driver converts this
- * to a SQL TIMESTAMP value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @throws java.sql.SQLException
- * if a database access error occurs
- */
- public void setTimestamp(int parameterIndex, Timestamp x)
- throws java.sql.SQLException {
- setTimestampInternal(parameterIndex, x, null, Util.getDefaultTimeZone(), false);
- }
-
- /**
- * Set a parameter to a java.sql.Timestamp value. The driver converts this
- * to a SQL TIMESTAMP value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- * @param tz
- * the timezone to use
- *
- * @throws SQLException
- * if a database-access error occurs.
- */
- private void setTimestampInternal(int parameterIndex,
- Timestamp x, Calendar targetCalendar,
- TimeZone tz, boolean rollForward) throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.TIMESTAMP);
- } else {
- checkClosed();
-
- if (!this.useLegacyDatetimeCode) {
- newSetTimestampInternal(parameterIndex, x, targetCalendar);
- } else {
- String timestampString = null;
-
- Calendar sessionCalendar = this.connection.getUseJDBCCompliantTimezoneShift() ?
- this.connection.getUtcCalendar() :
- getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- x = TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- x, tz, this.connection
- .getServerTimezoneTZ(), rollForward);
- }
-
- if (this.connection.getUseSSPSCompatibleTimezoneShift()) {
- doSSPSCompatibleTimezoneShift(parameterIndex, x, sessionCalendar);
- } else {
- synchronized (this) {
- if (this.tsdf == null) {
- this.tsdf = new SimpleDateFormat("''yyyy-MM-dd HH:mm:ss", Locale.US); //$NON-NLS-1$
- }
-
- timestampString = this.tsdf.format(x);
- StringBuffer buf = new StringBuffer();
- buf.append(timestampString);
- buf.append('.');
- buf.append(formatNanos(x.getNanos()));
- buf.append('\'');
-
- setInternal(parameterIndex, buf.toString()); // SimpleDateFormat is not
- // thread-safe
- }
- }
- }
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.TIMESTAMP;
- }
- }
-
- private synchronized void newSetTimestampInternal(int parameterIndex,
- Timestamp x, Calendar targetCalendar) throws SQLException {
- if (this.tsdf == null) {
- this.tsdf = new SimpleDateFormat("''yyyy-MM-dd HH:mm:ss", Locale.US); //$NON-NLS-1$
- }
-
- String timestampString = null;
-
- if (targetCalendar != null) {
- targetCalendar.setTime(x);
- this.tsdf.setTimeZone(targetCalendar.getTimeZone());
-
- timestampString = this.tsdf.format(x);
- } else {
- this.tsdf.setTimeZone(this.connection.getServerTimezoneTZ());
- timestampString = this.tsdf.format(x);
- }
-
- StringBuffer buf = new StringBuffer();
- buf.append(timestampString);
- buf.append('.');
- buf.append(formatNanos(x.getNanos()));
- buf.append('\'');
-
- setInternal(parameterIndex, buf.toString());
- }
-
- private String formatNanos(int nanos) {
- if (true /* for now */ || nanos == 0) {
- return "0";
- }
-
- boolean usingMicros = true;
-
- if (usingMicros) {
- nanos /= 1000;
- }
-
- final int digitCount = usingMicros ? 6 : 9;
-
- String nanosString = Integer.toString(nanos);
- final String zeroPadding = usingMicros ? "000000" : "000000000";
-
- nanosString = zeroPadding.substring(0, (digitCount-nanosString.length())) +
- nanosString;
-
- int pos = digitCount; // the end, we're padded to the end by the code above
-
- while (nanosString.charAt(pos) == '0') {
- pos--;
- }
-
- nanosString = nanosString.substring(0, pos + 1);
-
- return nanosString;
- }
-
- private synchronized void newSetTimeInternal(int parameterIndex,
- Time x, Calendar targetCalendar) throws SQLException {
- if (this.tdf == null) {
- this.tdf = new SimpleDateFormat("''HH:mm:ss''", Locale.US); //$NON-NLS-1$
-
- }
-
- String timeString = null;
-
- if (targetCalendar != null) {
- targetCalendar.setTime(x);
- this.tdf.setTimeZone(targetCalendar.getTimeZone());
-
- timeString = this.tdf.format(x);
- } else {
- this.tdf.setTimeZone(this.connection.getServerTimezoneTZ());
- timeString = this.tdf.format(x);
- }
-
- setInternal(parameterIndex, timeString);
- }
-
- private synchronized void newSetDateInternal(int parameterIndex,
- Date x, Calendar targetCalendar) throws SQLException {
- if (this.ddf == null) {
- this.ddf = new SimpleDateFormat("''yyyy-MM-dd''", Locale.US); //$NON-NLS-1$
-
- }
-
- String timeString = null;
-
- if (targetCalendar != null) {
- targetCalendar.setTime(x);
- this.ddf.setTimeZone(targetCalendar.getTimeZone());
-
- timeString = this.ddf.format(x);
- } else {
- this.ddf.setTimeZone(this.connection.getServerTimezoneTZ());
- timeString = this.ddf.format(x);
- }
-
- setInternal(parameterIndex, timeString);
- }
-
- private void doSSPSCompatibleTimezoneShift(int parameterIndex, Timestamp x, Calendar sessionCalendar) throws SQLException {
- Calendar sessionCalendar2 = (this.connection
- .getUseJDBCCompliantTimezoneShift()) ? this.connection
- .getUtcCalendar()
- : getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar2) {
- java.util.Date oldTime = sessionCalendar2.getTime();
-
- try {
- sessionCalendar2.setTime(x);
-
- int year = sessionCalendar2.get(Calendar.YEAR);
- int month = sessionCalendar2.get(Calendar.MONTH) + 1;
- int date = sessionCalendar2.get(Calendar.DAY_OF_MONTH);
-
- int hour = sessionCalendar2.get(Calendar.HOUR_OF_DAY);
- int minute = sessionCalendar2.get(Calendar.MINUTE);
- int seconds = sessionCalendar2.get(Calendar.SECOND);
-
- StringBuffer tsBuf = new StringBuffer();
-
- tsBuf.append('\'');
- tsBuf.append(year);
-
- tsBuf.append("-");
-
- if (month < 10) {
- tsBuf.append('0');
- }
-
- tsBuf.append(month);
-
- tsBuf.append('-');
-
- if (date < 10) {
- tsBuf.append('0');
- }
-
- tsBuf.append(date);
-
- tsBuf.append(' ');
-
- if (hour < 10) {
- tsBuf.append('0');
- }
-
- tsBuf.append(hour);
-
- tsBuf.append(':');
-
- if (minute < 10) {
- tsBuf.append('0');
- }
-
- tsBuf.append(minute);
-
- tsBuf.append(':');
-
- if (seconds < 10) {
- tsBuf.append('0');
- }
-
- tsBuf.append(seconds);
-
- tsBuf.append('.');
- tsBuf.append(formatNanos(x.getNanos()));
- tsBuf.append('\'');
-
- setInternal(parameterIndex, tsBuf.toString());
-
- } finally {
- sessionCalendar.setTime(oldTime);
- }
- }
- }
-
- /**
- * When a very large Unicode value is input to a LONGVARCHAR parameter, it
- * may be more practical to send it via a java.io.InputStream. JDBC will
- * read the data from the stream as needed, until it reaches end-of-file.
- * The JDBC driver will do any necessary conversion from UNICODE to the
- * database char format.
- *
- *
- * Note: This stream object can either be a standard Java stream
- * object or your own subclass that implements the standard interface.
- *
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- * @param length
- * the number of bytes to read from the stream
- *
- * @throws SQLException
- * if a database access error occurs
- *
- * @deprecated
- */
- public void setUnicodeStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.VARCHAR);
- } else {
- setBinaryStream(parameterIndex, x, length);
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.CLOB;
- }
- }
-
- /**
- * @see PreparedStatement#setURL(int, URL)
- */
- public void setURL(int parameterIndex, URL arg) throws SQLException {
- if (arg != null) {
- setString(parameterIndex, arg.toString());
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DATALINK;
- } else {
- setNull(parameterIndex, Types.CHAR);
- }
- }
-
- private final void streamToBytes(Buffer packet, InputStream in,
- boolean escape, int streamLength, boolean useLength)
- throws SQLException {
- try {
- String connectionEncoding = this.connection.getEncoding();
-
- boolean hexEscape = false;
-
- if (this.connection.isNoBackslashEscapesSet()
- || (this.connection.getUseUnicode()
- && connectionEncoding != null
- && CharsetMapping.isMultibyteCharset(connectionEncoding)
- && !this.connection.parserKnowsUnicode())) {
- hexEscape = true;
- }
-
- if (streamLength == -1) {
- useLength = false;
- }
-
- int bc = -1;
-
- if (useLength) {
- bc = readblock(in, streamConvertBuf, streamLength);
- } else {
- bc = readblock(in, streamConvertBuf);
- }
-
- int lengthLeftToRead = streamLength - bc;
-
- if (hexEscape) {
- packet.writeStringNoNull("x");
- } else if (this.connection.getIO().versionMeetsMinimum(4, 1, 0)) {
- packet.writeStringNoNull("_binary");
- }
-
- if (escape) {
- packet.writeByte((byte) '\'');
- }
-
- while (bc > 0) {
- if (hexEscape) {
- hexEscapeBlock(streamConvertBuf, packet, bc);
- } else if (escape) {
- escapeblockFast(streamConvertBuf, packet, bc);
- } else {
- packet.writeBytesNoNull(streamConvertBuf, 0, bc);
- }
-
- if (useLength) {
- bc = readblock(in, streamConvertBuf, lengthLeftToRead);
-
- if (bc > 0) {
- lengthLeftToRead -= bc;
- }
- } else {
- bc = readblock(in, streamConvertBuf);
- }
- }
-
- if (escape) {
- packet.writeByte((byte) '\'');
- }
- } finally {
- if (this.connection.getAutoClosePStmtStreams()) {
- try {
- in.close();
- } catch (IOException ioEx) {
- ;
- }
-
- in = null;
- }
- }
- }
-
- private final byte[] streamToBytes(InputStream in, boolean escape,
- int streamLength, boolean useLength) throws SQLException {
- try {
- if (streamLength == -1) {
- useLength = false;
- }
-
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
-
- int bc = -1;
-
- if (useLength) {
- bc = readblock(in, this.streamConvertBuf, streamLength);
- } else {
- bc = readblock(in, this.streamConvertBuf);
- }
-
- int lengthLeftToRead = streamLength - bc;
-
- if (escape) {
- if (this.connection.versionMeetsMinimum(4, 1, 0)) {
- bytesOut.write('_');
- bytesOut.write('b');
- bytesOut.write('i');
- bytesOut.write('n');
- bytesOut.write('a');
- bytesOut.write('r');
- bytesOut.write('y');
- }
-
- bytesOut.write('\'');
- }
-
- while (bc > 0) {
- if (escape) {
- escapeblockFast(this.streamConvertBuf, bytesOut, bc);
- } else {
- bytesOut.write(this.streamConvertBuf, 0, bc);
- }
-
- if (useLength) {
- bc = readblock(in, this.streamConvertBuf, lengthLeftToRead);
-
- if (bc > 0) {
- lengthLeftToRead -= bc;
- }
- } else {
- bc = readblock(in, this.streamConvertBuf);
- }
- }
-
- if (escape) {
- bytesOut.write('\'');
- }
-
- return bytesOut.toByteArray();
- } finally {
- if (this.connection.getAutoClosePStmtStreams()) {
- try {
- in.close();
- } catch (IOException ioEx) {
- ;
- }
-
- in = null;
- }
- }
- }
-
- /**
- * Returns this PreparedStatement represented as a string.
- *
- * @return this PreparedStatement represented as a string.
- */
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append(super.toString());
- buf.append(": "); //$NON-NLS-1$
-
- try {
- buf.append(asSql());
- } catch (SQLException sqlEx) {
- buf.append("EXCEPTION: " + sqlEx.toString());
- }
-
- return buf.toString();
- }
-
-
-
- public synchronized boolean isClosed() throws SQLException {
- return this.isClosed;
- }
-
- /**
- * For calling stored functions, this will be -1 as we don't really count
- * the first '?' parameter marker, it's only syntax, but JDBC counts it
- * as #1, otherwise it will return 0
- *
- */
-
- protected int getParameterIndexOffset() {
- return 0;
- }
-
- public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
- setAsciiStream(parameterIndex, x, -1);
- }
-
- public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
- setAsciiStream(parameterIndex, x, (int)length);
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.CLOB;
- }
-
- public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
- setBinaryStream(parameterIndex, x, -1);
- }
-
- public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
- setBinaryStream(parameterIndex, x, (int)length);
- }
-
- public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
- setBinaryStream(parameterIndex, inputStream);
- }
-
- public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
- setCharacterStream(parameterIndex, reader, -1);
- }
-
- public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
- setCharacterStream(parameterIndex, reader, (int)length);
-
- }
-
- public void setClob(int parameterIndex, Reader reader) throws SQLException {
- setCharacterStream(parameterIndex, reader);
-
- }
-
- public void setClob(int parameterIndex, Reader reader, long length)
- throws SQLException {
- setCharacterStream(parameterIndex, reader, length);
- }
-
- public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
- setNCharacterStream(parameterIndex, value, -1);
- }
-
- /**
- * Set a parameter to a Java String value. The driver converts this to a SQL
- * VARCHAR or LONGVARCHAR value with introducer _utf8 (depending on the
- * arguments size relative to the driver's limits on VARCHARs) when it sends
- * it to the database. If charset is set as utf8, this method just call setString.
- *
- * @param parameterIndex
- * the first parameter is 1...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setNString(int parameterIndex, String x) throws SQLException {
- if (this.charEncoding.equalsIgnoreCase("UTF-8")
- || this.charEncoding.equalsIgnoreCase("utf8")) {
- setString(parameterIndex, x);
- return;
- }
-
- // if the passed string is null, then set this column to null
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.CHAR);
- } else {
- int stringLength = x.length();
- // Ignore sql_mode=NO_BACKSLASH_ESCAPES in current implementation.
-
- // Add introducer _utf8 for NATIONAL CHARACTER
- StringBuffer buf = new StringBuffer((int) (x.length() * 1.1 + 4));
- buf.append("_utf8");
- buf.append('\'');
-
- //
- // Note: buf.append(char) is _faster_ than
- // appending in blocks, because the block
- // append requires a System.arraycopy()....
- // go figure...
- //
-
- for (int i = 0; i < stringLength; ++i) {
- char c = x.charAt(i);
-
- switch (c) {
- case 0: /* Must be escaped for 'mysql' */
- buf.append('\\');
- buf.append('0');
-
- break;
-
- case '\n': /* Must be escaped for logs */
- buf.append('\\');
- buf.append('n');
-
- break;
-
- case '\r':
- buf.append('\\');
- buf.append('r');
-
- break;
-
- case '\\':
- buf.append('\\');
- buf.append('\\');
-
- break;
-
- case '\'':
- buf.append('\\');
- buf.append('\'');
-
- break;
-
- case '"': /* Better safe than sorry */
- if (this.usingAnsiMode) {
- buf.append('\\');
- }
-
- buf.append('"');
-
- break;
-
- case '\032': /* This gives problems on Win32 */
- buf.append('\\');
- buf.append('Z');
-
- break;
-
- default:
- buf.append(c);
- }
- }
-
- buf.append('\'');
-
- String parameterAsString = buf.toString();
-
- byte[] parameterAsBytes = null;
-
- if (!this.isLoadDataQuery) {
- parameterAsBytes = StringUtils.getBytes(parameterAsString,
- this.connection.getCharsetConverter("UTF-8"), "UTF-8",
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), getExceptionInterceptor());
- } else {
- // Send with platform character encoding
- parameterAsBytes = parameterAsString.getBytes();
- }
-
- setInternal(parameterIndex, parameterAsBytes);
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = -9; /* Types.NVARCHAR */
- }
- }
-
- /**
- * JDBC 2.0 When a very large UNICODE value is input to a LONGVARCHAR
- * parameter, it may be more practical to send it via a java.io.Reader. JDBC
- * will read the data from the stream as needed, until it reaches
- * end-of-file. The JDBC driver will do any necessary conversion from
- * UNICODE to the database char format.
- *
- *
- * Note: This stream object can either be a standard Java stream
- * object or your own subclass that implements the standard interface.
- *
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param reader
- * the java reader which contains the UNICODE data
- * @param length
- * the number of characters in the stream
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public void setNCharacterStream(int parameterIndex, Reader reader,
- long length) throws SQLException {
- try {
- if (reader == null) {
- setNull(parameterIndex, java.sql.Types.LONGVARCHAR);
-
- } else {
- char[] c = null;
- int len = 0;
-
- boolean useLength = this.connection
- .getUseStreamLengthsInPrepStmts();
-
- // Ignore "clobCharacterEncoding" because utf8 should be used this time.
-
- if (useLength && (length != -1)) {
- c = new char[(int) length]; // can't take more than Integer.MAX_VALUE
-
- int numCharsRead = readFully(reader, c, (int) length); // blocks
- // until
- // all
- // read
- setNString(parameterIndex, new String(c, 0, numCharsRead));
-
- } else {
- c = new char[4096];
-
- StringBuffer buf = new StringBuffer();
-
- while ((len = reader.read(c)) != -1) {
- buf.append(c, 0, len);
- }
-
- setNString(parameterIndex, buf.toString());
- }
-
- this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = 2011; /* Types.NCLOB */
- }
- } catch (java.io.IOException ioEx) {
- throw SQLError.createSQLException(ioEx.toString(),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- public void setNClob(int parameterIndex, Reader reader) throws SQLException {
- setNCharacterStream(parameterIndex, reader);
- }
-
- /**
- * JDBC 4.0 Set a NCLOB parameter.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param reader
- * the java reader which contains the UNICODE data
- * @param length
- * the number of characters in the stream
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void setNClob(int parameterIndex, Reader reader, long length)
- throws SQLException {
- if (reader == null) {
- setNull(parameterIndex, java.sql.Types.LONGVARCHAR);
- } else {
- setNCharacterStream(parameterIndex, reader, length);
- }
- }
-
- public ParameterBindings getParameterBindings() throws SQLException {
- return new EmulatedPreparedStatementBindings();
- }
-
- class EmulatedPreparedStatementBindings implements ParameterBindings {
-
- private ResultSetImpl bindingsAsRs;
- private boolean[] parameterIsNull;
-
- public EmulatedPreparedStatementBindings() throws SQLException {
- List rows = new ArrayList();
- parameterIsNull = new boolean[parameterCount];
- System
- .arraycopy(isNull, 0, this.parameterIsNull, 0,
- parameterCount);
- byte[][] rowData = new byte[parameterCount][];
- Field[] typeMetadata = new Field[parameterCount];
-
- for (int i = 0; i < parameterCount; i++) {
- if (batchCommandIndex == -1)
- rowData[i] = getBytesRepresentation(i);
- else
- rowData[i] = getBytesRepresentationForBatch(i, batchCommandIndex);
-
- int charsetIndex = 0;
-
- if (parameterTypes[i] == Types.BINARY
- || parameterTypes[i] == Types.BLOB) {
- charsetIndex = 63;
- } else {
- String mysqlEncodingName = CharsetMapping
- .getMysqlEncodingForJavaEncoding(connection
- .getEncoding(), connection);
- charsetIndex = CharsetMapping
- .getCharsetIndexForMysqlEncodingName(mysqlEncodingName);
- }
-
- Field parameterMetadata = new Field(null, "parameter_"
- + (i + 1), charsetIndex, parameterTypes[i],
- rowData[i].length);
- parameterMetadata.setConnection(connection);
- typeMetadata[i] = parameterMetadata;
- }
-
- rows.add(new ByteArrayRow(rowData, getExceptionInterceptor()));
-
- this.bindingsAsRs = new ResultSetImpl(connection.getCatalog(),
- typeMetadata, new RowDataStatic(rows), connection, null);
- this.bindingsAsRs.next();
- }
-
- public Array getArray(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getArray(parameterIndex);
- }
-
- public InputStream getAsciiStream(int parameterIndex)
- throws SQLException {
- return this.bindingsAsRs.getAsciiStream(parameterIndex);
- }
-
- public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getBigDecimal(parameterIndex);
- }
-
- public InputStream getBinaryStream(int parameterIndex)
- throws SQLException {
- return this.bindingsAsRs.getBinaryStream(parameterIndex);
- }
-
- public java.sql.Blob getBlob(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getBlob(parameterIndex);
- }
-
- public boolean getBoolean(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getBoolean(parameterIndex);
- }
-
- public byte getByte(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getByte(parameterIndex);
- }
-
- public byte[] getBytes(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getBytes(parameterIndex);
- }
-
- public Reader getCharacterStream(int parameterIndex)
- throws SQLException {
- return this.bindingsAsRs.getCharacterStream(parameterIndex);
- }
-
- public java.sql.Clob getClob(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getClob(parameterIndex);
- }
-
- public Date getDate(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getDate(parameterIndex);
- }
-
- public double getDouble(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getDouble(parameterIndex);
- }
-
- public float getFloat(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getFloat(parameterIndex);
- }
-
- public int getInt(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getInt(parameterIndex);
- }
-
- public long getLong(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getLong(parameterIndex);
- }
-
- public Reader getNCharacterStream(int parameterIndex)
- throws SQLException {
- return this.bindingsAsRs.getCharacterStream(parameterIndex);
- }
-
- public Reader getNClob(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getCharacterStream(parameterIndex);
- }
-
- public Object getObject(int parameterIndex) throws SQLException {
- checkBounds(parameterIndex, 0);
-
- if (parameterIsNull[parameterIndex - 1]) {
- return null;
- }
-
- // we can't rely on the default mapping for JDBC's
- // ResultSet.getObject() for numerics, they're not one-to-one with
- // PreparedStatement.setObject
-
- switch (parameterTypes[parameterIndex - 1]) {
- case Types.TINYINT:
- return new Byte(getByte(parameterIndex));
- case Types.SMALLINT:
- return new Short(getShort(parameterIndex));
- case Types.INTEGER:
- return new Integer(getInt(parameterIndex));
- case Types.BIGINT:
- return new Long(getLong(parameterIndex));
- case Types.FLOAT:
- return new Float(getFloat(parameterIndex));
- case Types.DOUBLE:
- return new Double(getDouble(parameterIndex));
- default:
- return this.bindingsAsRs.getObject(parameterIndex);
- }
- }
-
- public Ref getRef(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getRef(parameterIndex);
- }
-
- public short getShort(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getShort(parameterIndex);
- }
-
- public String getString(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getString(parameterIndex);
- }
-
- public Time getTime(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getTime(parameterIndex);
- }
-
- public Timestamp getTimestamp(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getTimestamp(parameterIndex);
- }
-
- public URL getURL(int parameterIndex) throws SQLException {
- return this.bindingsAsRs.getURL(parameterIndex);
- }
-
- public boolean isNull(int parameterIndex) throws SQLException {
- checkBounds(parameterIndex, 0);
-
- return this.parameterIsNull[parameterIndex -1];
- }
- }
-
- public String getPreparedSql() {
- return this.originalSql;
- }
-
- public int getUpdateCount() throws SQLException {
- int count = super.getUpdateCount();
-
- if (containsOnDuplicateKeyUpdateInSQL() &&
- this.compensateForOnDuplicateKeyUpdate) {
- if (count == 2 || count == 0) {
- count = 1;
- }
- }
-
- return count;
- }
-
- protected static boolean canRewrite(String sql, boolean isOnDuplicateKeyUpdate, int locationOfOnDuplicateKeyUpdate, int statementStartPos) {
- // Needs to be INSERT, can't have INSERT ... SELECT or
- // INSERT ... ON DUPLICATE KEY UPDATE with an id=LAST_INSERT_ID(...)
-
- boolean rewritableOdku = true;
-
- if (isOnDuplicateKeyUpdate) {
- int updateClausePos = StringUtils.indexOfIgnoreCase(
- locationOfOnDuplicateKeyUpdate, sql, " UPDATE ");
-
- if (updateClausePos != -1) {
- rewritableOdku = StringUtils
- .indexOfIgnoreCaseRespectMarker(updateClausePos,
- sql, "LAST_INSERT_ID", "\"'`", "\"'`",
- false) == -1;
- }
- }
-
- return StringUtils
- .startsWithIgnoreCaseAndWs(sql, "INSERT",
- statementStartPos)
- && StringUtils.indexOfIgnoreCaseRespectMarker(
- statementStartPos, sql, "SELECT", "\"'`",
- "\"'`", false) == -1 && rewritableOdku;
- }
-}
diff --git a/src/com/mysql/jdbc/RandomBalanceStrategy.java b/src/com/mysql/jdbc/RandomBalanceStrategy.java
deleted file mode 100644
index 3e20c8681..000000000
--- a/src/com/mysql/jdbc/RandomBalanceStrategy.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-public class RandomBalanceStrategy implements BalanceStrategy {
-
- public RandomBalanceStrategy() {
- }
-
- public void destroy() {
- // we don't have anything to clean up
- }
-
- public void init(Connection conn, Properties props) throws SQLException {
- // we don't have anything to initialize
- }
-
- public Connection pickConnection(LoadBalancingConnectionProxy proxy,
- List configuredHosts, Map liveConnections, long[] responseTimes,
- int numRetries) throws SQLException {
- int numHosts = configuredHosts.size();
-
- SQLException ex = null;
-
- List whiteList = new ArrayList(numHosts);
- whiteList.addAll(configuredHosts);
-
- Map blackList = proxy.getGlobalBlacklist();
-
- whiteList.removeAll(blackList.keySet());
-
- Map whiteListMap = this.getArrayIndexMap(whiteList);
-
-
- for (int attempts = 0; attempts < numRetries;) {
- int random = (int) Math.floor((Math.random() * whiteList.size()));
-
- String hostPortSpec = (String) whiteList.get(random);
-
- Connection conn = (Connection) liveConnections.get(hostPortSpec);
-
- if (conn == null) {
- try {
- conn = proxy.createConnectionForHost(hostPortSpec);
- } catch (SQLException sqlEx) {
- ex = sqlEx;
-
- if (sqlEx instanceof CommunicationsException
- || "08S01".equals(sqlEx.getSQLState())) {
-
- Integer whiteListIndex = (Integer) whiteListMap
- .get(hostPortSpec);
-
- // exclude this host from being picked again
- if (whiteListIndex != null) {
- whiteList.remove(whiteListIndex.intValue());
- whiteListMap = this.getArrayIndexMap(whiteList);
- }
- proxy.addToGlobalBlacklist( hostPortSpec );
-
- if (whiteList.size() == 0) {
- attempts++;
- try {
- Thread.sleep(250);
- } catch (InterruptedException e) {
- }
-
- // start fresh
- whiteListMap = new HashMap(numHosts);
- whiteList.addAll(configuredHosts);
- blackList = proxy.getGlobalBlacklist();
-
- whiteList.removeAll(blackList.keySet());
- whiteListMap = this.getArrayIndexMap(whiteList);
- }
-
- continue;
- } else {
- throw sqlEx;
- }
- }
- }
-
- return conn;
- }
-
- if (ex != null) {
- throw ex;
- }
-
- return null; // we won't get here, compiler can't tell
- }
-
- private Map getArrayIndexMap(List l) {
- Map m = new HashMap(l.size());
- for (int i = 0; i < l.size(); i++) {
- m.put(l.get(i), new Integer(i));
- }
- return m;
-
- }
-
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/ReplicationConnection.java b/src/com/mysql/jdbc/ReplicationConnection.java
deleted file mode 100644
index 0ec1ca13c..000000000
--- a/src/com/mysql/jdbc/ReplicationConnection.java
+++ /dev/null
@@ -1,2415 +0,0 @@
-/*
- Copyright 2004-2007 MySQL AB, 2008-2009 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package com.mysql.jdbc;
-
-import java.sql.CallableStatement;
-import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TimeZone;
-
-import com.mysql.jdbc.log.Log;
-
-/**
- * Connection that opens two connections, one two a replication master, and
- * another to one or more slaves, and decides to use master when the connection
- * is not read-only, and use slave(s) when the connection is read-only.
- *
- * @version $Id: ReplicationConnection.java,v 1.1.2.1 2005/05/13 18:58:38
- * mmatthews Exp $
- */
-public class ReplicationConnection implements Connection, PingTarget {
- protected Connection currentConnection;
-
- protected Connection masterConnection;
-
- protected Connection slavesConnection;
-
- protected ReplicationConnection() {}
-
- public ReplicationConnection(Properties masterProperties,
- Properties slaveProperties) throws SQLException {
- NonRegisteringDriver driver = new NonRegisteringDriver();
-
- StringBuffer masterUrl = new StringBuffer("jdbc:mysql://");
- StringBuffer slaveUrl = new StringBuffer("jdbc:mysql://");
-
- String masterHost = masterProperties
- .getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
-
- if (masterHost != null) {
- masterUrl.append(masterHost);
- }
-
- String slaveHost = slaveProperties
- .getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
-
- if (slaveHost != null) {
- slaveUrl.append(slaveHost);
- }
-
- String masterDb = masterProperties
- .getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
-
- masterUrl.append("/");
-
- if (masterDb != null) {
- masterUrl.append(masterDb);
- }
-
- String slaveDb = slaveProperties
- .getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
-
- slaveUrl.append("/");
-
- if (slaveDb != null) {
- slaveUrl.append(slaveDb);
- }
-
- slaveProperties.setProperty("roundRobinLoadBalance", "true");
-
- this.masterConnection = (com.mysql.jdbc.Connection) driver.connect(
- masterUrl.toString(), masterProperties);
- this.slavesConnection = (com.mysql.jdbc.Connection) driver.connect(
- slaveUrl.toString(), slaveProperties);
- this.slavesConnection.setReadOnly(true);
-
- this.currentConnection = this.masterConnection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#clearWarnings()
- */
- public synchronized void clearWarnings() throws SQLException {
- this.currentConnection.clearWarnings();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#close()
- */
- public synchronized void close() throws SQLException {
- this.masterConnection.close();
- this.slavesConnection.close();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#commit()
- */
- public synchronized void commit() throws SQLException {
- this.currentConnection.commit();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#createStatement()
- */
- public Statement createStatement() throws SQLException {
- Statement stmt = this.currentConnection.createStatement();
- ((com.mysql.jdbc.Statement) stmt).setPingTarget(this);
-
- return stmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#createStatement(int, int)
- */
- public synchronized Statement createStatement(int resultSetType,
- int resultSetConcurrency) throws SQLException {
- Statement stmt = this.currentConnection.createStatement(resultSetType,
- resultSetConcurrency);
-
- ((com.mysql.jdbc.Statement) stmt).setPingTarget(this);
-
- return stmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#createStatement(int, int, int)
- */
- public synchronized Statement createStatement(int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- throws SQLException {
- Statement stmt = this.currentConnection.createStatement(resultSetType,
- resultSetConcurrency, resultSetHoldability);
-
- ((com.mysql.jdbc.Statement) stmt).setPingTarget(this);
-
- return stmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#getAutoCommit()
- */
- public synchronized boolean getAutoCommit() throws SQLException {
- return this.currentConnection.getAutoCommit();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#getCatalog()
- */
- public synchronized String getCatalog() throws SQLException {
- return this.currentConnection.getCatalog();
- }
-
- public synchronized Connection getCurrentConnection() {
- return this.currentConnection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#getHoldability()
- */
- public synchronized int getHoldability() throws SQLException {
- return this.currentConnection.getHoldability();
- }
-
- public synchronized Connection getMasterConnection() {
- return this.masterConnection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#getMetaData()
- */
- public synchronized DatabaseMetaData getMetaData() throws SQLException {
- return this.currentConnection.getMetaData();
- }
-
- public synchronized Connection getSlavesConnection() {
- return this.slavesConnection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#getTransactionIsolation()
- */
- public synchronized int getTransactionIsolation() throws SQLException {
- return this.currentConnection.getTransactionIsolation();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#getTypeMap()
- */
- public synchronized Map getTypeMap() throws SQLException {
- return this.currentConnection.getTypeMap();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#getWarnings()
- */
- public synchronized SQLWarning getWarnings() throws SQLException {
- return this.currentConnection.getWarnings();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#isClosed()
- */
- public synchronized boolean isClosed() throws SQLException {
- return this.currentConnection.isClosed();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#isReadOnly()
- */
- public synchronized boolean isReadOnly() throws SQLException {
- return this.currentConnection == this.slavesConnection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#nativeSQL(java.lang.String)
- */
- public synchronized String nativeSQL(String sql) throws SQLException {
- return this.currentConnection.nativeSQL(sql);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareCall(java.lang.String)
- */
- public CallableStatement prepareCall(String sql) throws SQLException {
- return this.currentConnection.prepareCall(sql);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareCall(java.lang.String, int, int)
- */
- public synchronized CallableStatement prepareCall(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- return this.currentConnection.prepareCall(sql, resultSetType,
- resultSetConcurrency);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)
- */
- public synchronized CallableStatement prepareCall(String sql,
- int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- return this.currentConnection.prepareCall(sql, resultSetType,
- resultSetConcurrency, resultSetHoldability);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareStatement(java.lang.String)
- */
- public PreparedStatement prepareStatement(String sql) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.prepareStatement(sql);
-
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareStatement(java.lang.String, int)
- */
- public synchronized PreparedStatement prepareStatement(String sql,
- int autoGeneratedKeys) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.prepareStatement(sql, autoGeneratedKeys);
-
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareStatement(java.lang.String, int, int)
- */
- public synchronized PreparedStatement prepareStatement(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.prepareStatement(sql, resultSetType,
- resultSetConcurrency);
-
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareStatement(java.lang.String, int, int,
- * int)
- */
- public synchronized PreparedStatement prepareStatement(String sql,
- int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.prepareStatement(sql, resultSetType,
- resultSetConcurrency, resultSetHoldability);
-
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareStatement(java.lang.String, int[])
- */
- public synchronized PreparedStatement prepareStatement(String sql,
- int[] columnIndexes) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.prepareStatement(sql, columnIndexes);
-
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#prepareStatement(java.lang.String,
- * java.lang.String[])
- */
- public synchronized PreparedStatement prepareStatement(String sql,
- String[] columnNames) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.prepareStatement(sql, columnNames);
-
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#releaseSavepoint(java.sql.Savepoint)
- */
- public synchronized void releaseSavepoint(Savepoint savepoint)
- throws SQLException {
- this.currentConnection.releaseSavepoint(savepoint);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#rollback()
- */
- public synchronized void rollback() throws SQLException {
- this.currentConnection.rollback();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#rollback(java.sql.Savepoint)
- */
- public synchronized void rollback(Savepoint savepoint) throws SQLException {
- this.currentConnection.rollback(savepoint);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setAutoCommit(boolean)
- */
- public synchronized void setAutoCommit(boolean autoCommit)
- throws SQLException {
- this.currentConnection.setAutoCommit(autoCommit);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setCatalog(java.lang.String)
- */
- public synchronized void setCatalog(String catalog) throws SQLException {
- this.currentConnection.setCatalog(catalog);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setHoldability(int)
- */
- public synchronized void setHoldability(int holdability)
- throws SQLException {
- this.currentConnection.setHoldability(holdability);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setReadOnly(boolean)
- */
- public synchronized void setReadOnly(boolean readOnly) throws SQLException {
- if (readOnly) {
- if (currentConnection != slavesConnection) {
- switchToSlavesConnection();
- }
- } else {
- if (currentConnection != masterConnection) {
- switchToMasterConnection();
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setSavepoint()
- */
- public synchronized Savepoint setSavepoint() throws SQLException {
- return this.currentConnection.setSavepoint();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setSavepoint(java.lang.String)
- */
- public synchronized Savepoint setSavepoint(String name) throws SQLException {
- return this.currentConnection.setSavepoint(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setTransactionIsolation(int)
- */
- public synchronized void setTransactionIsolation(int level)
- throws SQLException {
- this.currentConnection.setTransactionIsolation(level);
- }
-
- // For testing
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Connection#setTypeMap(java.util.Map)
- */
- public synchronized void setTypeMap(Map arg0) throws SQLException {
- this.currentConnection.setTypeMap(arg0);
- }
-
- private synchronized void switchToMasterConnection() throws SQLException {
- swapConnections(this.masterConnection, this.slavesConnection);
- }
-
- private synchronized void switchToSlavesConnection() throws SQLException {
- swapConnections(this.slavesConnection, this.masterConnection);
- }
-
- /**
- * Swaps current context (catalog, autocommit and txn_isolation) from
- * sourceConnection to targetConnection, and makes targetConnection
- * the "current" connection that will be used for queries.
- *
- * @param switchToConnection the connection to swap from
- * @param switchFromConnection the connection to swap to
- *
- * @throws SQLException if an error occurs
- */
- private synchronized void swapConnections(Connection switchToConnection,
- Connection switchFromConnection) throws SQLException {
- String switchFromCatalog = switchFromConnection.getCatalog();
- String switchToCatalog = switchToConnection.getCatalog();
-
- if (switchToCatalog != null && !switchToCatalog.equals(switchFromCatalog)) {
- switchToConnection.setCatalog(switchFromCatalog);
- } else if (switchFromCatalog != null) {
- switchToConnection.setCatalog(switchFromCatalog);
- }
-
- boolean switchToAutoCommit = switchToConnection.getAutoCommit();
- boolean switchFromConnectionAutoCommit = switchFromConnection.getAutoCommit();
-
- if (switchFromConnectionAutoCommit != switchToAutoCommit) {
- switchToConnection.setAutoCommit(switchFromConnectionAutoCommit);
- }
-
- int switchToIsolation = switchToConnection
- .getTransactionIsolation();
-
- int switchFromIsolation = switchFromConnection.getTransactionIsolation();
-
- if (switchFromIsolation != switchToIsolation) {
- switchToConnection
- .setTransactionIsolation(switchFromIsolation);
- }
-
- this.currentConnection = switchToConnection;
- }
-
- public synchronized void doPing() throws SQLException {
- if (this.masterConnection != null) {
- this.masterConnection.ping();
- }
-
- if (this.slavesConnection != null) {
- this.slavesConnection.ping();
- }
- }
-
- public synchronized void changeUser(String userName, String newPassword)
- throws SQLException {
- this.masterConnection.changeUser(userName, newPassword);
- this.slavesConnection.changeUser(userName, newPassword);
- }
-
- public synchronized void clearHasTriedMaster() {
- this.masterConnection.clearHasTriedMaster();
- this.slavesConnection.clearHasTriedMaster();
-
- }
-
- public synchronized PreparedStatement clientPrepareStatement(String sql)
- throws SQLException {
- PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement clientPrepareStatement(String sql,
- int autoGenKeyIndex) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, autoGenKeyIndex);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement clientPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, resultSetType, resultSetConcurrency);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement clientPrepareStatement(String sql,
- int[] autoGenKeyIndexes) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, autoGenKeyIndexes);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement clientPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement clientPrepareStatement(String sql,
- String[] autoGenKeyColNames) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, autoGenKeyColNames);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized int getActiveStatementCount() {
- return this.currentConnection.getActiveStatementCount();
- }
-
- public synchronized long getIdleFor() {
- return this.currentConnection.getIdleFor();
- }
-
- public synchronized Log getLog() throws SQLException {
- return this.currentConnection.getLog();
- }
-
- public synchronized String getServerCharacterEncoding() {
- return this.currentConnection.getServerCharacterEncoding();
- }
-
- public synchronized TimeZone getServerTimezoneTZ() {
- return this.currentConnection.getServerTimezoneTZ();
- }
-
- public synchronized String getStatementComment() {
- return this.currentConnection.getStatementComment();
- }
-
- public synchronized boolean hasTriedMaster() {
- return this.currentConnection.hasTriedMaster();
- }
-
- public synchronized void initializeExtension(Extension ex) throws SQLException {
- this.currentConnection.initializeExtension(ex);
- }
-
- public synchronized boolean isAbonormallyLongQuery(long millisOrNanos) {
- return this.currentConnection.isAbonormallyLongQuery(millisOrNanos);
- }
-
- public synchronized boolean isInGlobalTx() {
- return this.currentConnection.isInGlobalTx();
- }
-
- public synchronized boolean isMasterConnection() {
- return this.currentConnection.isMasterConnection();
- }
-
- public synchronized boolean isNoBackslashEscapesSet() {
- return this.currentConnection.isNoBackslashEscapesSet();
- }
-
- public synchronized boolean lowerCaseTableNames() {
- return this.currentConnection.lowerCaseTableNames();
- }
-
- public synchronized boolean parserKnowsUnicode() {
- return this.currentConnection.parserKnowsUnicode();
- }
-
- public synchronized void ping() throws SQLException {
- this.masterConnection.ping();
- this.slavesConnection.ping();
- }
-
- public synchronized void reportQueryTime(long millisOrNanos) {
- this.currentConnection.reportQueryTime(millisOrNanos);
- }
-
- public synchronized void resetServerState() throws SQLException {
- this.currentConnection.resetServerState();
- }
-
- public synchronized PreparedStatement serverPrepareStatement(String sql)
- throws SQLException {
- PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement serverPrepareStatement(String sql,
- int autoGenKeyIndex) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, autoGenKeyIndex);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement serverPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, resultSetType, resultSetConcurrency);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement serverPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement serverPrepareStatement(String sql,
- int[] autoGenKeyIndexes) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, autoGenKeyIndexes);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized PreparedStatement serverPrepareStatement(String sql,
- String[] autoGenKeyColNames) throws SQLException {
- PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, autoGenKeyColNames);
- ((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);
-
- return pstmt;
- }
-
- public synchronized void setFailedOver(boolean flag) {
- this.currentConnection.setFailedOver(flag);
- }
-
- public synchronized void setPreferSlaveDuringFailover(boolean flag) {
- this.currentConnection.setPreferSlaveDuringFailover(flag);
- }
-
- public synchronized void setStatementComment(String comment) {
- this.masterConnection.setStatementComment(comment);
- this.slavesConnection.setStatementComment(comment);
- }
-
- public synchronized void shutdownServer() throws SQLException {
- this.currentConnection.shutdownServer();
- }
-
- public synchronized boolean supportsIsolationLevel() {
- return this.currentConnection.supportsIsolationLevel();
- }
-
- public synchronized boolean supportsQuotedIdentifiers() {
- return this.currentConnection.supportsQuotedIdentifiers();
- }
-
- public synchronized boolean supportsTransactions() {
- return this.currentConnection.supportsTransactions();
- }
-
- public synchronized boolean versionMeetsMinimum(int major, int minor, int subminor)
- throws SQLException {
- return this.currentConnection.versionMeetsMinimum(major, minor, subminor);
- }
-
- public synchronized String exposeAsXml() throws SQLException {
- return this.currentConnection.exposeAsXml();
- }
-
- public synchronized boolean getAllowLoadLocalInfile() {
- return this.currentConnection.getAllowLoadLocalInfile();
- }
-
- public synchronized boolean getAllowMultiQueries() {
- return this.currentConnection.getAllowMultiQueries();
- }
-
- public synchronized boolean getAllowNanAndInf() {
- return this.currentConnection.getAllowNanAndInf();
- }
-
- public synchronized boolean getAllowUrlInLocalInfile() {
- return this.currentConnection.getAllowUrlInLocalInfile();
- }
-
- public synchronized boolean getAlwaysSendSetIsolation() {
- return this.currentConnection.getAlwaysSendSetIsolation();
- }
-
- public synchronized boolean getAutoClosePStmtStreams() {
- return this.currentConnection.getAutoClosePStmtStreams();
- }
-
- public synchronized boolean getAutoDeserialize() {
- return this.currentConnection.getAutoDeserialize();
- }
-
- public synchronized boolean getAutoGenerateTestcaseScript() {
- return this.currentConnection.getAutoGenerateTestcaseScript();
- }
-
- public synchronized boolean getAutoReconnectForPools() {
- return this.currentConnection.getAutoReconnectForPools();
- }
-
- public synchronized boolean getAutoSlowLog() {
- return this.currentConnection.getAutoSlowLog();
- }
-
- public synchronized int getBlobSendChunkSize() {
- return this.currentConnection.getBlobSendChunkSize();
- }
-
- public synchronized boolean getBlobsAreStrings() {
- return this.currentConnection.getBlobsAreStrings();
- }
-
- public synchronized boolean getCacheCallableStatements() {
- return this.currentConnection.getCacheCallableStatements();
- }
-
- public synchronized boolean getCacheCallableStmts() {
- return this.currentConnection.getCacheCallableStmts();
- }
-
- public synchronized boolean getCachePrepStmts() {
- return this.currentConnection.getCachePrepStmts();
- }
-
- public synchronized boolean getCachePreparedStatements() {
- return this.currentConnection.getCachePreparedStatements();
- }
-
- public synchronized boolean getCacheResultSetMetadata() {
- return this.currentConnection.getCacheResultSetMetadata();
- }
-
- public synchronized boolean getCacheServerConfiguration() {
- return this.currentConnection.getCacheServerConfiguration();
- }
-
- public synchronized int getCallableStatementCacheSize() {
- return this.currentConnection.getCallableStatementCacheSize();
- }
-
- public synchronized int getCallableStmtCacheSize() {
- return this.currentConnection.getCallableStmtCacheSize();
- }
-
- public synchronized boolean getCapitalizeTypeNames() {
- return this.currentConnection.getCapitalizeTypeNames();
- }
-
- public synchronized String getCharacterSetResults() {
- return this.currentConnection.getCharacterSetResults();
- }
-
- public synchronized String getClientCertificateKeyStorePassword() {
- return this.currentConnection.getClientCertificateKeyStorePassword();
- }
-
- public synchronized String getClientCertificateKeyStoreType() {
- return this.currentConnection.getClientCertificateKeyStoreType();
- }
-
- public synchronized String getClientCertificateKeyStoreUrl() {
- return this.currentConnection.getClientCertificateKeyStoreUrl();
- }
-
- public synchronized String getClientInfoProvider() {
- return this.currentConnection.getClientInfoProvider();
- }
-
- public synchronized String getClobCharacterEncoding() {
- return this.currentConnection.getClobCharacterEncoding();
- }
-
- public synchronized boolean getClobberStreamingResults() {
- return this.currentConnection.getClobberStreamingResults();
- }
-
- public synchronized int getConnectTimeout() {
- return this.currentConnection.getConnectTimeout();
- }
-
- public synchronized String getConnectionCollation() {
- return this.currentConnection.getConnectionCollation();
- }
-
- public synchronized String getConnectionLifecycleInterceptors() {
- return this.currentConnection.getConnectionLifecycleInterceptors();
- }
-
- public synchronized boolean getContinueBatchOnError() {
- return this.currentConnection.getContinueBatchOnError();
- }
-
- public synchronized boolean getCreateDatabaseIfNotExist() {
- return this.currentConnection.getCreateDatabaseIfNotExist();
- }
-
- public synchronized int getDefaultFetchSize() {
- return this.currentConnection.getDefaultFetchSize();
- }
-
- public synchronized boolean getDontTrackOpenResources() {
- return this.currentConnection.getDontTrackOpenResources();
- }
-
- public synchronized boolean getDumpMetadataOnColumnNotFound() {
- return this.currentConnection.getDumpMetadataOnColumnNotFound();
- }
-
- public synchronized boolean getDumpQueriesOnException() {
- return this.currentConnection.getDumpQueriesOnException();
- }
-
- public synchronized boolean getDynamicCalendars() {
- return this.currentConnection.getDynamicCalendars();
- }
-
- public synchronized boolean getElideSetAutoCommits() {
- return this.currentConnection.getElideSetAutoCommits();
- }
-
- public synchronized boolean getEmptyStringsConvertToZero() {
- return this.currentConnection.getEmptyStringsConvertToZero();
- }
-
- public synchronized boolean getEmulateLocators() {
- return this.currentConnection.getEmulateLocators();
- }
-
- public synchronized boolean getEmulateUnsupportedPstmts() {
- return this.currentConnection.getEmulateUnsupportedPstmts();
- }
-
- public synchronized boolean getEnablePacketDebug() {
- return this.currentConnection.getEnablePacketDebug();
- }
-
- public synchronized boolean getEnableQueryTimeouts() {
- return this.currentConnection.getEnableQueryTimeouts();
- }
-
- public synchronized String getEncoding() {
- return this.currentConnection.getEncoding();
- }
-
- public synchronized boolean getExplainSlowQueries() {
- return this.currentConnection.getExplainSlowQueries();
- }
-
- public synchronized boolean getFailOverReadOnly() {
- return this.currentConnection.getFailOverReadOnly();
- }
-
- public synchronized boolean getFunctionsNeverReturnBlobs() {
- return this.currentConnection.getFunctionsNeverReturnBlobs();
- }
-
- public synchronized boolean getGatherPerfMetrics() {
- return this.currentConnection.getGatherPerfMetrics();
- }
-
- public synchronized boolean getGatherPerformanceMetrics() {
- return this.currentConnection.getGatherPerformanceMetrics();
- }
-
- public synchronized boolean getGenerateSimpleParameterMetadata() {
- return this.currentConnection.getGenerateSimpleParameterMetadata();
- }
-
- public synchronized boolean getHoldResultsOpenOverStatementClose() {
- return this.currentConnection.getHoldResultsOpenOverStatementClose();
- }
-
- public synchronized boolean getIgnoreNonTxTables() {
- return this.currentConnection.getIgnoreNonTxTables();
- }
-
- public synchronized boolean getIncludeInnodbStatusInDeadlockExceptions() {
- return this.currentConnection.getIncludeInnodbStatusInDeadlockExceptions();
- }
-
- public synchronized int getInitialTimeout() {
- return this.currentConnection.getInitialTimeout();
- }
-
- public synchronized boolean getInteractiveClient() {
- return this.currentConnection.getInteractiveClient();
- }
-
- public synchronized boolean getIsInteractiveClient() {
- return this.currentConnection.getIsInteractiveClient();
- }
-
- public synchronized boolean getJdbcCompliantTruncation() {
- return this.currentConnection.getJdbcCompliantTruncation();
- }
-
- public synchronized boolean getJdbcCompliantTruncationForReads() {
- return this.currentConnection.getJdbcCompliantTruncationForReads();
- }
-
- public synchronized String getLargeRowSizeThreshold() {
- return this.currentConnection.getLargeRowSizeThreshold();
- }
-
- public synchronized String getLoadBalanceStrategy() {
- return this.currentConnection.getLoadBalanceStrategy();
- }
-
- public synchronized String getLocalSocketAddress() {
- return this.currentConnection.getLocalSocketAddress();
- }
-
- public synchronized int getLocatorFetchBufferSize() {
- return this.currentConnection.getLocatorFetchBufferSize();
- }
-
- public synchronized boolean getLogSlowQueries() {
- return this.currentConnection.getLogSlowQueries();
- }
-
- public synchronized boolean getLogXaCommands() {
- return this.currentConnection.getLogXaCommands();
- }
-
- public synchronized String getLogger() {
- return this.currentConnection.getLogger();
- }
-
- public synchronized String getLoggerClassName() {
- return this.currentConnection.getLoggerClassName();
- }
-
- public synchronized boolean getMaintainTimeStats() {
- return this.currentConnection.getMaintainTimeStats();
- }
-
- public synchronized int getMaxQuerySizeToLog() {
- return this.currentConnection.getMaxQuerySizeToLog();
- }
-
- public synchronized int getMaxReconnects() {
- return this.currentConnection.getMaxReconnects();
- }
-
- public synchronized int getMaxRows() {
- return this.currentConnection.getMaxRows();
- }
-
- public synchronized int getMetadataCacheSize() {
- return this.currentConnection.getMetadataCacheSize();
- }
-
- public synchronized int getNetTimeoutForStreamingResults() {
- return this.currentConnection.getNetTimeoutForStreamingResults();
- }
-
- public synchronized boolean getNoAccessToProcedureBodies() {
- return this.currentConnection.getNoAccessToProcedureBodies();
- }
-
- public synchronized boolean getNoDatetimeStringSync() {
- return this.currentConnection.getNoDatetimeStringSync();
- }
-
- public synchronized boolean getNoTimezoneConversionForTimeType() {
- return this.currentConnection.getNoTimezoneConversionForTimeType();
- }
-
- public synchronized boolean getNullCatalogMeansCurrent() {
- return this.currentConnection.getNullCatalogMeansCurrent();
- }
-
- public synchronized boolean getNullNamePatternMatchesAll() {
- return this.currentConnection.getNullNamePatternMatchesAll();
- }
-
- public synchronized boolean getOverrideSupportsIntegrityEnhancementFacility() {
- return this.currentConnection.getOverrideSupportsIntegrityEnhancementFacility();
- }
-
- public synchronized int getPacketDebugBufferSize() {
- return this.currentConnection.getPacketDebugBufferSize();
- }
-
- public synchronized boolean getPadCharsWithSpace() {
- return this.currentConnection.getPadCharsWithSpace();
- }
-
- public synchronized boolean getParanoid() {
- return this.currentConnection.getParanoid();
- }
-
- public synchronized boolean getPedantic() {
- return this.currentConnection.getPedantic();
- }
-
- public synchronized boolean getPinGlobalTxToPhysicalConnection() {
- return this.currentConnection.getPinGlobalTxToPhysicalConnection();
- }
-
- public synchronized boolean getPopulateInsertRowWithDefaultValues() {
- return this.currentConnection.getPopulateInsertRowWithDefaultValues();
- }
-
- public synchronized int getPrepStmtCacheSize() {
- return this.currentConnection.getPrepStmtCacheSize();
- }
-
- public synchronized int getPrepStmtCacheSqlLimit() {
- return this.currentConnection.getPrepStmtCacheSqlLimit();
- }
-
- public synchronized int getPreparedStatementCacheSize() {
- return this.currentConnection.getPreparedStatementCacheSize();
- }
-
- public synchronized int getPreparedStatementCacheSqlLimit() {
- return this.currentConnection.getPreparedStatementCacheSqlLimit();
- }
-
- public synchronized boolean getProcessEscapeCodesForPrepStmts() {
- return this.currentConnection.getProcessEscapeCodesForPrepStmts();
- }
-
- public synchronized boolean getProfileSQL() {
- return this.currentConnection.getProfileSQL();
- }
-
- public synchronized boolean getProfileSql() {
- return this.currentConnection.getProfileSql();
- }
-
- public synchronized String getProfilerEventHandler() {
- return this.currentConnection.getProfilerEventHandler();
- }
-
- public synchronized String getPropertiesTransform() {
- return this.currentConnection.getPropertiesTransform();
- }
-
- public synchronized int getQueriesBeforeRetryMaster() {
- return this.currentConnection.getQueriesBeforeRetryMaster();
- }
-
- public synchronized boolean getReconnectAtTxEnd() {
- return this.currentConnection.getReconnectAtTxEnd();
- }
-
- public synchronized boolean getRelaxAutoCommit() {
- return this.currentConnection.getRelaxAutoCommit();
- }
-
- public synchronized int getReportMetricsIntervalMillis() {
- return this.currentConnection.getReportMetricsIntervalMillis();
- }
-
- public synchronized boolean getRequireSSL() {
- return this.currentConnection.getRequireSSL();
- }
-
- public synchronized String getResourceId() {
- return this.currentConnection.getResourceId();
- }
-
- public synchronized int getResultSetSizeThreshold() {
- return this.currentConnection.getResultSetSizeThreshold();
- }
-
- public synchronized boolean getRewriteBatchedStatements() {
- return this.currentConnection.getRewriteBatchedStatements();
- }
-
- public synchronized boolean getRollbackOnPooledClose() {
- return this.currentConnection.getRollbackOnPooledClose();
- }
-
- public synchronized boolean getRoundRobinLoadBalance() {
- return this.currentConnection.getRoundRobinLoadBalance();
- }
-
- public synchronized boolean getRunningCTS13() {
- return this.currentConnection.getRunningCTS13();
- }
-
- public synchronized int getSecondsBeforeRetryMaster() {
- return this.currentConnection.getSecondsBeforeRetryMaster();
- }
-
- public synchronized int getSelfDestructOnPingMaxOperations() {
- return this.currentConnection.getSelfDestructOnPingMaxOperations();
- }
-
- public synchronized int getSelfDestructOnPingSecondsLifetime() {
- return this.currentConnection.getSelfDestructOnPingSecondsLifetime();
- }
-
- public synchronized String getServerTimezone() {
- return this.currentConnection.getServerTimezone();
- }
-
- public synchronized String getSessionVariables() {
- return this.currentConnection.getSessionVariables();
- }
-
- public synchronized int getSlowQueryThresholdMillis() {
- return this.currentConnection.getSlowQueryThresholdMillis();
- }
-
- public synchronized long getSlowQueryThresholdNanos() {
- return this.currentConnection.getSlowQueryThresholdNanos();
- }
-
- public synchronized String getSocketFactory() {
- return this.currentConnection.getSocketFactory();
- }
-
- public synchronized String getSocketFactoryClassName() {
- return this.currentConnection.getSocketFactoryClassName();
- }
-
- public synchronized int getSocketTimeout() {
- return this.currentConnection.getSocketTimeout();
- }
-
- public synchronized String getStatementInterceptors() {
- return this.currentConnection.getStatementInterceptors();
- }
-
- public synchronized boolean getStrictFloatingPoint() {
- return this.currentConnection.getStrictFloatingPoint();
- }
-
- public synchronized boolean getStrictUpdates() {
- return this.currentConnection.getStrictUpdates();
- }
-
- public synchronized boolean getTcpKeepAlive() {
- return this.currentConnection.getTcpKeepAlive();
- }
-
- public synchronized boolean getTcpNoDelay() {
- return this.currentConnection.getTcpNoDelay();
- }
-
- public synchronized int getTcpRcvBuf() {
- return this.currentConnection.getTcpRcvBuf();
- }
-
- public synchronized int getTcpSndBuf() {
- return this.currentConnection.getTcpSndBuf();
- }
-
- public synchronized int getTcpTrafficClass() {
- return this.currentConnection.getTcpTrafficClass();
- }
-
- public synchronized boolean getTinyInt1isBit() {
- return this.currentConnection.getTinyInt1isBit();
- }
-
- public synchronized boolean getTraceProtocol() {
- return this.currentConnection.getTraceProtocol();
- }
-
- public synchronized boolean getTransformedBitIsBoolean() {
- return this.currentConnection.getTransformedBitIsBoolean();
- }
-
- public synchronized boolean getTreatUtilDateAsTimestamp() {
- return this.currentConnection.getTreatUtilDateAsTimestamp();
- }
-
- public synchronized String getTrustCertificateKeyStorePassword() {
- return this.currentConnection.getTrustCertificateKeyStorePassword();
- }
-
- public synchronized String getTrustCertificateKeyStoreType() {
- return this.currentConnection.getTrustCertificateKeyStoreType();
- }
-
- public synchronized String getTrustCertificateKeyStoreUrl() {
- return this.currentConnection.getTrustCertificateKeyStoreUrl();
- }
-
- public synchronized boolean getUltraDevHack() {
- return this.currentConnection.getUltraDevHack();
- }
-
- public synchronized boolean getUseBlobToStoreUTF8OutsideBMP() {
- return this.currentConnection.getUseBlobToStoreUTF8OutsideBMP();
- }
-
- public synchronized boolean getUseCompression() {
- return this.currentConnection.getUseCompression();
- }
-
- public synchronized String getUseConfigs() {
- return this.currentConnection.getUseConfigs();
- }
-
- public synchronized boolean getUseCursorFetch() {
- return this.currentConnection.getUseCursorFetch();
- }
-
- public synchronized boolean getUseDirectRowUnpack() {
- return this.currentConnection.getUseDirectRowUnpack();
- }
-
- public synchronized boolean getUseDynamicCharsetInfo() {
- return this.currentConnection.getUseDynamicCharsetInfo();
- }
-
- public synchronized boolean getUseFastDateParsing() {
- return this.currentConnection.getUseFastDateParsing();
- }
-
- public synchronized boolean getUseFastIntParsing() {
- return this.currentConnection.getUseFastIntParsing();
- }
-
- public synchronized boolean getUseGmtMillisForDatetimes() {
- return this.currentConnection.getUseGmtMillisForDatetimes();
- }
-
- public synchronized boolean getUseHostsInPrivileges() {
- return this.currentConnection.getUseHostsInPrivileges();
- }
-
- public synchronized boolean getUseInformationSchema() {
- return this.currentConnection.getUseInformationSchema();
- }
-
- public synchronized boolean getUseJDBCCompliantTimezoneShift() {
- return this.currentConnection.getUseJDBCCompliantTimezoneShift();
- }
-
- public synchronized boolean getUseJvmCharsetConverters() {
- return this.currentConnection.getUseJvmCharsetConverters();
- }
-
- public synchronized boolean getUseLegacyDatetimeCode() {
- return this.currentConnection.getUseLegacyDatetimeCode();
- }
-
- public synchronized boolean getUseLocalSessionState() {
- return this.currentConnection.getUseLocalSessionState();
- }
-
- public synchronized boolean getUseNanosForElapsedTime() {
- return this.currentConnection.getUseNanosForElapsedTime();
- }
-
- public synchronized boolean getUseOldAliasMetadataBehavior() {
- return this.currentConnection.getUseOldAliasMetadataBehavior();
- }
-
- public synchronized boolean getUseOldUTF8Behavior() {
- return this.currentConnection.getUseOldUTF8Behavior();
- }
-
- public synchronized boolean getUseOnlyServerErrorMessages() {
- return this.currentConnection.getUseOnlyServerErrorMessages();
- }
-
- public synchronized boolean getUseReadAheadInput() {
- return this.currentConnection.getUseReadAheadInput();
- }
-
- public synchronized boolean getUseSSL() {
- return this.currentConnection.getUseSSL();
- }
-
- public synchronized boolean getUseSSPSCompatibleTimezoneShift() {
- return this.currentConnection.getUseSSPSCompatibleTimezoneShift();
- }
-
- public synchronized boolean getUseServerPrepStmts() {
- return this.currentConnection.getUseServerPrepStmts();
- }
-
- public synchronized boolean getUseServerPreparedStmts() {
- return this.currentConnection.getUseServerPreparedStmts();
- }
-
- public synchronized boolean getUseSqlStateCodes() {
- return this.currentConnection.getUseSqlStateCodes();
- }
-
- public synchronized boolean getUseStreamLengthsInPrepStmts() {
- return this.currentConnection.getUseStreamLengthsInPrepStmts();
- }
-
- public synchronized boolean getUseTimezone() {
- return this.currentConnection.getUseTimezone();
- }
-
- public synchronized boolean getUseUltraDevWorkAround() {
- return this.currentConnection.getUseUltraDevWorkAround();
- }
-
- public synchronized boolean getUseUnbufferedInput() {
- return this.currentConnection.getUseUnbufferedInput();
- }
-
- public synchronized boolean getUseUnicode() {
- return this.currentConnection.getUseUnicode();
- }
-
- public synchronized boolean getUseUsageAdvisor() {
- return this.currentConnection.getUseUsageAdvisor();
- }
-
- public synchronized String getUtf8OutsideBmpExcludedColumnNamePattern() {
- return this.currentConnection.getUtf8OutsideBmpExcludedColumnNamePattern();
- }
-
- public synchronized String getUtf8OutsideBmpIncludedColumnNamePattern() {
- return this.currentConnection.getUtf8OutsideBmpIncludedColumnNamePattern();
- }
-
- public synchronized boolean getVerifyServerCertificate() {
- return this.currentConnection.getVerifyServerCertificate();
- }
-
- public synchronized boolean getYearIsDateType() {
- return this.currentConnection.getYearIsDateType();
- }
-
- public synchronized String getZeroDateTimeBehavior() {
- return this.currentConnection.getZeroDateTimeBehavior();
- }
-
- public synchronized void setAllowLoadLocalInfile(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setAllowMultiQueries(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setAllowNanAndInf(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAllowUrlInLocalInfile(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAlwaysSendSetIsolation(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAutoClosePStmtStreams(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAutoDeserialize(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAutoGenerateTestcaseScript(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAutoReconnect(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAutoReconnectForConnectionPools(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setAutoReconnectForPools(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setAutoSlowLog(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setBlobSendChunkSize(String value) throws SQLException {
- // not runtime configurable
-
- }
-
- public synchronized void setBlobsAreStrings(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setCacheCallableStatements(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setCacheCallableStmts(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setCachePrepStmts(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setCachePreparedStatements(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setCacheResultSetMetadata(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setCacheServerConfiguration(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setCallableStatementCacheSize(int size) {
- // not runtime configurable
-
- }
-
- public synchronized void setCallableStmtCacheSize(int cacheSize) {
- // not runtime configurable
-
- }
-
- public synchronized void setCapitalizeDBMDTypes(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setCapitalizeTypeNames(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setCharacterEncoding(String encoding) {
- // not runtime configurable
-
- }
-
- public synchronized void setCharacterSetResults(String characterSet) {
- // not runtime configurable
-
- }
-
- public synchronized void setClientCertificateKeyStorePassword(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setClientCertificateKeyStoreType(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setClientCertificateKeyStoreUrl(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setClientInfoProvider(String classname) {
- // not runtime configurable
-
- }
-
- public synchronized void setClobCharacterEncoding(String encoding) {
- // not runtime configurable
-
- }
-
- public synchronized void setClobberStreamingResults(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setConnectTimeout(int timeoutMs) {
- // not runtime configurable
-
- }
-
- public synchronized void setConnectionCollation(String collation) {
- // not runtime configurable
-
- }
-
- public synchronized void setConnectionLifecycleInterceptors(String interceptors) {
- // not runtime configurable
-
- }
-
- public synchronized void setContinueBatchOnError(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setCreateDatabaseIfNotExist(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setDefaultFetchSize(int n) {
- // not runtime configurable
-
- }
-
- public synchronized void setDetectServerPreparedStmts(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setDontTrackOpenResources(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setDumpMetadataOnColumnNotFound(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setDumpQueriesOnException(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setDynamicCalendars(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setElideSetAutoCommits(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setEmptyStringsConvertToZero(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setEmulateLocators(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setEmulateUnsupportedPstmts(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setEnablePacketDebug(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setEnableQueryTimeouts(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setEncoding(String property) {
- // not runtime configurable
-
- }
-
- public synchronized void setExplainSlowQueries(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setFailOverReadOnly(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setFunctionsNeverReturnBlobs(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setGatherPerfMetrics(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setGatherPerformanceMetrics(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setGenerateSimpleParameterMetadata(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setHoldResultsOpenOverStatementClose(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setIgnoreNonTxTables(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setIncludeInnodbStatusInDeadlockExceptions(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setInitialTimeout(int property) {
- // not runtime configurable
-
- }
-
- public synchronized void setInteractiveClient(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setIsInteractiveClient(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setJdbcCompliantTruncation(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setJdbcCompliantTruncationForReads(
- boolean jdbcCompliantTruncationForReads) {
- // not runtime configurable
-
- }
-
- public synchronized void setLargeRowSizeThreshold(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setLoadBalanceStrategy(String strategy) {
- // not runtime configurable
-
- }
-
- public synchronized void setLocalSocketAddress(String address) {
- // not runtime configurable
-
- }
-
- public synchronized void setLocatorFetchBufferSize(String value) throws SQLException {
- // not runtime configurable
-
- }
-
- public synchronized void setLogSlowQueries(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setLogXaCommands(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setLogger(String property) {
- // not runtime configurable
-
- }
-
- public synchronized void setLoggerClassName(String className) {
- // not runtime configurable
-
- }
-
- public synchronized void setMaintainTimeStats(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setMaxQuerySizeToLog(int sizeInBytes) {
- // not runtime configurable
-
- }
-
- public synchronized void setMaxReconnects(int property) {
- // not runtime configurable
-
- }
-
- public synchronized void setMaxRows(int property) {
- // not runtime configurable
-
- }
-
- public synchronized void setMetadataCacheSize(int value) {
- // not runtime configurable
-
- }
-
- public synchronized void setNetTimeoutForStreamingResults(int value) {
- // not runtime configurable
-
- }
-
- public synchronized void setNoAccessToProcedureBodies(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setNoDatetimeStringSync(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setNoTimezoneConversionForTimeType(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setNullCatalogMeansCurrent(boolean value) {
- // not runtime configurable
-
- }
-
- public synchronized void setNullNamePatternMatchesAll(boolean value) {
- // not runtime configurable
-
- }
-
- public synchronized void setOverrideSupportsIntegrityEnhancementFacility(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setPacketDebugBufferSize(int size) {
- // not runtime configurable
-
- }
-
- public synchronized void setPadCharsWithSpace(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setParanoid(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setPedantic(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setPinGlobalTxToPhysicalConnection(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setPopulateInsertRowWithDefaultValues(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setPrepStmtCacheSize(int cacheSize) {
- // not runtime configurable
-
- }
-
- public synchronized void setPrepStmtCacheSqlLimit(int sqlLimit) {
- // not runtime configurable
-
- }
-
- public synchronized void setPreparedStatementCacheSize(int cacheSize) {
- // not runtime configurable
-
- }
-
- public synchronized void setPreparedStatementCacheSqlLimit(int cacheSqlLimit) {
- // not runtime configurable
-
- }
-
- public synchronized void setProcessEscapeCodesForPrepStmts(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setProfileSQL(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setProfileSql(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setProfilerEventHandler(String handler) {
- // not runtime configurable
-
- }
-
- public synchronized void setPropertiesTransform(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setQueriesBeforeRetryMaster(int property) {
- // not runtime configurable
-
- }
-
- public synchronized void setReconnectAtTxEnd(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setRelaxAutoCommit(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setReportMetricsIntervalMillis(int millis) {
- // not runtime configurable
-
- }
-
- public synchronized void setRequireSSL(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setResourceId(String resourceId) {
- // not runtime configurable
-
- }
-
- public synchronized void setResultSetSizeThreshold(int threshold) {
- // not runtime configurable
-
- }
-
- public synchronized void setRetainStatementAfterResultSetClose(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setRewriteBatchedStatements(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setRollbackOnPooledClose(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setRoundRobinLoadBalance(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setRunningCTS13(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setSecondsBeforeRetryMaster(int property) {
- // not runtime configurable
-
- }
-
- public synchronized void setSelfDestructOnPingMaxOperations(int maxOperations) {
- // not runtime configurable
-
- }
-
- public synchronized void setSelfDestructOnPingSecondsLifetime(int seconds) {
- // not runtime configurable
-
- }
-
- public synchronized void setServerTimezone(String property) {
- // not runtime configurable
-
- }
-
- public synchronized void setSessionVariables(String variables) {
- // not runtime configurable
-
- }
-
- public synchronized void setSlowQueryThresholdMillis(int millis) {
- // not runtime configurable
-
- }
-
- public synchronized void setSlowQueryThresholdNanos(long nanos) {
- // not runtime configurable
-
- }
-
- public synchronized void setSocketFactory(String name) {
- // not runtime configurable
-
- }
-
- public synchronized void setSocketFactoryClassName(String property) {
- // not runtime configurable
-
- }
-
- public synchronized void setSocketTimeout(int property) {
- // not runtime configurable
-
- }
-
- public synchronized void setStatementInterceptors(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setStrictFloatingPoint(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setStrictUpdates(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setTcpKeepAlive(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setTcpNoDelay(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setTcpRcvBuf(int bufSize) {
- // not runtime configurable
-
- }
-
- public synchronized void setTcpSndBuf(int bufSize) {
- // not runtime configurable
-
- }
-
- public synchronized void setTcpTrafficClass(int classFlags) {
- // not runtime configurable
-
- }
-
- public synchronized void setTinyInt1isBit(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setTraceProtocol(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setTransformedBitIsBoolean(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setTreatUtilDateAsTimestamp(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setTrustCertificateKeyStorePassword(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setTrustCertificateKeyStoreType(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setTrustCertificateKeyStoreUrl(String value) {
- // not runtime configurable
-
- }
-
- public synchronized void setUltraDevHack(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseBlobToStoreUTF8OutsideBMP(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseCompression(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseConfigs(String configs) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseCursorFetch(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseDirectRowUnpack(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseDynamicCharsetInfo(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseFastDateParsing(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseFastIntParsing(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseGmtMillisForDatetimes(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseHostsInPrivileges(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseInformationSchema(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseJDBCCompliantTimezoneShift(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseJvmCharsetConverters(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseLegacyDatetimeCode(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseLocalSessionState(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseNanosForElapsedTime(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseOldAliasMetadataBehavior(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseOldUTF8Behavior(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseOnlyServerErrorMessages(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseReadAheadInput(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseSSL(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseSSPSCompatibleTimezoneShift(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseServerPrepStmts(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseServerPreparedStmts(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseSqlStateCodes(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseStreamLengthsInPrepStmts(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseTimezone(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseUltraDevWorkAround(boolean property) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseUnbufferedInput(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseUnicode(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUseUsageAdvisor(boolean useUsageAdvisorFlag) {
- // not runtime configurable
-
- }
-
- public synchronized void setUtf8OutsideBmpExcludedColumnNamePattern(String regexPattern) {
- // not runtime configurable
-
- }
-
- public synchronized void setUtf8OutsideBmpIncludedColumnNamePattern(String regexPattern) {
- // not runtime configurable
-
- }
-
- public synchronized void setVerifyServerCertificate(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setYearIsDateType(boolean flag) {
- // not runtime configurable
-
- }
-
- public synchronized void setZeroDateTimeBehavior(String behavior) {
- // not runtime configurable
-
- }
-
- public synchronized boolean useUnbufferedInput() {
- return this.currentConnection.useUnbufferedInput();
- }
-
- public synchronized boolean isSameResource(Connection c) {
- return this.currentConnection.isSameResource(c);
- }
-
- public void setInGlobalTx(boolean flag) {
- this.currentConnection.setInGlobalTx(flag);
- }
-
- public boolean getUseColumnNamesInFindColumn() {
- return this.currentConnection.getUseColumnNamesInFindColumn();
- }
-
- public void setUseColumnNamesInFindColumn(boolean flag) {
- // not runtime configurable
- }
-
- public boolean getUseLocalTransactionState() {
- return this.currentConnection.getUseLocalTransactionState();
- }
-
- public void setUseLocalTransactionState(boolean flag) {
- // not runtime configurable
-
- }
-
- public boolean getCompensateOnDuplicateKeyUpdateCounts() {
- return this.currentConnection.getCompensateOnDuplicateKeyUpdateCounts();
- }
-
- public void setCompensateOnDuplicateKeyUpdateCounts(boolean flag) {
- // not runtime configurable
-
- }
-
- public boolean getUseAffectedRows() {
- return this.currentConnection.getUseAffectedRows();
- }
-
- public void setUseAffectedRows(boolean flag) {
- // not runtime configurable
-
- }
-
- public String getPasswordCharacterEncoding() {
- return this.currentConnection.getPasswordCharacterEncoding();
- }
-
- public void setPasswordCharacterEncoding(String characterSet) {
- this.currentConnection.setPasswordCharacterEncoding(characterSet);
- }
-
- public int getAutoIncrementIncrement() {
- return this.currentConnection.getAutoIncrementIncrement();
- }
-
- public int getLoadBalanceBlacklistTimeout() {
- return this.currentConnection.getLoadBalanceBlacklistTimeout();
- }
-
- public void setLoadBalanceBlacklistTimeout(int loadBalanceBlacklistTimeout) {
- this.currentConnection.setLoadBalanceBlacklistTimeout(loadBalanceBlacklistTimeout);
- }
-
- public int getRetriesAllDown() {
- return this.currentConnection.getRetriesAllDown();
- }
-
- public void setRetriesAllDown(int retriesAllDown) {
- this.currentConnection.setRetriesAllDown(retriesAllDown);
- }
-
- public ExceptionInterceptor getExceptionInterceptor() {
- return this.currentConnection.getExceptionInterceptor();
- }
-
- public String getExceptionInterceptors() {
- return this.currentConnection.getExceptionInterceptors();
- }
-
- public void setExceptionInterceptors(String exceptionInterceptors) {
- this.currentConnection.setExceptionInterceptors(exceptionInterceptors);
- }
-
- public boolean getQueryTimeoutKillsConnection() {
- return this.currentConnection.getQueryTimeoutKillsConnection();
- }
-
- public void setQueryTimeoutKillsConnection(
- boolean queryTimeoutKillsConnection) {
- this.currentConnection.setQueryTimeoutKillsConnection(queryTimeoutKillsConnection);
- }
-}
diff --git a/src/com/mysql/jdbc/ReplicationDriver.java b/src/com/mysql/jdbc/ReplicationDriver.java
deleted file mode 100644
index 386da2e23..000000000
--- a/src/com/mysql/jdbc/ReplicationDriver.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-/**
- * The Java SQL framework allows for multiple database drivers. Each driver
- * should supply a class that implements the Driver interface
- *
- *
- * The DriverManager will try to load as many drivers as it can find and then
- * for any given connection request, it will ask each driver in turn to try to
- * connect to the target URL.
- *
- *
- * It is strongly recommended that each Driver class should be small and
- * standalone so that the Driver class can be loaded and queried without
- * bringing in vast quantities of supporting code.
- *
- *
- * When a Driver class is loaded, it should create an instance of itself and
- * register it with the DriverManager. This means that a user can load and
- * register a driver by doing Class.forName("foo.bah.Driver")
- *
- * @see org.gjt.mm.mysql.Connection
- * @see java.sql.Driver
- * @author Mark Matthews
- * @version $Id: ReplicationDriver.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews
- * Exp $
- */
-public class ReplicationDriver extends NonRegisteringReplicationDriver
- implements java.sql.Driver {
- // ~ Static fields/initializers
- // ---------------------------------------------
-
- //
- // Register ourselves with the DriverManager
- //
- static {
- try {
- java.sql.DriverManager
- .registerDriver(new NonRegisteringReplicationDriver());
- } catch (SQLException E) {
- throw new RuntimeException("Can't register driver!");
- }
- }
-
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Construct a new driver and register it with DriverManager
- *
- * @throws SQLException
- * if a database error occurs.
- */
- public ReplicationDriver() throws SQLException {
- // Required for Class.forName().newInstance()
- }
-}
diff --git a/src/com/mysql/jdbc/ResultSetImpl.java b/src/com/mysql/jdbc/ResultSetImpl.java
deleted file mode 100644
index 85acbcaf0..000000000
--- a/src/com/mysql/jdbc/ResultSetImpl.java
+++ /dev/null
@@ -1,8782 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Constructor;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-import java.util.TreeMap;
-
-import com.mysql.jdbc.profiler.ProfilerEvent;
-import com.mysql.jdbc.profiler.ProfilerEventHandler;
-import com.mysql.jdbc.profiler.ProfilerEventHandlerFactory;
-
-/**
- * A ResultSet provides access to a table of data generated by executing a
- * Statement. The table rows are retrieved in sequence. Within a row its column
- * values can be accessed in any order.
- *
- *
- * A ResultSet maintains a cursor pointing to its current row of data. Initially
- * the cursor is positioned before the first row. The 'next' method moves the
- * cursor to the next row.
- *
- *
- *
- * The getXXX methods retrieve column values for the current row. You can
- * retrieve values either using the index number of the column, or by using the
- * name of the column. In general using the column index will be more efficient.
- * Columns are numbered from 1.
- *
- *
- *
- * For maximum portability, ResultSet columns within each row should be read in
- * left-to-right order and each column should be read only once.
- *
- *
- *
- * For the getXXX methods, the JDBC driver attempts to convert the underlying
- * data to the specified Java type and returns a suitable Java value. See the
- * JDBC specification for allowable mappings from SQL types to Java types with
- * the ResultSet getXXX methods.
- *
- *
- *
- * Column names used as input to getXXX methods are case insenstive. When
- * performing a getXXX using a column name, if several columns have the same
- * name, then the value of the first matching column will be returned. The
- * column name option is designed to be used when column names are used in the
- * SQL Query. For columns that are NOT explicitly named in the query, it is best
- * to use column numbers. If column names were used there is no way for the
- * programmer to guarentee that they actually refer to the intended columns.
- *
- *
- *
- * A ResultSet is automatically closed by the Statement that generated it when
- * that Statement is closed, re-executed, or is used to retrieve the next result
- * from a sequence of multiple results.
- *
- *
- *
- * The number, types and properties of a ResultSet's columns are provided by the
- * ResultSetMetaData object returned by the getMetaData method.
- *
- *
- * @author Mark Matthews
- * @version $Id$
- *
- * @see ResultSetMetaData
- * @see java.sql.ResultSet
- */
-public class ResultSetImpl implements ResultSetInternalMethods {
-
- private static final Constructor JDBC_4_RS_4_ARG_CTOR;
- private static final Constructor JDBC_4_RS_6_ARG_CTOR;;
- private static final Constructor JDBC_4_UPD_RS_6_ARG_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_RS_4_ARG_CTOR = Class.forName(
- "com.mysql.jdbc.JDBC4ResultSet").getConstructor(
- new Class[] { Long.TYPE, Long.TYPE,
- ConnectionImpl.class,
- com.mysql.jdbc.StatementImpl.class });
- JDBC_4_RS_6_ARG_CTOR = Class.forName(
- "com.mysql.jdbc.JDBC4ResultSet").getConstructor(
- new Class[] { String.class, Field[].class,
- RowData.class,
- ConnectionImpl.class,
- com.mysql.jdbc.StatementImpl.class });
- JDBC_4_UPD_RS_6_ARG_CTOR = Class.forName(
- "com.mysql.jdbc.JDBC4UpdatableResultSet")
- .getConstructor(
- new Class[] { String.class, Field[].class,
- RowData.class,
- ConnectionImpl.class,
- com.mysql.jdbc.StatementImpl.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_RS_4_ARG_CTOR = null;
- JDBC_4_RS_6_ARG_CTOR = null;
- JDBC_4_UPD_RS_6_ARG_CTOR = null;
- }
- }
-
- /**
- * Epsillon between Float.MIN_VALUE and the double representation of said value.
- */
- protected static final double MIN_DIFF_PREC = Float.parseFloat(Float.toString(Float.MIN_VALUE))
- - Double.parseDouble(Float.toString(Float.MIN_VALUE));
-
- /**
- * Epsillon between Float.MAX_VALUE and the double representation of said value.
- */
- protected static final double MAX_DIFF_PREC = Float.parseFloat(Float.toString(Float.MAX_VALUE))
- - Double.parseDouble(Float.toString(Float.MAX_VALUE));
-
- /** Counter used to generate IDs for profiling. */
- protected static int resultCounter = 1;
-
- /**
- * Converts the given value as a java long, to an 'unsigned' long, using the
- * java.math.BigInteger class.
- */
- protected static BigInteger convertLongToUlong(long longVal) {
- byte[] asBytes = new byte[8];
- asBytes[7] = (byte) (longVal & 0xff);
- asBytes[6] = (byte) (longVal >>> 8);
- asBytes[5] = (byte) (longVal >>> 16);
- asBytes[4] = (byte) (longVal >>> 24);
- asBytes[3] = (byte) (longVal >>> 32);
- asBytes[2] = (byte) (longVal >>> 40);
- asBytes[1] = (byte) (longVal >>> 48);
- asBytes[0] = (byte) (longVal >>> 56);
-
- return new BigInteger(1, asBytes);
- }
-
- /** The catalog that was in use when we were created */
- protected String catalog = null;
-
- /** Map column names (and all of their permutations) to column indices */
- protected Map columnLabelToIndex = null;
-
- /** The above map is a case-insensitive tree-map, it can be slow, this caches
- * lookups into that map, because the other alternative is to create new
- * object instances for every call to findColumn()....
- */
- protected Map columnToIndexCache = null;
-
- /** Keep track of columns accessed */
- protected boolean[] columnUsed = null;
-
- /** The Connection instance that created us */
- protected ConnectionImpl connection; // The connection that
- // created us
-
- protected long connectionId = 0;
-
- /** The current row #, -1 == before start of result set */
- protected int currentRow = -1; // Cursor to current row;
-
- TimeZone defaultTimeZone;
-
- /** Are we in the middle of doing updates to the current row? */
- protected boolean doingUpdates = false;
-
- protected ProfilerEventHandler eventSink = null;
-
- Calendar fastDateCal = null;
-
- /** The direction to fetch rows (always FETCH_FORWARD) */
- protected int fetchDirection = FETCH_FORWARD;
-
- /** The number of rows to fetch in one go... */
- protected int fetchSize = 0;
-
- /** The fields for this result set */
- protected Field[] fields; // The fields
-
- /**
- * First character of the query that created this result set...Used to
- * determine whether or not to parse server info messages in certain
- * circumstances.
- */
- protected char firstCharOfQuery;
-
- /** Map of fully-specified column names to column indices */
- protected Map fullColumnNameToIndex = null;
-
- protected Map columnNameToIndex = null;
-
- protected boolean hasBuiltIndexMapping = false;
-
- /**
- * Is the data stored as strings (default) or natively (which is the case
- * with results from PrepStmts)
- */
- protected boolean isBinaryEncoded = false;
-
- /** Has this result set been closed? */
- protected boolean isClosed = false;
-
- protected ResultSetInternalMethods nextResultSet = null;
-
- /** Are we on the insert row? */
- protected boolean onInsertRow = false;
-
- /** The statement that created us */
- protected com.mysql.jdbc.StatementImpl owningStatement;
-
- /**
- * StackTrace generated where ResultSet was created... used when profiling
- */
- protected Throwable pointOfOrigin;
-
- /** Are we tracking items for profileSql? */
- protected boolean profileSql = false;
-
- /**
- * Do we actually contain rows, or just information about
- * UPDATE/INSERT/DELETE?
- */
- protected boolean reallyResult = false;
-
- /** The id (used when profiling) to identify us */
- protected int resultId;
-
- /** Are we read-only or updatable? */
- protected int resultSetConcurrency = 0;
-
- /** Are we scroll-sensitive/insensitive? */
- protected int resultSetType = 0;
-
- /** The actual rows */
- protected RowData rowData; // The results
-
- /**
- * Any info message from the server that was created while generating this
- * result set (if 'info parsing' is enabled for the connection).
- */
- protected String serverInfo = null;
-
- PreparedStatement statementUsedForFetchingRows;
-
- /** Pointer to current row data */
- protected ResultSetRow thisRow = null; // Values for current row
-
- // These are longs for
- // recent versions of the MySQL server.
- //
- // They get reduced to ints via the JDBC API,
- // but can be retrieved through a MySQLStatement
- // in their entirety.
- //
-
- /** How many rows were affected by UPDATE/INSERT/DELETE? */
- protected long updateCount;
-
- /** Value generated for AUTO_INCREMENT columns */
- protected long updateId = -1;
-
- private boolean useStrictFloatingPoint = false;
-
- protected boolean useUsageAdvisor = false;
-
- /** The warning chain */
- protected java.sql.SQLWarning warningChain = null;
-
- /** Did the previous value retrieval find a NULL? */
- protected boolean wasNullFlag = false;
-
- protected java.sql.Statement wrapperStatement;
-
- protected boolean retainOwningStatement;
-
- protected Calendar gmtCalendar = null;
-
- protected boolean useFastDateParsing = false;
-
- private boolean padCharsWithSpace = false;
-
- private boolean jdbcCompliantTruncationForReads;
-
- private boolean useFastIntParsing = true;
- private boolean useColumnNamesInFindColumn;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- protected final static char[] EMPTY_SPACE = new char[255];
-
- static {
- for (int i = 0; i < EMPTY_SPACE.length; i++) {
- EMPTY_SPACE[i] = ' ';
- }
- }
-
- protected static ResultSetImpl getInstance(long updateCount, long updateID,
- ConnectionImpl conn, StatementImpl creatorStmt) throws SQLException {
- if (!Util.isJdbc4()) {
- return new ResultSetImpl(updateCount, updateID, conn, creatorStmt);
- }
-
- return (ResultSetImpl) Util.handleNewInstance(JDBC_4_RS_4_ARG_CTOR,
- new Object[] { Constants.longValueOf(updateCount), Constants.longValueOf(updateID), conn,
- creatorStmt}, conn.getExceptionInterceptor());
- }
-
- /**
- * Creates a result set instance that represents a query result -- We need
- * to provide factory-style methods so we can support both JDBC3 (and older)
- * and JDBC4 runtimes, otherwise the class verifier complains when it tries
- * to load JDBC4-only interface classes that are present in JDBC4 method
- * signatures.
- */
-
- protected static ResultSetImpl getInstance(String catalog, Field[] fields,
- RowData tuples, ConnectionImpl conn, StatementImpl creatorStmt,
- boolean isUpdatable) throws SQLException {
- if (!Util.isJdbc4()) {
- if (!isUpdatable) {
- return new ResultSetImpl(catalog, fields, tuples, conn, creatorStmt);
- }
-
- return new UpdatableResultSet(catalog, fields, tuples, conn,
- creatorStmt);
- }
-
- if (!isUpdatable) {
- return (ResultSetImpl) Util
- .handleNewInstance(JDBC_4_RS_6_ARG_CTOR, new Object[] {
- catalog, fields, tuples, conn, creatorStmt }, conn.getExceptionInterceptor());
- }
-
- return (ResultSetImpl) Util.handleNewInstance(JDBC_4_UPD_RS_6_ARG_CTOR,
- new Object[] { catalog, fields, tuples, conn, creatorStmt }, conn.getExceptionInterceptor());
- }
-
- /**
- * Create a result set for an executeUpdate statement.
- *
- * @param updateCount
- * the number of rows affected by the update
- * @param updateID
- * the autoincrement value (if any)
- * @param conn
- * DOCUMENT ME!
- * @param creatorStmt
- * DOCUMENT ME!
- */
- public ResultSetImpl(long updateCount, long updateID, ConnectionImpl conn,
- StatementImpl creatorStmt) {
- this.updateCount = updateCount;
- this.updateId = updateID;
- this.reallyResult = false;
- this.fields = new Field[0];
-
- this.connection = conn;
- this.owningStatement = creatorStmt;
-
- this.exceptionInterceptor = this.connection.getExceptionInterceptor();
-
- this.retainOwningStatement = false;
-
- if (this.connection != null) {
- this.retainOwningStatement =
- this.connection.getRetainStatementAfterResultSetClose();
-
- this.connectionId = this.connection.getId();
- this.serverTimeZoneTz = this.connection.getServerTimezoneTZ();
- this.padCharsWithSpace = this.connection.getPadCharsWithSpace();
- }
-
- useLegacyDatetimeCode = this.connection.getUseLegacyDatetimeCode();
- }
-
- /**
- * Creates a new ResultSet object.
- *
- * @param catalog
- * the database in use when we were created
- * @param fields
- * an array of Field objects (basically, the ResultSet MetaData)
- * @param tuples
- * actual row data
- * @param conn
- * the Connection that created us.
- * @param creatorStmt
- * DOCUMENT ME!
- *
- * @throws SQLException
- * if an error occurs
- */
- public ResultSetImpl(String catalog, Field[] fields, RowData tuples,
- ConnectionImpl conn, StatementImpl creatorStmt) throws SQLException {
- this.connection = conn;
-
- this.retainOwningStatement = false;
-
- if (this.connection != null) {
- this.useStrictFloatingPoint = this.connection
- .getStrictFloatingPoint();
- this.setDefaultTimeZone(this.connection.getDefaultTimeZone());
- this.connectionId = this.connection.getId();
- this.useFastDateParsing = this.connection.getUseFastDateParsing();
- this.profileSql = this.connection.getProfileSql();
- this.retainOwningStatement =
- this.connection.getRetainStatementAfterResultSetClose();
- this.jdbcCompliantTruncationForReads = this.connection.getJdbcCompliantTruncationForReads();
- this.useFastIntParsing = this.connection.getUseFastIntParsing();
- this.serverTimeZoneTz = this.connection.getServerTimezoneTZ();
- this.padCharsWithSpace = this.connection.getPadCharsWithSpace();
- }
-
- this.owningStatement = creatorStmt;
-
- this.catalog = catalog;
-
- this.fields = fields;
- this.rowData = tuples;
- this.updateCount = this.rowData.size();
-
- if (Driver.DEBUG) {
- System.out.println(Messages.getString("ResultSet.Retrieved__1")
- + this.updateCount + " rows"); //$NON-NLS-1$
- }
-
- this.reallyResult = true;
-
- // Check for no results
- if (this.rowData.size() > 0) {
- if (this.updateCount == 1) {
- if (this.thisRow == null) {
- this.rowData.close(); // empty result set
- this.updateCount = -1;
- }
- }
- } else {
- this.thisRow = null;
- }
-
- this.rowData.setOwner(this);
-
- if (this.fields != null) {
- initializeWithMetadata();
- } // else called by Connection.initializeResultsMetadataFromCache() when cached
- useLegacyDatetimeCode = this.connection.getUseLegacyDatetimeCode();
-
- this.useColumnNamesInFindColumn = this.connection.getUseColumnNamesInFindColumn();
-
- setRowPositionValidity();
- }
-
- public void initializeWithMetadata() throws SQLException {
- this.rowData.setMetadata(this.fields);
-
- this.columnToIndexCache = new HashMap();
-
- if (this.profileSql || this.connection.getUseUsageAdvisor()) {
- this.columnUsed = new boolean[this.fields.length];
- this.pointOfOrigin = new Throwable();
- this.resultId = resultCounter++;
- this.useUsageAdvisor = this.connection.getUseUsageAdvisor();
- this.eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);
- }
-
- if (this.connection.getGatherPerformanceMetrics()) {
- this.connection.incrementNumberOfResultSetsCreated();
-
- Map tableNamesMap = new HashMap();
-
- for (int i = 0; i < this.fields.length; i++) {
- Field f = this.fields[i];
-
- String tableName = f.getOriginalTableName();
-
- if (tableName == null) {
- tableName = f.getTableName();
- }
-
- if (tableName != null) {
- if (this.connection.lowerCaseTableNames()) {
- tableName = tableName.toLowerCase(); // on windows, table
- // names are not case-sens.
- }
-
- tableNamesMap.put(tableName, null);
- }
- }
-
- this.connection.reportNumberOfTablesAccessed(tableNamesMap.size());
- }
- }
-
- private synchronized void createCalendarIfNeeded() {
- if (this.fastDateCal == null) {
- this.fastDateCal = new GregorianCalendar(Locale.US);
- this.fastDateCal.setTimeZone(this.getDefaultTimeZone());
- }
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Move to an absolute row number in the result set.
- *
- *
- *
- * If row is positive, moves to an absolute row with respect to the
- * beginning of the result set. The first row is row 1, the second is row 2,
- * etc.
- *
- *
- *
- * If row is negative, moves to an absolute row position with respect to the
- * end of result set. For example, calling absolute(-1) positions the cursor
- * on the last row, absolute(-2) indicates the next-to-last row, etc.
- *
- *
- *
- * An attempt to position the cursor beyond the first/last row in the result
- * set, leaves the cursor before/after the first/last row, respectively.
- *
- *
- *
- * Note: Calling absolute(1) is the same as calling first(). Calling
- * absolute(-1) is the same as calling last().
- *
- *
- * @param row
- * the row number to move to
- *
- * @return true if on the result set, false if off.
- *
- * @exception SQLException
- * if a database-access error occurs, or row is 0, or result
- * set type is TYPE_FORWARD_ONLY.
- */
- public boolean absolute(int row) throws SQLException {
- checkClosed();
-
- boolean b;
-
- if (this.rowData.size() == 0) {
- b = false;
- } else {
- if (row == 0) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Cannot_absolute_position_to_row_0_110"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- if (this.onInsertRow) {
- this.onInsertRow = false;
- }
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- }
-
- if (this.thisRow != null) {
- this.thisRow.closeOpenStreams();
- }
-
- if (row == 1) {
- b = first();
- } else if (row == -1) {
- b = last();
- } else if (row > this.rowData.size()) {
- afterLast();
- b = false;
- } else {
- if (row < 0) {
- // adjust to reflect after end of result set
- int newRowPosition = this.rowData.size() + row + 1;
-
- if (newRowPosition <= 0) {
- beforeFirst();
- b = false;
- } else {
- b = absolute(newRowPosition);
- }
- } else {
- row--; // adjust for index difference
- this.rowData.setCurrentRow(row);
- this.thisRow = this.rowData.getAt(row);
- b = true;
- }
- }
- }
-
- setRowPositionValidity();
-
- return b;
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the end of the result set, just after the last row. Has no
- * effect if the result set contains no rows.
- *
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY.
- */
- public void afterLast() throws SQLException {
- checkClosed();
-
- if (this.onInsertRow) {
- this.onInsertRow = false;
- }
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- }
-
- if (this.thisRow != null) {
- this.thisRow.closeOpenStreams();
- }
-
- if (this.rowData.size() != 0) {
- this.rowData.afterLast();
- this.thisRow = null;
- }
-
- setRowPositionValidity();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the front of the result set, just before the first row. Has no
- * effect if the result set contains no rows.
- *
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY
- */
- public void beforeFirst() throws SQLException {
- checkClosed();
-
- if (this.onInsertRow) {
- this.onInsertRow = false;
- }
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- }
-
- if (this.rowData.size() == 0) {
- return;
- }
-
- if (this.thisRow != null) {
- this.thisRow.closeOpenStreams();
- }
-
- this.rowData.beforeFirst();
- this.thisRow = null;
-
- setRowPositionValidity();
- }
-
- // ---------------------------------------------------------------------
- // Traversal/Positioning
- // ---------------------------------------------------------------------
-
- /**
- * Builds a hash between column names and their indices for fast retrieval.
- */
- public void buildIndexMapping() throws SQLException {
- int numFields = this.fields.length;
- this.columnLabelToIndex = new TreeMap(String.CASE_INSENSITIVE_ORDER);
- this.fullColumnNameToIndex = new TreeMap(String.CASE_INSENSITIVE_ORDER);
- this.columnNameToIndex = new TreeMap(String.CASE_INSENSITIVE_ORDER);
-
- // We do this in reverse order, so that the 'first' column
- // with a given name ends up as the final mapping in the
- // hashtable...
- //
- // Quoting the JDBC Spec:
- //
- // "Column names used as input to getter
- // methods are case insensitive. When a getter method is called with a
- // column
- // name and several columns have the same name, the value of the first
- // matching column will be returned. "
- //
- for (int i = numFields - 1; i >= 0; i--) {
- Integer index = Constants.integerValueOf(i);
- String columnName = this.fields[i].getOriginalName();
- String columnLabel = this.fields[i].getName();
- String fullColumnName = this.fields[i].getFullName();
-
- if (columnLabel != null) {
- this.columnLabelToIndex.put(columnLabel, index);
- }
-
- if (fullColumnName != null) {
- this.fullColumnNameToIndex.put(fullColumnName, index);
- }
-
- if (columnName != null) {
- this.columnNameToIndex.put(columnName, index);
- }
- }
-
- // set the flag to prevent rebuilding...
- this.hasBuiltIndexMapping = true;
- }
-
- /**
- * JDBC 2.0 The cancelRowUpdates() method may be called after calling an
- * updateXXX() method(s) and before calling updateRow() to rollback the
- * updates made to a row. If no updates have been made or updateRow() has
- * already been called, then this method has no effect.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row.
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void cancelRowUpdates() throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * Ensures that the result set is not closed
- *
- * @throws SQLException
- * if the result set is closed
- */
- protected final void checkClosed() throws SQLException {
- if (this.isClosed) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Operation_not_allowed_after_ResultSet_closed_144"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- /**
- * Checks if columnIndex is within the number of columns in this result set.
- *
- * @param columnIndex
- * the index to check
- *
- * @throws SQLException
- * if the index is out of bounds
- */
- protected final void checkColumnBounds(int columnIndex) throws SQLException {
- if ((columnIndex < 1)) {
- throw SQLError.createSQLException(Messages.getString(
- "ResultSet.Column_Index_out_of_range_low", new Object[] {
- Constants.integerValueOf(columnIndex),
- Constants.integerValueOf(this.fields.length) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- } else if ((columnIndex > this.fields.length)) {
- throw SQLError.createSQLException(Messages.getString(
- "ResultSet.Column_Index_out_of_range_high", new Object[] {
- Constants.integerValueOf(columnIndex),
- Constants.integerValueOf(this.fields.length) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (this.profileSql || this.useUsageAdvisor) {
- this.columnUsed[columnIndex - 1] = true;
- }
- }
-
- /**
- * Ensures that the cursor is positioned on a valid row and that the result
- * set is not closed
- *
- * @throws SQLException
- * if the result set is not in a valid state for traversal
- */
- protected void checkRowPos() throws SQLException {
- checkClosed();
-
- if (!this.onValidRow) {
- throw SQLError.createSQLException(this.invalidRowReason,
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- private boolean onValidRow = false;
- private String invalidRowReason = null;
- protected boolean useLegacyDatetimeCode;
- private TimeZone serverTimeZoneTz;
-
- private void setRowPositionValidity() throws SQLException {
- if (!this.rowData.isDynamic() && (this.rowData.size() == 0)) {
- this.invalidRowReason = Messages
- .getString("ResultSet.Illegal_operation_on_empty_result_set");//$NON-NLS-1$
- this.onValidRow = false;
- } else if (this.rowData.isBeforeFirst()) {
- this.invalidRowReason = Messages
- .getString("ResultSet.Before_start_of_result_set_146"); //$NON-NLS-1$
- this.onValidRow = false;
- } else if (this.rowData.isAfterLast()) {
- this.invalidRowReason = Messages
- .getString("ResultSet.After_end_of_result_set_148"); //$NON-NLS-1$
- this.onValidRow = false;
- } else {
- this.onValidRow = true;
- this.invalidRowReason = null;
- }
- }
-
- /**
- * We can't do this ourselves, otherwise the contract for
- * Statement.getMoreResults() won't work correctly.
- */
- public void clearNextResult() {
- this.nextResultSet = null;
- }
-
- /**
- * After this call, getWarnings returns null until a new warning is reported
- * for this ResultSet
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void clearWarnings() throws SQLException {
- this.warningChain = null;
- }
-
- /**
- * In some cases, it is desirable to immediately release a ResultSet
- * database and JDBC resources instead of waiting for this to happen when it
- * is automatically closed. The close method provides this immediate
- * release.
- *
- *
- * Note: A ResultSet is automatically closed by the Statement the
- * Statement that generated it when that Statement is closed, re-executed,
- * or is used to retrieve the next result from a sequence of multiple
- * results. A ResultSet is also automatically closed when it is garbage
- * collected.
- *
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void close() throws SQLException {
- realClose(true);
- }
-
- /**
- * @return
- */
- private int convertToZeroWithEmptyCheck() throws SQLException {
- if (this.connection.getEmptyStringsConvertToZero()) {
- return 0;
- }
-
- throw SQLError.createSQLException("Can't convert empty string ('') to numeric",
- SQLError.SQL_STATE_INVALID_CHARACTER_VALUE_FOR_CAST, getExceptionInterceptor());
- }
-
- private String convertToZeroLiteralStringWithEmptyCheck()
- throws SQLException {
-
- if (this.connection.getEmptyStringsConvertToZero()) {
- return "0";
- }
-
- throw SQLError.createSQLException("Can't convert empty string ('') to numeric",
- SQLError.SQL_STATE_INVALID_CHARACTER_VALUE_FOR_CAST, getExceptionInterceptor());
- }
-
- //
- // Note, row data is linked between these two result sets
- //
- public ResultSetInternalMethods copy() throws SQLException {
- ResultSetInternalMethods rs = ResultSetImpl.getInstance(this.catalog, this.fields, this.rowData,
- this.connection, this.owningStatement, false); // note, doesn't work for updatable result sets
-
- return rs;
- }
-
- public void redefineFieldsForDBMD(Field[] f) {
- this.fields = f;
-
- for (int i = 0; i < this.fields.length; i++) {
- this.fields[i].setUseOldNameMetadata(true);
- this.fields[i].setConnection(this.connection);
- }
- }
-
- public void populateCachedMetaData(CachedResultSetMetaData cachedMetaData)
- throws SQLException {
- cachedMetaData.fields = this.fields;
- cachedMetaData.columnNameToIndex = this.columnLabelToIndex;
- cachedMetaData.fullColumnNameToIndex = this.fullColumnNameToIndex;
- cachedMetaData.metadata = getMetaData();
- }
-
- public void initializeFromCachedMetaData(CachedResultSetMetaData cachedMetaData) {
- this.fields = cachedMetaData.fields;
- this.columnLabelToIndex = cachedMetaData.columnNameToIndex;
- this.fullColumnNameToIndex = cachedMetaData.fullColumnNameToIndex;
- this.hasBuiltIndexMapping = true;
- }
-
-
- /**
- * JDBC 2.0 Delete the current row from the result set and the underlying
- * database. Cannot be called when on the insert row.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row.
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void deleteRow() throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * @param columnIndex
- * @param stringVal
- * @param mysqlType
- * @return
- * @throws SQLException
- */
- private String extractStringFromNativeColumn(int columnIndex, int mysqlType)
- throws SQLException {
- int columnIndexMinusOne = columnIndex - 1;
-
- this.wasNullFlag = false;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- String encoding = this.fields[columnIndexMinusOne]
- .getCharacterSet();
-
- return this.thisRow.getString(columnIndex - 1, encoding, this.connection);
- }
-
- protected synchronized Date fastDateCreate(Calendar cal, int year, int month,
- int day) {
- if (this.useLegacyDatetimeCode) {
- return TimeUtil.fastDateCreate(year, month, day, cal);
- }
-
- if (cal == null) {
- createCalendarIfNeeded();
- cal = this.fastDateCal;
- }
-
- boolean useGmtMillis = this.connection.getUseGmtMillisForDatetimes();
-
- return TimeUtil.fastDateCreate(useGmtMillis,
- useGmtMillis ? getGmtCalendar() : cal,
- cal, year, month, day);
- }
-
- protected synchronized Time fastTimeCreate(Calendar cal, int hour,
- int minute, int second) throws SQLException {
- if (!this.useLegacyDatetimeCode) {
- return TimeUtil.fastTimeCreate(hour, minute, second, cal, getExceptionInterceptor());
- }
-
- if (cal == null) {
- createCalendarIfNeeded();
- cal = this.fastDateCal;
- }
-
- return TimeUtil.fastTimeCreate(cal, hour, minute, second, getExceptionInterceptor());
- }
-
- protected synchronized Timestamp fastTimestampCreate(Calendar cal, int year,
- int month, int day, int hour, int minute, int seconds,
- int secondsPart) {
- if (!this.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(cal.getTimeZone(), year, month, day, hour,
- minute, seconds, secondsPart);
- }
-
- if (cal == null) {
- createCalendarIfNeeded();
- cal = this.fastDateCal;
- }
-
- boolean useGmtMillis = this.connection.getUseGmtMillisForDatetimes();
-
- return TimeUtil.fastTimestampCreate(useGmtMillis,
- useGmtMillis ? getGmtCalendar() : null,
- cal, year, month, day, hour,
- minute, seconds, secondsPart);
- }
-
- /*
- /**
- * Required by JDBC spec
- */
- /*
- protected void finalize() throws Throwable {
- if (!this.isClosed) {
- realClose(false);
- }
- }
- */
-
- // --------------------------JDBC 2.0-----------------------------------
- // ---------------------------------------------------------------------
- // Getter's and Setter's
- // ---------------------------------------------------------------------
-
-
- /*
- * [For JDBC-3.0 and older - http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html#findColumn(java.lang.String)]
- * Map a ResultSet column name to a ResultSet column index
- *
- * @param columnName
- * the name of the column
- *
- * @return the column index
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * [For JDBC-4.0 and newer - http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html#findColumn(java.lang.String)]
- *
- * Maps the given ResultSet column label to its ResultSet column index.
- *
- * @param columnLabel
- * the label for the column specified with the SQL AS clause. If the
- * SQL AS clause was not specified, then the label is the name of the column
- *
- * @return the column index of the given column name
- */
- public synchronized int findColumn(String columnName) throws SQLException {
- Integer index;
-
- checkClosed();
-
- if (!this.hasBuiltIndexMapping) {
- buildIndexMapping();
- }
-
- index = (Integer) this.columnToIndexCache.get(columnName);
-
- if (index != null) {
- return index.intValue() + 1;
- }
-
- index = (Integer) this.columnLabelToIndex.get(columnName);
-
- if (index == null && this.useColumnNamesInFindColumn) {
- index = (Integer) this.columnNameToIndex.get(columnName);
- }
-
- if (index == null) {
- index = (Integer) this.fullColumnNameToIndex.get(columnName);
- }
-
- if (index != null) {
- this.columnToIndexCache.put(columnName, index);
-
- return index.intValue() + 1;
- }
-
- // Try this inefficient way, now
-
- for (int i = 0; i < this.fields.length; i++) {
- if (this.fields[i].getName().equalsIgnoreCase(columnName)) {
- return i + 1;
- } else if (this.fields[i].getFullName()
- .equalsIgnoreCase(columnName)) {
- return i + 1;
- }
- }
-
- throw SQLError.createSQLException(Messages.getString("ResultSet.Column____112")
- + columnName
- + Messages.getString("ResultSet.___not_found._113"), //$NON-NLS-1$ //$NON-NLS-2$
- SQLError.SQL_STATE_COLUMN_NOT_FOUND, getExceptionInterceptor());
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the first row in the result set.
- *
- *
- * @return true if on a valid row, false if no rows in the result set.
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY.
- */
- public boolean first() throws SQLException {
- checkClosed();
-
- boolean b = true;
-
- if (this.rowData.isEmpty()) {
- b = false;
- } else {
-
- if (this.onInsertRow) {
- this.onInsertRow = false;
- }
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- }
-
- this.rowData.beforeFirst();
- this.thisRow = this.rowData.next();
- }
-
- setRowPositionValidity();
-
- return b;
- }
-
- /**
- * JDBC 2.0 Get an array column.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing an SQL array
- *
- * @throws SQLException
- * if a database error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- public java.sql.Array getArray(int i) throws SQLException {
- checkColumnBounds(i);
-
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Get an array column.
- *
- * @param colName
- * the column name
- *
- * @return an object representing an SQL array
- *
- * @throws SQLException
- * if a database error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- public java.sql.Array getArray(String colName) throws SQLException {
- return getArray(findColumn(colName));
- }
-
- /**
- * A column value can be retrieved as a stream of ASCII characters and then
- * read in chunks from the stream. This method is particulary suitable for
- * retrieving large LONGVARCHAR values. The JDBC driver will do any
- * necessary conversion from the database format into ASCII.
- *
- *
- * Note: All the data in the returned stream must be read prior to
- * getting the value of any other column. The next call to a get method
- * implicitly closes the stream. Also, a stream may return 0 for available()
- * whether there is data available or not.
- *
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return a Java InputStream that delivers the database column value as a
- * stream of one byte ASCII characters. If the value is SQL NULL
- * then the result is null
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see getBinaryStream
- */
- public InputStream getAsciiStream(int columnIndex) throws SQLException {
- checkRowPos();
-
- if (!this.isBinaryEncoded) {
- return getBinaryStream(columnIndex);
- }
-
- return getNativeBinaryStream(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public InputStream getAsciiStream(String columnName) throws SQLException {
- return getAsciiStream(findColumn(columnName));
- }
-
- /**
- * JDBC 2.0 Get the value of a column in the current row as a
- * java.math.BigDecimal object.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return the column value (full precision); if the value is SQL NULL, the
- * result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- if (!this.isBinaryEncoded) {
- String stringVal = getString(columnIndex);
- BigDecimal val;
-
- if (stringVal != null) {
- if (stringVal.length() == 0) {
-
- val = new BigDecimal(
- convertToZeroLiteralStringWithEmptyCheck());
-
- return val;
- }
-
- try {
- val = new BigDecimal(stringVal);
-
- return val;
- } catch (NumberFormatException ex) {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Bad_format_for_BigDecimal",
- new Object[] { stringVal,
- Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- return null;
- }
-
- return getNativeBigDecimal(columnIndex);
- }
-
- /**
- * Get the value of a column in the current row as a java.math.BigDecimal
- * object
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- * @param scale
- * the number of digits to the right of the decimal
- *
- * @return the column value; if the value is SQL NULL, null
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @deprecated
- */
- public BigDecimal getBigDecimal(int columnIndex, int scale)
- throws SQLException {
- if (!this.isBinaryEncoded) {
- String stringVal = getString(columnIndex);
- BigDecimal val;
-
- if (stringVal != null) {
- if (stringVal.length() == 0) {
- val = new BigDecimal(
- convertToZeroLiteralStringWithEmptyCheck());
-
- try {
- return val.setScale(scale);
- } catch (ArithmeticException ex) {
- try {
- return val
- .setScale(scale, BigDecimal.ROUND_HALF_UP);
- } catch (ArithmeticException arEx) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Bad_format_for_BigDecimal", //$NON-NLS-1$
- new Object[] {stringVal, new Integer(columnIndex)}),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
- }
-
- try {
- val = new BigDecimal(stringVal);
- } catch (NumberFormatException ex) {
- if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
-
- val = new BigDecimal(valueAsLong);
- } else {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Bad_format_for_BigDecimal",
- new Object[] { Constants.integerValueOf(columnIndex),
- stringVal }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- try {
- return val.setScale(scale);
- } catch (ArithmeticException ex) {
- try {
- return val.setScale(scale, BigDecimal.ROUND_HALF_UP);
- } catch (ArithmeticException arithEx) {
- throw SQLError.createSQLException(Messages.getString(
- "ResultSet.Bad_format_for_BigDecimal",
- new Object[] { Constants.integerValueOf(columnIndex),
- stringVal }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
- }
-
- return null;
- }
-
- return getNativeBigDecimal(columnIndex, scale);
- }
-
- /**
- * JDBC 2.0 Get the value of a column in the current row as a
- * java.math.BigDecimal object.
- *
- * @param columnName
- * the name of the column to retrieve the value from
- *
- * @return the BigDecimal value in the column
- *
- * @throws SQLException
- * if an error occurs
- */
- public BigDecimal getBigDecimal(String columnName) throws SQLException {
- return getBigDecimal(findColumn(columnName));
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- * @param scale
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- *
- * @deprecated
- */
- public BigDecimal getBigDecimal(String columnName, int scale)
- throws SQLException {
- return getBigDecimal(findColumn(columnName), scale);
- }
-
- private final BigDecimal getBigDecimalFromString(String stringVal,
- int columnIndex, int scale) throws SQLException {
- BigDecimal bdVal;
-
- if (stringVal != null) {
- if (stringVal.length() == 0) {
- bdVal = new BigDecimal(convertToZeroLiteralStringWithEmptyCheck());
-
- try {
- return bdVal.setScale(scale);
- } catch (ArithmeticException ex) {
- try {
- return bdVal.setScale(scale, BigDecimal.ROUND_HALF_UP);
- } catch (ArithmeticException arEx) {
- throw new SQLException(Messages
- .getString("ResultSet.Bad_format_for_BigDecimal",
- new Object[] { stringVal,
- Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
- }
- }
- }
-
- try {
- try {
- return new BigDecimal(stringVal).setScale(scale);
- } catch (ArithmeticException ex) {
- try {
- return new BigDecimal(stringVal).setScale(scale,
- BigDecimal.ROUND_HALF_UP);
- } catch (ArithmeticException arEx) {
- throw new SQLException(Messages
- .getString("ResultSet.Bad_format_for_BigDecimal",
- new Object[] { stringVal,
- Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
- }
- }
- } catch (NumberFormatException ex) {
- if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
-
- try {
- return new BigDecimal(valueAsLong).setScale(scale);
- } catch (ArithmeticException arEx1) {
- try {
- return new BigDecimal(valueAsLong).setScale(scale,
- BigDecimal.ROUND_HALF_UP);
- } catch (ArithmeticException arEx2) {
- throw new SQLException(Messages
- .getString("ResultSet.Bad_format_for_BigDecimal",
- new Object[] { stringVal,
- Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
- }
- }
- }
-
- if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_TINY &&
- this.connection.getTinyInt1isBit() && this.fields[columnIndex - 1].getLength() == 1) {
- return new BigDecimal(stringVal.equalsIgnoreCase("true") ? 1 : 0).setScale(scale);
- }
-
- throw new SQLException(Messages
- .getString("ResultSet.Bad_format_for_BigDecimal",
- new Object[] { stringVal,
- Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
- }
- }
-
- return null;
- }
-
- /**
- * A column value can also be retrieved as a binary stream. This method is
- * suitable for retrieving LONGVARBINARY values.
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return a Java InputStream that delivers the database column value as a
- * stream of bytes. If the value is SQL NULL, then the result is
- * null
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see getAsciiStream
- * @see getUnicodeStream
- */
- public InputStream getBinaryStream(int columnIndex) throws SQLException {
- checkRowPos();
-
- if (!this.isBinaryEncoded) {
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return this.thisRow.getBinaryInputStream(columnIndexMinusOne);
- }
-
- return getNativeBinaryStream(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public InputStream getBinaryStream(String columnName) throws SQLException {
- return getBinaryStream(findColumn(columnName));
- }
-
- /**
- * JDBC 2.0 Get a BLOB column.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a BLOB
- *
- * @throws SQLException
- * if an error occurs.
- */
- public java.sql.Blob getBlob(int columnIndex) throws SQLException {
- if (!this.isBinaryEncoded) {
- checkRowPos();
-
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return null;
- }
-
- if (!this.connection.getEmulateLocators()) {
- return new Blob(this.thisRow.getColumnValue(columnIndexMinusOne), getExceptionInterceptor());
- }
-
- return new BlobFromLocator(this, columnIndex, getExceptionInterceptor());
- }
-
- return getNativeBlob(columnIndex);
- }
-
- /**
- * JDBC 2.0 Get a BLOB column.
- *
- * @param colName
- * the column name
- *
- * @return an object representing a BLOB
- *
- * @throws SQLException
- * if an error occurs.
- */
- public java.sql.Blob getBlob(String colName) throws SQLException {
- return getBlob(findColumn(colName));
- }
-
- /**
- * Get the value of a column in the current row as a Java boolean
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value, false for SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public boolean getBoolean(int columnIndex) throws SQLException {
-
- checkColumnBounds(columnIndex);
-
- //
- // MySQL 5.0 and newer have an actual BIT type,
- // so we need to check for that here...
- //
-
- int columnIndexMinusOne = columnIndex - 1;
-
- Field field = this.fields[columnIndexMinusOne];
-
- if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- return byteArrayToBoolean(columnIndexMinusOne);
- }
-
- this.wasNullFlag = false;
-
- int sqlType = field.getSQLType();
-
- switch (sqlType) {
- case Types.BOOLEAN:
- if (field.getMysqlType() == -1) { // from dbmd
- String stringVal = getString(columnIndex);
-
- return getBooleanFromString(stringVal, columnIndex);
- }
-
- long boolVal = getLong(columnIndex, false);
-
- return (boolVal == -1 || boolVal > 0);
- case Types.BIT:
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.DECIMAL:
- case Types.NUMERIC:
- case Types.REAL:
- case Types.FLOAT:
- case Types.DOUBLE:
- boolVal = getLong(columnIndex, false);
-
- return (boolVal == -1 || boolVal > 0);
- default:
- if (this.connection.getPedantic()) {
- // Table B-6 from JDBC spec
- switch (sqlType) {
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- case Types.CLOB:
- case Types.BLOB:
- case Types.ARRAY:
- case Types.REF:
- case Types.DATALINK:
- case Types.STRUCT:
- case Types.JAVA_OBJECT:
- throw SQLError.createSQLException("Required type conversion not allowed",
- SQLError.SQL_STATE_INVALID_CHARACTER_VALUE_FOR_CAST, getExceptionInterceptor());
- }
- }
-
- if (sqlType == Types.BINARY ||
- sqlType == Types.VARBINARY ||
- sqlType == Types.LONGVARBINARY ||
- sqlType == Types.BLOB) {
- return byteArrayToBoolean(columnIndexMinusOne);
- }
-
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getBoolean()", columnIndex,
- this.thisRow.getColumnValue(columnIndexMinusOne), this.fields[columnIndex],
- new int[] {
- MysqlDefs.FIELD_TYPE_BIT,
- MysqlDefs.FIELD_TYPE_DOUBLE,
- MysqlDefs.FIELD_TYPE_TINY,
- MysqlDefs.FIELD_TYPE_SHORT,
- MysqlDefs.FIELD_TYPE_LONG,
- MysqlDefs.FIELD_TYPE_LONGLONG,
- MysqlDefs.FIELD_TYPE_FLOAT });
- }
-
- String stringVal = getString(columnIndex);
-
- return getBooleanFromString(stringVal, columnIndex);
- }
- }
-
- private boolean byteArrayToBoolean(int columnIndexMinusOne) throws SQLException {
- Object value = this.thisRow.getColumnValue(columnIndexMinusOne);
-
- if (value == null) {
- this.wasNullFlag = true;
-
- return false;
- }
-
- this.wasNullFlag = false;
-
- if (((byte[]) value).length == 0) {
- return false;
- }
-
- byte boolVal = ((byte[]) value)[0];
-
- if (boolVal == (byte)'1') {
- return true;
- } else if (boolVal == (byte)'0') {
- return false;
- }
-
- return (boolVal == -1 || boolVal > 0);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public boolean getBoolean(String columnName) throws SQLException {
- return getBoolean(findColumn(columnName));
- }
-
- private final boolean getBooleanFromString(String stringVal, int columnIndex)
- throws SQLException {
- if ((stringVal != null) && (stringVal.length() > 0)) {
- int c = Character.toLowerCase(stringVal.charAt(0));
-
- return ((c == 't') || (c == 'y') || (c == '1') || stringVal
- .equals("-1"));
- }
-
- return false;
- }
-
- /**
- * Get the value of a column in the current row as a Java byte.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public byte getByte(int columnIndex) throws SQLException {
- if (!this.isBinaryEncoded) {
- String stringVal = getString(columnIndex);
-
- if (this.wasNullFlag || (stringVal == null)) {
- return 0;
- }
-
- return getByteFromString(stringVal, columnIndex);
- }
-
- return getNativeByte(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public byte getByte(String columnName) throws SQLException {
- return getByte(findColumn(columnName));
- }
-
- private final byte getByteFromString(String stringVal, int columnIndex)
- throws SQLException {
-
- if (stringVal != null && stringVal.length() == 0) {
- return (byte) convertToZeroWithEmptyCheck();
- }
-
- //
- // JDK-6 doesn't like trailing whitespace
- //
- // Note this isn't a performance issue, other
- // than the iteration over the string, as String.trim()
- // will return a new string only if whitespace is present
- //
-
- if (stringVal == null) {
- return 0;
- }
-
- stringVal = stringVal.trim();
-
- try {
- int decimalIndex = stringVal.indexOf(".");
-
-
- if (decimalIndex != -1) {
- double valueAsDouble = Double.parseDouble(stringVal);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Byte.MIN_VALUE
- || valueAsDouble > Byte.MAX_VALUE) {
- throwRangeException(stringVal, columnIndex,
- Types.TINYINT);
- }
- }
-
- return (byte) valueAsDouble;
- }
-
- long valueAsLong = Long.parseLong(stringVal);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsLong < Byte.MIN_VALUE
- || valueAsLong > Byte.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsLong),
- columnIndex, Types.TINYINT);
- }
- }
-
- return (byte) valueAsLong;
- } catch (NumberFormatException NFE) {
- throw SQLError.createSQLException(
- Messages.getString("ResultSet.Value____173")
- + stringVal //$NON-NLS-1$
- + Messages
- .getString("ResultSet.___is_out_of_range_[-127,127]_174"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java byte array.
- *
- *
- * Be warned If the blob is huge, then you may run out of memory.
- *
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public byte[] getBytes(int columnIndex) throws SQLException {
- return getBytes(columnIndex, false);
- }
-
- protected byte[] getBytes(int columnIndex, boolean noConversion)
- throws SQLException {
- if (!this.isBinaryEncoded) {
- checkRowPos();
-
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return null;
- }
-
- return this.thisRow.getColumnValue(columnIndexMinusOne);
- }
-
- return getNativeBytes(columnIndex, noConversion);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public byte[] getBytes(String columnName) throws SQLException {
- return getBytes(findColumn(columnName));
- }
-
- private final byte[] getBytesFromString(String stringVal, int columnIndex)
- throws SQLException {
- if (stringVal != null) {
- return StringUtils.getBytes(stringVal, this.connection
- .getEncoding(), this.connection
- .getServerCharacterEncoding(), this.connection
- .parserKnowsUnicode(),
- this.connection, getExceptionInterceptor());
- }
-
- return null;
- }
-
- /**
- * Optimization to only use one calendar per-session, or calculate it for
- * each call, depending on user configuration
- */
- protected Calendar getCalendarInstanceForSessionOrNew() {
- if (this.connection != null) {
- return this.connection.getCalendarInstanceForSessionOrNew();
- } else {
- // punt, no connection around
- return new GregorianCalendar();
- }
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Get the value of a column in the current row as a java.io.Reader.
- *
- *
- * @param columnIndex
- * the column to get the value from
- *
- * @return the value in the column as a java.io.Reader.
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.io.Reader getCharacterStream(int columnIndex)
- throws SQLException {
- if (!this.isBinaryEncoded) {
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return this.thisRow.getReader(columnIndexMinusOne);
- }
-
- return getNativeCharacterStream(columnIndex);
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Get the value of a column in the current row as a java.io.Reader.
- *
- *
- * @param columnName
- * the column name to retrieve the value from
- *
- * @return the value as a java.io.Reader
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.io.Reader getCharacterStream(String columnName)
- throws SQLException {
- return getCharacterStream(findColumn(columnName));
- }
-
- private final java.io.Reader getCharacterStreamFromString(String stringVal,
- int columnIndex) throws SQLException {
- if (stringVal != null) {
- return new StringReader(stringVal);
- }
-
- return null;
- }
-
- /**
- * JDBC 2.0 Get a CLOB column.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a CLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.sql.Clob getClob(int i) throws SQLException {
- if (!this.isBinaryEncoded) {
- String asString = getStringForClob(i);
-
- if (asString == null) {
- return null;
- }
-
- return new com.mysql.jdbc.Clob(asString, getExceptionInterceptor());
- }
-
- return getNativeClob(i);
- }
-
- /**
- * JDBC 2.0 Get a CLOB column.
- *
- * @param colName
- * the column name
- *
- * @return an object representing a CLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.sql.Clob getClob(String colName) throws SQLException {
- return getClob(findColumn(colName));
- }
-
- private final java.sql.Clob getClobFromString(String stringVal,
- int columnIndex) throws SQLException {
- return new com.mysql.jdbc.Clob(stringVal, getExceptionInterceptor());
- }
-
- /**
- * JDBC 2.0 Return the concurrency of this result set. The concurrency used
- * is determined by the statement that created the result set.
- *
- * @return the concurrency type, CONCUR_READ_ONLY, etc.
- *
- * @throws SQLException
- * if a database-access error occurs
- */
- public int getConcurrency() throws SQLException {
- return (CONCUR_READ_ONLY);
- }
-
- /**
- * Get the name of the SQL cursor used by this ResultSet
- *
- *
- * In SQL, a result table is retrieved though a cursor that is named. The
- * current row of a result can be updated or deleted using a positioned
- * update/delete statement that references the cursor name.
- *
- *
- *
- * JDBC supports this SQL feature by providing the name of the SQL cursor
- * used by a ResultSet. The current row of a ResulSet is also the current
- * row of this SQL cursor.
- *
- *
- *
- * Note: If positioned update is not supported, a SQLException is
- * thrown.
- *
- *
- * @return the ResultSet's SQL cursor name.
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public String getCursorName() throws SQLException {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Positioned_Update_not_supported"),
- SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Date object
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value; null if SQL NULL
- *
- * @exception java.sql.SQLException
- * if a database access error occurs
- */
- public java.sql.Date getDate(int columnIndex) throws java.sql.SQLException {
- return getDate(columnIndex, null);
- }
-
- /**
- * JDBC 2.0 Get the value of a column in the current row as a java.sql.Date
- * object. Use the calendar to construct an appropriate millisecond value
- * for the Date, if the underlying database doesn't store timezone
- * information.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param cal
- * the calendar to use in constructing the date
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.Date getDate(int columnIndex, Calendar cal)
- throws SQLException {
- if (this.isBinaryEncoded) {
- return getNativeDate(columnIndex, cal);
- }
-
- if (!this.useFastDateParsing) {
- String stringVal = getStringInternal(columnIndex, false);
-
- if (stringVal == null) {
- return null;
- }
-
- return getDateFromString(stringVal, columnIndex, cal);
- }
-
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return this.thisRow.getDateFast(columnIndexMinusOne, this.connection, this, cal);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws java.sql.SQLException
- * DOCUMENT ME!
- */
- public java.sql.Date getDate(String columnName)
- throws java.sql.SQLException {
- return getDate(findColumn(columnName));
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Date object.
- * Use the calendar to construct an appropriate millisecond value for the
- * Date, if the underlying database doesn't store timezone information.
- *
- * @param columnName
- * is the SQL name of the column
- * @param cal
- * the calendar to use in constructing the date
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.Date getDate(String columnName, Calendar cal)
- throws SQLException {
- return getDate(findColumn(columnName), cal);
- }
-
- private final java.sql.Date getDateFromString(String stringVal,
- int columnIndex, Calendar targetCalendar) throws SQLException {
- int year = 0;
- int month = 0;
- int day = 0;
-
- try {
- this.wasNullFlag = false;
-
- if (stringVal == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- //
- // JDK-6 doesn't like trailing whitespace
- //
- // Note this isn't a performance issue, other
- // than the iteration over the string, as String.trim()
- // will return a new string only if whitespace is present
- //
-
- stringVal = stringVal.trim();
-
- if (stringVal.equals("0") || stringVal.equals("0000-00-00")
- || stringVal.equals("0000-00-00 00:00:00")
- || stringVal.equals("00000000000000")
- || stringVal.equals("0")) {
-
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(this.connection.getZeroDateTimeBehavior())) {
- this.wasNullFlag = true;
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(this.connection.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '" + stringVal
- + "' can not be represented as java.sql.Date",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- // We're left with the case of 'round' to a date Java _can_
- // represent, which is '0001-01-01'.
- return fastDateCreate(targetCalendar, 1, 1, 1);
-
- } else if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_TIMESTAMP) {
- // Convert from TIMESTAMP
- switch (stringVal.length()) {
- case 21:
- case 19: { // java.sql.Timestamp format
- year = Integer.parseInt(stringVal.substring(0, 4));
- month = Integer.parseInt(stringVal.substring(5, 7));
- day = Integer.parseInt(stringVal.substring(8, 10));
-
- return fastDateCreate(targetCalendar, year, month, day);
- }
-
- case 14:
- case 8: {
- year = Integer.parseInt(stringVal.substring(0, 4));
- month = Integer.parseInt(stringVal.substring(4, 6));
- day = Integer.parseInt(stringVal.substring(6, 8));
-
- return fastDateCreate(targetCalendar, year, month, day);
- }
-
- case 12:
- case 10:
- case 6: {
- year = Integer.parseInt(stringVal.substring(0, 2));
-
- if (year <= 69) {
- year = year + 100;
- }
-
- month = Integer.parseInt(stringVal.substring(2, 4));
- day = Integer.parseInt(stringVal.substring(4, 6));
-
- return fastDateCreate(targetCalendar, year + 1900, month, day);
- }
-
- case 4: {
- year = Integer.parseInt(stringVal.substring(0, 4));
-
- if (year <= 69) {
- year = year + 100;
- }
-
- month = Integer.parseInt(stringVal.substring(2, 4));
-
- return fastDateCreate(targetCalendar, year + 1900, month, 1);
- }
-
- case 2: {
- year = Integer.parseInt(stringVal.substring(0, 2));
-
- if (year <= 69) {
- year = year + 100;
- }
-
- return fastDateCreate(targetCalendar, year + 1900, 1, 1);
- }
-
- default:
- throw SQLError.createSQLException(Messages.getString(
- "ResultSet.Bad_format_for_Date", new Object[] {
- stringVal, Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- } /* endswitch */
- } else if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR) {
-
- if (stringVal.length() == 2 || stringVal.length() == 1) {
- year = Integer.parseInt(stringVal);
-
- if (year <= 69) {
- year = year + 100;
- }
-
- year += 1900;
- } else {
- year = Integer.parseInt(stringVal.substring(0, 4));
- }
-
- return fastDateCreate(targetCalendar, year, 1, 1);
- } else if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_TIME) {
- return fastDateCreate(targetCalendar, 1970, 1, 1); // Return EPOCH
- } else {
- if (stringVal.length() < 10) {
- if (stringVal.length() == 8) {
- return fastDateCreate(targetCalendar, 1970, 1, 1); // Return EPOCH for TIME
- }
-
- throw SQLError.createSQLException(Messages.getString(
- "ResultSet.Bad_format_for_Date", new Object[] {
- stringVal, Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (stringVal.length() != 18) {
- year = Integer.parseInt(stringVal.substring(0, 4));
- month = Integer.parseInt(stringVal.substring(5, 7));
- day = Integer.parseInt(stringVal.substring(8, 10));
- } else {
- // JDK-1.3 timestamp format, not real easy to parse positionally :p
- StringTokenizer st = new StringTokenizer(stringVal, "- ");
-
- year = Integer.parseInt(st.nextToken());
- month = Integer.parseInt(st.nextToken());
- day = Integer.parseInt(st.nextToken());
- }
- }
-
- return fastDateCreate(targetCalendar, year, month, day);
- } catch (SQLException sqlEx) {
- throw sqlEx; // don't re-wrap
- } catch (Exception e) {
- SQLException sqlEx = SQLError.createSQLException(Messages.getString(
- "ResultSet.Bad_format_for_Date", new Object[] { stringVal,
- Constants.integerValueOf(columnIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
-
- sqlEx.initCause(e);
-
- throw sqlEx;
- }
- }
-
- private TimeZone getDefaultTimeZone() {
- if (!this.useLegacyDatetimeCode && this.connection != null) {
- return this.serverTimeZoneTz;
- }
-
- return this.connection.getDefaultTimeZone();
- }
-
- /**
- * Get the value of a column in the current row as a Java double.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public double getDouble(int columnIndex) throws SQLException {
- if (!this.isBinaryEncoded) {
- return getDoubleInternal(columnIndex);
- }
-
- return getNativeDouble(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public double getDouble(String columnName) throws SQLException {
- return getDouble(findColumn(columnName));
- }
-
- private final double getDoubleFromString(String stringVal, int columnIndex)
- throws SQLException {
- return getDoubleInternal(stringVal, columnIndex);
- }
-
- /**
- * Converts a string representation of a number to a double. Need a faster
- * way to do this.
- *
- * @param colIndex
- * the 1-based index of the column to retrieve a double from.
- *
- * @return the double value represented by the string in buf
- *
- * @throws SQLException
- * if an error occurs
- */
- protected double getDoubleInternal(int colIndex) throws SQLException {
- return getDoubleInternal(getString(colIndex), colIndex);
- }
-
- /**
- * Converts a string representation of a number to a double. Need a faster
- * way to do this.
- *
- * @param stringVal
- * the double as a String
- * @param colIndex
- * the 1-based index of the column to retrieve a double from.
- *
- * @return the double value represented by the string in buf
- *
- * @throws SQLException
- * if an error occurs
- */
- protected double getDoubleInternal(String stringVal, int colIndex)
- throws SQLException {
- try {
- if ((stringVal == null)) {
- return 0;
- }
-
- if (stringVal.length() == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- double d = Double.parseDouble(stringVal);
-
- if (this.useStrictFloatingPoint) {
- // Fix endpoint rounding precision loss in MySQL server
- if (d == 2.147483648E9) {
- // Fix Odd end-point rounding on MySQL
- d = 2.147483647E9;
- } else if (d == 1.0000000036275E-15) {
- // Fix odd end-point rounding on MySQL
- d = 1.0E-15;
- } else if (d == 9.999999869911E14) {
- d = 9.99999999999999E14;
- } else if (d == 1.4012984643248E-45) {
- d = 1.4E-45;
- } else if (d == 1.4013E-45) {
- d = 1.4E-45;
- } else if (d == 3.4028234663853E37) {
- d = 3.4028235E37;
- } else if (d == -2.14748E9) {
- d = -2.147483648E9;
- } else if (d == 3.40282E37) {
- d = 3.4028235E37;
- }
- }
-
- return d;
- } catch (NumberFormatException e) {
- if (this.fields[colIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- long valueAsLong = getNumericRepresentationOfSQLBitType(colIndex);
-
- return valueAsLong;
- }
-
- throw SQLError.createSQLException(Messages.getString(
- "ResultSet.Bad_format_for_number", new Object[] {
- stringVal, Constants.integerValueOf(colIndex) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- /**
- * JDBC 2.0 Returns the fetch direction for this result set.
- *
- * @return the fetch direction for this result set.
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public int getFetchDirection() throws SQLException {
- return this.fetchDirection;
- }
-
- /**
- * JDBC 2.0 Return the fetch size for this result set.
- *
- * @return the fetch size for this result set.
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public int getFetchSize() throws SQLException {
- return this.fetchSize;
- }
-
- /**
- * Returns the first character of the query that this result set was created
- * from.
- *
- * @return the first character of the query...uppercased
- */
- public char getFirstCharOfQuery() {
- return this.firstCharOfQuery;
- }
-
- /**
- * Get the value of a column in the current row as a Java float.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public float getFloat(int columnIndex) throws SQLException {
- if (!this.isBinaryEncoded) {
- String val = null;
-
- val = getString(columnIndex);
-
- return getFloatFromString(val, columnIndex);
- }
-
- return getNativeFloat(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public float getFloat(String columnName) throws SQLException {
- return getFloat(findColumn(columnName));
- }
-
- private final float getFloatFromString(String val, int columnIndex)
- throws SQLException {
- try {
- if ((val != null)) {
- if (val.length() == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- float f = Float.parseFloat(val);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (f == Float.MIN_VALUE || f == Float.MAX_VALUE) {
- double valAsDouble = Double.parseDouble(val);
-
- // Straight comparison is not reliable when at
- // absolute endpoints of Float.MIN_VALUE or
- // Float.MAX_VALUE, so use epsillons with DOUBLEs
-
- if ((valAsDouble < Float.MIN_VALUE - MIN_DIFF_PREC)
- || (valAsDouble > Float.MAX_VALUE - MAX_DIFF_PREC)) {
- throwRangeException(String.valueOf(valAsDouble), columnIndex,
- Types.FLOAT);
- }
- }
- }
-
- return f;
- }
-
- return 0; // for NULL
- } catch (NumberFormatException nfe) {
- try {
- Double valueAsDouble = new Double(val);
- float valueAsFloat = valueAsDouble.floatValue();
-
- if (this.jdbcCompliantTruncationForReads) {
-
- if (this.jdbcCompliantTruncationForReads &&
- valueAsFloat == Float.NEGATIVE_INFINITY ||
- valueAsFloat == Float.POSITIVE_INFINITY) {
- throwRangeException(valueAsDouble.toString(),
- columnIndex, Types.FLOAT);
- }
- }
-
- return valueAsFloat;
- } catch (NumberFormatException newNfe) {
- ; // ignore, it's not a number
- }
-
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getFloat()_-____200")
- + val //$NON-NLS-1$
- + Messages.getString("ResultSet.___in_column__201")
- + columnIndex, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java int.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public int getInt(int columnIndex) throws SQLException {
- checkRowPos();
-
- if (!this.isBinaryEncoded) {
- int columnIndexMinusOne = columnIndex - 1;
- if (this.useFastIntParsing) {
- checkColumnBounds(columnIndex);
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return 0;
- }
-
- if (this.thisRow.length(columnIndexMinusOne) == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- boolean needsFullParse = this.thisRow
- .isFloatingPointNumber(columnIndexMinusOne);
-
- if (!needsFullParse) {
- try {
- return getIntWithOverflowCheck(columnIndexMinusOne);
- } catch (NumberFormatException nfe) {
- try {
-
- return parseIntAsDouble(columnIndex, this.thisRow
- .getString(columnIndexMinusOne,
- this.fields[columnIndexMinusOne]
- .getCharacterSet(),
- this.connection));
- } catch (NumberFormatException newNfe) {
- // ignore, it's not a number
- }
-
- if (this.fields[columnIndexMinusOne].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
-
- if (this.connection
- .getJdbcCompliantTruncationForReads()
- && (valueAsLong < Integer.MIN_VALUE || valueAsLong > Integer.MAX_VALUE)) {
- throwRangeException(
- String.valueOf(valueAsLong),
- columnIndex, Types.INTEGER);
- }
-
- return (int) valueAsLong;
- }
-
- throw SQLError
- .createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getInt()_-____74")
- + this.thisRow
- .getString(
- columnIndexMinusOne,
- this.fields[columnIndexMinusOne]
- .getCharacterSet(),
- this.connection) //$NON-NLS-1$
- + "'",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
- }
-
- String val = null;
-
- try {
- val = getString(columnIndex);
-
- if ((val != null)) {
- if (val.length() == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
- && (val.indexOf(".") == -1)) {
- int intVal = Integer.parseInt(val);
-
- checkForIntegerTruncation(columnIndexMinusOne, null, intVal);
-
- return intVal;
- }
-
- // Convert floating point
- int intVal = parseIntAsDouble(columnIndex, val);
-
- checkForIntegerTruncation(columnIndex, null, intVal);
-
- return intVal;
- }
-
- return 0;
- } catch (NumberFormatException nfe) {
- try {
- return parseIntAsDouble(columnIndex, val);
- } catch (NumberFormatException newNfe) {
- ; // ignore, it's not a number
- }
-
- if (this.fields[columnIndexMinusOne].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
-
- if (this.jdbcCompliantTruncationForReads
- && (valueAsLong < Integer.MIN_VALUE || valueAsLong > Integer.MAX_VALUE)) {
- throwRangeException(String.valueOf(valueAsLong),
- columnIndex, Types.INTEGER);
- }
-
- return (int) valueAsLong;
- }
-
- throw SQLError
- .createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getInt()_-____74")
- + val //$NON-NLS-1$
- + "'",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- return getNativeInt(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public int getInt(String columnName) throws SQLException {
- return getInt(findColumn(columnName));
- }
-
- private final int getIntFromString(String val, int columnIndex)
- throws SQLException {
- try {
- if ((val != null)) {
-
- if (val.length() == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
- && (val.indexOf(".") == -1)) {
- //
- // JDK-6 doesn't like trailing whitespace
- //
- // Note this isn't a performance issue, other
- // than the iteration over the string, as String.trim()
- // will return a new string only if whitespace is present
- //
-
- val = val.trim();
-
- int valueAsInt = Integer.parseInt(val);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsInt == Integer.MIN_VALUE
- || valueAsInt == Integer.MAX_VALUE) {
- long valueAsLong = Long.parseLong(val);
-
- if (valueAsLong < Integer.MIN_VALUE
- || valueAsLong > Integer.MAX_VALUE) {
- throwRangeException(
- String.valueOf(valueAsLong),
- columnIndex, Types.INTEGER);
- }
- }
- }
-
- return valueAsInt;
- }
-
- // Convert floating point
-
- double valueAsDouble = Double.parseDouble(val);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Integer.MIN_VALUE
- || valueAsDouble > Integer.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex, Types.INTEGER);
- }
- }
-
- return (int) valueAsDouble;
- }
-
- return 0; // for NULL
- } catch (NumberFormatException nfe) {
- try {
- double valueAsDouble = Double.parseDouble(val);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Integer.MIN_VALUE
- || valueAsDouble > Integer.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex, Types.INTEGER);
- }
- }
-
- return (int) valueAsDouble;
- } catch (NumberFormatException newNfe) {
- ; // ignore, it's not a number
- }
-
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Invalid_value_for_getInt()_-____206")
- + val //$NON-NLS-1$
- + Messages.getString("ResultSet.___in_column__207")
- + columnIndex, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java long.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public long getLong(int columnIndex) throws SQLException {
- return getLong(columnIndex, true);
- }
-
- private long getLong(int columnIndex, boolean overflowCheck) throws SQLException {
- if (!this.isBinaryEncoded) {
- checkRowPos();
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.useFastIntParsing) {
-
- checkColumnBounds(columnIndex);
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return 0;
- }
-
- if (this.thisRow.length(columnIndexMinusOne) == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- boolean needsFullParse = this.thisRow.isFloatingPointNumber(columnIndexMinusOne);
-
- if (!needsFullParse) {
- try {
- return getLongWithOverflowCheck(columnIndexMinusOne, overflowCheck);
- } catch (NumberFormatException nfe) {
- try {
- // To do: Warn of over/underflow???
- return parseLongAsDouble(columnIndexMinusOne, this.thisRow
- .getString(columnIndexMinusOne,
- this.fields[columnIndexMinusOne]
- .getCharacterSet(),
- this.connection));
- } catch (NumberFormatException newNfe) {
- // ; // ignore, it's not a number
- }
-
- if (this.fields[columnIndexMinusOne].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- return getNumericRepresentationOfSQLBitType(columnIndex);
- }
-
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getLong()_-____79")
- + this.thisRow
- .getString(columnIndexMinusOne,
- this.fields[columnIndexMinusOne]
- .getCharacterSet(),
- this.connection) //$NON-NLS-1$
- + "'",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
- }
-
- String val = null;
-
- try {
- val = getString(columnIndex);
-
- if ((val != null)) {
- if (val.length() == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)) {
- return parseLongWithOverflowCheck(columnIndexMinusOne, null,
- val, overflowCheck);
- }
-
- // Convert floating point
- return parseLongAsDouble(columnIndexMinusOne, val);
- }
-
- return 0; // for NULL
- } catch (NumberFormatException nfe) {
- try {
- return parseLongAsDouble(columnIndexMinusOne, val);
- } catch (NumberFormatException newNfe) {
- // ; // ignore, it's not a number
- }
-
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getLong()_-____79")
- + val //$NON-NLS-1$
- + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- return getNativeLong(columnIndex, overflowCheck, true);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public long getLong(String columnName) throws SQLException {
- return getLong(findColumn(columnName));
- }
-
- private final long getLongFromString(String val, int columnIndexZeroBased)
- throws SQLException {
- try {
- if ((val != null)) {
-
- if (val.length() == 0) {
- return convertToZeroWithEmptyCheck();
- }
-
- if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)) {
- return parseLongWithOverflowCheck(columnIndexZeroBased, null, val, true);
- }
-
- // Convert floating point
- return parseLongAsDouble(columnIndexZeroBased, val);
- }
-
- return 0; // for NULL
- } catch (NumberFormatException nfe) {
- try {
- // To do: Warn of over/underflow???
- return parseLongAsDouble(columnIndexZeroBased, val);
- } catch (NumberFormatException newNfe) {
- ; // ignore, it's not a number
- }
-
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getLong()_-____211")
- + val //$NON-NLS-1$
- + Messages.getString("ResultSet.___in_column__212")
- + (columnIndexZeroBased + 1), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * The numbers, types and properties of a ResultSet's columns are provided
- * by the getMetaData method
- *
- * @return a description of the ResultSet's columns
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public java.sql.ResultSetMetaData getMetaData() throws SQLException {
- checkClosed();
-
- return new com.mysql.jdbc.ResultSetMetaData(this.fields,
- this.connection.getUseOldAliasMetadataBehavior(), getExceptionInterceptor());
- }
-
- /**
- * JDBC 2.0 Get an array column.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing an SQL array
- *
- * @throws SQLException
- * if a database error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- protected java.sql.Array getNativeArray(int i) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * A column value can be retrieved as a stream of ASCII characters and then
- * read in chunks from the stream. This method is particulary suitable for
- * retrieving large LONGVARCHAR values. The JDBC driver will do any
- * necessary conversion from the database format into ASCII.
- *
- *
- * Note: All the data in the returned stream must be read prior to
- * getting the value of any other column. The next call to a get method
- * implicitly closes the stream. Also, a stream may return 0 for available()
- * whether there is data available or not.
- *
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return a Java InputStream that delivers the database column value as a
- * stream of one byte ASCII characters. If the value is SQL NULL
- * then the result is null
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see getBinaryStream
- */
- protected InputStream getNativeAsciiStream(int columnIndex)
- throws SQLException {
- checkRowPos();
-
- return getNativeBinaryStream(columnIndex);
- }
-
- /**
- * JDBC 2.0 Get the value of a column in the current row as a
- * java.math.BigDecimal object.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return the column value (full precision); if the value is SQL NULL, the
- * result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- protected BigDecimal getNativeBigDecimal(int columnIndex)
- throws SQLException {
-
- checkColumnBounds(columnIndex);
-
- int scale = this.fields[columnIndex - 1].getDecimals();
-
- return getNativeBigDecimal(columnIndex, scale);
- }
-
- /**
- * Get the value of a column in the current row as a java.math.BigDecimal
- * object
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- * @param scale
- * the number of digits to the right of the decimal
- *
- * @return the column value; if the value is SQL NULL, null
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected BigDecimal getNativeBigDecimal(int columnIndex, int scale)
- throws SQLException {
- checkColumnBounds(columnIndex);
-
- String stringVal = null;
-
- Field f = this.fields[columnIndex - 1];
-
- Object value = this.thisRow.getColumnValue(columnIndex - 1);
-
- if (value == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- switch (f.getSQLType()) {
- case Types.DECIMAL:
- case Types.NUMERIC:
- stringVal = StringUtils
- .toAsciiString((byte[]) value);
- break;
- default:
- stringVal = getNativeString(columnIndex);
- }
-
- return getBigDecimalFromString(stringVal, columnIndex, scale);
- }
-
- /**
- * A column value can also be retrieved as a binary stream. This method is
- * suitable for retrieving LONGVARBINARY values.
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return a Java InputStream that delivers the database column value as a
- * stream of bytes. If the value is SQL NULL, then the result is
- * null
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see getAsciiStream
- * @see getUnicodeStream
- */
- protected InputStream getNativeBinaryStream(int columnIndex)
- throws SQLException {
- checkRowPos();
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- switch (this.fields[columnIndexMinusOne].getSQLType()) {
- case Types.BIT:
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.BLOB:
- case Types.LONGVARBINARY:
- return this.thisRow.getBinaryInputStream(columnIndexMinusOne);
- }
-
- byte[] b = getNativeBytes(columnIndex, false);
-
- if (b != null) {
- return new ByteArrayInputStream(b);
- }
-
- return null;
- }
-
- /**
- * JDBC 2.0 Get a BLOB column.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a BLOB
- *
- * @throws SQLException
- * if an error occurs.
- */
- protected java.sql.Blob getNativeBlob(int columnIndex) throws SQLException {
- checkRowPos();
-
- checkColumnBounds(columnIndex);
-
- Object value = this.thisRow.getColumnValue(columnIndex - 1);
-
- if (value == null) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return null;
- }
-
- int mysqlType = this.fields[columnIndex - 1].getMysqlType();
-
- byte[] dataAsBytes = null;
-
- switch (mysqlType) {
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- case MysqlDefs.FIELD_TYPE_BLOB:
- dataAsBytes = (byte[]) value;
- break;
-
- default:
- dataAsBytes = getNativeBytes(columnIndex, false);
- }
-
- if (!this.connection.getEmulateLocators()) {
- return new Blob(dataAsBytes, getExceptionInterceptor());
- }
-
- return new BlobFromLocator(this, columnIndex, getExceptionInterceptor());
- }
-
- public static boolean arraysEqual(byte[] left, byte[] right) {
- if (left == null) {
- return right == null;
- }
- if (right == null) {
- return false;
- }
- if (left.length != right.length) {
- return false;
- }
- for (int i = 0; i < left.length; i++) {
- if (left[i] != right[i]) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Get the value of a column in the current row as a Java byte.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected byte getNativeByte(int columnIndex) throws SQLException {
- return getNativeByte(columnIndex, true);
- }
-
- protected byte getNativeByte(int columnIndex, boolean overflowCheck) throws SQLException {
- checkRowPos();
-
- checkColumnBounds(columnIndex);
-
- Object value = this.thisRow.getColumnValue(columnIndex - 1);
-
- if (value == null) {
- this.wasNullFlag = true;
-
- return 0;
- }
-
- if (value == null) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return 0;
- }
-
- columnIndex--;
-
- Field field = this.fields[columnIndex];
-
- switch (field.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_BIT:
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- (valueAsLong < Byte.MIN_VALUE
- || valueAsLong > Byte.MAX_VALUE)) {
- throwRangeException(String.valueOf(valueAsLong), columnIndex + 1,
- Types.TINYINT);
- }
-
- return (byte)valueAsLong;
- case MysqlDefs.FIELD_TYPE_TINY:
- byte valueAsByte = ((byte[]) value)[0];
-
- if (!field.isUnsigned()) {
- return valueAsByte;
- }
-
- short valueAsShort = (valueAsByte >= 0) ?
- valueAsByte : (short)(valueAsByte + (short)256);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsShort > Byte.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsShort),
- columnIndex + 1, Types.TINYINT);
- }
- }
-
- return (byte)valueAsShort;
-
- case MysqlDefs.FIELD_TYPE_SHORT:
- case MysqlDefs.FIELD_TYPE_YEAR:
- valueAsShort = getNativeShort(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsShort < Byte.MIN_VALUE
- || valueAsShort > Byte.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsShort),
- columnIndex + 1, Types.TINYINT);
- }
- }
-
- return (byte) valueAsShort;
- case MysqlDefs.FIELD_TYPE_INT24:
- case MysqlDefs.FIELD_TYPE_LONG:
- int valueAsInt = getNativeInt(columnIndex + 1, false);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsInt < Byte.MIN_VALUE || valueAsInt > Byte.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsInt),
- columnIndex + 1, Types.TINYINT);
- }
- }
-
- return (byte) valueAsInt;
-
- case MysqlDefs.FIELD_TYPE_FLOAT:
- float valueAsFloat = getNativeFloat(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsFloat < Byte.MIN_VALUE
- || valueAsFloat > Byte.MAX_VALUE) {
-
- throwRangeException(String.valueOf(valueAsFloat),
- columnIndex + 1, Types.TINYINT);
- }
- }
-
- return (byte) valueAsFloat;
-
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- double valueAsDouble = getNativeDouble(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Byte.MIN_VALUE
- || valueAsDouble > Byte.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex + 1, Types.TINYINT);
- }
- }
-
- return (byte) valueAsDouble;
-
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- valueAsLong = getNativeLong(columnIndex + 1, false, true);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsLong < Byte.MIN_VALUE
- || valueAsLong > Byte.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsLong),
- columnIndex + 1, Types.TINYINT);
- }
- }
-
- return (byte) valueAsLong;
-
- default:
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getByte()", columnIndex,
- this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex],
- new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
- MysqlDefs.FIELD_TYPE_TINY,
- MysqlDefs.FIELD_TYPE_SHORT,
- MysqlDefs.FIELD_TYPE_LONG,
- MysqlDefs.FIELD_TYPE_LONGLONG,
- MysqlDefs.FIELD_TYPE_FLOAT });
- }
-
- return getByteFromString(getNativeString(columnIndex + 1),
- columnIndex + 1);
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java byte array.
- *
- *
- * Be warned If the blob is huge, then you may run out of memory.
- *
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected byte[] getNativeBytes(int columnIndex, boolean noConversion)
- throws SQLException {
- checkRowPos();
-
- checkColumnBounds(columnIndex);
-
- Object value = this.thisRow.getColumnValue(columnIndex - 1);
-
- if (value == null) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return null;
- }
-
- Field field = this.fields[columnIndex - 1];
-
- int mysqlType = field.getMysqlType();
-
- // Workaround for emulated locators in servers > 4.1,
- // as server returns SUBSTRING(blob) as STRING type...
- if (noConversion) {
- mysqlType = MysqlDefs.FIELD_TYPE_BLOB;
- }
-
- switch (mysqlType) {
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- case MysqlDefs.FIELD_TYPE_BLOB:
- case MysqlDefs.FIELD_TYPE_BIT:
- return (byte[]) value;
-
- case MysqlDefs.FIELD_TYPE_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- if (value instanceof byte[]) {
- return (byte[]) value;
- }
- // fallthrough
- default:
- int sqlType = field.getSQLType();
-
- if (sqlType == Types.VARBINARY || sqlType == Types.BINARY) {
- return (byte[]) value;
- }
-
- return getBytesFromString(getNativeString(columnIndex), columnIndex);
- }
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Get the value of a column in the current row as a java.io.Reader.
- *
- *
- * @param columnIndex
- * the column to get the value from
- *
- * @return the value in the column as a java.io.Reader.
- *
- * @throws SQLException
- * if an error occurs
- */
- protected java.io.Reader getNativeCharacterStream(int columnIndex)
- throws SQLException {
- int columnIndexMinusOne = columnIndex - 1;
-
- switch (this.fields[columnIndexMinusOne].getSQLType()) {
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- case Types.CLOB:
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return this.thisRow.getReader(columnIndexMinusOne);
- }
-
- String asString = null;
-
- asString = getStringForClob(columnIndex);
-
- if (asString == null) {
- return null;
- }
-
- return getCharacterStreamFromString(asString, columnIndex);
- }
-
- /**
- * JDBC 2.0 Get a CLOB column.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing a CLOB
- *
- * @throws SQLException
- * if an error occurs
- */
- protected java.sql.Clob getNativeClob(int columnIndex) throws SQLException {
- String stringVal = getStringForClob(columnIndex);
-
- if (stringVal == null) {
- return null;
- }
-
- return getClobFromString(stringVal, columnIndex);
- }
-
- private String getNativeConvertToString(int columnIndex,
- Field field)
- throws SQLException {
-
-
- int sqlType = field.getSQLType();
- int mysqlType = field.getMysqlType();
-
- switch (sqlType) {
- case Types.BIT:
- return String.valueOf(getNumericRepresentationOfSQLBitType(columnIndex));
- case Types.BOOLEAN:
- boolean booleanVal = getBoolean(columnIndex);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- return String.valueOf(booleanVal);
-
- case Types.TINYINT:
- byte tinyintVal = getNativeByte(columnIndex, false);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- if (!field.isUnsigned() || tinyintVal >= 0) {
- return String.valueOf(tinyintVal);
- }
-
- short unsignedTinyVal = (short) (tinyintVal & 0xff);
-
- return String.valueOf(unsignedTinyVal);
-
- case Types.SMALLINT:
-
- int intVal = getNativeInt(columnIndex, false);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- if (!field.isUnsigned() || intVal >= 0) {
- return String.valueOf(intVal);
- }
-
- intVal = intVal & 0xffff;
-
- return String.valueOf(intVal);
-
- case Types.INTEGER:
- intVal = getNativeInt(columnIndex, false);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- if (!field.isUnsigned() || intVal >= 0
- || field.getMysqlType() == MysqlDefs.FIELD_TYPE_INT24) {
-
- return String.valueOf(intVal);
- }
-
- long longVal = intVal & 0xffffffffL;
-
- return String.valueOf(longVal);
-
- case Types.BIGINT:
-
- if (!field.isUnsigned()) {
- longVal = getNativeLong(columnIndex, false, true);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- return String.valueOf(longVal);
- }
-
- longVal = getNativeLong(columnIndex, false, false);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- return String.valueOf(convertLongToUlong(longVal));
- case Types.REAL:
- float floatVal = getNativeFloat(columnIndex);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- return String.valueOf(floatVal);
-
- case Types.FLOAT:
- case Types.DOUBLE:
- double doubleVal = getNativeDouble(columnIndex);
-
- if (this.wasNullFlag) {
- return null;
- }
-
- return String.valueOf(doubleVal);
-
- case Types.DECIMAL:
- case Types.NUMERIC:
- String stringVal = StringUtils
- .toAsciiString((byte[]) this.thisRow.getColumnValue(columnIndex - 1));
-
- BigDecimal val;
-
- if (stringVal != null) {
- this.wasNullFlag = false;
-
- if (stringVal.length() == 0) {
- val = new BigDecimal(0);
-
- return val.toString();
- }
-
- try {
- val = new BigDecimal(stringVal);
- } catch (NumberFormatException ex) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Bad_format_for_BigDecimal",
- new Object[] {stringVal, Constants.integerValueOf(columnIndex)}),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- return val.toString();
- }
-
- this.wasNullFlag = true;
-
- return null;
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
-
- return extractStringFromNativeColumn(columnIndex, mysqlType);
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
-
- if (!field.isBlob()) {
- return extractStringFromNativeColumn(columnIndex, mysqlType);
- } else if (!field.isBinary()) {
- return extractStringFromNativeColumn(columnIndex, mysqlType);
- } else {
- byte[] data = getBytes(columnIndex);
- Object obj = data;
-
- if ((data != null) && (data.length >= 2)) {
- if ((data[0] == -84) && (data[1] == -19)) {
- // Serialized object?
- try {
- ByteArrayInputStream bytesIn = new ByteArrayInputStream(
- data);
- ObjectInputStream objIn = new ObjectInputStream(
- bytesIn);
- obj = objIn.readObject();
- objIn.close();
- bytesIn.close();
- } catch (ClassNotFoundException cnfe) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Class_not_found___91") //$NON-NLS-1$
- + cnfe.toString()
- + Messages
- .getString("ResultSet._while_reading_serialized_object_92"), getExceptionInterceptor()); //$NON-NLS-1$
- } catch (IOException ex) {
- obj = data; // not serialized?
- }
- }
-
- return obj.toString();
- }
-
- return extractStringFromNativeColumn(columnIndex, mysqlType);
- }
-
- case Types.DATE:
-
- // The YEAR datatype needs to be handled differently here.
- if (mysqlType == MysqlDefs.FIELD_TYPE_YEAR) {
- short shortVal = getNativeShort(columnIndex);
-
- if (!this.connection.getYearIsDateType()) {
-
- if (this.wasNullFlag) {
- return null;
- }
-
- return String.valueOf(shortVal);
- }
-
- if (field.getLength() == 2) {
-
- if (shortVal <= 69) {
- shortVal = (short) (shortVal + 100);
- }
-
- shortVal += 1900;
- }
-
- return fastDateCreate(null, shortVal, 1, 1).toString();
-
- }
-
- Date dt = getNativeDate(columnIndex);
-
- if (dt == null) {
- return null;
- }
-
- return String.valueOf(dt);
-
- case Types.TIME:
- Time tm = getNativeTime(columnIndex, null, this.defaultTimeZone, false);
-
- if (tm == null) {
- return null;
- }
-
- return String.valueOf(tm);
-
- case Types.TIMESTAMP:
- Timestamp tstamp = getNativeTimestamp(columnIndex,
- null, this.defaultTimeZone, false);
-
- if (tstamp == null) {
- return null;
- }
-
- String result = String.valueOf(tstamp);
-
- if (!this.connection.getNoDatetimeStringSync()) {
- return result;
- }
-
- if (result.endsWith(".0")) {
- return result.substring(0, result.length() - 2);
- }
-
- default:
- return extractStringFromNativeColumn(columnIndex, mysqlType);
- }
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Date object
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value; null if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected java.sql.Date getNativeDate(int columnIndex) throws SQLException {
- return getNativeDate(columnIndex, null);
- }
-
- /**
- * JDBC 2.0 Get the value of a column in the current row as a java.sql.Date
- * object. Use the calendar to construct an appropriate millisecond value
- * for the Date, if the underlying database doesn't store timezone
- * information.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param tz
- * the calendar to use in constructing the date
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- protected java.sql.Date getNativeDate(int columnIndex, Calendar cal)
- throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- int mysqlType = this.fields[columnIndexMinusOne].getMysqlType();
-
- java.sql.Date dateToReturn = null;
-
- if (mysqlType == MysqlDefs.FIELD_TYPE_DATE) {
-
- dateToReturn = this.thisRow.getNativeDate(columnIndexMinusOne,
- this.connection, this, cal);
- } else {
- TimeZone tz = (cal != null) ? cal.getTimeZone()
- : this.getDefaultTimeZone();
-
- boolean rollForward = (tz != null && !tz.equals(this.getDefaultTimeZone()));
-
- dateToReturn = (Date) this.thisRow.getNativeDateTimeValue(columnIndexMinusOne,
- null, Types.DATE, mysqlType, tz, rollForward, this.connection,
- this);
- }
-
- //
- // normally, we allow ResultSetImpl methods to check for null first,
- // but with DATETIME values we have this wacky need to support
- // 0000-00-00 00:00:00 -> NULL, so we have to defer
- // to the RowHolder implementation, and check the return value.
- //
-
- if (dateToReturn == null) {
-
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return dateToReturn;
- }
-
- java.sql.Date getNativeDateViaParseConversion(int columnIndex) throws SQLException {
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getDate()", columnIndex,
- this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex - 1],
- new int[] { MysqlDefs.FIELD_TYPE_DATE });
- }
-
- String stringVal = getNativeString(columnIndex);
-
- return getDateFromString(stringVal, columnIndex, null);
- }
-
- /**
- * Get the value of a column in the current row as a Java double.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected double getNativeDouble(int columnIndex) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- columnIndex--; // / JDBC is 1-based
-
- if (this.thisRow.isNull(columnIndex)) {
- this.wasNullFlag = true;
-
- return 0;
- }
-
- this.wasNullFlag = false;
-
- Field f= this.fields[columnIndex];
-
- switch (f.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- return this.thisRow.getNativeDouble(columnIndex);
- case MysqlDefs.FIELD_TYPE_TINY:
- if (!f.isUnsigned()) {
- return (double) getNativeByte(columnIndex + 1);
- }
-
- return (double) getNativeShort(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_SHORT:
- case MysqlDefs.FIELD_TYPE_YEAR:
- if (!f.isUnsigned()) {
- return (double) getNativeShort(columnIndex + 1);
- }
-
- return (double) getNativeInt(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_INT24:
- case MysqlDefs.FIELD_TYPE_LONG:
- if (!f.isUnsigned()) {
- return (double) getNativeInt(columnIndex + 1);
- }
-
- return (double) getNativeLong(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- long valueAsLong = getNativeLong(columnIndex + 1);
-
- if (!f.isUnsigned()) {
- return (double) valueAsLong;
- }
-
- BigInteger asBigInt = convertLongToUlong(valueAsLong);
-
- // TODO: Check for overflow
-
- return asBigInt.doubleValue();
- case MysqlDefs.FIELD_TYPE_FLOAT:
- return (double) getNativeFloat(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_BIT:
- return getNumericRepresentationOfSQLBitType(columnIndex + 1);
- default:
- String stringVal = getNativeString(columnIndex + 1);
-
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getDouble()", columnIndex,
- stringVal, this.fields[columnIndex],
- new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
- MysqlDefs.FIELD_TYPE_TINY,
- MysqlDefs.FIELD_TYPE_SHORT,
- MysqlDefs.FIELD_TYPE_LONG,
- MysqlDefs.FIELD_TYPE_LONGLONG,
- MysqlDefs.FIELD_TYPE_FLOAT });
- }
-
- return getDoubleFromString(stringVal, columnIndex + 1);
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java float.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected float getNativeFloat(int columnIndex) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- columnIndex--; // / JDBC is 1-based
-
- if (this.thisRow.isNull(columnIndex)) {
- this.wasNullFlag = true;
-
- return 0;
- }
-
- this.wasNullFlag = false;
-
- Field f = this.fields[columnIndex];
-
- switch (f.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_BIT:
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex + 1);
-
- return valueAsLong;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
-
- // Only foolproof way to check for overflow
- // Not efficient, but if you don't want to be inefficient, use the
- // correct binding for the type!
-
- Double valueAsDouble = new Double(getNativeDouble(columnIndex + 1));
-
- float valueAsFloat = valueAsDouble.floatValue();
-
- if (this.jdbcCompliantTruncationForReads &&
- valueAsFloat == Float.NEGATIVE_INFINITY ||
- valueAsFloat == Float.POSITIVE_INFINITY) {
- throwRangeException(valueAsDouble.toString(),
- columnIndex + 1, Types.FLOAT);
- }
-
- return (float) getNativeDouble(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_TINY:
- if (!f.isUnsigned()) {
- return (float) getNativeByte(columnIndex + 1);
- }
-
- return (float) getNativeShort(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_SHORT:
- case MysqlDefs.FIELD_TYPE_YEAR:
- if (!f.isUnsigned()) {
- return (float) getNativeShort(columnIndex + 1);
- }
-
- return (float) getNativeInt(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_INT24:
- case MysqlDefs.FIELD_TYPE_LONG:
- if (!f.isUnsigned()) {
- return (float) getNativeInt(columnIndex + 1);
- }
-
- return (float) getNativeLong(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- valueAsLong = getNativeLong(columnIndex + 1);
-
- if (!f.isUnsigned()) {
- return (float) valueAsLong;
- }
-
- BigInteger asBigInt = convertLongToUlong(valueAsLong);
-
- // TODO: Check for overflow
-
- return asBigInt.floatValue();
- case MysqlDefs.FIELD_TYPE_FLOAT:
-
- return this.thisRow.getNativeFloat(columnIndex);
-
- default:
- String stringVal = getNativeString(columnIndex + 1);
-
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getFloat()", columnIndex,
- stringVal, this.fields[columnIndex],
- new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
- MysqlDefs.FIELD_TYPE_TINY,
- MysqlDefs.FIELD_TYPE_SHORT,
- MysqlDefs.FIELD_TYPE_LONG,
- MysqlDefs.FIELD_TYPE_LONGLONG,
- MysqlDefs.FIELD_TYPE_FLOAT });
- }
-
- return getFloatFromString(stringVal, columnIndex + 1);
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java int.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected int getNativeInt(int columnIndex) throws SQLException {
- return getNativeInt(columnIndex, true);
- }
-
- protected int getNativeInt(int columnIndex, boolean overflowCheck) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- columnIndex--; // / JDBC is 1-based
-
- if (this.thisRow.isNull(columnIndex)) {
- this.wasNullFlag = true;
-
- return 0;
- }
-
- this.wasNullFlag = false;
-
- Field f = this.fields[columnIndex];
-
- switch (f.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_BIT:
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- (valueAsLong < Integer.MIN_VALUE
- || valueAsLong > Integer.MAX_VALUE)) {
- throwRangeException(String.valueOf(valueAsLong), columnIndex + 1,
- Types.INTEGER);
- }
-
- return (short)valueAsLong;
- case MysqlDefs.FIELD_TYPE_TINY:
- byte tinyintVal = getNativeByte(columnIndex + 1, false);
-
- if (!f.isUnsigned() || tinyintVal >= 0) {
- return tinyintVal;
- }
-
- return tinyintVal + 256;
- case MysqlDefs.FIELD_TYPE_SHORT:
- case MysqlDefs.FIELD_TYPE_YEAR:
- short asShort = getNativeShort(columnIndex + 1, false);
-
- if (!f.isUnsigned() || asShort >= 0) {
- return asShort;
- }
-
- return asShort + 65536;
- case MysqlDefs.FIELD_TYPE_INT24:
- case MysqlDefs.FIELD_TYPE_LONG:
-
- int valueAsInt = this.thisRow.getNativeInt(columnIndex);
-
- if (!f.isUnsigned()) {
- return valueAsInt;
- }
-
- valueAsLong = (valueAsInt >= 0) ?
- valueAsInt : valueAsInt + 4294967296L;
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- valueAsLong > Integer.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsLong),
- columnIndex + 1, Types.INTEGER);
- }
-
- return (int)valueAsLong;
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- valueAsLong = getNativeLong(columnIndex + 1, false, true);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsLong < Integer.MIN_VALUE
- || valueAsLong > Integer.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsLong),
- columnIndex + 1, Types.INTEGER);
- }
- }
-
- return (int) valueAsLong;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- double valueAsDouble = getNativeDouble(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Integer.MIN_VALUE
- || valueAsDouble > Integer.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex + 1, Types.INTEGER);
- }
- }
-
- return (int) valueAsDouble;
- case MysqlDefs.FIELD_TYPE_FLOAT:
- valueAsDouble = getNativeFloat(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Integer.MIN_VALUE
- || valueAsDouble > Integer.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex + 1, Types.INTEGER);
- }
- }
-
- return (int) valueAsDouble;
-
- default:
- String stringVal = getNativeString(columnIndex + 1);
-
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getInt()", columnIndex,
- stringVal, this.fields[columnIndex],
- new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
- MysqlDefs.FIELD_TYPE_TINY,
- MysqlDefs.FIELD_TYPE_SHORT,
- MysqlDefs.FIELD_TYPE_LONG,
- MysqlDefs.FIELD_TYPE_LONGLONG,
- MysqlDefs.FIELD_TYPE_FLOAT });
- }
-
- return getIntFromString(stringVal, columnIndex + 1);
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java long.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected long getNativeLong(int columnIndex) throws SQLException {
- return getNativeLong(columnIndex, true, true);
- }
-
- protected long getNativeLong(int columnIndex, boolean overflowCheck,
- boolean expandUnsignedLong) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- columnIndex--; // / JDBC is 1-based
-
- if (this.thisRow.isNull(columnIndex)) {
- this.wasNullFlag = true;
-
- return 0;
- }
-
- this.wasNullFlag = false;
-
- Field f = this.fields[columnIndex];
-
- switch (f.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_BIT:
- return getNumericRepresentationOfSQLBitType(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_TINY:
- if (!f.isUnsigned()) {
- return getNativeByte(columnIndex + 1);
- }
-
- return getNativeInt(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_SHORT:
- if (!f.isUnsigned()) {
- return getNativeShort(columnIndex + 1);
- }
-
- return getNativeInt(columnIndex + 1, false);
- case MysqlDefs.FIELD_TYPE_YEAR:
-
- return getNativeShort(columnIndex + 1);
- case MysqlDefs.FIELD_TYPE_INT24:
- case MysqlDefs.FIELD_TYPE_LONG:
- int asInt = getNativeInt(columnIndex + 1, false);
-
- if (!f.isUnsigned() || asInt >= 0) {
- return asInt;
- }
-
- return asInt + 4294967296L;
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- long valueAsLong = this.thisRow.getNativeLong(columnIndex);
-
- if (!f.isUnsigned() || !expandUnsignedLong) {
- return valueAsLong;
- }
-
- BigInteger asBigInt = convertLongToUlong(valueAsLong);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- ((asBigInt.compareTo(new BigInteger(String.valueOf(Long.MAX_VALUE))) > 0 ) ||
- (asBigInt.compareTo(new BigInteger(String.valueOf(Long.MIN_VALUE))) < 0))) {
- throwRangeException(asBigInt.toString(),
- columnIndex + 1, Types.BIGINT);
- }
-
- return getLongFromString(asBigInt.toString(), columnIndex);
-
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- double valueAsDouble = getNativeDouble(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Long.MIN_VALUE
- || valueAsDouble > Long.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex + 1, Types.BIGINT);
- }
- }
-
- return (long) valueAsDouble;
- case MysqlDefs.FIELD_TYPE_FLOAT:
- valueAsDouble = getNativeFloat(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Long.MIN_VALUE
- || valueAsDouble > Long.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex + 1, Types.BIGINT);
- }
- }
-
- return (long) valueAsDouble;
- default:
- String stringVal = getNativeString(columnIndex + 1);
-
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getLong()", columnIndex,
- stringVal, this.fields[columnIndex],
- new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
- MysqlDefs.FIELD_TYPE_TINY,
- MysqlDefs.FIELD_TYPE_SHORT,
- MysqlDefs.FIELD_TYPE_LONG,
- MysqlDefs.FIELD_TYPE_LONGLONG,
- MysqlDefs.FIELD_TYPE_FLOAT });
- }
-
- return getLongFromString(stringVal, columnIndex + 1);
- }
- }
-
- /**
- * JDBC 2.0 Get a REF(<structured-type>) column.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing data of an SQL REF type
- *
- * @throws SQLException
- * as this is not implemented
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- protected java.sql.Ref getNativeRef(int i) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * Get the value of a column in the current row as a Java short.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected short getNativeShort(int columnIndex) throws SQLException {
- return getNativeShort(columnIndex, true);
- }
-
- protected short getNativeShort(int columnIndex, boolean overflowCheck) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- columnIndex--; // / JDBC is 1-based
-
-
- if (this.thisRow.isNull(columnIndex)) {
- this.wasNullFlag = true;
-
- return 0;
- }
-
- this.wasNullFlag = false;
-
- Field f = this.fields[columnIndex];
-
- switch (f.getMysqlType()) {
-
- case MysqlDefs.FIELD_TYPE_TINY:
- byte tinyintVal = getNativeByte(columnIndex + 1, false);
-
- if (!f.isUnsigned() || tinyintVal >= 0) {
- return tinyintVal;
- }
-
- return (short)(tinyintVal + (short)256);
- case MysqlDefs.FIELD_TYPE_SHORT:
- case MysqlDefs.FIELD_TYPE_YEAR:
-
- short asShort = this.thisRow.getNativeShort(columnIndex);
-
- if (!f.isUnsigned()) {
- return asShort;
- }
-
- int valueAsInt = asShort & 0xffff;
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- valueAsInt > Short.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsInt),
- columnIndex + 1, Types.SMALLINT);
- }
-
- return (short)valueAsInt;
- case MysqlDefs.FIELD_TYPE_INT24:
- case MysqlDefs.FIELD_TYPE_LONG:
- if (!f.isUnsigned()) {
- valueAsInt = getNativeInt(columnIndex + 1, false);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- valueAsInt > Short.MAX_VALUE ||
- valueAsInt < Short.MIN_VALUE) {
- throwRangeException(String.valueOf(valueAsInt),
- columnIndex + 1, Types.SMALLINT);
- }
-
- return (short)valueAsInt;
- }
-
- long valueAsLong = getNativeLong(columnIndex + 1, false, true);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- valueAsLong > Short.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsLong),
- columnIndex + 1, Types.SMALLINT);
- }
-
- return (short)valueAsLong;
-
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- valueAsLong = getNativeLong(columnIndex + 1, false, false);
-
- if (!f.isUnsigned()) {
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsLong < Short.MIN_VALUE
- || valueAsLong > Short.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsLong),
- columnIndex + 1, Types.SMALLINT);
- }
- }
-
- return (short) valueAsLong;
- }
-
- BigInteger asBigInt = convertLongToUlong(valueAsLong);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads &&
- ((asBigInt.compareTo(new BigInteger(String.valueOf(Short.MAX_VALUE))) > 0 ) ||
- (asBigInt.compareTo(new BigInteger(String.valueOf(Short.MIN_VALUE))) < 0))) {
- throwRangeException(asBigInt.toString(),
- columnIndex + 1, Types.SMALLINT);
- }
-
- return (short)getIntFromString(asBigInt.toString(), columnIndex + 1);
-
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- double valueAsDouble = getNativeDouble(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Short.MIN_VALUE
- || valueAsDouble > Short.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble),
- columnIndex + 1, Types.SMALLINT);
- }
- }
-
- return (short) valueAsDouble;
- case MysqlDefs.FIELD_TYPE_FLOAT:
- float valueAsFloat = getNativeFloat(columnIndex + 1);
-
- if (overflowCheck && this.jdbcCompliantTruncationForReads) {
- if (valueAsFloat < Short.MIN_VALUE
- || valueAsFloat > Short.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsFloat),
- columnIndex + 1, Types.SMALLINT);
- }
- }
-
- return (short) valueAsFloat;
- default:
- String stringVal = getNativeString(columnIndex + 1);
-
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getShort()", columnIndex,
- stringVal, this.fields[columnIndex],
- new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
- MysqlDefs.FIELD_TYPE_TINY,
- MysqlDefs.FIELD_TYPE_SHORT,
- MysqlDefs.FIELD_TYPE_LONG,
- MysqlDefs.FIELD_TYPE_LONGLONG,
- MysqlDefs.FIELD_TYPE_FLOAT });
- }
-
- return getShortFromString(stringVal, columnIndex + 1);
- }
- }
-
- /**
- * Get the value of a column in the current row as a Java String
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value, null for SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- protected String getNativeString(int columnIndex) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- if (this.fields == null) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Query_generated_no_fields_for_ResultSet_133"), //$NON-NLS-1$
- SQLError.SQL_STATE_INVALID_COLUMN_NUMBER, getExceptionInterceptor());
- }
-
- if (this.thisRow.isNull(columnIndex - 1)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- String stringVal = null;
-
- Field field = this.fields[columnIndex - 1];
-
- // TODO: Check Types Here.
- stringVal = getNativeConvertToString(columnIndex, field);
-
- if (field.isZeroFill() && (stringVal != null)) {
- int origLength = stringVal.length();
-
- StringBuffer zeroFillBuf = new StringBuffer(origLength);
-
- long numZeros = field.getLength() - origLength;
-
- for (long i = 0; i < numZeros; i++) {
- zeroFillBuf.append('0');
- }
-
- zeroFillBuf.append(stringVal);
-
- stringVal = zeroFillBuf.toString();
- }
-
- return stringVal;
- }
-
- private Time getNativeTime(int columnIndex, Calendar targetCalendar,
- TimeZone tz, boolean rollForward)
- throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- int mysqlType = this.fields[columnIndexMinusOne].getMysqlType();
-
- Time timeVal = null;
-
- if (mysqlType == MysqlDefs.FIELD_TYPE_TIME) {
- timeVal = this.thisRow.getNativeTime(columnIndexMinusOne,
- targetCalendar, tz, rollForward, this.connection, this);
-
- } else {
- timeVal = (Time) this.thisRow.getNativeDateTimeValue(columnIndexMinusOne,
- null, Types.TIME, mysqlType, tz, rollForward, this.connection,
- this);
- }
-
- //
- // normally, we allow ResultSetImpl methods to check for null first,
- // but with DATETIME values we have this wacky need to support
- // 0000-00-00 00:00:00 -> NULL, so we have to defer
- // to the RowHolder implementation, and check the return value.
- //
-
- if (timeVal == null) {
-
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return timeVal;
- }
-
- Time getNativeTimeViaParseConversion(int columnIndex, Calendar targetCalendar,
- TimeZone tz, boolean rollForward) throws SQLException {
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getTime()", columnIndex,
- this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex - 1],
- new int[] { MysqlDefs.FIELD_TYPE_TIME });
- }
-
- String strTime = getNativeString(columnIndex);
-
- return getTimeFromString(strTime, targetCalendar, columnIndex, tz, rollForward);
- }
-
- private Timestamp getNativeTimestamp(int columnIndex,
- Calendar targetCalendar,
- TimeZone tz,
- boolean rollForward) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- Timestamp tsVal = null;
-
- int mysqlType = this.fields[columnIndexMinusOne].getMysqlType();
-
- switch (mysqlType) {
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- tsVal = this.thisRow.getNativeTimestamp(columnIndexMinusOne,
- targetCalendar, tz, rollForward, this.connection, this);
- break;
-
- default:
-
-
- tsVal = (Timestamp) this.thisRow.getNativeDateTimeValue(
- columnIndexMinusOne, null, Types.TIMESTAMP, mysqlType, tz,
- rollForward, this.connection, this);
- }
-
- //
- // normally, we allow ResultSetImpl methods to check for null first,
- // but with DATETIME values we have this wacky need to support
- // 0000-00-00 00:00:00 -> NULL, so we have to defer
- // to the RowHolder implementation, and check the return value.
- //
-
- if (tsVal == null) {
-
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return tsVal;
- }
-
- Timestamp getNativeTimestampViaParseConversion(int columnIndex, Calendar targetCalendar,
- TimeZone tz, boolean rollForward) throws SQLException {
- if (this.useUsageAdvisor) {
- issueConversionViaParsingWarning("getTimestamp()", columnIndex,
- this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex - 1],
- new int[] { MysqlDefs.FIELD_TYPE_TIMESTAMP,
- MysqlDefs.FIELD_TYPE_DATETIME });
- }
-
- String strTimestamp = getNativeString(columnIndex);
-
- return getTimestampFromString(columnIndex, targetCalendar, strTimestamp, tz,
- rollForward);
- }
-
- // ---------------------------------------------------------------------
- // Updates
- // ---------------------------------------------------------------------
-
- /**
- * A column value can also be retrieved as a stream of Unicode characters.
- * We implement this as a binary stream.
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return a Java InputStream that delivers the database column value as a
- * stream of two byte Unicode characters. If the value is SQL NULL,
- * then the result is null
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see getAsciiStream
- * @see getBinaryStream
- */
- protected InputStream getNativeUnicodeStream(int columnIndex)
- throws SQLException {
- checkRowPos();
-
- return getBinaryStream(columnIndex);
- }
-
- /**
- * @see ResultSetInternalMethods#getURL(int)
- */
- protected URL getNativeURL(int colIndex) throws SQLException {
- String val = getString(colIndex);
-
- if (val == null) {
- return null;
- }
-
- try {
- return new URL(val);
- } catch (MalformedURLException mfe) {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Malformed_URL____141")
- + val + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return Returns the nextResultSet, if any, null if none exists.
- */
- public ResultSetInternalMethods getNextResultSet() {
- return this.nextResultSet;
- }
-
- /**
- * Get the value of a column in the current row as a Java object
- *
- *
- * This method will return the value of the given column as a Java object.
- * The type of the Java object will be the default Java Object type
- * corresponding to the column's SQL type, following the mapping specified
- * in the JDBC specification.
- *
- *
- *
- * This method may also be used to read database specific abstract data
- * types.
- *
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return a Object holding the column value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public Object getObject(int columnIndex) throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- Field field;
- field = this.fields[columnIndexMinusOne];
-
- switch (field.getSQLType()) {
- case Types.BIT:
- case Types.BOOLEAN:
- if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_BIT
- && !field.isSingleBit()) {
- return getBytes(columnIndex);
- }
-
- // valueOf would be nicer here, but it isn't
- // present in JDK-1.3.1, which is what the CTS
- // uses.
- return Boolean.valueOf(getBoolean(columnIndex));
-
- case Types.TINYINT:
- if (!field.isUnsigned()) {
- return Constants.integerValueOf(getByte(columnIndex));
- }
-
- return Constants.integerValueOf(getInt(columnIndex));
-
- case Types.SMALLINT:
-
- return Constants.integerValueOf(getInt(columnIndex));
-
- case Types.INTEGER:
-
- if (!field.isUnsigned() ||
- field.getMysqlType() == MysqlDefs.FIELD_TYPE_INT24) {
- return Constants.integerValueOf(getInt(columnIndex));
- }
-
- return Constants.longValueOf(getLong(columnIndex));
-
- case Types.BIGINT:
-
- if (!field.isUnsigned()) {
- return Constants.longValueOf(getLong(columnIndex));
- }
-
- String stringVal = getString(columnIndex);
-
- if (stringVal == null) {
- return null;
- }
-
- try {
- return new BigInteger(stringVal);
- } catch (NumberFormatException nfe) {
- throw SQLError.createSQLException(Messages.getString(
- "ResultSet.Bad_format_for_BigInteger", new Object[] {
- Constants.integerValueOf(columnIndex), stringVal }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- case Types.DECIMAL:
- case Types.NUMERIC:
- stringVal = getString(columnIndex);
-
- BigDecimal val;
-
- if (stringVal != null) {
- if (stringVal.length() == 0) {
- val = new BigDecimal(0);
-
- return val;
- }
-
- try {
- val = new BigDecimal(stringVal);
- } catch (NumberFormatException ex) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Bad_format_for_BigDecimal", //$NON-NLS-1$
- new Object[] {stringVal, new Integer(columnIndex)}),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- return val;
- }
-
- return null;
-
- case Types.REAL:
- return new Float(getFloat(columnIndex));
-
- case Types.FLOAT:
- case Types.DOUBLE:
- return new Double(getDouble(columnIndex));
-
- case Types.CHAR:
- case Types.VARCHAR:
- if (!field.isOpaqueBinary()) {
- return getString(columnIndex);
- }
-
- return getBytes(columnIndex);
- case Types.LONGVARCHAR:
- if (!field.isOpaqueBinary()) {
- return getStringForClob(columnIndex);
- }
-
- return getBytes(columnIndex);
-
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_GEOMETRY) {
- return getBytes(columnIndex);
- } else if (field.isBinary() || field.isBlob()) {
- byte[] data = getBytes(columnIndex);
-
- if (this.connection.getAutoDeserialize()) {
- Object obj = data;
-
- if ((data != null) && (data.length >= 2)) {
- if ((data[0] == -84) && (data[1] == -19)) {
- // Serialized object?
- try {
- ByteArrayInputStream bytesIn = new ByteArrayInputStream(
- data);
- ObjectInputStream objIn = new ObjectInputStream(
- bytesIn);
- obj = objIn.readObject();
- objIn.close();
- bytesIn.close();
- } catch (ClassNotFoundException cnfe) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Class_not_found___91") //$NON-NLS-1$
- + cnfe.toString()
- + Messages
- .getString("ResultSet._while_reading_serialized_object_92"), getExceptionInterceptor()); //$NON-NLS-1$
- } catch (IOException ex) {
- obj = data; // not serialized?
- }
- } else {
- return getString(columnIndex);
- }
- }
-
- return obj;
- }
-
- return data;
- }
-
- return getBytes(columnIndex);
-
- case Types.DATE:
- if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR
- && !this.connection.getYearIsDateType()) {
- return Constants.shortValueOf(getShort(columnIndex));
- }
-
- return getDate(columnIndex);
-
- case Types.TIME:
- return getTime(columnIndex);
-
- case Types.TIMESTAMP:
- return getTimestamp(columnIndex);
-
- default:
- return getString(columnIndex);
- }
- }
-
- /**
- * JDBC 2.0 Returns the value of column i as a Java object. Use the map to
- * determine the class from which to construct data of SQL structured and
- * distinct types.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- * @param map
- * the mapping from SQL type names to Java classes
- *
- * @return an object representing the SQL value
- *
- * @throws SQLException
- * because this is not implemented
- */
- public Object getObject(int i, java.util.Map map) throws SQLException {
- return getObject(i);
- }
-
- /**
- * Get the value of a column in the current row as a Java object
- *
- *
- * This method will return the value of the given column as a Java object.
- * The type of the Java object will be the default Java Object type
- * corresponding to the column's SQL type, following the mapping specified
- * in the JDBC specification.
- *
- *
- *
- * This method may also be used to read database specific abstract data
- * types.
- *
- *
- * @param columnName
- * is the SQL name of the column
- *
- * @return a Object holding the column value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public Object getObject(String columnName) throws SQLException {
- return getObject(findColumn(columnName));
- }
-
- /**
- * JDBC 2.0 Returns the value of column i as a Java object. Use the map to
- * determine the class from which to construct data of SQL structured and
- * distinct types.
- *
- * @param colName
- * the column name
- * @param map
- * the mapping from SQL type names to Java classes
- *
- * @return an object representing the SQL value
- *
- * @throws SQLException
- * as this is not implemented
- */
- public Object getObject(String colName, java.util.Map map)
- throws SQLException {
- return getObject(findColumn(colName), map);
- }
-
- public Object getObjectStoredProc(int columnIndex, int desiredSqlType)
- throws SQLException {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- Object value = this.thisRow.getColumnValue(columnIndex - 1);
-
- if (value == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- Field field;
- field = this.fields[columnIndex - 1];
-
- switch (desiredSqlType) {
- case Types.BIT:
- case Types.BOOLEAN:
- // valueOf would be nicer here, but it isn't
- // present in JDK-1.3.1, which is what the CTS
- // uses.
- return Boolean.valueOf(getBoolean(columnIndex));
-
- case Types.TINYINT:
- return Constants.integerValueOf(getInt(columnIndex));
-
- case Types.SMALLINT:
- return Constants.integerValueOf(getInt(columnIndex));
-
- case Types.INTEGER:
-
- if (!field.isUnsigned() ||
- field.getMysqlType() == MysqlDefs.FIELD_TYPE_INT24) {
- return Constants.integerValueOf(getInt(columnIndex));
- }
-
- return Constants.longValueOf(getLong(columnIndex));
-
- case Types.BIGINT:
-
- if (field.isUnsigned()) {
- return getBigDecimal(columnIndex);
- }
-
- return Constants.longValueOf(getLong(columnIndex));
-
- case Types.DECIMAL:
- case Types.NUMERIC:
-
- String stringVal = getString(columnIndex);
- BigDecimal val;
-
- if (stringVal != null) {
- if (stringVal.length() == 0) {
- val = new BigDecimal(0);
-
- return val;
- }
-
- try {
- val = new BigDecimal(stringVal);
- } catch (NumberFormatException ex) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Bad_format_for_BigDecimal", //$NON-NLS-1$
- new Object[] {stringVal, new Integer(columnIndex)}),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- return val;
- }
-
- return null;
-
- case Types.REAL:
- return new Float(getFloat(columnIndex));
-
- case Types.FLOAT:
-
- if (!this.connection.getRunningCTS13()) {
- return new Double(getFloat(columnIndex));
- } else {
- return new Float(getFloat(columnIndex)); // NB - bug in JDBC
- // compliance test,
- // according
- // to JDBC spec, FLOAT type should return DOUBLE
- // but causes ClassCastException in CTS :(
- }
- case Types.DOUBLE:
- return new Double(getDouble(columnIndex));
-
- case Types.CHAR:
- case Types.VARCHAR:
- return getString(columnIndex);
- case Types.LONGVARCHAR:
- return getStringForClob(columnIndex);
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- return getBytes(columnIndex);
-
- case Types.DATE:
- if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR
- && !this.connection.getYearIsDateType()) {
- return Constants.shortValueOf(getShort(columnIndex));
- }
-
- return getDate(columnIndex);
-
- case Types.TIME:
- return getTime(columnIndex);
-
- case Types.TIMESTAMP:
- return getTimestamp(columnIndex);
-
- default:
- return getString(columnIndex);
- }
- }
-
- public Object getObjectStoredProc(int i, java.util.Map map,
- int desiredSqlType) throws SQLException {
- return getObjectStoredProc(i, desiredSqlType);
- }
-
- public Object getObjectStoredProc(String columnName, int desiredSqlType)
- throws SQLException {
- return getObjectStoredProc(findColumn(columnName), desiredSqlType);
- }
-
- public Object getObjectStoredProc(String colName, java.util.Map map,
- int desiredSqlType) throws SQLException {
- return getObjectStoredProc(findColumn(colName), map, desiredSqlType);
- }
-
- /**
- * JDBC 2.0 Get a REF(<structured-type>) column.
- *
- * @param i
- * the first column is 1, the second is 2, ...
- *
- * @return an object representing data of an SQL REF type
- *
- * @throws SQLException
- * as this is not implemented
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- public java.sql.Ref getRef(int i) throws SQLException {
- checkColumnBounds(i);
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Get a REF(<structured-type>) column.
- *
- * @param colName
- * the column name
- *
- * @return an object representing data of an SQL REF type
- *
- * @throws SQLException
- * as this method is not implemented.
- * @throws NotImplemented
- * DOCUMENT ME!
- */
- public java.sql.Ref getRef(String colName) throws SQLException {
- return getRef(findColumn(colName));
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine the current row number. The first row is number 1, the second
- * number 2, etc.
- *
- *
- * @return the current row number, else return 0 if there is no current row
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public int getRow() throws SQLException {
- checkClosed();
-
- int currentRowNumber = this.rowData.getCurrentRowNumber();
- int row = 0;
-
- // Non-dynamic result sets can be interrogated
- // for this information
- if (!this.rowData.isDynamic()) {
- if ((currentRowNumber < 0) || this.rowData.isAfterLast()
- || this.rowData.isEmpty()) {
- row = 0;
- } else {
- row = currentRowNumber + 1;
- }
- } else {
- // dynamic (streaming) can not
- row = currentRowNumber + 1;
- }
-
- return row;
- }
-
- /**
- * Returns the server info (if any), or null if none.
- *
- * @return server info created for this ResultSet
- */
- public String getServerInfo() {
- return this.serverInfo;
- }
-
- private long getNumericRepresentationOfSQLBitType(int columnIndex) throws SQLException {
-
- Object value = this.thisRow.getColumnValue(columnIndex - 1);
-
- if (this.fields[columnIndex - 1].isSingleBit() ||
- ((byte[])value).length == 1) {
- return ((byte[])value)[0];
- }
-
-
- byte[] asBytes = (byte[])value;
-
-
- int shift = 0;
-
- long[] steps = new long[asBytes.length];
-
- for (int i = asBytes.length - 1; i >= 0; i--) {
- steps[i] = (long)(asBytes[i] & 0xff) << shift;
- shift += 8;
- }
-
- long valueAsLong = 0;
-
- for (int i = 0; i < asBytes.length; i++) {
- valueAsLong |= steps[i];
- }
-
- return valueAsLong;
- }
-
- /**
- * Get the value of a column in the current row as a Java short.
- *
- * @param columnIndex
- * the first column is 1, the second is 2,...
- *
- * @return the column value; 0 if SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public short getShort(int columnIndex) throws SQLException {
- if (!this.isBinaryEncoded) {
- checkRowPos();
-
- if (this.useFastIntParsing) {
-
- checkColumnBounds(columnIndex);
-
- Object value = this.thisRow.getColumnValue(columnIndex - 1);
-
- if (value == null) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- if (this.wasNullFlag) {
- return 0;
- }
-
- byte[] shortAsBytes = (byte[]) value;
-
- if (shortAsBytes.length == 0) {
- return (short) convertToZeroWithEmptyCheck();
- }
-
- boolean needsFullParse = false;
-
- for (int i = 0; i < shortAsBytes.length; i++) {
- if (((char) shortAsBytes[i] == 'e')
- || ((char) shortAsBytes[i] == 'E')) {
- needsFullParse = true;
-
- break;
- }
- }
-
- if (!needsFullParse) {
- try {
- return parseShortWithOverflowCheck(columnIndex,
- shortAsBytes, null);
- } catch (NumberFormatException nfe) {
- try {
- // To do: Warn of over/underflow???
- return parseShortAsDouble(columnIndex, new String(
- shortAsBytes));
- } catch (NumberFormatException newNfe) {
- ; // ignore, it's not a number
- }
-
- if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
-
- if (this.jdbcCompliantTruncationForReads &&
- (valueAsLong < Short.MIN_VALUE
- || valueAsLong > Short.MAX_VALUE)) {
- throwRangeException(String.valueOf(valueAsLong), columnIndex,
- Types.SMALLINT);
- }
-
- return (short)valueAsLong;
- }
-
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getShort()_-____96")
- + new String(shortAsBytes) //$NON-NLS-1$
- + "'",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
- }
-
- String val = null;
-
- try {
- val = getString(columnIndex);
-
- if ((val != null)) {
-
- if (val.length() == 0) {
- return (short) convertToZeroWithEmptyCheck();
- }
-
- if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
- && (val.indexOf(".") == -1)) {
- return parseShortWithOverflowCheck(columnIndex, null,
- val);
- }
-
- // Convert floating point
- return parseShortAsDouble(columnIndex, val);
- }
-
- return 0; // for NULL
- } catch (NumberFormatException nfe) {
- try {
- return parseShortAsDouble(columnIndex, val);
- } catch (NumberFormatException newNfe) {
- ; // ignore, it's not a number
- }
-
- if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
-
- if (this.jdbcCompliantTruncationForReads &&
- (valueAsLong < Short.MIN_VALUE
- || valueAsLong > Short.MAX_VALUE)) {
- throwRangeException(String.valueOf(valueAsLong), columnIndex,
- Types.SMALLINT);
- }
-
- return (short)valueAsLong;
- }
-
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getShort()_-____96")
- + val //$NON-NLS-1$
- + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- return getNativeShort(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public short getShort(String columnName) throws SQLException {
- return getShort(findColumn(columnName));
- }
-
- private final short getShortFromString(String val, int columnIndex)
- throws SQLException {
- try {
- if ((val != null)) {
-
- if (val.length() == 0) {
- return (short) convertToZeroWithEmptyCheck();
- }
-
- if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
- && (val.indexOf(".") == -1)) {
- return parseShortWithOverflowCheck(columnIndex, null, val);
- }
-
- // Convert floating point
- return parseShortAsDouble(columnIndex, val);
- }
-
- return 0; // for NULL
- } catch (NumberFormatException nfe) {
- try {
- return parseShortAsDouble(columnIndex, val);
- } catch (NumberFormatException newNfe) {
- ; // ignore, it's not a number
- }
-
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Invalid_value_for_getShort()_-____217")
- + val //$NON-NLS-1$
- + Messages.getString("ResultSet.___in_column__218")
- + columnIndex, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * JDBC 2.0 Return the Statement that produced the ResultSet.
- *
- * @return the Statment that produced the result set, or null if the result
- * was produced some other way.
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public java.sql.Statement getStatement() throws SQLException {
- if (this.isClosed && !this.retainOwningStatement) {
- throw SQLError.createSQLException(
- "Operation not allowed on closed ResultSet. Statements "
- + "can be retained over result set closure by setting the connection property "
- + "\"retainStatementAfterResultSetClose\" to \"true\".",
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
-
- }
-
- if (this.wrapperStatement != null) {
- return this.wrapperStatement;
- }
-
- return this.owningStatement;
- }
-
- /**
- * Get the value of a column in the current row as a Java String
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value, null for SQL NULL
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public String getString(int columnIndex) throws SQLException {
- String stringVal = getStringInternal(columnIndex, true);
-
- if (this.padCharsWithSpace && stringVal != null) {
- Field f = this.fields[columnIndex - 1];
-
- if (f.getMysqlType() == MysqlDefs.FIELD_TYPE_STRING ) {
- int fieldLength = (int)f.getLength() /* safe, bytes in a CHAR <= 1024 */ /
- f.getMaxBytesPerCharacter(); /* safe, this will never be 0 */
-
- int currentLength = stringVal.length();
-
- if (currentLength < fieldLength) {
- StringBuffer paddedBuf = new StringBuffer(fieldLength);
- paddedBuf.append(stringVal);
-
- int difference = fieldLength - currentLength;
-
- paddedBuf.append(EMPTY_SPACE, 0, difference);
-
- stringVal = paddedBuf.toString();
- }
- }
- }
-
- return stringVal;
- }
-
- /**
- * The following routines simply convert the columnName into a columnIndex
- * and then call the appropriate routine above.
- *
- * @param columnName
- * is the SQL name of the column
- *
- * @return the column value
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public String getString(String columnName) throws SQLException {
- return getString(findColumn(columnName));
- }
-
- private String getStringForClob(int columnIndex) throws SQLException {
- String asString = null;
-
- String forcedEncoding =
- this.connection.getClobCharacterEncoding();
-
- if (forcedEncoding == null) {
- if (!this.isBinaryEncoded) {
- asString = getString(columnIndex);
- } else {
- asString = getNativeString(columnIndex);
- }
- } else {
- try {
- byte[] asBytes = null;
-
- if (!this.isBinaryEncoded) {
- asBytes = getBytes(columnIndex);
- } else {
- asBytes = getNativeBytes(columnIndex, true);
- }
-
- if (asBytes != null) {
- asString = new String(asBytes, forcedEncoding);
- }
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException("Unsupported character encoding " +
- forcedEncoding, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- return asString;
- }
-
- protected String getStringInternal(int columnIndex, boolean checkDateTypes)
- throws SQLException {
- if (!this.isBinaryEncoded) {
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- if (this.fields == null) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Query_generated_no_fields_for_ResultSet_99"), //$NON-NLS-1$
- SQLError.SQL_STATE_INVALID_COLUMN_NUMBER, getExceptionInterceptor());
- }
-
- // JDBC is 1-based, Java is not !?
-
- int internalColumnIndex = columnIndex - 1;
-
- if (this.thisRow.isNull(internalColumnIndex)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
-
- Field metadata = this.fields[internalColumnIndex];
-
- String stringVal = null;
-
- if (metadata.getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
- if (metadata.isSingleBit()) {
- byte[] value = this.thisRow.getColumnValue(internalColumnIndex);
-
- if (value.length == 0) {
- return String.valueOf(convertToZeroWithEmptyCheck());
- }
-
- return String.valueOf(value[0]);
- }
-
- return String.valueOf(getNumericRepresentationOfSQLBitType(columnIndex));
- }
-
- String encoding = metadata.getCharacterSet();
-
- stringVal = this.thisRow.getString(internalColumnIndex, encoding, this.connection);
-
- //
- // Special handling for YEAR type from mysql, some people
- // want it as a DATE, others want to treat it as a SHORT
- //
-
- if (metadata.getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR) {
- if (!this.connection.getYearIsDateType()) {
- return stringVal;
- }
-
- Date dt = getDateFromString(stringVal, columnIndex, null);
-
- if (dt == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return dt.toString();
- }
-
- // Handles timezone conversion and zero-date behavior
-
- if (checkDateTypes && !this.connection.getNoDatetimeStringSync()) {
- switch (metadata.getSQLType()) {
- case Types.TIME:
- Time tm = getTimeFromString(stringVal, null, columnIndex,
- this.getDefaultTimeZone(), false);
-
- if (tm == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return tm.toString();
- case Types.DATE:
-
- Date dt = getDateFromString(stringVal, columnIndex, null);
-
- if (dt == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return dt.toString();
- case Types.TIMESTAMP:
- Timestamp ts = getTimestampFromString(columnIndex,
- null, stringVal, this.getDefaultTimeZone(), false);
-
- if (ts == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return ts.toString();
- default:
- break;
- }
- }
-
- return stringVal;
- }
-
- return getNativeString(columnIndex);
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Time object
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value; null if SQL NULL
- *
- * @throws java.sql.SQLException
- * if a database access error occurs
- */
- public Time getTime(int columnIndex) throws java.sql.SQLException {
- return getTimeInternal(columnIndex, null, this.getDefaultTimeZone(), false);
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Time object.
- * Use the calendar to construct an appropriate millisecond value for the
- * Time, if the underlying database doesn't store timezone information.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param cal
- * the calendar to use in constructing the time
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.Time getTime(int columnIndex, Calendar cal)
- throws SQLException {
- return getTimeInternal(columnIndex, cal, cal.getTimeZone(), true);
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Time object.
- *
- * @param columnName
- * is the SQL name of the column
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @throws java.sql.SQLException
- * if a database-access error occurs.
- */
- public Time getTime(String columnName) throws java.sql.SQLException {
- return getTime(findColumn(columnName));
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Time object.
- * Use the calendar to construct an appropriate millisecond value for the
- * Time, if the underlying database doesn't store timezone information.
- *
- * @param columnName
- * is the SQL name of the column
- * @param cal
- * the calendar to use in constructing the time
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.Time getTime(String columnName, Calendar cal)
- throws SQLException {
- return getTime(findColumn(columnName), cal);
- }
-
- private Time getTimeFromString(String timeAsString, Calendar targetCalendar,
- int columnIndex,
- TimeZone tz,
- boolean rollForward) throws SQLException {
- int hr = 0;
- int min = 0;
- int sec = 0;
-
- try {
-
- if (timeAsString == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- //
- // JDK-6 doesn't like trailing whitespace
- //
- // Note this isn't a performance issue, other
- // than the iteration over the string, as String.trim()
- // will return a new string only if whitespace is present
- //
-
- timeAsString = timeAsString.trim();
-
- if (timeAsString.equals("0")
- || timeAsString.equals("0000-00-00")
- || timeAsString.equals("0000-00-00 00:00:00")
- || timeAsString.equals("00000000000000")) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(this.connection.getZeroDateTimeBehavior())) {
- this.wasNullFlag = true;
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(this.connection.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '" + timeAsString
- + "' can not be represented as java.sql.Time",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- // We're left with the case of 'round' to a time Java _can_
- // represent, which is '00:00:00'
- return fastTimeCreate(targetCalendar, 0, 0, 0);
- }
-
- this.wasNullFlag = false;
-
- Field timeColField = this.fields[columnIndex - 1];
-
- if (timeColField.getMysqlType() == MysqlDefs.FIELD_TYPE_TIMESTAMP) {
- // It's a timestamp
- int length = timeAsString.length();
-
- switch (length) {
- case 19: { // YYYY-MM-DD hh:mm:ss
-
- hr = Integer.parseInt(timeAsString.substring(length - 8,
- length - 6));
- min = Integer.parseInt(timeAsString.substring(length - 5,
- length - 3));
- sec = Integer.parseInt(timeAsString.substring(length - 2,
- length));
- }
-
- break;
- case 14:
- case 12: {
- hr = Integer.parseInt(timeAsString.substring(length - 6,
- length - 4));
- min = Integer.parseInt(timeAsString.substring(length - 4,
- length - 2));
- sec = Integer.parseInt(timeAsString.substring(length - 2,
- length));
- }
-
- break;
-
- case 10: {
- hr = Integer.parseInt(timeAsString.substring(6, 8));
- min = Integer.parseInt(timeAsString.substring(8, 10));
- sec = 0;
- }
-
- break;
-
- default:
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Timestamp_too_small_to_convert_to_Time_value_in_column__257") //$NON-NLS-1$
- + columnIndex
- + "("
- + this.fields[columnIndex - 1] + ").",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- } /* endswitch */
-
- SQLWarning precisionLost = new SQLWarning(
- Messages
- .getString("ResultSet.Precision_lost_converting_TIMESTAMP_to_Time_with_getTime()_on_column__261") //$NON-NLS-1$
- + columnIndex
- + "("
- + this.fields[columnIndex - 1] + ").");
-
- if (this.warningChain == null) {
- this.warningChain = precisionLost;
- } else {
- this.warningChain.setNextWarning(precisionLost);
- }
- } else if (timeColField.getMysqlType() == MysqlDefs.FIELD_TYPE_DATETIME) {
- hr = Integer.parseInt(timeAsString.substring(11, 13));
- min = Integer.parseInt(timeAsString.substring(14, 16));
- sec = Integer.parseInt(timeAsString.substring(17, 19));
-
- SQLWarning precisionLost = new SQLWarning(
- Messages
- .getString("ResultSet.Precision_lost_converting_DATETIME_to_Time_with_getTime()_on_column__264") //$NON-NLS-1$
- + columnIndex
- + "("
- + this.fields[columnIndex - 1] + ").");
-
- if (this.warningChain == null) {
- this.warningChain = precisionLost;
- } else {
- this.warningChain.setNextWarning(precisionLost);
- }
- } else if (timeColField.getMysqlType() == MysqlDefs.FIELD_TYPE_DATE) {
- return fastTimeCreate(targetCalendar, 0, 0, 0); // midnight on the given
- // date
- } else {
- // convert a String to a Time
- if ((timeAsString.length() != 5)
- && (timeAsString.length() != 8)) {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Bad_format_for_Time____267") //$NON-NLS-1$
- + timeAsString
- + Messages.getString("ResultSet.___in_column__268")
- + columnIndex, SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- hr = Integer.parseInt(timeAsString.substring(0, 2));
- min = Integer.parseInt(timeAsString.substring(3, 5));
- sec = (timeAsString.length() == 5) ? 0 : Integer
- .parseInt(timeAsString.substring(6));
- }
-
- Calendar sessionCalendar = this.getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- return TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- fastTimeCreate(
- sessionCalendar, hr, min, sec),
- this.connection.getServerTimezoneTZ(),
- tz, rollForward);
- }
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(ex.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Time object in
- * the given timezone
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- * @param tz
- * the Timezone to use
- *
- * @return the column value; null if SQL NULL
- *
- * @exception java.sql.SQLException
- * if a database access error occurs
- */
- private Time getTimeInternal(int columnIndex, Calendar targetCalendar,
- TimeZone tz,
- boolean rollForward) throws java.sql.SQLException {
- checkRowPos();
-
- if (this.isBinaryEncoded) {
- return getNativeTime(columnIndex, targetCalendar, tz, rollForward);
- }
-
- if (!this.useFastDateParsing) {
- String timeAsString = getStringInternal(columnIndex, false);
-
- return getTimeFromString(timeAsString, targetCalendar,
- columnIndex, tz, rollForward);
- }
-
- checkColumnBounds(columnIndex);
-
- int columnIndexMinusOne = columnIndex - 1;
-
- if (this.thisRow.isNull(columnIndexMinusOne)) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- this.wasNullFlag = false;
-
- return this.thisRow.getTimeFast(columnIndexMinusOne,
- targetCalendar, tz, rollForward, this.connection, this);
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Timestamp
- * object
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return the column value; null if SQL NULL
- *
- * @exception java.sql.SQLException
- * if a database access error occurs
- */
- public Timestamp getTimestamp(int columnIndex) throws java.sql.SQLException {
- return getTimestampInternal(columnIndex, null, this.getDefaultTimeZone(),
- false);
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Timestamp
- * object. Use the calendar to construct an appropriate millisecond value
- * for the Timestamp, if the underlying database doesn't store timezone
- * information.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param cal
- * the calendar to use in constructing the timestamp
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal)
- throws SQLException {
- return getTimestampInternal(columnIndex, cal, cal.getTimeZone(), true);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws java.sql.SQLException
- * DOCUMENT ME!
- */
- public Timestamp getTimestamp(String columnName)
- throws java.sql.SQLException {
- return getTimestamp(findColumn(columnName));
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Timestamp
- * object. Use the calendar to construct an appropriate millisecond value
- * for the Timestamp, if the underlying database doesn't store timezone
- * information.
- *
- * @param columnName
- * is the SQL name of the column
- * @param cal
- * the calendar to use in constructing the timestamp
- *
- * @return the column value; if the value is SQL NULL, the result is null
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public java.sql.Timestamp getTimestamp(String columnName, Calendar cal)
- throws SQLException {
- return getTimestamp(findColumn(columnName), cal);
- }
-
- private Timestamp getTimestampFromString(int columnIndex,
- Calendar targetCalendar,
- String timestampValue, TimeZone tz, boolean rollForward)
- throws java.sql.SQLException {
- try {
- this.wasNullFlag = false;
-
- if (timestampValue == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- //
- // JDK-6 doesn't like trailing whitespace
- //
- // Note this isn't a performance issue, other
- // than the iteration over the string, as String.trim()
- // will return a new string only if whitespace is present
- //
-
- timestampValue = timestampValue.trim();
-
- int length = timestampValue.length();
-
- Calendar sessionCalendar = this.connection.getUseJDBCCompliantTimezoneShift() ?
- this.connection.getUtcCalendar() :
- getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- if ((length > 0)
- && (timestampValue.charAt(0) == '0')
- && (timestampValue.equals("0000-00-00")
- || timestampValue.equals("0000-00-00 00:00:00")
- || timestampValue.equals("00000000000000") || timestampValue
- .equals("0"))) {
-
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(this.connection.getZeroDateTimeBehavior())) {
- this.wasNullFlag = true;
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(this.connection.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '" + timestampValue
- + "' can not be represented as java.sql.Timestamp",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- // We're left with the case of 'round' to a date Java _can_
- // represent, which is '0001-01-01'.
- return fastTimestampCreate(null, 1, 1, 1, 0, 0, 0, 0);
-
- } else if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR) {
-
- if (!this.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz, Integer
- .parseInt(timestampValue.substring(0, 4)), 1,
- 1, 0, 0, 0, 0);
- } else {
- return TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- fastTimestampCreate(sessionCalendar,
- Integer
- .parseInt(timestampValue.substring(0, 4)), 1,
- 1, 0, 0, 0, 0), this.connection
- .getServerTimezoneTZ(), tz, rollForward);
- }
- } else {
- if (timestampValue.endsWith(".")) {
- timestampValue = timestampValue.substring(0, timestampValue
- .length() - 1);
- }
-
- // Convert from TIMESTAMP or DATE
-
- int year = 0;
- int month = 0;
- int day = 0;
- int hour = 0;
- int minutes = 0;
- int seconds = 0;
- int nanos = 0;
-
- switch (length) {
- case 26:
- case 25:
- case 24:
- case 23:
- case 22:
- case 21:
- case 20:
- case 19: {
- year = Integer.parseInt(timestampValue.substring(0, 4));
- month = Integer
- .parseInt(timestampValue.substring(5, 7));
- day = Integer.parseInt(timestampValue.substring(8, 10));
- hour = Integer.parseInt(timestampValue
- .substring(11, 13));
- minutes = Integer.parseInt(timestampValue.substring(14,
- 16));
- seconds = Integer.parseInt(timestampValue.substring(17,
- 19));
-
- nanos = 0;
-
- if (length > 19) {
- int decimalIndex = timestampValue.lastIndexOf('.');
-
- if (decimalIndex != -1) {
- if ((decimalIndex + 2) <= length) {
- nanos = Integer.parseInt(timestampValue
- .substring(decimalIndex + 1));
-
- int numDigits = length - (decimalIndex + 1);
-
- if (numDigits < 9) {
- int factor = (int)(Math.pow(10, 9 - numDigits));
- nanos = nanos * factor;
- }
- } else {
- throw new IllegalArgumentException(); // re-thrown
- // further
- // down
- // with
- // a
- // much better error message
- }
- }
- }
-
- break;
- }
-
- case 14: {
- year = Integer.parseInt(timestampValue.substring(0, 4));
- month = Integer
- .parseInt(timestampValue.substring(4, 6));
- day = Integer.parseInt(timestampValue.substring(6, 8));
- hour = Integer
- .parseInt(timestampValue.substring(8, 10));
- minutes = Integer.parseInt(timestampValue.substring(10,
- 12));
- seconds = Integer.parseInt(timestampValue.substring(12,
- 14));
-
- break;
- }
-
- case 12: {
- year = Integer.parseInt(timestampValue.substring(0, 2));
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = Integer
- .parseInt(timestampValue.substring(2, 4));
- day = Integer.parseInt(timestampValue.substring(4, 6));
- hour = Integer.parseInt(timestampValue.substring(6, 8));
- minutes = Integer.parseInt(timestampValue.substring(8,
- 10));
- seconds = Integer.parseInt(timestampValue.substring(10,
- 12));
-
- break;
- }
-
- case 10: {
- if ((this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_DATE)
- || (timestampValue.indexOf("-") != -1)) {
- year = Integer.parseInt(timestampValue.substring(0, 4));
- month = Integer
- .parseInt(timestampValue.substring(5, 7));
- day = Integer.parseInt(timestampValue.substring(8, 10));
- hour = 0;
- minutes = 0;
- } else {
- year = Integer.parseInt(timestampValue.substring(0, 2));
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- month = Integer
- .parseInt(timestampValue.substring(2, 4));
- day = Integer.parseInt(timestampValue.substring(4, 6));
- hour = Integer.parseInt(timestampValue.substring(6, 8));
- minutes = Integer.parseInt(timestampValue.substring(8,
- 10));
-
- year += 1900; // two-digit year
- }
-
- break;
- }
-
- case 8: {
- if (timestampValue.indexOf(":") != -1) {
- hour = Integer.parseInt(timestampValue.substring(0,
- 2));
- minutes = Integer.parseInt(timestampValue
- .substring(3, 5));
- seconds = Integer.parseInt(timestampValue
- .substring(6, 8));
- year = 1970;
- month = 1;
- day = 1;
- break;
- }
-
- year = Integer.parseInt(timestampValue.substring(0, 4));
- month = Integer
- .parseInt(timestampValue.substring(4, 6));
- day = Integer.parseInt(timestampValue.substring(6, 8));
-
- year -= 1900;
- month--;
-
- break;
- }
-
- case 6: {
- year = Integer.parseInt(timestampValue.substring(0, 2));
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = Integer
- .parseInt(timestampValue.substring(2, 4));
- day = Integer.parseInt(timestampValue.substring(4, 6));
-
- break;
- }
-
- case 4: {
- year = Integer.parseInt(timestampValue.substring(0, 2));
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = Integer
- .parseInt(timestampValue.substring(2, 4));
-
- day = 1;
-
- break;
- }
-
- case 2: {
- year = Integer.parseInt(timestampValue.substring(0, 2));
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
- month = 1;
- day = 1;
-
- break;
- }
-
- default:
- throw new java.sql.SQLException(
- "Bad format for Timestamp '" + timestampValue
- + "' in column " + columnIndex + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
- }
-
- if (!this.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz, year, month, day, hour,
- minutes, seconds, nanos);
- }
-
- return TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- fastTimestampCreate(sessionCalendar, year, month, day, hour,
- minutes, seconds, nanos), this.connection
- .getServerTimezoneTZ(), tz, rollForward);
- }
- }
- } catch (Exception e) {
- SQLException sqlEx = SQLError.createSQLException("Cannot convert value '"
- + timestampValue + "' from column " + columnIndex
- + " to TIMESTAMP.", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- sqlEx.initCause(e);
-
- throw sqlEx;
- }
-
- }
-
- private Timestamp getTimestampFromBytes(int columnIndex,
- Calendar targetCalendar,
- byte[] timestampAsBytes, TimeZone tz, boolean rollForward)
- throws java.sql.SQLException {
- checkColumnBounds(columnIndex);
-
- try {
- this.wasNullFlag = false;
-
- if (timestampAsBytes == null) {
- this.wasNullFlag = true;
-
- return null;
- }
-
- int length = timestampAsBytes.length;
-
- Calendar sessionCalendar = this.connection.getUseJDBCCompliantTimezoneShift() ?
- this.connection.getUtcCalendar() :
- getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- boolean allZeroTimestamp = true;
-
- boolean onlyTimePresent = StringUtils.indexOf(timestampAsBytes, ':') != -1;
-
- for (int i = 0; i < length; i++) {
- byte b = timestampAsBytes[i];
-
- if (b == ' ' || b == '-' || b == '/') {
- onlyTimePresent = false;
- }
-
- if (b != '0' && b != ' ' && b != ':' && b != '-' && b != '/'
- && b != '.') {
- allZeroTimestamp = false;
-
- break;
- }
- }
-
- if (!onlyTimePresent && allZeroTimestamp) {
-
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(this.connection.getZeroDateTimeBehavior())) {
- this.wasNullFlag = true;
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(this.connection.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '" + timestampAsBytes
- + "' can not be represented as java.sql.Timestamp",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- // We're left with the case of 'round' to a date Java _can_
- // represent, which is '0001-01-01'.
- if (!this.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz,
- 1, 1, 1, 0, 0, 0, 0);
- }
-
- return fastTimestampCreate(null, 1, 1, 1, 0, 0, 0, 0);
- } else if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR) {
-
- if (!this.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz,
- StringUtils.getInt(timestampAsBytes, 0, 4), 1, 1, 0, 0, 0, 0);
- }
-
- return TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- fastTimestampCreate(sessionCalendar,
- StringUtils.getInt(timestampAsBytes, 0, 4), 1,
- 1, 0, 0, 0, 0), this.connection
- .getServerTimezoneTZ(), tz, rollForward);
- } else {
- if (timestampAsBytes[length - 1] == '.') {
- length--;
- }
-
- // Convert from TIMESTAMP or DATE
-
- int year = 0;
- int month = 0;
- int day = 0;
- int hour = 0;
- int minutes = 0;
- int seconds = 0;
- int nanos = 0;
-
- switch (length) {
- case 26:
- case 25:
- case 24:
- case 23:
- case 22:
- case 21:
- case 20:
- case 19: {
- year = StringUtils.getInt(timestampAsBytes, 0, 4);
- month = StringUtils.getInt(timestampAsBytes, 5, 7);
- day = StringUtils.getInt(timestampAsBytes, 8, 10);
- hour = StringUtils.getInt(timestampAsBytes, 11, 13);
- minutes = StringUtils.getInt(timestampAsBytes, 14, 16);
- seconds = StringUtils.getInt(timestampAsBytes, 17, 19);
-
- nanos = 0;
-
- if (length > 19) {
- int decimalIndex = StringUtils.lastIndexOf(timestampAsBytes, '.');
-
- if (decimalIndex != -1) {
- if ((decimalIndex + 2) <= length) {
- nanos = StringUtils.getInt(timestampAsBytes, decimalIndex + 1, length);
- } else {
- throw new IllegalArgumentException(); // re-thrown
- // further
- // down
- // with
- // a
- // much better error message
- }
- }
- }
-
- break;
- }
-
- case 14: {
- year = StringUtils.getInt(timestampAsBytes, 0, 4);
- month = StringUtils.getInt(timestampAsBytes, 4, 6);
- day = StringUtils.getInt(timestampAsBytes, 6, 8);
- hour = StringUtils.getInt(timestampAsBytes, 8, 10);
- minutes = StringUtils.getInt(timestampAsBytes, 10, 12);
- seconds = StringUtils.getInt(timestampAsBytes, 12, 14);
-
- break;
- }
-
- case 12: {
- year = StringUtils.getInt(timestampAsBytes, 0, 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = StringUtils.getInt(timestampAsBytes, 2, 4);
- day = StringUtils.getInt(timestampAsBytes, 4, 6);
- hour = StringUtils.getInt(timestampAsBytes, 6, 8);
- minutes = StringUtils.getInt(timestampAsBytes, 8, 10);
- seconds = StringUtils.getInt(timestampAsBytes, 10, 12);
-
- break;
- }
-
- case 10: {
- if ((this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_DATE)
- || (StringUtils.indexOf(timestampAsBytes, '-') != -1)) {
- year = StringUtils.getInt(timestampAsBytes, 0, 4);
- month = StringUtils.getInt(timestampAsBytes, 5, 7);
- day = StringUtils.getInt(timestampAsBytes, 8, 10);
- hour = 0;
- minutes = 0;
- } else {
- year = StringUtils.getInt(timestampAsBytes, 0, 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- month = StringUtils.getInt(timestampAsBytes, 2, 4);
- day = StringUtils.getInt(timestampAsBytes, 4, 6);
- hour = StringUtils.getInt(timestampAsBytes, 6, 8);
- minutes = StringUtils.getInt(timestampAsBytes, 8, 10);
-
- year += 1900; // two-digit year
- }
-
- break;
- }
-
- case 8: {
- if (StringUtils.indexOf(timestampAsBytes, ':') != -1) {
- hour = StringUtils.getInt(timestampAsBytes, 0, 2);
- minutes = StringUtils.getInt(timestampAsBytes, 3, 5);
- seconds = StringUtils.getInt(timestampAsBytes, 6, 8);
-
- year = 1970;
- month = 1;
- day = 1;
-
- break;
- }
-
- year = StringUtils.getInt(timestampAsBytes, 0, 4);
- month = StringUtils.getInt(timestampAsBytes, 4, 6);
- day = StringUtils.getInt(timestampAsBytes, 6, 8);
-
- year -= 1900;
- month--;
-
- break;
- }
-
- case 6: {
- year = StringUtils.getInt(timestampAsBytes, 0, 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = StringUtils.getInt(timestampAsBytes, 2, 4);
- day = StringUtils.getInt(timestampAsBytes, 4, 6);
-
- break;
- }
-
- case 4: {
- year = StringUtils.getInt(timestampAsBytes, 0, 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = StringUtils.getInt(timestampAsBytes, 2, 4);
- day = 1;
-
- break;
- }
-
- case 2: {
- year = StringUtils.getInt(timestampAsBytes, 0, 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
- month = 1;
- day = 1;
-
- break;
- }
-
- default:
- throw new java.sql.SQLException(
- "Bad format for Timestamp '" + new String(timestampAsBytes)
- + "' in column " + columnIndex + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
- }
-
- if (!this.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz,
- year, month, day, hour, minutes, seconds, nanos);
- }
-
- return TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- fastTimestampCreate(sessionCalendar, year, month, day, hour,
- minutes, seconds, nanos), this.connection
- .getServerTimezoneTZ(), tz, rollForward);
- }
- }
- } catch (Exception e) {
- SQLException sqlEx = SQLError.createSQLException("Cannot convert value '"
- + new String(timestampAsBytes) + "' from column " + columnIndex
- + " to TIMESTAMP.", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- sqlEx.initCause(e);
-
- throw sqlEx;
- }
- }
-
- /**
- * Get the value of a column in the current row as a java.sql.Timestamp
- * object in the given timezone
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- * @param tz
- * the timezone to use
- *
- * @return the column value; null if SQL NULL
- *
- * @exception java.sql.SQLException
- * if a database access error occurs
- */
- private Timestamp getTimestampInternal(int columnIndex, Calendar targetCalendar,
- TimeZone tz,
- boolean rollForward) throws java.sql.SQLException {
- if (this.isBinaryEncoded) {
- return getNativeTimestamp(columnIndex, targetCalendar, tz, rollForward);
- }
-
- Timestamp tsVal = null;
-
- if (!this.useFastDateParsing) {
- String timestampValue = getStringInternal(columnIndex, false);
-
- tsVal = getTimestampFromString(columnIndex, targetCalendar,
- timestampValue, tz,
- rollForward);
- } else {
- checkClosed();
- checkRowPos();
- checkColumnBounds(columnIndex);
-
- tsVal = this.thisRow.getTimestampFast(columnIndex - 1,
- targetCalendar, tz, rollForward, this.connection, this);
- }
-
- if (tsVal == null) {
- this.wasNullFlag = true;
- } else {
- this.wasNullFlag = false;
- }
-
- return tsVal;
- }
-
- /**
- * JDBC 2.0 Return the type of this result set. The type is determined based
- * on the statement that created the result set.
- *
- * @return TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, or
- * TYPE_SCROLL_SENSITIVE
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public int getType() throws SQLException {
- return this.resultSetType;
- }
-
- /**
- * A column value can also be retrieved as a stream of Unicode characters.
- * We implement this as a binary stream.
- *
- * @param columnIndex
- * the first column is 1, the second is 2...
- *
- * @return a Java InputStream that delivers the database column value as a
- * stream of two byte Unicode characters. If the value is SQL NULL,
- * then the result is null
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see getAsciiStream
- * @see getBinaryStream
- * @deprecated
- */
- public InputStream getUnicodeStream(int columnIndex) throws SQLException {
- if (!this.isBinaryEncoded) {
- checkRowPos();
-
- return getBinaryStream(columnIndex);
- }
-
- return getNativeBinaryStream(columnIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param columnName
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- *
- * @deprecated
- */
- public InputStream getUnicodeStream(String columnName) throws SQLException {
- return getUnicodeStream(findColumn(columnName));
- }
-
- public long getUpdateCount() {
- return this.updateCount;
- }
-
- public long getUpdateID() {
- return this.updateId;
- }
-
- /**
- * @see ResultSetInternalMethods#getURL(int)
- */
- public URL getURL(int colIndex) throws SQLException {
- String val = getString(colIndex);
-
- if (val == null) {
- return null;
- }
-
- try {
- return new URL(val);
- } catch (MalformedURLException mfe) {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Malformed_URL____104")
- + val + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * @see ResultSetInternalMethods#getURL(String)
- */
- public URL getURL(String colName) throws SQLException {
- String val = getString(colName);
-
- if (val == null) {
- return null;
- }
-
- try {
- return new URL(val);
- } catch (MalformedURLException mfe) {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Malformed_URL____107")
- + val + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * The first warning reported by calls on this ResultSet is returned.
- * Subsequent ResultSet warnings will be chained to this
- * java.sql.SQLWarning.
- *
- *
- * The warning chain is automatically cleared each time a new row is read.
- *
- *
- *
- * Note: This warning chain only covers warnings caused by ResultSet
- * methods. Any warnings caused by statement methods (such as reading OUT
- * parameters) will be chained on the Statement object.
- *
- *
- * @return the first java.sql.SQLWarning or null;
- *
- * @exception SQLException
- * if a database access error occurs.
- */
- public java.sql.SQLWarning getWarnings() throws SQLException {
- return this.warningChain;
- }
-
- /**
- * JDBC 2.0 Insert the contents of the insert row into the result set and
- * the database. Must be on the insert row when this method is called.
- *
- * @exception SQLException
- * if a database-access error occurs, if called when not on
- * the insert row, or if all non-nullable columns in the
- * insert row have not been given a value
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void insertRow() throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is after the last row in the result set.
- *
- *
- * @return true if after the last row, false otherwise. Returns false when
- * the result set contains no rows.
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public boolean isAfterLast() throws SQLException {
- checkClosed();
-
- boolean b = this.rowData.isAfterLast();
-
- return b;
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is before the first row in the result set.
- *
- *
- * @return true if before the first row, false otherwise. Returns false when
- * the result set contains no rows.
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public boolean isBeforeFirst() throws SQLException {
- checkClosed();
-
- return this.rowData.isBeforeFirst();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is on the first row of the result set.
- *
- *
- * @return true if on the first row, false otherwise.
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public boolean isFirst() throws SQLException {
- checkClosed();
-
- return this.rowData.isFirst();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is on the last row of the result set. Note:
- * Calling isLast() may be expensive since the JDBC driver might need to
- * fetch ahead one row in order to determine whether the current row is the
- * last row in the result set.
- *
- *
- * @return true if on a valid row, false if no rows in the result set.
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY.
- */
- public boolean last() throws SQLException {
- checkClosed();
-
- boolean b = true;
-
- if (this.rowData.size() == 0) {
- b = false;
- } else {
-
- if (this.onInsertRow) {
- this.onInsertRow = false;
- }
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- }
-
- if (this.thisRow != null) {
- this.thisRow.closeOpenStreams();
- }
-
- this.rowData.beforeLast();
- this.thisRow = this.rowData.next();
- }
-
- setRowPositionValidity();
-
- return b;
- }
-
- // /////////////////////////////////////////
- //
- // These number conversion routines save
- // a ton of "new()s", especially for the heavily
- // used getInt() and getDouble() methods
- //
- // /////////////////////////////////////////
-
- /**
- * JDBC 2.0 Move the cursor to the remembered cursor position, usually the
- * current row. Has no effect unless the cursor is on the insert row.
- *
- * @exception SQLException
- * if a database-access error occurs, or the result set is
- * not updatable
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void moveToCurrentRow() throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Move to the insert row. The current cursor position is
- * remembered while the cursor is positioned on the insert row. The insert
- * row is a special row associated with an updatable result set. It is
- * essentially a buffer where a new row may be constructed by calling the
- * updateXXX() methods prior to inserting the row into the result set. Only
- * the updateXXX(), getXXX(), and insertRow() methods may be called when the
- * cursor is on the insert row. All of the columns in a result set must be
- * given a value each time this method is called before calling insertRow().
- * UpdateXXX()must be called before getXXX() on a column.
- *
- * @exception SQLException
- * if a database-access error occurs, or the result set is
- * not updatable
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void moveToInsertRow() throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * A ResultSet is initially positioned before its first row, the first call
- * to next makes the first row the current row; the second call makes the
- * second row the current row, etc.
- *
- *
- * If an input stream from the previous row is open, it is implicitly
- * closed. The ResultSet's warning chain is cleared when a new row is read
- *
- *
- * @return true if the new current is valid; false if there are no more rows
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public boolean next() throws SQLException {
- checkClosed();
-
- if (this.onInsertRow) {
- this.onInsertRow = false;
- }
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- }
-
- boolean b;
-
- if (!reallyResult()) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.ResultSet_is_from_UPDATE._No_Data_115"),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (this.thisRow != null) {
- this.thisRow.closeOpenStreams();
- }
-
- if (this.rowData.size() == 0) {
- b = false;
- } else {
- this.thisRow = this.rowData.next();
-
- if (this.thisRow == null) {
- b = false;
- } else {
- clearWarnings();
-
- b = true;
-
- }
- }
-
- setRowPositionValidity();
-
- return b;
- }
-
- private int parseIntAsDouble(int columnIndex, String val)
- throws NumberFormatException, SQLException {
- if (val == null) {
- return 0;
- }
-
- double valueAsDouble = Double.parseDouble(val);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Integer.MIN_VALUE
- || valueAsDouble > Integer.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble), columnIndex,
- Types.INTEGER);
- }
- }
-
- return (int) valueAsDouble;
- }
-
- private int getIntWithOverflowCheck(int columnIndex) throws SQLException {
- int intValue = this.thisRow.getInt(columnIndex);
-
- checkForIntegerTruncation(columnIndex,
- null, intValue);
-
- return intValue;
- }
-
- private void checkForIntegerTruncation(int columnIndex,
- byte[] valueAsBytes, int intValue)
- throws SQLException {
- if (this.jdbcCompliantTruncationForReads) {
- if (intValue == Integer.MIN_VALUE || intValue == Integer.MAX_VALUE) {
- String valueAsString = null;
-
- if (valueAsBytes == null) {
- valueAsString = this.thisRow.getString(
- columnIndex, this.fields[columnIndex].getCharacterSet(),
- this.connection);
- }
-
- long valueAsLong = Long
- .parseLong(valueAsString == null ? new String(
- valueAsBytes) : valueAsString);
-
- if (valueAsLong < Integer.MIN_VALUE
- || valueAsLong > Integer.MAX_VALUE) {
- throwRangeException(valueAsString == null ? new String(
- valueAsBytes) : valueAsString, columnIndex + 1,
- Types.INTEGER);
- }
- }
- }
- }
-
- private long parseLongAsDouble(int columnIndexZeroBased, String val)
- throws NumberFormatException, SQLException {
- if (val == null) {
- return 0;
- }
-
- double valueAsDouble = Double.parseDouble(val);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Long.MIN_VALUE
- || valueAsDouble > Long.MAX_VALUE) {
- throwRangeException(val, columnIndexZeroBased + 1, Types.BIGINT);
- }
- }
-
- return (long) valueAsDouble;
- }
-
- private long getLongWithOverflowCheck(int columnIndexZeroBased, boolean doOverflowCheck) throws SQLException {
- long longValue = this.thisRow.getLong(columnIndexZeroBased);
-
- if (doOverflowCheck) {
- checkForLongTruncation(columnIndexZeroBased, null, longValue);
- }
-
- return longValue;
- }
-
- private long parseLongWithOverflowCheck(int columnIndexZeroBased,
- byte[] valueAsBytes, String valueAsString, boolean doCheck)
- throws NumberFormatException, SQLException {
-
- long longValue = 0;
-
- if (valueAsBytes == null && valueAsString == null) {
- return 0;
- }
-
- if (valueAsBytes != null) {
- longValue = StringUtils.getLong(valueAsBytes);
- } else {
- //
- // JDK-6 doesn't like trailing whitespace
- //
- // Note this isn't a performance issue, other
- // than the iteration over the string, as String.trim()
- // will return a new string only if whitespace is present
- //
-
- valueAsString = valueAsString.trim();
-
- longValue = Long.parseLong(valueAsString);
- }
-
- if (doCheck && this.jdbcCompliantTruncationForReads) {
- checkForLongTruncation(columnIndexZeroBased, valueAsBytes, longValue);
- }
-
- return longValue;
- }
-
- private void checkForLongTruncation(int columnIndexZeroBased, byte[] valueAsBytes, long longValue) throws SQLException {
- if (longValue == Long.MIN_VALUE
- || longValue == Long.MAX_VALUE) {
- String valueAsString = null;
-
- if (valueAsBytes == null) {
- valueAsString = this.thisRow.getString(
- columnIndexZeroBased, this.fields[columnIndexZeroBased].getCharacterSet(),
- this.connection);
- }
-
- double valueAsDouble = Double
- .parseDouble(valueAsString == null ? new String(
- valueAsBytes) : valueAsString);
-
- if (valueAsDouble < Long.MIN_VALUE
- || valueAsDouble > Long.MAX_VALUE) {
- throwRangeException(valueAsString == null ? new String(
- valueAsBytes) : valueAsString, columnIndexZeroBased + 1,
- Types.BIGINT);
- }
- }
- }
-
- private short parseShortAsDouble(int columnIndex, String val)
- throws NumberFormatException, SQLException {
- if (val == null) {
- return 0;
- }
-
- double valueAsDouble = Double.parseDouble(val);
-
- if (this.jdbcCompliantTruncationForReads) {
- if (valueAsDouble < Short.MIN_VALUE
- || valueAsDouble > Short.MAX_VALUE) {
- throwRangeException(String.valueOf(valueAsDouble), columnIndex,
- Types.SMALLINT);
- }
- }
-
- return (short) valueAsDouble;
- }
-
- private short parseShortWithOverflowCheck(int columnIndex,
- byte[] valueAsBytes, String valueAsString)
- throws NumberFormatException, SQLException {
-
- short shortValue = 0;
-
- if (valueAsBytes == null && valueAsString == null) {
- return 0;
- }
-
- if (valueAsBytes != null) {
- shortValue = StringUtils.getShort(valueAsBytes);
- } else {
- //
- // JDK-6 doesn't like trailing whitespace
- //
- // Note this isn't a performance issue, other
- // than the iteration over the string, as String.trim()
- // will return a new string only if whitespace is present
- //
-
- valueAsString = valueAsString.trim();
-
- shortValue = Short.parseShort(valueAsString);
- }
-
- if (this.jdbcCompliantTruncationForReads) {
- if (shortValue == Short.MIN_VALUE || shortValue == Short.MAX_VALUE) {
- long valueAsLong = Long
- .parseLong(valueAsString == null ? new String(
- valueAsBytes) : valueAsString);
-
- if (valueAsLong < Short.MIN_VALUE
- || valueAsLong > Short.MAX_VALUE) {
- throwRangeException(valueAsString == null ? new String(
- valueAsBytes) : valueAsString, columnIndex,
- Types.SMALLINT);
- }
- }
- }
-
- return shortValue;
- }
-
- // --------------------------JDBC 2.0-----------------------------------
- // ---------------------------------------------------------------------
- // Getter's and Setter's
- // ---------------------------------------------------------------------
-
- /**
- * The prev method is not part of JDBC, but because of the architecture of
- * this driver it is possible to move both forward and backward within the
- * result set.
- *
- *
- * If an input stream from the previous row is open, it is implicitly
- * closed. The ResultSet's warning chain is cleared when a new row is read
- *
- *
- * @return true if the new current is valid; false if there are no more rows
- *
- * @exception java.sql.SQLException
- * if a database access error occurs
- */
- public boolean prev() throws java.sql.SQLException {
- checkClosed();
-
- int rowIndex = this.rowData.getCurrentRowNumber();
-
- if (this.thisRow != null) {
- this.thisRow.closeOpenStreams();
- }
-
- boolean b = true;
-
- if ((rowIndex - 1) >= 0) {
- rowIndex--;
- this.rowData.setCurrentRow(rowIndex);
- this.thisRow = this.rowData.getAt(rowIndex);
-
- b = true;
- } else if ((rowIndex - 1) == -1) {
- rowIndex--;
- this.rowData.setCurrentRow(rowIndex);
- this.thisRow = null;
-
- b = false;
- } else {
- b = false;
- }
-
- setRowPositionValidity();
-
- return b;
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the previous row in the result set.
- *
- *
- *
- * Note: previous() is not the same as relative(-1) since it makes sense to
- * call previous() when there is no current row.
- *
- *
- * @return true if on a valid row, false if off the result set.
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWAR_DONLY.
- */
- public boolean previous() throws SQLException {
- if (this.onInsertRow) {
- this.onInsertRow = false;
- }
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- }
-
- return prev();
- }
-
- /**
- * Closes this ResultSet and releases resources.
- *
- * @param calledExplicitly
- * was this called by close()?
- *
- * @throws SQLException
- * if an error occurs
- */
- public void realClose(boolean calledExplicitly) throws SQLException {
- if (this.isClosed) {
- return;
- }
-
- try {
- if (this.useUsageAdvisor) {
-
- // Report on result set closed by driver instead of application
-
- if (!calledExplicitly) {
- this.eventSink
- .consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN,
- "",
- (this.owningStatement == null) ? "N/A"
- : this.owningStatement.currentCatalog,
- this.connectionId,
- (this.owningStatement == null) ? (-1)
- : this.owningStatement.getId(),
- this.resultId,
- System.currentTimeMillis(),
- 0,
- Constants.MILLIS_I18N,
- null,
- this.pointOfOrigin,
- Messages
- .getString("ResultSet.ResultSet_implicitly_closed_by_driver"))); //$NON-NLS-1$
- }
-
- if (this.rowData instanceof RowDataStatic) {
-
- // Report on possibly too-large result sets
-
- if (this.rowData.size() > this.connection
- .getResultSetSizeThreshold()) {
- this.eventSink
- .consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN,
- "",
- (this.owningStatement == null) ? Messages
- .getString("ResultSet.N/A_159")
- : this.owningStatement.currentCatalog, //$NON-NLS-1$
- this.connectionId,
- (this.owningStatement == null) ? (-1)
- : this.owningStatement.getId(),
- this.resultId,
- System.currentTimeMillis(),
- 0,
- Constants.MILLIS_I18N,
- null,
- this.pointOfOrigin,
- Messages
- .getString(
- "ResultSet.Too_Large_Result_Set",
- new Object[] {
- new Integer(
- this.rowData
- .size()),
- new Integer(
- this.connection
- .getResultSetSizeThreshold()) })));
- }
-
- if (!isLast() && !isAfterLast() && (this.rowData.size() != 0)) {
-
- this.eventSink
- .consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN,
- "",
- (this.owningStatement == null) ? Messages
- .getString("ResultSet.N/A_159")
- : this.owningStatement.currentCatalog, //$NON-NLS-1$
- this.connectionId,
- (this.owningStatement == null) ? (-1)
- : this.owningStatement.getId(),
- this.resultId,
- System.currentTimeMillis(),
- 0,
- Constants.MILLIS_I18N,
- null,
- this.pointOfOrigin,
- Messages
- .getString(
- "ResultSet.Possible_incomplete_traversal_of_result_set", //$NON-NLS-1$
- new Object[] {
- new Integer(
- getRow()),
- new Integer(
- this.rowData
- .size()) })));
- }
- }
-
- //
- // Report on any columns that were selected but
- // not referenced
- //
-
- if (this.columnUsed.length > 0 && !this.rowData.wasEmpty()) {
- StringBuffer buf = new StringBuffer(
- Messages
- .getString("ResultSet.The_following_columns_were_never_referenced")); //$NON-NLS-1$
-
- boolean issueWarn = false;
-
- for (int i = 0; i < this.columnUsed.length; i++) {
- if (!this.columnUsed[i]) {
- if (!issueWarn) {
- issueWarn = true;
- } else {
- buf.append(", ");
- }
-
- buf.append(this.fields[i].getFullName());
- }
- }
-
- if (issueWarn) {
- this.eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN, "",
- (this.owningStatement == null) ? "N/A"
- : this.owningStatement.currentCatalog,
- this.connectionId,
- (this.owningStatement == null) ? (-1)
- : this.owningStatement.getId(), 0,
- System.currentTimeMillis(), 0,
- Constants.MILLIS_I18N, null,
- this.pointOfOrigin, buf.toString()));
- }
- }
- }
- } finally {
- if (this.owningStatement != null && calledExplicitly) {
- this.owningStatement.removeOpenResultSet(this);
- }
-
- SQLException exceptionDuringClose = null;
-
- if (this.rowData != null) {
- try {
- this.rowData.close();
- } catch (SQLException sqlEx) {
- exceptionDuringClose = sqlEx;
- }
- }
-
- if (this.statementUsedForFetchingRows != null) {
- try {
- this.statementUsedForFetchingRows.realClose(true, false);
- } catch (SQLException sqlEx) {
- if (exceptionDuringClose != null) {
- exceptionDuringClose.setNextException(sqlEx);
- } else {
- exceptionDuringClose = sqlEx;
- }
- }
- }
-
- this.rowData = null;
- this.defaultTimeZone = null;
- this.fields = null;
- this.columnLabelToIndex = null;
- this.fullColumnNameToIndex = null;
- this.columnToIndexCache = null;
- this.eventSink = null;
- this.warningChain = null;
-
- if (!this.retainOwningStatement) {
- this.owningStatement = null;
- }
-
- this.catalog = null;
- this.serverInfo = null;
- this.thisRow = null;
- this.fastDateCal = null;
- this.connection = null;
-
- this.isClosed = true;
-
- if (exceptionDuringClose != null) {
- throw exceptionDuringClose;
- }
- }
- }
-
- public boolean reallyResult() {
- if (this.rowData != null) {
- return true;
- }
-
- return this.reallyResult;
- }
-
- /**
- * JDBC 2.0 Refresh the value of the current row with its current value in
- * the database. Cannot be called when on the insert row. The refreshRow()
- * method provides a way for an application to explicitly tell the JDBC
- * driver to refetch a row(s) from the database. An application may want to
- * call refreshRow() when caching or prefetching is being done by the JDBC
- * driver to fetch the latest value of a row from the database. The JDBC
- * driver may actually refresh multiple rows at once if the fetch size is
- * greater than one. All values are refetched subject to the transaction
- * isolation level and cursor sensitivity. If refreshRow() is called after
- * calling updateXXX(), but before calling updateRow() then the updates made
- * to the row are lost. Calling refreshRow() frequently will likely slow
- * performance.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row.
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void refreshRow() throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves a relative number of rows, either positive or negative. Attempting
- * to move beyond the first/last row in the result set positions the cursor
- * before/after the the first/last row. Calling relative(0) is valid, but
- * does not change the cursor position.
- *
- *
- *
- * Note: Calling relative(1) is different than calling next() since is makes
- * sense to call next() when there is no current row, for example, when the
- * cursor is positioned before the first row or after the last row of the
- * result set.
- *
- *
- * @param rows
- * the number of relative rows to move the cursor.
- *
- * @return true if on a row, false otherwise.
- *
- * @throws SQLException
- * if a database-access error occurs, or there is no current
- * row, or result set type is TYPE_FORWARD_ONLY.
- */
- public boolean relative(int rows) throws SQLException {
- checkClosed();
-
- if (this.rowData.size() == 0) {
- setRowPositionValidity();
-
- return false;
- }
-
- if (this.thisRow != null) {
- this.thisRow.closeOpenStreams();
- }
-
- this.rowData.moveRowRelative(rows);
- this.thisRow = this.rowData.getAt(this.rowData.getCurrentRowNumber());
-
- setRowPositionValidity();
-
- return (!this.rowData.isAfterLast() && !this.rowData.isBeforeFirst());
- }
-
- /**
- * JDBC 2.0 Determine if this row has been deleted. A deleted row may leave
- * a visible "hole" in a result set. This method can be used to detect holes
- * in a result set. The value returned depends on whether or not the result
- * set can detect deletions.
- *
- * @return true if deleted and deletes are detected
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- *
- * @see DatabaseMetaData#deletesAreDetected
- */
- public boolean rowDeleted() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Determine if the current row has been inserted. The value
- * returned depends on whether or not the result set can detect visible
- * inserts.
- *
- * @return true if inserted and inserts are detected
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- *
- * @see DatabaseMetaData#insertsAreDetected
- */
- public boolean rowInserted() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Determine if the current row has been updated. The value
- * returned depends on whether or not the result set can detect updates.
- *
- * @return true if the row has been visibly updated by the owner or another,
- * and updates are detected
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- *
- * @see DatabaseMetaData#updatesAreDetected
- */
- public boolean rowUpdated() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * Flag that this result set is 'binary' encoded (from a PreparedStatement),
- * not stored as strings.
- */
- protected void setBinaryEncoded() {
- this.isBinaryEncoded = true;
- }
-
- private void setDefaultTimeZone(TimeZone defaultTimeZone) {
- this.defaultTimeZone = defaultTimeZone;
- }
-
- /**
- * JDBC 2.0 Give a hint as to the direction in which the rows in this result
- * set will be processed. The initial value is determined by the statement
- * that produced the result set. The fetch direction may be changed at any
- * time.
- *
- * @param direction
- * the direction to fetch rows in.
- *
- * @exception SQLException
- * if a database-access error occurs, or the result set type
- * is TYPE_FORWARD_ONLY and direction is not FETCH_FORWARD.
- * MM.MySQL actually ignores this, because it has the whole
- * result set anyway, so the direction is immaterial.
- */
- public void setFetchDirection(int direction) throws SQLException {
- if ((direction != FETCH_FORWARD) && (direction != FETCH_REVERSE)
- && (direction != FETCH_UNKNOWN)) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Illegal_value_for_fetch_direction_64"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- this.fetchDirection = direction;
- }
-
- /**
- * JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should
- * be fetched from the database when more rows are needed for this result
- * set. If the fetch size specified is zero, then the JDBC driver ignores
- * the value, and is free to make its own best guess as to what the fetch
- * size should be. The default value is set by the statement that creates
- * the result set. The fetch size may be changed at any time.
- *
- * @param rows
- * the number of rows to fetch
- *
- * @exception SQLException
- * if a database-access error occurs, or the condition 0 lteq
- * rows lteq this.getMaxRows() is not satisfied. Currently
- * ignored by this driver.
- */
- public void setFetchSize(int rows) throws SQLException {
- if (rows < 0) { /* || rows > getMaxRows() */
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Value_must_be_between_0_and_getMaxRows()_66"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- this.fetchSize = rows;
- }
-
- /**
- * Sets the first character of the query that this result set was created
- * from.
- *
- * @param c
- * the first character of the query...uppercased
- */
- public void setFirstCharOfQuery(char c) {
- this.firstCharOfQuery = c;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param nextResultSet
- * Sets the next result set in the result set chain for multiple
- * result sets.
- */
- protected void setNextResultSet(ResultSetInternalMethods nextResultSet) {
- this.nextResultSet = nextResultSet;
- }
-
- public void setOwningStatement(com.mysql.jdbc.StatementImpl owningStatement) {
- this.owningStatement = owningStatement;
- }
-
- /**
- * Sets the concurrency (JDBC2)
- *
- * @param concurrencyFlag
- * CONCUR_UPDATABLE or CONCUR_READONLY
- */
- protected void setResultSetConcurrency(int concurrencyFlag) {
- this.resultSetConcurrency = concurrencyFlag;
- }
-
- /**
- * Sets the result set type for (JDBC2)
- *
- * @param typeFlag
- * SCROLL_SENSITIVE or SCROLL_INSENSITIVE (we only support
- * SCROLL_INSENSITIVE)
- */
- protected void setResultSetType(int typeFlag) {
- this.resultSetType = typeFlag;
- }
-
- /**
- * Sets server info (if any)
- *
- * @param info
- * the server info message
- */
- protected void setServerInfo(String info) {
- this.serverInfo = info;
- }
-
- public void setStatementUsedForFetchingRows(PreparedStatement stmt) {
- this.statementUsedForFetchingRows = stmt;
- }
-
- /**
- * @param wrapperStatement
- * The wrapperStatement to set.
- */
- public void setWrapperStatement(java.sql.Statement wrapperStatement) {
- this.wrapperStatement = wrapperStatement;
- }
-
- private void throwRangeException(String valueAsString, int columnIndex,
- int jdbcType) throws SQLException {
- String datatype = null;
-
- switch (jdbcType) {
- case Types.TINYINT:
- datatype = "TINYINT";
- break;
- case Types.SMALLINT:
- datatype = "SMALLINT";
- break;
- case Types.INTEGER:
- datatype = "INTEGER";
- break;
- case Types.BIGINT:
- datatype = "BIGINT";
- break;
- case Types.REAL:
- datatype = "REAL";
- break;
- case Types.FLOAT:
- datatype = "FLOAT";
- break;
- case Types.DOUBLE:
- datatype = "DOUBLE";
- break;
- case Types.DECIMAL:
- datatype = "DECIMAL";
- break;
- default:
- datatype = " (JDBC type '" + jdbcType + "')";
- }
-
- throw SQLError.createSQLException("'" + valueAsString + "' in column '"
- + columnIndex + "' is outside valid range for the datatype "
- + datatype + ".", SQLError.SQL_STATE_NUMERIC_VALUE_OUT_OF_RANGE, getExceptionInterceptor());
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String toString() {
- if (this.reallyResult) {
- return super.toString();
- }
-
- return "Result set representing update count of " + this.updateCount;
- }
-
- /**
- * @see ResultSetInternalMethods#updateArray(int, Array)
- */
- public void updateArray(int arg0, Array arg1) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * @see ResultSetInternalMethods#updateArray(String, Array)
- */
- public void updateArray(String arg0, Array arg1) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Update a column with an ascii stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateAsciiStream(int columnIndex, java.io.InputStream x,
- int length) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with an ascii stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- * @param length
- * of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateAsciiStream(String columnName, java.io.InputStream x,
- int length) throws SQLException {
- updateAsciiStream(findColumn(columnName), x, length);
- }
-
- /**
- * JDBC 2.0 Update a column with a BigDecimal value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateBigDecimal(int columnIndex, BigDecimal x)
- throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a BigDecimal value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateBigDecimal(String columnName, BigDecimal x)
- throws SQLException {
- updateBigDecimal(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a binary stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateBinaryStream(int columnIndex, java.io.InputStream x,
- int length) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a binary stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- * @param length
- * of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateBinaryStream(String columnName, java.io.InputStream x,
- int length) throws SQLException {
- updateBinaryStream(findColumn(columnName), x, length);
- }
-
- /**
- * @see ResultSetInternalMethods#updateBlob(int, Blob)
- */
- public void updateBlob(int arg0, java.sql.Blob arg1) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * @see ResultSetInternalMethods#updateBlob(String, Blob)
- */
- public void updateBlob(String arg0, java.sql.Blob arg1) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a boolean value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateBoolean(int columnIndex, boolean x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a boolean value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateBoolean(String columnName, boolean x) throws SQLException {
- updateBoolean(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a byte value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateByte(int columnIndex, byte x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a byte value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateByte(String columnName, byte x) throws SQLException {
- updateByte(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a byte array value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateBytes(int columnIndex, byte[] x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a byte array value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateBytes(String columnName, byte[] x) throws SQLException {
- updateBytes(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateCharacterStream(int columnIndex, java.io.Reader x,
- int length) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param reader
- * the stream to update the column with
- * @param length
- * of the stream
- *
- * @throws SQLException
- * if a database-access error occurs
- */
- public void updateCharacterStream(String columnName, java.io.Reader reader,
- int length) throws SQLException {
- updateCharacterStream(findColumn(columnName), reader, length);
- }
-
- /**
- * @see ResultSetInternalMethods#updateClob(int, Clob)
- */
- public void updateClob(int arg0, java.sql.Clob arg1) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * @see ResultSetInternalMethods#updateClob(String, Clob)
- */
- public void updateClob(String columnName, java.sql.Clob clob)
- throws SQLException {
- updateClob(findColumn(columnName), clob);
- }
-
- /**
- * JDBC 2.0 Update a column with a Date value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateDate(int columnIndex, java.sql.Date x)
- throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a Date value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateDate(String columnName, java.sql.Date x)
- throws SQLException {
- updateDate(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a Double value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateDouble(int columnIndex, double x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a double value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateDouble(String columnName, double x) throws SQLException {
- updateDouble(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a float value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateFloat(int columnIndex, float x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a float value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateFloat(String columnName, float x) throws SQLException {
- updateFloat(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with an integer value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateInt(int columnIndex, int x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with an integer value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateInt(String columnName, int x) throws SQLException {
- updateInt(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a long value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateLong(int columnIndex, long x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a long value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateLong(String columnName, long x) throws SQLException {
- updateLong(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Give a nullable column a null value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateNull(int columnIndex) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a null value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateNull(String columnName) throws SQLException {
- updateNull(findColumn(columnName));
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateObject(int columnIndex, Object x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param scale
- * For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types
- * this is the number of digits after the decimal. For all other
- * types this value will be ignored.
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateObject(int columnIndex, Object x, int scale)
- throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateObject(String columnName, Object x) throws SQLException {
- updateObject(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- * @param scale
- * For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types
- * this is the number of digits after the decimal. For all other
- * types this value will be ignored.
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateObject(String columnName, Object x, int scale)
- throws SQLException {
- updateObject(findColumn(columnName), x);
- }
-
- /**
- * @see ResultSetInternalMethods#updateRef(int, Ref)
- */
- public void updateRef(int arg0, Ref arg1) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * @see ResultSetInternalMethods#updateRef(String, Ref)
- */
- public void updateRef(String arg0, Ref arg1) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Update the underlying database with the new contents of the
- * current row. Cannot be called when on the insert row.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateRow() throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a short value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateShort(int columnIndex, short x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a short value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateShort(String columnName, short x) throws SQLException {
- updateShort(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a String value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateString(int columnIndex, String x) throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a String value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateString(String columnName, String x) throws SQLException {
- updateString(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a Time value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateTime(int columnIndex, java.sql.Time x)
- throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a Time value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateTime(String columnName, java.sql.Time x)
- throws SQLException {
- updateTime(findColumn(columnName), x);
- }
-
-
- /**
- * JDBC 2.0 Update a column with a Timestamp value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public void updateTimestamp(int columnIndex, java.sql.Timestamp x)
- throws SQLException {
- throw new NotUpdatable();
- }
-
- /**
- * JDBC 2.0 Update a column with a Timestamp value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public void updateTimestamp(String columnName, java.sql.Timestamp x)
- throws SQLException {
- updateTimestamp(findColumn(columnName), x);
- }
-
- /**
- * A column may have the value of SQL NULL; wasNull() reports whether the
- * last column read had this special value. Note that you must first call
- * getXXX on a column to try to read its value and then call wasNull() to
- * find if the value was SQL NULL
- *
- * @return true if the last column read was SQL NULL
- *
- * @exception SQLException
- * if a database access error occurred
- */
- public boolean wasNull() throws SQLException {
- return this.wasNullFlag;
- }
-
- protected Calendar getGmtCalendar() {
-
- // Worst case we allocate this twice and the other gets GC'd,
- // however prevents deadlock
- if (this.gmtCalendar == null) {
- this.gmtCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- }
-
- return this.gmtCalendar;
- }
-
- protected ExceptionInterceptor getExceptionInterceptor() {
- return this.exceptionInterceptor;
- }
-}
diff --git a/src/com/mysql/jdbc/ResultSetInternalMethods.java b/src/com/mysql/jdbc/ResultSetInternalMethods.java
deleted file mode 100644
index bf29ca3fe..000000000
--- a/src/com/mysql/jdbc/ResultSetInternalMethods.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-/**
- * This interface is intended to be used by implementors of statement
- * interceptors so that implementors can create static or dynamic (via
- * java.lang.reflect.Proxy) proxy instances of ResultSets. It consists
- * of methods outside of java.sql.Result that are used internally by
- * other classes in the driver.
- *
- * This interface, although public is not designed to
- * be consumed publicly other than for the statement interceptor use case.
- *
- * @version $Id: $
- */
-public interface ResultSetInternalMethods extends java.sql.ResultSet {
-
- /**
- * Returns a new instance of this result set, that shares the
- * underlying row data.
- */
- public abstract ResultSetInternalMethods copy() throws SQLException;
-
- /**
- * Does the result set contain rows, or is it the result of a DDL or DML
- * statement?
- */
- public abstract boolean reallyResult();
-
- /**
- * Functions like ResultSet.getObject(), but using the given SQL type
- * (as registered during CallableStatement.registerOutParameter()).
- */
- public abstract Object getObjectStoredProc(int columnIndex, int desiredSqlType)
- throws SQLException;
-
- /**
- * Functions like ResultSet.getObject(), but using the given SQL type
- * (as registered during CallableStatement.registerOutParameter()).
- */
- public abstract Object getObjectStoredProc(int i, java.util.Map map,
- int desiredSqlType) throws SQLException;
-
- /**
- * Functions like ResultSet.getObject(), but using the given SQL type
- * (as registered during CallableStatement.registerOutParameter()).
- */
- public abstract Object getObjectStoredProc(String columnName, int desiredSqlType)
- throws SQLException;
-
- /**
- * Functions like ResultSet.getObject(), but using the given SQL type
- * (as registered during CallableStatement.registerOutParameter()).
- */
- public abstract Object getObjectStoredProc(String colName, java.util.Map map,
- int desiredSqlType) throws SQLException;
-
- /**
- * Returns the server informational message returned from a DDL or DML
- * statement (if any), or null if none.
- */
- public String getServerInfo();
-
- /**
- * Returns the update count for this result set (if one exists), otherwise
- * -1.
- *
- * @ return the update count for this result set (if one exists), otherwise
- * -1.
- */
- public long getUpdateCount();
-
- /**
- * Returns the AUTO_INCREMENT value for the DDL/DML statement which created
- * this result set.
- *
- * @return the AUTO_INCREMENT value for the DDL/DML statement which created
- * this result set.
- */
- public long getUpdateID();
-
- /**
- * Closes this ResultSet and releases resources.
- *
- * @param calledExplicitly was realClose called by the standard
- * ResultSet.close() method, or was it closed internally by the driver?
- */
- public void realClose(boolean calledExplicitly) throws SQLException;
-
- /**
- * Sets the first character of the query that was issued to create
- * this result set. The character should be upper-cased.
- */
- public void setFirstCharOfQuery(char firstCharUpperCase);
-
- /**
- * Sets the statement that "owns" this result set (usually used when the
- * result set should internally "belong" to one statement, but is created
- * by another.
- */
- public void setOwningStatement(com.mysql.jdbc.StatementImpl owningStatement);
-
- /**
- * Returns the first character of the query that was issued to create this
- * result set, upper-cased.
- */
- public char getFirstCharOfQuery();
-
- /**
- * Clears the reference to the next result set in a multi-result set
- * "chain".
- */
- public void clearNextResult();
-
- /**
- * Returns the next ResultSet in a multi-resultset "chain", if any,
- * null if none exists.
- */
- public ResultSetInternalMethods getNextResultSet();
-
- public void setStatementUsedForFetchingRows(PreparedStatement stmt);
-
- /**
- * @param wrapperStatement
- * The wrapperStatement to set.
- */
- public void setWrapperStatement(java.sql.Statement wrapperStatement);
-
- /**
- * Builds a hash between column names and their indices for fast retrieval.
- * This is done lazily to support findColumn() and get*(String), as it
- * can be more expensive than just retrieving result set values by ordinal
- * index.
- */
- public void buildIndexMapping() throws SQLException;
-
- public void initializeWithMetadata() throws SQLException;
-
- /**
- * Used by DatabaseMetadata implementations to coerce the metadata returned
- * by metadata queries into that required by the JDBC specification.
- *
- * @param metadataFields the coerced metadata to be applied to result sets
- * returned by "SHOW ..." or SELECTs on INFORMATION_SCHEMA performed on behalf
- * of methods in DatabaseMetadata.
- */
- public void redefineFieldsForDBMD(Field[] metadataFields);
-
- public void populateCachedMetaData(CachedResultSetMetaData cachedMetaData) throws SQLException;
-
- public void initializeFromCachedMetaData(CachedResultSetMetaData cachedMetaData);
-
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/ResultSetMetaData.java b/src/com/mysql/jdbc/ResultSetMetaData.java
deleted file mode 100644
index 31038b7a2..000000000
--- a/src/com/mysql/jdbc/ResultSetMetaData.java
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.sql.Types;
-
-/**
- * A ResultSetMetaData object can be used to find out about the types and
- * properties of the columns in a ResultSet
- *
- * @author Mark Matthews
- * @version $Id: ResultSetMetaData.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews
- * Exp $
- *
- * @see java.sql.ResultSetMetaData
- */
-public class ResultSetMetaData implements java.sql.ResultSetMetaData {
- private static int clampedGetLength(Field f) {
- long fieldLength = f.getLength();
-
- if (fieldLength > Integer.MAX_VALUE) {
- fieldLength = Integer.MAX_VALUE;
- }
-
- return (int) fieldLength;
- }
-
- /**
- * Checks if the SQL Type is a Decimal/Number Type
- *
- * @param type
- * SQL Type
- *
- * @return ...
- */
- private static final boolean isDecimalType(int type) {
- switch (type) {
- case Types.BIT:
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.NUMERIC:
- case Types.DECIMAL:
- return true;
- }
-
- return false;
- }
-
- Field[] fields;
- boolean useOldAliasBehavior = false;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- /**
- * Initialise for a result with a tuple set and a field descriptor set
- *
- * @param fields
- * the array of field descriptors
- */
- public ResultSetMetaData(Field[] fields, boolean useOldAliasBehavior, ExceptionInterceptor exceptionInterceptor) {
- this.fields = fields;
- this.useOldAliasBehavior = useOldAliasBehavior;
- this.exceptionInterceptor = exceptionInterceptor;
- }
-
- /**
- * What's a column's table's catalog name?
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return catalog name, or "" if not applicable
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public String getCatalogName(int column) throws SQLException {
- Field f = getField(column);
-
- String database = f.getDatabaseName();
-
- return (database == null) ? "" : database; //$NON-NLS-1$
- }
-
- /**
- * What's the Java character encoding name for the given column?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return the Java character encoding name for the given column, or null if
- * no Java character encoding maps to the MySQL character set for
- * the given column.
- *
- * @throws SQLException
- * if an invalid column index is given.
- */
- public String getColumnCharacterEncoding(int column) throws SQLException {
- String mysqlName = getColumnCharacterSet(column);
-
- String javaName = null;
-
- if (mysqlName != null) {
- javaName = CharsetMapping.getJavaEncodingForMysqlEncoding(
- mysqlName, null);
- }
-
- return javaName;
- }
-
- /**
- * What's the MySQL character set name for the given column?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return the MySQL character set name for the given column
- *
- * @throws SQLException
- * if an invalid column index is given.
- */
- public String getColumnCharacterSet(int column) throws SQLException {
- return getField(column).getCharacterSet();
- }
-
- // --------------------------JDBC 2.0-----------------------------------
-
- /**
- * JDBC 2.0
- *
- *
- * Return the fully qualified name of the Java class whose instances are
- * manufactured if ResultSet.getObject() is called to retrieve a value from
- * the column. ResultSet.getObject() may return a subClass of the class
- * returned by this method.
- *
- *
- * @param column
- * the column number to retrieve information for
- *
- * @return the fully qualified name of the Java class whose instances are
- * manufactured if ResultSet.getObject() is called to retrieve a
- * value from the column.
- *
- * @throws SQLException
- * if an error occurs
- */
- public String getColumnClassName(int column) throws SQLException {
- Field f = getField(column);
-
- return getClassNameForJavaType(f.getSQLType(),
- f.isUnsigned(),
- f.getMysqlType(),
- f.isBinary() || f.isBlob(),
- f.isOpaqueBinary());
- }
-
- /**
- * Whats the number of columns in the ResultSet?
- *
- * @return the number
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public int getColumnCount() throws SQLException {
- return this.fields.length;
- }
-
- /**
- * What is the column's normal maximum width in characters?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return the maximum width
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public int getColumnDisplaySize(int column) throws SQLException {
- Field f = getField(column);
-
- int lengthInBytes = clampedGetLength(f);
-
- return lengthInBytes / f.getMaxBytesPerCharacter();
- }
-
- /**
- * What is the suggested column title for use in printouts and displays?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return the column label
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public String getColumnLabel(int column) throws SQLException {
- if (this.useOldAliasBehavior) {
- return getColumnName(column);
- }
-
- return getField(column).getColumnLabel();
- }
-
- /**
- * What's a column's name?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return the column name
- *
- * @throws SQLException
- * if a databvase access error occurs
- */
- public String getColumnName(int column) throws SQLException {
- if (this.useOldAliasBehavior) {
- return getField(column).getName();
- }
-
- String name = getField(column).getNameNoAliases();
-
- if (name != null && name.length() == 0) {
- return getField(column).getName();
- }
-
- return name;
- }
-
- /**
- * What is a column's SQL Type? (java.sql.Type int)
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return the java.sql.Type value
- *
- * @throws SQLException
- * if a database access error occurs
- *
- * @see java.sql.Types
- */
- public int getColumnType(int column) throws SQLException {
- return getField(column).getSQLType();
- }
-
- /**
- * Whats is the column's data source specific type name?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return the type name
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public String getColumnTypeName(int column) throws java.sql.SQLException {
- Field field = getField(column);
-
- int mysqlType = field.getMysqlType();
- int jdbcType = field.getSQLType();
-
- switch (mysqlType) {
- case MysqlDefs.FIELD_TYPE_BIT:
- return "BIT";
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- return field.isUnsigned() ? "DECIMAL UNSIGNED" : "DECIMAL";
-
- case MysqlDefs.FIELD_TYPE_TINY:
- return field.isUnsigned() ? "TINYINT UNSIGNED" : "TINYINT";
-
- case MysqlDefs.FIELD_TYPE_SHORT:
- return field.isUnsigned() ? "SMALLINT UNSIGNED" : "SMALLINT";
-
- case MysqlDefs.FIELD_TYPE_LONG:
- return field.isUnsigned() ? "INT UNSIGNED" : "INT";
-
- case MysqlDefs.FIELD_TYPE_FLOAT:
- return field.isUnsigned() ? "FLOAT UNSIGNED" : "FLOAT";
-
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- return field.isUnsigned() ? "DOUBLE UNSIGNED" : "DOUBLE";
-
- case MysqlDefs.FIELD_TYPE_NULL:
- return "NULL"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- return "TIMESTAMP"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- return field.isUnsigned() ? "BIGINT UNSIGNED" : "BIGINT";
-
- case MysqlDefs.FIELD_TYPE_INT24:
- return field.isUnsigned() ? "MEDIUMINT UNSIGNED" : "MEDIUMINT";
-
- case MysqlDefs.FIELD_TYPE_DATE:
- return "DATE"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_TIME:
- return "TIME"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_DATETIME:
- return "DATETIME"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- return "TINYBLOB"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- return "MEDIUMBLOB"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- return "LONGBLOB"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_BLOB:
- if (getField(column).isBinary()) {
- return "BLOB";//$NON-NLS-1$
- }
-
- return "TEXT";//$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- return "VARCHAR"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- if (jdbcType == Types.VARBINARY) {
- return "VARBINARY";
- }
-
- return "VARCHAR"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_STRING:
- if (jdbcType == Types.BINARY) {
- return "BINARY";
- }
-
- return "CHAR"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_ENUM:
- return "ENUM"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_YEAR:
- return "YEAR"; // $NON_NLS-1$
-
- case MysqlDefs.FIELD_TYPE_SET:
- return "SET"; //$NON-NLS-1$
-
- case MysqlDefs.FIELD_TYPE_GEOMETRY:
- return "GEOMETRY"; //$NON-NLS-1$
-
- default:
- return "UNKNOWN"; //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the field instance for the given column index
- *
- * @param columnIndex
- * the column number to retrieve a field instance for
- *
- * @return the field instance for the given column index
- *
- * @throws SQLException
- * if an error occurs
- */
- protected Field getField(int columnIndex) throws SQLException {
- if ((columnIndex < 1) || (columnIndex > this.fields.length)) {
- throw SQLError.createSQLException(Messages.getString("ResultSetMetaData.46"), //$NON-NLS-1$
- SQLError.SQL_STATE_INVALID_COLUMN_NUMBER, this.exceptionInterceptor);
- }
-
- return this.fields[columnIndex - 1];
- }
-
- /**
- * What is a column's number of decimal digits.
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return the precision
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public int getPrecision(int column) throws SQLException {
- Field f = getField(column);
-
- // if (f.getMysqlType() == MysqlDefs.FIELD_TYPE_NEW_DECIMAL) {
- // return f.getLength();
- // }
-
- if (isDecimalType(f.getSQLType())) {
- if (f.getDecimals() > 0) {
- return clampedGetLength(f) - 1 + f.getPrecisionAdjustFactor();
- }
-
- return clampedGetLength(f) + f.getPrecisionAdjustFactor();
- }
-
- switch (f.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_TINY_BLOB:
- case MysqlDefs.FIELD_TYPE_BLOB:
- case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
- case MysqlDefs.FIELD_TYPE_LONG_BLOB:
- return clampedGetLength(f); // this may change in the future
- // for now, the server only
- // returns FIELD_TYPE_BLOB for _all_
- // BLOB types, but varying lengths
- // indicating the _maximum_ size
- // for each BLOB type.
- default:
- return clampedGetLength(f) / f.getMaxBytesPerCharacter();
-
- }
- }
-
- /**
- * What is a column's number of digits to the right of the decimal point?
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return the scale
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public int getScale(int column) throws SQLException {
- Field f = getField(column);
-
- if (isDecimalType(f.getSQLType())) {
- return f.getDecimals();
- }
-
- return 0;
- }
-
- /**
- * What is a column's table's schema? This relies on us knowing the table
- * name. The JDBC specification allows us to return "" if this is not
- * applicable.
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return the Schema
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public String getSchemaName(int column) throws SQLException {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Whats a column's table's name?
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return column name, or "" if not applicable
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public String getTableName(int column) throws SQLException {
- if (this.useOldAliasBehavior) {
- return getField(column).getTableName();
- }
-
- return getField(column).getTableNameNoAliases();
- }
-
- /**
- * Is the column automatically numbered (and thus read-only)
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return true if so
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public boolean isAutoIncrement(int column) throws SQLException {
- Field f = getField(column);
-
- return f.isAutoIncrement();
- }
-
- /**
- * Does a column's case matter?
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return true if so
- *
- * @throws java.sql.SQLException
- * if a database access error occurs
- */
- public boolean isCaseSensitive(int column) throws java.sql.SQLException {
- Field field = getField(column);
-
- int sqlType = field.getSQLType();
-
- switch (sqlType) {
- case Types.BIT:
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return false;
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
-
- if (field.isBinary()) {
- return true;
- }
-
- String collationName = field.getCollation();
-
- return ((collationName != null) && !collationName.endsWith("_ci"));
-
- default:
- return true;
- }
- }
-
- /**
- * Is the column a cash value?
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return true if its a cash column
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public boolean isCurrency(int column) throws SQLException {
- return false;
- }
-
- /**
- * Will a write on this column definately succeed?
- *
- * @param column
- * the first column is 1, the second is 2, etc..
- *
- * @return true if so
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public boolean isDefinitelyWritable(int column) throws SQLException {
- return isWritable(column);
- }
-
- /**
- * Can you put a NULL in this column?
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return one of the columnNullable values
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public int isNullable(int column) throws SQLException {
- if (!getField(column).isNotNull()) {
- return java.sql.ResultSetMetaData.columnNullable;
- }
-
- return java.sql.ResultSetMetaData.columnNoNulls;
- }
-
- /**
- * Is the column definitely not writable?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return true if so
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public boolean isReadOnly(int column) throws SQLException {
- return getField(column).isReadOnly();
- }
-
- /**
- * Can the column be used in a WHERE clause? Basically for this, I split the
- * functions into two types: recognised types (which are always useable),
- * and OTHER types (which may or may not be useable). The OTHER types, for
- * now, I will assume they are useable. We should really query the catalog
- * to see if they are useable.
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return true if they can be used in a WHERE clause
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public boolean isSearchable(int column) throws SQLException {
- return true;
- }
-
- /**
- * Is the column a signed number?
- *
- * @param column
- * the first column is 1, the second is 2...
- *
- * @return true if so
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public boolean isSigned(int column) throws SQLException {
- Field f = getField(column);
- int sqlType = f.getSQLType();
-
- switch (sqlType) {
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.NUMERIC:
- case Types.DECIMAL:
- return !f.isUnsigned();
-
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- return false;
-
- default:
- return false;
- }
- }
-
- /**
- * Is it possible for a write on the column to succeed?
- *
- * @param column
- * the first column is 1, the second is 2, etc.
- *
- * @return true if so
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public boolean isWritable(int column) throws SQLException {
- return !isReadOnly(column);
- }
-
- /**
- * Returns a string representation of this object
- *
- * @return ...
- */
- public String toString() {
- StringBuffer toStringBuf = new StringBuffer();
- toStringBuf.append(super.toString());
- toStringBuf.append(" - Field level information: "); //$NON-NLS-1$
-
- for (int i = 0; i < this.fields.length; i++) {
- toStringBuf.append("\n\t"); //$NON-NLS-1$
- toStringBuf.append(this.fields[i].toString());
- }
-
- return toStringBuf.toString();
- }
-
- static String getClassNameForJavaType(int javaType,
- boolean isUnsigned, int mysqlTypeIfKnown,
- boolean isBinaryOrBlob,
- boolean isOpaqueBinary) {
- switch (javaType) {
- case Types.BIT:
- case Types.BOOLEAN:
- return "java.lang.Boolean"; //$NON-NLS-1$
-
- case Types.TINYINT:
-
- if (isUnsigned) {
- return "java.lang.Integer"; //$NON-NLS-1$
- }
-
- return "java.lang.Integer"; //$NON-NLS-1$
-
- case Types.SMALLINT:
-
- if (isUnsigned) {
- return "java.lang.Integer"; //$NON-NLS-1$
- }
-
- return "java.lang.Integer"; //$NON-NLS-1$
-
- case Types.INTEGER:
-
- if (!isUnsigned ||
- mysqlTypeIfKnown == MysqlDefs.FIELD_TYPE_INT24) {
- return "java.lang.Integer"; //$NON-NLS-1$
- }
-
- return "java.lang.Long"; //$NON-NLS-1$
-
- case Types.BIGINT:
-
- if (!isUnsigned) {
- return "java.lang.Long"; //$NON-NLS-1$
- }
-
- return "java.math.BigInteger"; //$NON-NLS-1$
-
- case Types.DECIMAL:
- case Types.NUMERIC:
- return "java.math.BigDecimal"; //$NON-NLS-1$
-
- case Types.REAL:
- return "java.lang.Float"; //$NON-NLS-1$
-
- case Types.FLOAT:
- case Types.DOUBLE:
- return "java.lang.Double"; //$NON-NLS-1$
-
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- if (!isOpaqueBinary) {
- return "java.lang.String"; //$NON-NLS-1$
- }
-
- return "[B";
-
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
-
- if (mysqlTypeIfKnown == MysqlDefs.FIELD_TYPE_GEOMETRY) {
- return "[B";
- } else if (isBinaryOrBlob) {
- return "[B";
- } else {
- return "java.lang.String";
- }
-
- case Types.DATE:
- return "java.sql.Date"; //$NON-NLS-1$
-
- case Types.TIME:
- return "java.sql.Time"; //$NON-NLS-1$
-
- case Types.TIMESTAMP:
- return "java.sql.Timestamp"; //$NON-NLS-1$
-
- default:
- return "java.lang.Object"; //$NON-NLS-1$
- }
- }
-
- /**
- * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
- * for an object that does. Returns false otherwise. If this implements the interface then return true,
- * else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
- * object. If this does not implement the interface and is not a wrapper, return false.
- * This method should be implemented as a low-cost operation compared to unwrap so that
- * callers can use this method to avoid expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument should succeed.
- *
- * @param interfaces a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly wraps an object that does.
- * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
- * for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class iface) throws SQLException {
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to non-standard methods,
- * or standard methods not exposed by the proxy.
- * The result may be either the object found to implement the interface or a proxy for that object.
- * If the receiver implements the interface then that is the object. If the receiver is a wrapper
- * and the wrapped object implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped object. If the receiver is not a
- * wrapper and does not implement the interface, then an SQLException is thrown.
- *
- * @param iface A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the actual implementing object.
- * @throws java.sql.SQLException If no object found that implements the interface
- * @since 1.6
- */
- public Object unwrap(Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return Util.cast(iface, this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-}
diff --git a/src/com/mysql/jdbc/ResultSetRow.java b/src/com/mysql/jdbc/ResultSetRow.java
deleted file mode 100644
index c48adb9ba..000000000
--- a/src/com/mysql/jdbc/ResultSetRow.java
+++ /dev/null
@@ -1,1414 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.sql.Date;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.Calendar;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-/**
- * Classes that implement this interface represent one row of data from the
- * MySQL server that might be stored in different ways depending on whether the
- * result set was streaming (so they wrap a reusable packet), or whether the
- * result set was cached or via a server-side cursor (so they represent a
- * byte[][]).
- *
- * Notice that no bounds checking is expected for implementors
- * of this interface, it happens in ResultSetImpl.
- *
- * @version $Id: $
- */
-public abstract class ResultSetRow {
- protected ExceptionInterceptor exceptionInterceptor;
-
- protected ResultSetRow(ExceptionInterceptor exceptionInterceptor) {
- this.exceptionInterceptor = exceptionInterceptor;
- }
-
- /**
- * The metadata of the fields of this result set.
- */
- protected Field[] metadata;
-
- /**
- * Called during navigation to next row to close all open
- * streams.
- */
- public abstract void closeOpenStreams();
-
- /**
- * Returns data at the given index as an InputStream with no
- * character conversion.
- *
- * @param columnIndex
- * of the column value (starting at 0) to return.
- * @return the value at the given index as an InputStream or null
- * if null.
- *
- * @throws SQLException if an error occurs while retrieving the value.
- */
- public abstract InputStream getBinaryInputStream(int columnIndex)
- throws SQLException;
-
- /**
- * Returns the value at the given column (index starts at 0) "raw" (i.e.
- * as-returned by the server).
- *
- * @param index
- * of the column value (starting at 0) to return.
- * @return the value for the given column (including NULL if it is)
- * @throws SQLException
- * if an error occurs while retrieving the value.
- */
- public abstract byte[] getColumnValue(int index) throws SQLException;
-
- protected final java.sql.Date getDateFast(int columnIndex,
- byte[] dateAsBytes, int offset, int length, ConnectionImpl conn,
- ResultSetImpl rs, Calendar targetCalendar) throws SQLException {
-
- int year = 0;
- int month = 0;
- int day = 0;
-
- try {
- if (dateAsBytes == null) {
- return null;
- }
-
- boolean allZeroDate = true;
-
- boolean onlyTimePresent = false;
-
- for (int i = 0; i < length; i++) {
- if (dateAsBytes[offset + i] == ':') {
- onlyTimePresent = true;
- break;
- }
- }
-
- for (int i = 0; i < length; i++) {
- byte b = dateAsBytes[offset + i];
-
- if (b == ' ' || b == '-' || b == '/') {
- onlyTimePresent = false;
- }
-
- if (b != '0' && b != ' ' && b != ':' && b != '-' && b != '/'
- && b != '.') {
- allZeroDate = false;
-
- break;
- }
- }
-
- if (!onlyTimePresent && allZeroDate) {
-
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(conn.getZeroDateTimeBehavior())) {
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(conn.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '"
- + new String(dateAsBytes)
- + "' can not be represented as java.sql.Date",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
-
- // We're left with the case of 'round' to a date Java _can_
- // represent, which is '0001-01-01'.
- return rs.fastDateCreate(targetCalendar, 1, 1, 1);
-
- } else if (this.metadata[columnIndex].getMysqlType() == MysqlDefs.FIELD_TYPE_TIMESTAMP) {
- // Convert from TIMESTAMP
- switch (length) {
- case 29:
- case 21:
- case 19: { // java.sql.Timestamp format
- year = StringUtils.getInt(dateAsBytes, offset + 0,
- offset + 4);
- month = StringUtils.getInt(dateAsBytes, offset + 5,
- offset + 7);
- day = StringUtils.getInt(dateAsBytes, offset + 8,
- offset + 10);
-
- return rs.fastDateCreate(targetCalendar, year, month, day);
- }
-
- case 14:
- case 8: {
- year = StringUtils.getInt(dateAsBytes, offset + 0,
- offset + 4);
- month = StringUtils.getInt(dateAsBytes, offset + 4,
- offset + 6);
- day = StringUtils.getInt(dateAsBytes, offset + 6,
- offset + 8);
-
- return rs.fastDateCreate(targetCalendar, year, month, day);
- }
-
- case 12:
- case 10:
- case 6: {
- year = StringUtils.getInt(dateAsBytes, offset + 0,
- offset + 2);
-
- if (year <= 69) {
- year = year + 100;
- }
-
- month = StringUtils.getInt(dateAsBytes, offset + 2,
- offset + 4);
- day = StringUtils.getInt(dateAsBytes, offset + 4,
- offset + 6);
-
- return rs.fastDateCreate(targetCalendar, year + 1900, month, day);
- }
-
- case 4: {
- year = StringUtils.getInt(dateAsBytes, offset + 0,
- offset + 4);
-
- if (year <= 69) {
- year = year + 100;
- }
-
- month = StringUtils.getInt(dateAsBytes, offset + 2,
- offset + 4);
-
- return rs.fastDateCreate(targetCalendar, year + 1900, month, 1);
- }
-
- case 2: {
- year = StringUtils.getInt(dateAsBytes, offset + 0,
- offset + 2);
-
- if (year <= 69) {
- year = year + 100;
- }
-
- return rs.fastDateCreate(targetCalendar, year + 1900, 1, 1);
- }
-
- default:
- throw SQLError
- .createSQLException(
- Messages
- .getString(
- "ResultSet.Bad_format_for_Date",
- new Object[] {
- new String(
- dateAsBytes),
- Constants
- .integerValueOf(columnIndex + 1) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor); //$NON-NLS-1$
- } /* endswitch */
- } else if (this.metadata[columnIndex].getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR) {
-
- if (length == 2 || length == 1) {
- year = StringUtils.getInt(dateAsBytes, offset, offset
- + length);
-
- if (year <= 69) {
- year = year + 100;
- }
-
- year += 1900;
- } else {
- year = StringUtils.getInt(dateAsBytes, offset + 0,
- offset + 4);
- }
-
- return rs.fastDateCreate(targetCalendar, year, 1, 1);
- } else if (this.metadata[columnIndex].getMysqlType() == MysqlDefs.FIELD_TYPE_TIME) {
- return rs.fastDateCreate(targetCalendar, 1970, 1, 1); // Return EPOCH
- } else {
- if (length < 10) {
- if (length == 8) {
- return rs.fastDateCreate(targetCalendar, 1970, 1, 1); // Return
- // EPOCH for
- // TIME
- }
-
- throw SQLError
- .createSQLException(
- Messages
- .getString(
- "ResultSet.Bad_format_for_Date",
- new Object[] {
- new String(
- dateAsBytes),
- Constants
- .integerValueOf(columnIndex + 1) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor); //$NON-NLS-1$
- }
-
- if (length != 18) {
- year = StringUtils.getInt(dateAsBytes, offset + 0,
- offset + 4);
- month = StringUtils.getInt(dateAsBytes, offset + 5,
- offset + 7);
- day = StringUtils.getInt(dateAsBytes, offset + 8,
- offset + 10);
- } else {
- // JDK-1.3 timestamp format, not real easy to parse
- // positionally :p
- StringTokenizer st = new StringTokenizer(new String(
- dateAsBytes, offset, length, "ISO8859_1"), "- ");
-
- year = Integer.parseInt(st.nextToken());
- month = Integer.parseInt(st.nextToken());
- day = Integer.parseInt(st.nextToken());
- }
- }
-
- return rs.fastDateCreate(targetCalendar, year, month, day);
- } catch (SQLException sqlEx) {
- throw sqlEx; // don't re-wrap
- } catch (Exception e) {
- SQLException sqlEx = SQLError.createSQLException(Messages.getString(
- "ResultSet.Bad_format_for_Date", new Object[] {
- new String(dateAsBytes),
- Constants.integerValueOf(columnIndex + 1) }),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor); //$NON-NLS-1$
- sqlEx.initCause(e);
-
- throw sqlEx;
- }
- }
-
- public abstract java.sql.Date getDateFast(int columnIndex,
- ConnectionImpl conn, ResultSetImpl rs, Calendar targetCalendar) throws SQLException;
-
- /**
- * Returns the value at the given column (index starts at 0) as an int. *
- *
- * @param index
- * of the column value (starting at 0) to return.
- * @return the value for the given column (returns 0 if NULL, use isNull()
- * to determine if the value was actually NULL)
- * @throws SQLException
- * if an error occurs while retrieving the value.
- */
- public abstract int getInt(int columnIndex) throws SQLException;
-
- /**
- * Returns the value at the given column (index starts at 0) as a long. *
- *
- * @param index
- * of the column value (starting at 0) to return.
- * @return the value for the given column (returns 0 if NULL, use isNull()
- * to determine if the value was actually NULL)
- * @throws SQLException
- * if an error occurs while retrieving the value.
- */
- public abstract long getLong(int columnIndex) throws SQLException;
-
- protected java.sql.Date getNativeDate(int columnIndex, byte[] bits,
- int offset, int length, ConnectionImpl conn, ResultSetImpl rs, Calendar cal)
- throws SQLException {
-
- int year = 0;
- int month = 0;
- int day = 0;
-
- if (length != 0) {
- year = (bits[offset + 0] & 0xff) | ((bits[offset + 1] & 0xff) << 8);
-
- month = bits[offset + 2];
- day = bits[offset + 3];
- }
-
- if ((year == 0) && (month == 0) && (day == 0)) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(conn.getZeroDateTimeBehavior())) {
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(conn.getZeroDateTimeBehavior())) {
- throw SQLError
- .createSQLException(
- "Value '0000-00-00' can not be represented as java.sql.Date",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
-
- year = 1;
- month = 1;
- day = 1;
- }
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastDateCreate(year, month, day, cal);
- }
-
- return rs.fastDateCreate(cal == null ? rs.getCalendarInstanceForSessionOrNew() : cal, year,
- month, day);
- }
-
- public abstract Date getNativeDate(int columnIndex, ConnectionImpl conn,
- ResultSetImpl rs, Calendar cal) throws SQLException;
-
- protected Object getNativeDateTimeValue(int columnIndex, byte[] bits,
- int offset, int length, Calendar targetCalendar, int jdbcType,
- int mysqlType, TimeZone tz, boolean rollForward, ConnectionImpl conn,
- ResultSetImpl rs) throws SQLException {
-
- int year = 0;
- int month = 0;
- int day = 0;
-
- int hour = 0;
- int minute = 0;
- int seconds = 0;
-
- int nanos = 0;
-
- if (bits == null) {
-
- return null;
- }
-
- Calendar sessionCalendar = conn.getUseJDBCCompliantTimezoneShift() ? conn
- .getUtcCalendar()
- : rs.getCalendarInstanceForSessionOrNew();
-
- boolean populatedFromDateTimeValue = false;
-
- switch (mysqlType) {
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- populatedFromDateTimeValue = true;
-
- if (length != 0) {
- year = (bits[offset + 0] & 0xff)
- | ((bits[offset + 1] & 0xff) << 8);
- month = bits[offset + 2];
- day = bits[offset + 3];
-
- if (length > 4) {
- hour = bits[offset + 4];
- minute = bits[offset + 5];
- seconds = bits[offset + 6];
- }
-
- if (length > 7) {
- // MySQL uses microseconds
- nanos = ((bits[offset + 7] & 0xff)
- | ((bits[offset + 8] & 0xff) << 8)
- | ((bits[offset + 9] & 0xff) << 16) | ((bits[offset + 10] & 0xff) << 24)) * 1000;
- }
- }
-
- break;
- case MysqlDefs.FIELD_TYPE_DATE:
- populatedFromDateTimeValue = true;
-
- if (bits.length != 0) {
- year = (bits[offset + 0] & 0xff)
- | ((bits[offset + 1] & 0xff) << 8);
- month = bits[offset + 2];
- day = bits[offset + 3];
- }
-
- break;
- case MysqlDefs.FIELD_TYPE_TIME:
- populatedFromDateTimeValue = true;
-
- if (bits.length != 0) {
- // bits[0] // skip tm->neg
- // binaryData.readLong(); // skip daysPart
- hour = bits[offset + 5];
- minute = bits[offset + 6];
- seconds = bits[offset + 7];
- }
-
- year = 1970;
- month = 1;
- day = 1;
-
- break;
- default:
- populatedFromDateTimeValue = false;
- }
-
- switch (jdbcType) {
- case Types.TIME:
- if (populatedFromDateTimeValue) {
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastTimeCreate(hour, minute, seconds, targetCalendar, this.exceptionInterceptor);
- }
-
- Time time = TimeUtil.fastTimeCreate(rs
- .getCalendarInstanceForSessionOrNew(), hour, minute,
- seconds, this.exceptionInterceptor);
-
- Time adjustedTime = TimeUtil.changeTimezone(conn,
- sessionCalendar, targetCalendar, time, conn
- .getServerTimezoneTZ(), tz, rollForward);
-
- return adjustedTime;
- }
-
- return rs.getNativeTimeViaParseConversion(columnIndex + 1,
- targetCalendar, tz, rollForward);
-
- case Types.DATE:
- if (populatedFromDateTimeValue) {
- if ((year == 0) && (month == 0) && (day == 0)) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(conn.getZeroDateTimeBehavior())) {
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(conn.getZeroDateTimeBehavior())) {
- throw new SQLException(
- "Value '0000-00-00' can not be represented as java.sql.Date",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
- }
-
- year = 1;
- month = 1;
- day = 1;
- }
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastDateCreate(year, month, day, targetCalendar);
- }
-
- return rs
- .fastDateCreate(
- rs.getCalendarInstanceForSessionOrNew(), year,
- month, day);
- }
-
- return rs.getNativeDateViaParseConversion(columnIndex + 1);
- case Types.TIMESTAMP:
- if (populatedFromDateTimeValue) {
- if ((year == 0) && (month == 0) && (day == 0)) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(conn.getZeroDateTimeBehavior())) {
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(conn.getZeroDateTimeBehavior())) {
- throw new SQLException(
- "Value '0000-00-00' can not be represented as java.sql.Timestamp",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
- }
-
- year = 1;
- month = 1;
- day = 1;
- }
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz, year, month, day, hour, minute,
- seconds, nanos);
- }
-
- Timestamp ts = rs.fastTimestampCreate(rs
- .getCalendarInstanceForSessionOrNew(), year, month,
- day, hour, minute, seconds, nanos);
-
- Timestamp adjustedTs = TimeUtil.changeTimezone(conn,
- sessionCalendar, targetCalendar, ts, conn
- .getServerTimezoneTZ(), tz, rollForward);
-
- return adjustedTs;
- }
-
- return rs.getNativeTimestampViaParseConversion(columnIndex + 1,
- targetCalendar, tz, rollForward);
-
- default:
- throw new SQLException(
- "Internal error - conversion method doesn't support this type",
- SQLError.SQL_STATE_GENERAL_ERROR);
- }
- }
-
- public abstract Object getNativeDateTimeValue(int columnIndex,
- Calendar targetCalendar, int jdbcType, int mysqlType,
- TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
- throws SQLException;
-
- protected double getNativeDouble(byte[] bits, int offset) {
- long valueAsLong = (bits[offset + 0] & 0xff)
- | ((long) (bits[offset + 1] & 0xff) << 8)
- | ((long) (bits[offset + 2] & 0xff) << 16)
- | ((long) (bits[offset + 3] & 0xff) << 24)
- | ((long) (bits[offset + 4] & 0xff) << 32)
- | ((long) (bits[offset + 5] & 0xff) << 40)
- | ((long) (bits[offset + 6] & 0xff) << 48)
- | ((long) (bits[offset + 7] & 0xff) << 56);
-
- return Double.longBitsToDouble(valueAsLong);
- }
-
- public abstract double getNativeDouble(int columnIndex) throws SQLException;
-
- protected float getNativeFloat(byte[] bits, int offset) {
- int asInt = (bits[offset + 0] & 0xff)
- | ((bits[offset + 1] & 0xff) << 8)
- | ((bits[offset + 2] & 0xff) << 16)
- | ((bits[offset + 3] & 0xff) << 24);
-
- return Float.intBitsToFloat(asInt);
- }
-
- public abstract float getNativeFloat(int columnIndex) throws SQLException;
-
- protected int getNativeInt(byte[] bits, int offset) {
-
- int valueAsInt = (bits[offset + 0] & 0xff)
- | ((bits[offset + 1] & 0xff) << 8)
- | ((bits[offset + 2] & 0xff) << 16)
- | ((bits[offset + 3] & 0xff) << 24);
-
- return valueAsInt;
- }
-
- public abstract int getNativeInt(int columnIndex) throws SQLException;
-
- protected long getNativeLong(byte[] bits, int offset) {
- long valueAsLong = (bits[offset + 0] & 0xff)
- | ((long) (bits[offset + 1] & 0xff) << 8)
- | ((long) (bits[offset + 2] & 0xff) << 16)
- | ((long) (bits[offset + 3] & 0xff) << 24)
- | ((long) (bits[offset + 4] & 0xff) << 32)
- | ((long) (bits[offset + 5] & 0xff) << 40)
- | ((long) (bits[offset + 6] & 0xff) << 48)
- | ((long) (bits[offset + 7] & 0xff) << 56);
-
- return valueAsLong;
- }
-
- public abstract long getNativeLong(int columnIndex) throws SQLException;
-
- protected short getNativeShort(byte[] bits, int offset) {
- short asShort = (short) ((bits[offset + 0] & 0xff) | ((bits[offset + 1] & 0xff) << 8));
-
- return asShort;
- }
-
- public abstract short getNativeShort(int columnIndex) throws SQLException;
-
- protected Time getNativeTime(int columnIndex, byte[] bits, int offset,
- int length, Calendar targetCalendar, TimeZone tz,
- boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
- throws SQLException {
-
- int hour = 0;
- int minute = 0;
- int seconds = 0;
-
- if (length != 0) {
- // bits[0] // skip tm->neg
- // binaryData.readLong(); // skip daysPart
- hour = bits[offset + 5];
- minute = bits[offset + 6];
- seconds = bits[offset + 7];
- }
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastTimeCreate(hour, minute, seconds, targetCalendar, this.exceptionInterceptor);
- }
-
- Calendar sessionCalendar = rs.getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- Time time = TimeUtil.fastTimeCreate(sessionCalendar, hour, minute,
- seconds, this.exceptionInterceptor);
-
- Time adjustedTime = TimeUtil.changeTimezone(conn, sessionCalendar,
- targetCalendar, time, conn.getServerTimezoneTZ(), tz,
- rollForward);
-
- return adjustedTime;
- }
- }
-
- public abstract Time getNativeTime(int columnIndex,
- Calendar targetCalendar, TimeZone tz, boolean rollForward,
- ConnectionImpl conn, ResultSetImpl rs) throws SQLException;
-
- protected Timestamp getNativeTimestamp(byte[] bits, int offset, int length,
- Calendar targetCalendar, TimeZone tz, boolean rollForward,
- ConnectionImpl conn, ResultSetImpl rs) throws SQLException {
- int year = 0;
- int month = 0;
- int day = 0;
-
- int hour = 0;
- int minute = 0;
- int seconds = 0;
-
- int nanos = 0;
-
- if (length != 0) {
- year = (bits[offset + 0] & 0xff) | ((bits[offset + 1] & 0xff) << 8);
- month = bits[offset + 2];
- day = bits[offset + 3];
-
- if (length > 4) {
- hour = bits[offset + 4];
- minute = bits[offset + 5];
- seconds = bits[offset + 6];
- }
-
- if (length > 7) {
- // MySQL uses microseconds
- nanos = ((bits[offset + 7] & 0xff)
- | ((bits[offset + 8] & 0xff) << 8)
- | ((bits[offset + 9] & 0xff) << 16) | ((bits[offset + 10] & 0xff) << 24)) * 1000;
- }
- }
-
- if ((year == 0) && (month == 0) && (day == 0)) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(conn.getZeroDateTimeBehavior())) {
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(conn.getZeroDateTimeBehavior())) {
- throw SQLError
- .createSQLException(
- "Value '0000-00-00' can not be represented as java.sql.Timestamp",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
-
- year = 1;
- month = 1;
- day = 1;
- }
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz, year, month,
- day, hour, minute, seconds, nanos);
- }
-
- Calendar sessionCalendar = conn.getUseJDBCCompliantTimezoneShift() ? conn
- .getUtcCalendar()
- : rs.getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- Timestamp ts = rs.fastTimestampCreate(sessionCalendar, year, month,
- day, hour, minute, seconds, nanos);
-
- Timestamp adjustedTs = TimeUtil.changeTimezone(conn,
- sessionCalendar, targetCalendar, ts, conn
- .getServerTimezoneTZ(), tz, rollForward);
-
- return adjustedTs;
- }
- }
-
- public abstract Timestamp getNativeTimestamp(int columnIndex,
- Calendar targetCalendar, TimeZone tz, boolean rollForward,
- ConnectionImpl conn, ResultSetImpl rs) throws SQLException;
-
- public abstract Reader getReader(int columnIndex) throws SQLException;
-
- /**
- * Returns the value at the given column (index starts at 0) as a
- * java.lang.String with the requested encoding, using the given
- * ConnectionImpl to find character converters.
- *
- * @param index
- * of the column value (starting at 0) to return.
- * @param encoding
- * the Java name for the character encoding
- * @param conn
- * the connection that created this result set row
- *
- * @return the value for the given column (including NULL if it is) as a
- * String
- *
- * @throws SQLException
- * if an error occurs while retrieving the value.
- */
- public abstract String getString(int index, String encoding,
- ConnectionImpl conn) throws SQLException;
-
- /**
- * Convenience method for turning a byte[] into a string with the given
- * encoding.
- *
- * @param encoding
- * the Java encoding name for the byte[] -> char conversion
- * @param conn
- * the ConnectionImpl that created the result set
- * @param value
- * the String value as a series of bytes, encoded using
- * "encoding"
- * @param offset
- * where to start the decoding
- * @param length
- * how many bytes to decode
- *
- * @return the String as decoded from bytes with the given encoding
- *
- * @throws SQLException
- * if an error occurs
- */
- protected String getString(String encoding, ConnectionImpl conn,
- byte[] value, int offset, int length) throws SQLException {
- String stringVal = null;
-
- if ((conn != null) && conn.getUseUnicode()) {
- try {
- if (encoding == null) {
- stringVal = new String(value);
- } else {
- SingleByteCharsetConverter converter = conn
- .getCharsetConverter(encoding);
-
- if (converter != null) {
- stringVal = converter.toString(value, offset, length);
- } else {
- stringVal = new String(value, offset, length, encoding);
- }
- }
- } catch (java.io.UnsupportedEncodingException E) {
- throw SQLError
- .createSQLException(
- Messages
- .getString("ResultSet.Unsupported_character_encoding____101") //$NON-NLS-1$
- + encoding + "'.", "0S100", this.exceptionInterceptor);
- }
- } else {
- stringVal = StringUtils.toAsciiString(value, offset, length);
- }
-
- return stringVal;
- }
-
- protected Time getTimeFast(int columnIndex, byte[] timeAsBytes, int offset,
- int length, Calendar targetCalendar, TimeZone tz,
- boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
- throws SQLException {
-
- int hr = 0;
- int min = 0;
- int sec = 0;
-
- try {
-
- if (timeAsBytes == null) {
- return null;
- }
-
- boolean allZeroTime = true;
- boolean onlyTimePresent = false;
-
- for (int i = 0; i < length; i++) {
- if (timeAsBytes[offset + i] == ':') {
- onlyTimePresent = true;
- break;
- }
- }
-
- for (int i = 0; i < length; i++) {
- byte b = timeAsBytes[offset + i];
-
- if (b == ' ' || b == '-' || b == '/') {
- onlyTimePresent = false;
- }
-
- if (b != '0' && b != ' ' && b != ':' && b != '-' && b != '/'
- && b != '.') {
- allZeroTime = false;
-
- break;
- }
- }
-
- if (!onlyTimePresent && allZeroTime) {
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(conn.getZeroDateTimeBehavior())) {
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(conn.getZeroDateTimeBehavior())) {
- throw SQLError.createSQLException("Value '"
- + new String(timeAsBytes)
- + "' can not be represented as java.sql.Time",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
-
- // We're left with the case of 'round' to a time Java _can_
- // represent, which is '00:00:00'
- return rs.fastTimeCreate(targetCalendar, 0, 0, 0);
- }
-
- Field timeColField = this.metadata[columnIndex];
-
- if (timeColField.getMysqlType() == MysqlDefs.FIELD_TYPE_TIMESTAMP) {
-
- switch (length) {
- case 19: { // YYYY-MM-DD hh:mm:ss
-
- hr = StringUtils.getInt(timeAsBytes, offset + length - 8,
- offset + length - 6);
- min = StringUtils.getInt(timeAsBytes, offset + length - 5,
- offset + length - 3);
- sec = StringUtils.getInt(timeAsBytes, offset + length - 2,
- offset + length);
- }
-
- break;
- case 14:
- case 12: {
- hr = StringUtils.getInt(timeAsBytes, offset + length - 6,
- offset + length - 4);
- min = StringUtils.getInt(timeAsBytes, offset + length - 4,
- offset + length - 2);
- sec = StringUtils.getInt(timeAsBytes, offset + length - 2,
- offset + length);
- }
-
- break;
-
- case 10: {
- hr = StringUtils
- .getInt(timeAsBytes, offset + 6, offset + 8);
- min = StringUtils.getInt(timeAsBytes, offset + 8,
- offset + 10);
- sec = 0;
- }
-
- break;
-
- default:
- throw SQLError
- .createSQLException(
- Messages
- .getString("ResultSet.Timestamp_too_small_to_convert_to_Time_value_in_column__257") //$NON-NLS-1$
- + (columnIndex + 1)
- + "("
- + timeColField + ").",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } /* endswitch */
-
- SQLWarning precisionLost = new SQLWarning(
- Messages
- .getString("ResultSet.Precision_lost_converting_TIMESTAMP_to_Time_with_getTime()_on_column__261") //$NON-NLS-1$
- + columnIndex + "(" + timeColField + ").");
- /*
- * if (this.warningChain == null) { this.warningChain =
- * precisionLost; } else {
- * this.warningChain.setNextWarning(precisionLost); }
- */
- } else if (timeColField.getMysqlType() == MysqlDefs.FIELD_TYPE_DATETIME) {
- hr = StringUtils.getInt(timeAsBytes, offset + 11, offset + 13);
- min = StringUtils.getInt(timeAsBytes, offset + 14, offset + 16);
- sec = StringUtils.getInt(timeAsBytes, offset + 17, offset + 19);
-
- SQLWarning precisionLost = new SQLWarning(
- Messages
- .getString("ResultSet.Precision_lost_converting_DATETIME_to_Time_with_getTime()_on_column__264") //$NON-NLS-1$
- + (columnIndex + 1) + "(" + timeColField + ").");
-
- /*
- * if (this.warningChain == null) { this.warningChain =
- * precisionLost; } else {
- * this.warningChain.setNextWarning(precisionLost); }
- */
- } else if (timeColField.getMysqlType() == MysqlDefs.FIELD_TYPE_DATE) {
- return rs.fastTimeCreate(null, 0, 0, 0); // midnight on the
- // given
- // date
- } else {
- // convert a String to a Time
- if ((length != 5) && (length != 8)) {
- throw SQLError.createSQLException(Messages
- .getString("ResultSet.Bad_format_for_Time____267") //$NON-NLS-1$
- + new String(timeAsBytes)
- + Messages.getString("ResultSet.___in_column__268")
- + (columnIndex + 1),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
-
- hr = StringUtils.getInt(timeAsBytes, offset + 0, offset + 2);
- min = StringUtils.getInt(timeAsBytes, offset + 3, offset + 5);
- sec = (length == 5) ? 0 : StringUtils.getInt(timeAsBytes,
- offset + 6, offset + 8);
- }
-
- Calendar sessionCalendar = rs.getCalendarInstanceForSessionOrNew();
-
- if (!rs.useLegacyDatetimeCode) {
- return rs.fastTimeCreate(targetCalendar, hr, min, sec);
- }
-
- synchronized (sessionCalendar) {
- return TimeUtil.changeTimezone(conn, sessionCalendar,
- targetCalendar, rs.fastTimeCreate(sessionCalendar, hr,
- min, sec), conn.getServerTimezoneTZ(), tz,
- rollForward);
- }
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(ex.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- public abstract Time getTimeFast(int columnIndex, Calendar targetCalendar,
- TimeZone tz, boolean rollForward, ConnectionImpl conn,
- ResultSetImpl rs) throws SQLException;
-
- protected Timestamp getTimestampFast(int columnIndex,
- byte[] timestampAsBytes, int offset, int length,
- Calendar targetCalendar, TimeZone tz, boolean rollForward,
- ConnectionImpl conn, ResultSetImpl rs) throws SQLException {
-
- try {
- Calendar sessionCalendar = conn.getUseJDBCCompliantTimezoneShift() ? conn
- .getUtcCalendar()
- : rs.getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- boolean allZeroTimestamp = true;
-
- boolean onlyTimePresent = false;
-
- for (int i = 0; i < length; i++) {
- if (timestampAsBytes[offset + i] == ':') {
- onlyTimePresent = true;
- break;
- }
- }
-
- for (int i = 0; i < length; i++) {
- byte b = timestampAsBytes[offset + i];
-
- if (b == ' ' || b == '-' || b == '/') {
- onlyTimePresent = false;
- }
-
- if (b != '0' && b != ' ' && b != ':' && b != '-'
- && b != '/' && b != '.') {
- allZeroTimestamp = false;
-
- break;
- }
- }
-
- if (!onlyTimePresent && allZeroTimestamp) {
-
- if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL
- .equals(conn.getZeroDateTimeBehavior())) {
-
- return null;
- } else if (ConnectionPropertiesImpl.ZERO_DATETIME_BEHAVIOR_EXCEPTION
- .equals(conn.getZeroDateTimeBehavior())) {
- throw SQLError
- .createSQLException(
- "Value '"
- + timestampAsBytes
- + "' can not be represented as java.sql.Timestamp",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz, 1, 1, 1, 0, 0, 0, 0);
- }
- // We're left with the case of 'round' to a date Java _can_
- // represent, which is '0001-01-01'.
- return rs.fastTimestampCreate(null, 1, 1, 1, 0, 0, 0, 0);
-
- } else if (this.metadata[columnIndex].getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR) {
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz, StringUtils
- .getInt(timestampAsBytes, offset, 4), 1, 1, 0,
- 0, 0, 0);
- }
-
- return TimeUtil.changeTimezone(conn, sessionCalendar,
- targetCalendar, rs.fastTimestampCreate(
- sessionCalendar, StringUtils.getInt(
- timestampAsBytes, offset, 4), 1, 1,
- 0, 0, 0, 0), conn.getServerTimezoneTZ(),
- tz, rollForward);
- } else {
- if (timestampAsBytes[offset + length - 1] == '.') {
- length--;
- }
-
- // Convert from TIMESTAMP or DATE
-
- int year = 0;
- int month = 0;
- int day = 0;
- int hour = 0;
- int minutes = 0;
- int seconds = 0;
- int nanos = 0;
-
- switch (length) {
- case 29:
- case 26:
- case 25:
- case 24:
- case 23:
- case 22:
- case 21:
- case 20:
- case 19: {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 4);
- month = StringUtils.getInt(timestampAsBytes,
- offset + 5, offset + 7);
- day = StringUtils.getInt(timestampAsBytes,
- offset + 8, offset + 10);
- hour = StringUtils.getInt(timestampAsBytes,
- offset + 11, offset + 13);
- minutes = StringUtils.getInt(timestampAsBytes,
- offset + 14, offset + 16);
- seconds = StringUtils.getInt(timestampAsBytes,
- offset + 17, offset + 19);
-
- nanos = 0;
-
- if (length > 19) {
- int decimalIndex = -1;
-
- for (int i = 0; i < length; i++) {
- if (timestampAsBytes[offset + i] == '.') {
- decimalIndex = i;
- }
- }
-
- if (decimalIndex != -1) {
- if ((decimalIndex + 2) <= length) {
- nanos = StringUtils.getInt(
- timestampAsBytes, decimalIndex + 1,
- offset + length);
-
- int numDigits = (offset + length) - (decimalIndex + 1);
-
- if (numDigits < 9) {
- int factor = (int)(Math.pow(10, 9 - numDigits));
- nanos = nanos * factor;
- }
- } else {
- throw new IllegalArgumentException(); // re-thrown
- // further
- // down
- // with
- // a
- // much better error message
- }
- }
- }
-
- break;
- }
-
- case 14: {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 4);
- month = StringUtils.getInt(timestampAsBytes,
- offset + 4, offset + 6);
- day = StringUtils.getInt(timestampAsBytes,
- offset + 6, offset + 8);
- hour = StringUtils.getInt(timestampAsBytes,
- offset + 8, offset + 10);
- minutes = StringUtils.getInt(timestampAsBytes,
- offset + 10, offset + 12);
- seconds = StringUtils.getInt(timestampAsBytes,
- offset + 12, offset + 14);
-
- break;
- }
-
- case 12: {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = StringUtils.getInt(timestampAsBytes,
- offset + 2, offset + 4);
- day = StringUtils.getInt(timestampAsBytes,
- offset + 4, offset + 6);
- hour = StringUtils.getInt(timestampAsBytes,
- offset + 6, offset + 8);
- minutes = StringUtils.getInt(timestampAsBytes,
- offset + 8, offset + 10);
- seconds = StringUtils.getInt(timestampAsBytes,
- offset + 10, offset + 12);
-
- break;
- }
-
- case 10: {
- boolean hasDash = false;
-
- for (int i = 0; i < length; i++) {
- if (timestampAsBytes[offset + i] == '-') {
- hasDash = true;
- break;
- }
- }
-
- if ((this.metadata[columnIndex].getMysqlType() == MysqlDefs.FIELD_TYPE_DATE)
- || hasDash) {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 4);
- month = StringUtils.getInt(timestampAsBytes,
- offset + 5, offset + 7);
- day = StringUtils.getInt(timestampAsBytes,
- offset + 8, offset + 10);
- hour = 0;
- minutes = 0;
- } else {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- month = StringUtils.getInt(timestampAsBytes,
- offset + 2, offset + 4);
- day = StringUtils.getInt(timestampAsBytes,
- offset + 4, offset + 6);
- hour = StringUtils.getInt(timestampAsBytes,
- offset + 6, offset + 8);
- minutes = StringUtils.getInt(timestampAsBytes,
- offset + 8, offset + 10);
-
- year += 1900; // two-digit year
- }
-
- break;
- }
-
- case 8: {
- boolean hasColon = false;
-
- for (int i = 0; i < length; i++) {
- if (timestampAsBytes[offset + i] == ':') {
- hasColon = true;
- break;
- }
- }
-
- if (hasColon) {
- hour = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 2);
- minutes = StringUtils.getInt(timestampAsBytes,
- offset + 3, offset + 5);
- seconds = StringUtils.getInt(timestampAsBytes,
- offset + 6, offset + 8);
-
- year = 1970;
- month = 1;
- day = 1;
-
- break;
- }
-
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 4);
- month = StringUtils.getInt(timestampAsBytes,
- offset + 4, offset + 6);
- day = StringUtils.getInt(timestampAsBytes,
- offset + 6, offset + 8);
-
- year -= 1900;
- month--;
-
- break;
- }
-
- case 6: {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
-
- month = StringUtils.getInt(timestampAsBytes,
- offset + 2, offset + 4);
- day = StringUtils.getInt(timestampAsBytes,
- offset + 4, offset + 6);
-
- break;
- }
-
- case 4: {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- month = StringUtils.getInt(timestampAsBytes,
- offset + 2, offset + 4);
-
- day = 1;
-
- break;
- }
-
- case 2: {
- year = StringUtils.getInt(timestampAsBytes,
- offset + 0, offset + 2);
-
- if (year <= 69) {
- year = (year + 100);
- }
-
- year += 1900;
- month = 1;
- day = 1;
-
- break;
- }
-
- default:
- throw new java.sql.SQLException(
- "Bad format for Timestamp '"
- + new String(timestampAsBytes)
- + "' in column " + (columnIndex + 1)
- + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
- }
-
- if (!rs.useLegacyDatetimeCode) {
- return TimeUtil.fastTimestampCreate(tz,
- year, month,
- day, hour, minutes, seconds,
- nanos);
- }
-
- return TimeUtil
- .changeTimezone(conn, sessionCalendar,
- targetCalendar, rs.fastTimestampCreate(
- sessionCalendar, year, month,
- day, hour, minutes, seconds,
- nanos), conn
- .getServerTimezoneTZ(), tz,
- rollForward);
- }
- }
- } catch (Exception e) {
- SQLException sqlEx = SQLError.createSQLException("Cannot convert value '"
- + getString(columnIndex, "ISO8859_1", conn)
- + "' from column " + (columnIndex + 1) + " to TIMESTAMP.",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- sqlEx.initCause(e);
-
- throw sqlEx;
- }
- }
-
- public abstract Timestamp getTimestampFast(int columnIndex,
- Calendar targetCalendar, TimeZone tz, boolean rollForward,
- ConnectionImpl conn, ResultSetImpl rs) throws SQLException;
-
- /**
- * Could the column value at the given index (which starts at 0) be
- * interpreted as a floating-point number (has +/-/E/e in it)?
- *
- * @param index
- * of the column value (starting at 0) to check.
- *
- * @return true if the column value at the given index looks like it might
- * be a floating-point number, false if not.
- *
- * @throws SQLException
- * if an error occurs
- */
- public abstract boolean isFloatingPointNumber(int index)
- throws SQLException;
-
- /**
- * Is the column value at the given index (which starts at 0) NULL?
- *
- * @param index
- * of the column value (starting at 0) to check.
- *
- * @return true if the column value is NULL, false if not.
- *
- * @throws SQLException
- * if an error occurs
- */
- public abstract boolean isNull(int index) throws SQLException;
-
- /**
- * Returns the length of the column at the given index (which starts at 0).
- *
- * @param index
- * of the column value (starting at 0) for which to return the
- * length.
- * @return the length of the requested column, 0 if null (clients of this
- * interface should use isNull() beforehand to determine status of
- * NULL values in the column).
- *
- * @throws SQLException
- */
- public abstract long length(int index) throws SQLException;
-
- /**
- * Sets the given column value (only works currently with
- * ByteArrayRowHolder).
- *
- * @param index
- * index of the column value (starting at 0) to set.
- * @param value
- * the (raw) value to set
- *
- * @throws SQLException
- * if an error occurs, or the concrete RowHolder doesn't support
- * this operation.
- */
- public abstract void setColumnValue(int index, byte[] value)
- throws SQLException;
-
- public ResultSetRow setMetadata(Field[] f) throws SQLException {
- this.metadata = f;
-
- return this;
- }
-}
diff --git a/src/com/mysql/jdbc/RowData.java b/src/com/mysql/jdbc/RowData.java
deleted file mode 100644
index 9693f871d..000000000
--- a/src/com/mysql/jdbc/RowData.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-
-/**
- * This interface abstracts away how row data is accessed by the result set. It
- * is meant to allow a static implementation (Current version), and a streaming
- * one.
- *
- * @author dgan
- */
-public interface RowData {
-
- /**
- * What's returned for the size of a result set when its size can not be
- * determined.
- */
- public static final int RESULT_SET_SIZE_UNKNOWN = -1;
-
- /**
- * Adds a row to this row data.
- *
- * @param row
- * the row to add
- * @throws SQLException
- * if a database error occurs
- */
- void addRow(ResultSetRow row) throws SQLException;
-
- /**
- * Moves to after last.
- *
- * @throws SQLException
- * if a database error occurs
- */
- void afterLast() throws SQLException;
-
- /**
- * Moves to before first.
- *
- * @throws SQLException
- * if a database error occurs
- */
- void beforeFirst() throws SQLException;
-
- /**
- * Moves to before last so next el is the last el.
- *
- * @throws SQLException
- * if a database error occurs
- */
- void beforeLast() throws SQLException;
-
- /**
- * We're done.
- *
- * @throws SQLException
- * if a database error occurs
- */
- void close() throws SQLException;
-
- /**
- * Only works on non dynamic result sets.
- *
- * @param index
- * row number to get at
- * @return row data at index
- * @throws SQLException
- * if a database error occurs
- */
- ResultSetRow getAt(int index) throws SQLException;
-
- /**
- * Returns the current position in the result set as a row number.
- *
- * @return the current row number
- * @throws SQLException
- * if a database error occurs
- */
- int getCurrentRowNumber() throws SQLException;
-
- /**
- * Returns the result set that 'owns' this RowData
- */
- ResultSetInternalMethods getOwner();
-
- /**
- * Returns true if another row exsists.
- *
- * @return true if more rows
- * @throws SQLException
- * if a database error occurs
- */
- boolean hasNext() throws SQLException;
-
- /**
- * Returns true if we got the last element.
- *
- * @return true if after last row
- * @throws SQLException
- * if a database error occurs
- */
- boolean isAfterLast() throws SQLException;
-
- /**
- * Returns if iteration has not occured yet.
- *
- * @return true if before first row
- * @throws SQLException
- * if a database error occurs
- */
- boolean isBeforeFirst() throws SQLException;
-
- /**
- * Returns true if the result set is dynamic.
- *
- * This means that move back and move forward won't work because we do not
- * hold on to the records.
- *
- * @return true if this result set is streaming from the server
- * @throws SQLException
- * if a database error occurs
- */
- boolean isDynamic() throws SQLException;
-
- /**
- * Has no records.
- *
- * @return true if no records
- * @throws SQLException
- * if a database error occurs
- */
- boolean isEmpty() throws SQLException;
-
- /**
- * Are we on the first row of the result set?
- *
- * @return true if on first row
- * @throws SQLException
- * if a database error occurs
- */
- boolean isFirst() throws SQLException;
-
- /**
- * Are we on the last row of the result set?
- *
- * @return true if on last row
- * @throws SQLException
- * if a database error occurs
- */
- boolean isLast() throws SQLException;
-
- /**
- * Moves the current position relative 'rows' from the current position.
- *
- * @param rows
- * the relative number of rows to move
- * @throws SQLException
- * if a database error occurs
- */
- void moveRowRelative(int rows) throws SQLException;
-
- /**
- * Returns the next row.
- *
- * @return the next row value
- * @throws SQLException
- * if a database error occurs
- */
- ResultSetRow next() throws SQLException;
-
- /**
- * Removes the row at the given index.
- *
- * @param index
- * the row to move to
- * @throws SQLException
- * if a database error occurs
- */
- void removeRow(int index) throws SQLException;
-
- /**
- * Moves the current position in the result set to the given row number.
- *
- * @param rowNumber
- * row to move to
- * @throws SQLException
- * if a database error occurs
- */
- void setCurrentRow(int rowNumber) throws SQLException;
-
- /**
- * Set the result set that 'owns' this RowData
- *
- * @param rs
- * the result set that 'owns' this RowData
- */
- void setOwner(ResultSetImpl rs);
-
- /**
- * Only works on non dynamic result sets.
- *
- * @return the size of this row data
- * @throws SQLException
- * if a database error occurs
- */
- int size() throws SQLException;
-
- /**
- * Did this result set have no rows?
- */
- boolean wasEmpty();
-
- /**
- * Sometimes the driver doesn't have metadata until after
- * the statement has the result set in-hand (because it's cached),
- * so it can call this to set it after the fact.
- *
- * @param metadata field-level metadata for the result set
- */
- void setMetadata(Field[] metadata);
-}
diff --git a/src/com/mysql/jdbc/RowDataCursor.java b/src/com/mysql/jdbc/RowDataCursor.java
deleted file mode 100644
index 35c6b0480..000000000
--- a/src/com/mysql/jdbc/RowDataCursor.java
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- Copyright 2002-2006 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Model for result set data backed by a cursor. Only works for forward-only
- * result sets (but still works with updatable concurrency).
- *
- * @version $Id: CursorRowProvider.java,v 1.1.2.1 2005/05/19 18:31:49 mmatthews
- * Exp $
- */
-public class RowDataCursor implements RowData {
-
- private final static int BEFORE_START_OF_ROWS = -1;
-
- /**
- * The cache of rows we have retrieved from the server.
- */
- private List fetchedRows;
-
- /**
- * Where we are positionaly in the entire result set, used mostly to
- * facilitate easy 'isBeforeFirst()' and 'isFirst()' methods.
- */
- private int currentPositionInEntireResult = BEFORE_START_OF_ROWS;
-
- /**
- * Position in cache of rows, used to determine if we need to fetch more
- * rows from the server to satisfy a request for the next row.
- */
- private int currentPositionInFetchedRows = BEFORE_START_OF_ROWS;
-
- /**
- * The result set that we 'belong' to.
- */
- private ResultSetImpl owner;
-
- /**
- * Have we been told from the server that we have seen the last row?
- */
- private boolean lastRowFetched = false;
-
- /**
- * Field-level metadata from the server. We need this, because it is not
- * sent for each batch of rows, but we need the metadata to unpack the
- * results for each field.
- */
- private Field[] metadata;
-
- /**
- * Communications channel to the server
- */
- private MysqlIO mysql;
-
- /**
- * Identifier for the statement that created this cursor.
- */
- private long statementIdOnServer;
-
- /**
- * The prepared statement that created this cursor.
- */
- private ServerPreparedStatement prepStmt;
-
- /**
- * The server status for 'last-row-sent'...This might belong in mysqldefs,
- * but it it only ever referenced from here.
- */
- private static final int SERVER_STATUS_LAST_ROW_SENT = 128;
-
- /**
- * Have we attempted to fetch any rows yet?
- */
- private boolean firstFetchCompleted = false;
-
- private boolean wasEmpty = false;
-
- private boolean useBufferRowExplicit = false;
-
- /**
- * Creates a new cursor-backed row provider.
- *
- * @param ioChannel
- * connection to the server.
- * @param creatingStatement
- * statement that opened the cursor.
- * @param metadata
- * field-level metadata for the results that this cursor covers.
- */
- public RowDataCursor(MysqlIO ioChannel,
- ServerPreparedStatement creatingStatement, Field[] metadata) {
- this.currentPositionInEntireResult = BEFORE_START_OF_ROWS;
- this.metadata = metadata;
- this.mysql = ioChannel;
- this.statementIdOnServer = creatingStatement.getServerStatementId();
- this.prepStmt = creatingStatement;
- this.useBufferRowExplicit = MysqlIO.useBufferRowExplicit(this.metadata);
-
- }
-
- /**
- * Returns true if we got the last element.
- *
- * @return DOCUMENT ME!
- */
- public boolean isAfterLast() {
- return lastRowFetched
- && this.currentPositionInFetchedRows > this.fetchedRows.size();
- }
-
- /**
- * Only works on non dynamic result sets.
- *
- * @param index
- * row number to get at
- * @return row data at index
- * @throws SQLException
- * if a database error occurs
- */
- public ResultSetRow getAt(int ind) throws SQLException {
- notSupported();
-
- return null;
- }
-
- /**
- * Returns if iteration has not occured yet.
- *
- * @return true if before first row
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isBeforeFirst() throws SQLException {
- return this.currentPositionInEntireResult < 0;
- }
-
- /**
- * Moves the current position in the result set to the given row number.
- *
- * @param rowNumber
- * row to move to
- * @throws SQLException
- * if a database error occurs
- */
- public void setCurrentRow(int rowNumber) throws SQLException {
- notSupported();
- }
-
- /**
- * Returns the current position in the result set as a row number.
- *
- * @return the current row number
- * @throws SQLException
- * if a database error occurs
- */
- public int getCurrentRowNumber() throws SQLException {
- return this.currentPositionInEntireResult + 1;
- }
-
- /**
- * Returns true if the result set is dynamic.
- *
- * This means that move back and move forward won't work because we do not
- * hold on to the records.
- *
- * @return true if this result set is streaming from the server
- */
- public boolean isDynamic() {
- return true;
- }
-
- /**
- * Has no records.
- *
- * @return true if no records
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isEmpty() throws SQLException {
- return this.isBeforeFirst() && this.isAfterLast();
- }
-
- /**
- * Are we on the first row of the result set?
- *
- * @return true if on first row
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isFirst() throws SQLException {
- return this.currentPositionInEntireResult == 0;
- }
-
- /**
- * Are we on the last row of the result set?
- *
- * @return true if on last row
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isLast() throws SQLException {
- return this.lastRowFetched
- && this.currentPositionInFetchedRows == (this.fetchedRows
- .size() - 1);
- }
-
- /**
- * Adds a row to this row data.
- *
- * @param row
- * the row to add
- * @throws SQLException
- * if a database error occurs
- */
- public void addRow(ResultSetRow row) throws SQLException {
- notSupported();
- }
-
- /**
- * Moves to after last.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void afterLast() throws SQLException {
- notSupported();
- }
-
- /**
- * Moves to before first.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void beforeFirst() throws SQLException {
- notSupported();
- }
-
- /**
- * Moves to before last so next el is the last el.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void beforeLast() throws SQLException {
- notSupported();
- }
-
- /**
- * We're done.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void close() throws SQLException {
-
- this.metadata = null;
- this.owner = null;
- }
-
- /**
- * Returns true if another row exists.
- *
- * @return true if more rows
- * @throws SQLException
- * if a database error occurs
- */
- public boolean hasNext() throws SQLException {
-
- if (this.fetchedRows != null && this.fetchedRows.size() == 0) {
- return false;
- }
-
- if (this.owner != null && this.owner.owningStatement != null) {
- int maxRows = this.owner.owningStatement.maxRows;
-
- if (maxRows != -1 && this.currentPositionInEntireResult + 1 > maxRows) {
- return false;
- }
- }
-
- if (this.currentPositionInEntireResult != BEFORE_START_OF_ROWS) {
- // Case, we've fetched some rows, but are not at end of fetched
- // block
- if (this.currentPositionInFetchedRows < (this.fetchedRows.size() - 1)) {
- return true;
- } else if (this.currentPositionInFetchedRows == this.fetchedRows
- .size()
- && this.lastRowFetched) {
- return false;
- } else {
- // need to fetch to determine
- fetchMoreRows();
-
- return (this.fetchedRows.size() > 0);
- }
- }
-
- // Okay, no rows _yet_, so fetch 'em
-
- fetchMoreRows();
-
- return this.fetchedRows.size() > 0;
- }
-
- /**
- * Moves the current position relative 'rows' from the current position.
- *
- * @param rows
- * the relative number of rows to move
- * @throws SQLException
- * if a database error occurs
- */
- public void moveRowRelative(int rows) throws SQLException {
- notSupported();
- }
-
- /**
- * Returns the next row.
- *
- * @return the next row value
- * @throws SQLException
- * if a database error occurs
- */
- public ResultSetRow next() throws SQLException {
- if (this.fetchedRows == null && this.currentPositionInEntireResult != BEFORE_START_OF_ROWS) {
- throw SQLError.createSQLException(
- Messages
- .getString("ResultSet.Operation_not_allowed_after_ResultSet_closed_144"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, mysql.getExceptionInterceptor());
- }
-
- if (!hasNext()) {
- return null;
- }
-
- this.currentPositionInEntireResult++;
- this.currentPositionInFetchedRows++;
-
- // Catch the forced scroll-passed-end
- if (this.fetchedRows != null && this.fetchedRows.size() == 0) {
- return null;
- }
-
- if (this.currentPositionInFetchedRows > (this.fetchedRows.size() - 1)) {
- fetchMoreRows();
- this.currentPositionInFetchedRows = 0;
- }
-
- ResultSetRow row = (ResultSetRow) this.fetchedRows
- .get(this.currentPositionInFetchedRows);
-
- row.setMetadata(this.metadata);
-
- return row;
- }
-
- /**
- *
- */
- private void fetchMoreRows() throws SQLException {
- if (this.lastRowFetched) {
- this.fetchedRows = new ArrayList(0);
- return;
- }
-
- synchronized (this.owner.connection.getMutex()) {
- boolean oldFirstFetchCompleted = this.firstFetchCompleted;
-
- if (!this.firstFetchCompleted) {
- this.firstFetchCompleted = true;
- }
-
- int numRowsToFetch = this.owner.getFetchSize();
-
- if (numRowsToFetch == 0) {
- numRowsToFetch = this.prepStmt.getFetchSize();
- }
-
- if (numRowsToFetch == Integer.MIN_VALUE) {
- // Handle the case where the user used 'old'
- // streaming result sets
-
- numRowsToFetch = 1;
- }
-
- this.fetchedRows = this.mysql.fetchRowsViaCursor(this.fetchedRows,
- this.statementIdOnServer, this.metadata, numRowsToFetch,
- this.useBufferRowExplicit);
- this.currentPositionInFetchedRows = BEFORE_START_OF_ROWS;
-
- if ((this.mysql.getServerStatus() & SERVER_STATUS_LAST_ROW_SENT) != 0) {
- this.lastRowFetched = true;
-
- if (!oldFirstFetchCompleted && this.fetchedRows.size() == 0) {
- this.wasEmpty = true;
- }
- }
- }
- }
-
- /**
- * Removes the row at the given index.
- *
- * @param index
- * the row to move to
- * @throws SQLException
- * if a database error occurs
- */
- public void removeRow(int ind) throws SQLException {
- notSupported();
- }
-
- /**
- * Only works on non dynamic result sets.
- *
- * @return the size of this row data
- */
- public int size() {
- return RESULT_SET_SIZE_UNKNOWN;
- }
-
- private void nextRecord() throws SQLException {
-
- }
-
- private void notSupported() throws SQLException {
- throw new OperationNotSupportedException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.RowProvider#setOwner(com.mysql.jdbc.ResultSet)
- */
- public void setOwner(ResultSetImpl rs) {
- this.owner = rs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.RowProvider#getOwner()
- */
- public ResultSetInternalMethods getOwner() {
- return this.owner;
- }
-
- public boolean wasEmpty() {
- return this.wasEmpty;
- }
-
- public void setMetadata(Field[] metadata) {
- this.metadata = metadata;
- }
-
-}
diff --git a/src/com/mysql/jdbc/RowDataDynamic.java b/src/com/mysql/jdbc/RowDataDynamic.java
deleted file mode 100644
index 789d2a8e3..000000000
--- a/src/com/mysql/jdbc/RowDataDynamic.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import com.mysql.jdbc.profiler.ProfilerEvent;
-import com.mysql.jdbc.profiler.ProfilerEventHandler;
-import com.mysql.jdbc.profiler.ProfilerEventHandlerFactory;
-
-/**
- * Allows streaming of MySQL data.
- *
- * @author dgan
- * @version $Id$
- */
-public class RowDataDynamic implements RowData {
-
- class OperationNotSupportedException extends SQLException {
- OperationNotSupportedException() {
- super(
- Messages.getString("RowDataDynamic.10"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
- }
- }
-
- private int columnCount;
-
- private Field[] metadata;
-
- private int index = -1;
-
- private MysqlIO io;
-
- private boolean isAfterEnd = false;
-
- private boolean noMoreRows = false;
-
- private boolean isBinaryEncoded = false;
-
- private ResultSetRow nextRow;
-
- private ResultSetImpl owner;
-
- private boolean streamerClosed = false;
-
- private boolean wasEmpty = false; // we don't know until we attempt to traverse
-
- private boolean useBufferRowExplicit;
-
- private boolean moreResultsExisted;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- /**
- * Creates a new RowDataDynamic object.
- *
- * @param io
- * the connection to MySQL that this data is coming from
- * @param metadata
- * the metadata that describe this data
- * @param isBinaryEncoded
- * is this data in native format?
- * @param colCount
- * the number of columns
- * @throws SQLException
- * if the next record can not be found
- */
- public RowDataDynamic(MysqlIO io, int colCount, Field[] fields,
- boolean isBinaryEncoded) throws SQLException {
- this.io = io;
- this.columnCount = colCount;
- this.isBinaryEncoded = isBinaryEncoded;
- this.metadata = fields;
- this.exceptionInterceptor = this.io.getExceptionInterceptor();
- this.useBufferRowExplicit = MysqlIO.useBufferRowExplicit(this.metadata);
- }
-
- /**
- * Adds a row to this row data.
- *
- * @param row
- * the row to add
- * @throws SQLException
- * if a database error occurs
- */
- public void addRow(ResultSetRow row) throws SQLException {
- notSupported();
- }
-
- /**
- * Moves to after last.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void afterLast() throws SQLException {
- notSupported();
- }
-
- /**
- * Moves to before first.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void beforeFirst() throws SQLException {
- notSupported();
- }
-
- /**
- * Moves to before last so next el is the last el.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void beforeLast() throws SQLException {
- notSupported();
- }
-
- /**
- * We're done.
- *
- * @throws SQLException
- * if a database error occurs
- */
- public void close() throws SQLException {
- // Belt and suspenders here - if we don't
- // have a reference to the connection
- // it's more than likely dead/gone and we
- // won't be able to consume rows anyway
-
- Object mutex = this;
-
- ConnectionImpl conn = null;
-
- if (this.owner != null) {
- conn = this.owner.connection;
-
- if (conn != null) {
- mutex = conn.getMutex();
- }
- }
-
- boolean hadMore = false;
- int howMuchMore = 0;
-
- synchronized (mutex) {
- // drain the rest of the records.
- while (next() != null) {
- hadMore = true;
- howMuchMore++;
-
- if (howMuchMore % 100 == 0) {
- Thread.yield();
- }
- }
-
- if (conn != null) {
- if (!conn.getClobberStreamingResults() &&
- conn.getNetTimeoutForStreamingResults() > 0) {
- String oldValue = conn
- .getServerVariable("net_write_timeout");
-
- if (oldValue == null || oldValue.length() == 0) {
- oldValue = "60"; // the current default
- }
-
- this.io.clearInputStream();
-
- java.sql.Statement stmt = null;
-
- try {
- stmt = conn.createStatement();
- ((com.mysql.jdbc.StatementImpl)stmt).executeSimpleNonQuery(conn, "SET net_write_timeout=" + oldValue);
- } finally {
- if (stmt != null) {
- stmt.close();
- }
- }
- }
-
- if (conn.getUseUsageAdvisor()) {
- if (hadMore) {
-
- ProfilerEventHandler eventSink = ProfilerEventHandlerFactory
- .getInstance(conn);
-
- eventSink
- .consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN,
- "", //$NON-NLS-1$
- this.owner.owningStatement == null ? "N/A" : this.owner.owningStatement.currentCatalog, //$NON-NLS-1$
- this.owner.connectionId,
- this.owner.owningStatement == null ? -1
- : this.owner.owningStatement
- .getId(),
- -1,
- System.currentTimeMillis(),
- 0,
- Constants.MILLIS_I18N,
- null,
- null,
- Messages.getString("RowDataDynamic.2") //$NON-NLS-1$
- + howMuchMore
- + Messages
- .getString("RowDataDynamic.3") //$NON-NLS-1$
- + Messages
- .getString("RowDataDynamic.4") //$NON-NLS-1$
- + Messages
- .getString("RowDataDynamic.5") //$NON-NLS-1$
- + Messages
- .getString("RowDataDynamic.6") //$NON-NLS-1$
- + this.owner.pointOfOrigin));
- }
- }
- }
- }
-
- this.metadata = null;
- this.owner = null;
- }
-
- /**
- * Only works on non dynamic result sets.
- *
- * @param index
- * row number to get at
- * @return row data at index
- * @throws SQLException
- * if a database error occurs
- */
- public ResultSetRow getAt(int ind) throws SQLException {
- notSupported();
-
- return null;
- }
-
- /**
- * Returns the current position in the result set as a row number.
- *
- * @return the current row number
- * @throws SQLException
- * if a database error occurs
- */
- public int getCurrentRowNumber() throws SQLException {
- notSupported();
-
- return -1;
- }
-
- /**
- * @see com.mysql.jdbc.RowData#getOwner()
- */
- public ResultSetInternalMethods getOwner() {
- return this.owner;
- }
-
- /**
- * Returns true if another row exsists.
- *
- * @return true if more rows
- * @throws SQLException
- * if a database error occurs
- */
- public boolean hasNext() throws SQLException {
- boolean hasNext = (this.nextRow != null);
-
- if (!hasNext && !this.streamerClosed) {
- this.io.closeStreamer(this);
- this.streamerClosed = true;
- }
-
- return hasNext;
- }
-
- /**
- * Returns true if we got the last element.
- *
- * @return true if after last row
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isAfterLast() throws SQLException {
- return this.isAfterEnd;
- }
-
- /**
- * Returns if iteration has not occured yet.
- *
- * @return true if before first row
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isBeforeFirst() throws SQLException {
- return this.index < 0;
- }
-
- /**
- * Returns true if the result set is dynamic.
- *
- * This means that move back and move forward won't work because we do not
- * hold on to the records.
- *
- * @return true if this result set is streaming from the server
- */
- public boolean isDynamic() {
- return true;
- }
-
- /**
- * Has no records.
- *
- * @return true if no records
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isEmpty() throws SQLException {
- notSupported();
-
- return false;
- }
-
- /**
- * Are we on the first row of the result set?
- *
- * @return true if on first row
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isFirst() throws SQLException {
- notSupported();
-
- return false;
- }
-
- /**
- * Are we on the last row of the result set?
- *
- * @return true if on last row
- * @throws SQLException
- * if a database error occurs
- */
- public boolean isLast() throws SQLException {
- notSupported();
-
- return false;
- }
-
- /**
- * Moves the current position relative 'rows' from the current position.
- *
- * @param rows
- * the relative number of rows to move
- * @throws SQLException
- * if a database error occurs
- */
- public void moveRowRelative(int rows) throws SQLException {
- notSupported();
- }
-
- /**
- * Returns the next row.
- *
- * @return the next row value
- * @throws SQLException
- * if a database error occurs
- */
- public ResultSetRow next() throws SQLException {
-
-
- nextRecord();
-
- if (this.nextRow == null && !this.streamerClosed && !this.moreResultsExisted) {
- this.io.closeStreamer(this);
- this.streamerClosed = true;
- }
-
- if (this.nextRow != null) {
- if (this.index != Integer.MAX_VALUE) {
- this.index++;
- }
- }
-
- return this.nextRow;
- }
-
-
- private void nextRecord() throws SQLException {
-
- try {
- if (!this.noMoreRows) {
- this.nextRow = this.io.nextRow(this.metadata, this.columnCount,
- this.isBinaryEncoded,
- java.sql.ResultSet.CONCUR_READ_ONLY, true,
- this.useBufferRowExplicit, true, null);
-
- if (this.nextRow == null) {
- this.noMoreRows = true;
- this.isAfterEnd = true;
- this.moreResultsExisted = this.io.tackOnMoreStreamingResults(this.owner);
-
- if (this.index == -1) {
- this.wasEmpty = true;
- }
- }
- } else {
- this.isAfterEnd = true;
- }
- } catch (SQLException sqlEx) {
- if (sqlEx instanceof StreamingNotifiable) {
- ((StreamingNotifiable)sqlEx).setWasStreamingResults();
- }
-
- // don't wrap SQLExceptions
- throw sqlEx;
- } catch (Exception ex) {
- String exceptionType = ex.getClass().getName();
- String exceptionMessage = ex.getMessage();
-
- exceptionMessage += Messages.getString("RowDataDynamic.7"); //$NON-NLS-1$
- exceptionMessage += Util.stackTraceToString(ex);
-
- SQLException sqlEx = SQLError.createSQLException(
- Messages.getString("RowDataDynamic.8") //$NON-NLS-1$
- + exceptionType
- + Messages.getString("RowDataDynamic.9") + exceptionMessage, SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); //$NON-NLS-1$
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- private void notSupported() throws SQLException {
- throw new OperationNotSupportedException();
- }
-
- /**
- * Removes the row at the given index.
- *
- * @param index
- * the row to move to
- * @throws SQLException
- * if a database error occurs
- */
- public void removeRow(int ind) throws SQLException {
- notSupported();
- }
-
- /**
- * Moves the current position in the result set to the given row number.
- *
- * @param rowNumber
- * row to move to
- * @throws SQLException
- * if a database error occurs
- */
- public void setCurrentRow(int rowNumber) throws SQLException {
- notSupported();
- }
-
- /**
- * @see com.mysql.jdbc.RowData#setOwner(com.mysql.jdbc.ResultSetInternalMethods)
- */
- public void setOwner(ResultSetImpl rs) {
- this.owner = rs;
- }
-
- /**
- * Only works on non dynamic result sets.
- *
- * @return the size of this row data
- */
- public int size() {
- return RESULT_SET_SIZE_UNKNOWN;
- }
-
- public boolean wasEmpty() {
- return this.wasEmpty;
- }
-
- public void setMetadata(Field[] metadata) {
- this.metadata = metadata;
- }
-}
diff --git a/src/com/mysql/jdbc/RowDataStatic.java b/src/com/mysql/jdbc/RowDataStatic.java
deleted file mode 100644
index e5111a299..000000000
--- a/src/com/mysql/jdbc/RowDataStatic.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.List;
-
-/**
- * Represents an in-memory result set
- *
- * @author dgan
- * @version $Id$
- */
-public class RowDataStatic implements RowData {
- private Field[] metadata;
-
- private int index;
-
- ResultSetImpl owner;
-
- private List rows;
-
- /**
- * Creates a new RowDataStatic object.
- *
- * @param rows
- * DOCUMENT ME!
- */
- public RowDataStatic(List rows) {
- this.index = -1;
- this.rows = rows;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param row
- * DOCUMENT ME!
- */
- public void addRow(ResultSetRow row) {
- this.rows.add(row);
- }
-
- /**
- * Moves to after last.
- */
- public void afterLast() {
- this.index = this.rows.size();
- }
-
- /**
- * Moves to before first.
- */
- public void beforeFirst() {
- this.index = -1;
- }
-
- /**
- * DOCUMENT ME!
- */
- public void beforeLast() {
- this.index = this.rows.size() - 2;
- }
-
- /**
- * DOCUMENT ME!
- */
- public void close() {
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param atIndex
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public ResultSetRow getAt(int atIndex) throws SQLException {
- if ((atIndex < 0) || (atIndex >= this.rows.size())) {
- return null;
- }
-
- return ((ResultSetRow) this.rows.get(atIndex)).setMetadata(this.metadata);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public int getCurrentRowNumber() {
- return this.index;
- }
-
- /**
- * @see com.mysql.jdbc.RowData#getOwner()
- */
- public ResultSetInternalMethods getOwner() {
- return this.owner;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean hasNext() {
- boolean hasMore = (this.index + 1) < this.rows.size();
-
- return hasMore;
- }
-
- /**
- * Returns true if we got the last element.
- *
- * @return DOCUMENT ME!
- */
- public boolean isAfterLast() {
- return this.index >= this.rows.size();
- }
-
- /**
- * Returns if iteration has not occured yet.
- *
- * @return DOCUMENT ME!
- */
- public boolean isBeforeFirst() {
- return (this.index == -1) && (this.rows.size() != 0);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isDynamic() {
- return false;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isEmpty() {
- return this.rows.size() == 0;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isFirst() {
- return this.index == 0;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public boolean isLast() {
- //
- // You can never be on the 'last' row of
- // an empty result set
- //
- if (this.rows.size() == 0) {
- return false;
- }
-
- return (this.index == (this.rows.size() - 1));
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param rows
- * DOCUMENT ME!
- */
- public void moveRowRelative(int rowsToMove) {
- this.index += rowsToMove;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public ResultSetRow next() throws SQLException {
- this.index++;
-
- if (this.index < this.rows.size()) {
- ResultSetRow row = (ResultSetRow) this.rows.get(this.index);
-
- return row.setMetadata(this.metadata);
- }
-
- return null;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param atIndex
- * DOCUMENT ME!
- */
- public void removeRow(int atIndex) {
- this.rows.remove(atIndex);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param newIndex
- * DOCUMENT ME!
- */
- public void setCurrentRow(int newIndex) {
- this.index = newIndex;
- }
-
- /**
- * @see com.mysql.jdbc.RowData#setOwner(com.mysql.jdbc.ResultSetInternalMethods)
- */
- public void setOwner(ResultSetImpl rs) {
- this.owner = rs;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public int size() {
- return this.rows.size();
- }
-
- public boolean wasEmpty() {
- return (this.rows != null && this.rows.size() == 0);
- }
-
- public void setMetadata(Field[] metadata) {
- this.metadata = metadata;
- }
-}
diff --git a/src/com/mysql/jdbc/SQLError.java b/src/com/mysql/jdbc/SQLError.java
deleted file mode 100644
index 7cbf14611..000000000
--- a/src/com/mysql/jdbc/SQLError.java
+++ /dev/null
@@ -1,1286 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.net.BindException;
-import java.sql.DataTruncation;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import com.mysql.jdbc.exceptions.MySQLDataException;
-import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException;
-import com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException;
-import com.mysql.jdbc.exceptions.MySQLSyntaxErrorException;
-import com.mysql.jdbc.exceptions.MySQLTransactionRollbackException;
-import com.mysql.jdbc.exceptions.MySQLTransientConnectionException;
-
-/**
- * SQLError is a utility class that maps MySQL error codes to X/Open error codes
- * as is required by the JDBC spec.
- *
- * @author Mark Matthews
- * @version $Id: SQLError.java 5122 2006-04-03 15:37:11 +0000 (Mon, 03 Apr 2006)
- * mmatthews $
- */
-public class SQLError {
- static final int ER_WARNING_NOT_COMPLETE_ROLLBACK = 1196;
-
- private static Map mysqlToSql99State;
-
- private static Map mysqlToSqlState;
-
- public static final String SQL_STATE_BASE_TABLE_NOT_FOUND = "S0002"; //$NON-NLS-1$
-
- public static final String SQL_STATE_BASE_TABLE_OR_VIEW_ALREADY_EXISTS = "S0001"; //$NON-NLS-1$
-
- public static final String SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND = "42S02"; //$NON-NLS-1$
-
- public static final String SQL_STATE_COLUMN_ALREADY_EXISTS = "S0021"; //$NON-NLS-1$
-
- public static final String SQL_STATE_COLUMN_NOT_FOUND = "S0022"; //$NON-NLS-1$
-
- public static final String SQL_STATE_COMMUNICATION_LINK_FAILURE = "08S01"; //$NON-NLS-1$
-
- public static final String SQL_STATE_CONNECTION_FAIL_DURING_TX = "08007"; //$NON-NLS-1$
-
- public static final String SQL_STATE_CONNECTION_IN_USE = "08002"; //$NON-NLS-1$
-
- public static final String SQL_STATE_CONNECTION_NOT_OPEN = "08003"; //$NON-NLS-1$
-
- public static final String SQL_STATE_CONNECTION_REJECTED = "08004"; //$NON-NLS-1$
-
- public static final String SQL_STATE_DATE_TRUNCATED = "01004"; //$NON-NLS-1$
-
- public static final String SQL_STATE_DATETIME_FIELD_OVERFLOW = "22008"; //$NON-NLS-1$
-
- public static final String SQL_STATE_DEADLOCK = "41000"; //$NON-NLS-1$
-
- public static final String SQL_STATE_DISCONNECT_ERROR = "01002"; //$NON-NLS-1$
-
- public static final String SQL_STATE_DIVISION_BY_ZERO = "22012"; //$NON-NLS-1$
-
- public static final String SQL_STATE_DRIVER_NOT_CAPABLE = "S1C00"; //$NON-NLS-1$
-
- public static final String SQL_STATE_ERROR_IN_ROW = "01S01"; //$NON-NLS-1$
-
- public static final String SQL_STATE_GENERAL_ERROR = "S1000"; //$NON-NLS-1$
-
- public static final String SQL_STATE_ILLEGAL_ARGUMENT = "S1009"; //$NON-NLS-1$
-
- public static final String SQL_STATE_INDEX_ALREADY_EXISTS = "S0011"; //$NON-NLS-1$
-
- public static final String SQL_STATE_INDEX_NOT_FOUND = "S0012"; //$NON-NLS-1$
-
- public static final String SQL_STATE_INSERT_VALUE_LIST_NO_MATCH_COL_LIST = "21S01"; //$NON-NLS-1$
-
- public static final String SQL_STATE_INVALID_AUTH_SPEC = "28000"; //$NON-NLS-1$
-
- public static final String SQL_STATE_INVALID_CHARACTER_VALUE_FOR_CAST = "22018"; // $NON_NLS-1$
-
- public static final String SQL_STATE_INVALID_COLUMN_NUMBER = "S1002"; //$NON-NLS-1$
-
- public static final String SQL_STATE_INVALID_CONNECTION_ATTRIBUTE = "01S00"; //$NON-NLS-1$
-
- public static final String SQL_STATE_MEMORY_ALLOCATION_FAILURE = "S1001"; //$NON-NLS-1$
-
- public static final String SQL_STATE_MORE_THAN_ONE_ROW_UPDATED_OR_DELETED = "01S04"; //$NON-NLS-1$
-
- public static final String SQL_STATE_NO_DEFAULT_FOR_COLUMN = "S0023"; //$NON-NLS-1$
-
- public static final String SQL_STATE_NO_ROWS_UPDATED_OR_DELETED = "01S03"; //$NON-NLS-1$
-
- public static final String SQL_STATE_NUMERIC_VALUE_OUT_OF_RANGE = "22003"; //$NON-NLS-1$
-
- public static final String SQL_STATE_PRIVILEGE_NOT_REVOKED = "01006"; //$NON-NLS-1$
-
- public static final String SQL_STATE_SYNTAX_ERROR = "42000"; //$NON-NLS-1$
-
- public static final String SQL_STATE_TIMEOUT_EXPIRED = "S1T00"; //$NON-NLS-1$
-
- public static final String SQL_STATE_TRANSACTION_RESOLUTION_UNKNOWN = "08007"; // $NON_NLS-1$
-
- public static final String SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE = "08001"; //$NON-NLS-1$
-
- public static final String SQL_STATE_WRONG_NO_OF_PARAMETERS = "07001"; //$NON-NLS-1$
-
- public static final String SQL_STATE_INVALID_TRANSACTION_TERMINATION = "2D000"; // $NON_NLS-1$
-
- private static Map sqlStateMessages;
-
- private static final long DEFAULT_WAIT_TIMEOUT_SECONDS = 28800;
-
- private static final int DUE_TO_TIMEOUT_FALSE = 0;
-
- private static final int DUE_TO_TIMEOUT_MAYBE = 2;
-
- private static final int DUE_TO_TIMEOUT_TRUE = 1;
-
- private static final Constructor JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR;
-
- private static Method THROWABLE_INIT_CAUSE_METHOD;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR = Class.forName(
- "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException")
- .getConstructor(
- new Class[] { ConnectionImpl.class, Long.TYPE, Long.TYPE, Exception.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR = null;
- }
-
- try {
- THROWABLE_INIT_CAUSE_METHOD = Throwable.class.getMethod("initCause", new Class[] {Throwable.class});
- } catch (Throwable t) {
- // we're not on a VM that has it
- THROWABLE_INIT_CAUSE_METHOD = null;
- }
-
- sqlStateMessages = new HashMap();
- sqlStateMessages.put(SQL_STATE_DISCONNECT_ERROR, Messages
- .getString("SQLError.35")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_DATE_TRUNCATED, Messages
- .getString("SQLError.36")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_PRIVILEGE_NOT_REVOKED, Messages
- .getString("SQLError.37")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, Messages
- .getString("SQLError.38")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_ERROR_IN_ROW, Messages
- .getString("SQLError.39")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_NO_ROWS_UPDATED_OR_DELETED, Messages
- .getString("SQLError.40")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_MORE_THAN_ONE_ROW_UPDATED_OR_DELETED,
- Messages.getString("SQLError.41")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_WRONG_NO_OF_PARAMETERS, Messages
- .getString("SQLError.42")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_UNABLE_TO_CONNECT_TO_DATASOURCE,
- Messages.getString("SQLError.43")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_CONNECTION_IN_USE, Messages
- .getString("SQLError.44")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_CONNECTION_NOT_OPEN, Messages
- .getString("SQLError.45")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_CONNECTION_REJECTED, Messages
- .getString("SQLError.46")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_CONNECTION_FAIL_DURING_TX, Messages
- .getString("SQLError.47")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_COMMUNICATION_LINK_FAILURE, Messages
- .getString("SQLError.48")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_INSERT_VALUE_LIST_NO_MATCH_COL_LIST,
- Messages.getString("SQLError.49")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_NUMERIC_VALUE_OUT_OF_RANGE, Messages
- .getString("SQLError.50")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_DATETIME_FIELD_OVERFLOW, Messages
- .getString("SQLError.51")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_DIVISION_BY_ZERO, Messages
- .getString("SQLError.52")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_DEADLOCK, Messages
- .getString("SQLError.53")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_INVALID_AUTH_SPEC, Messages
- .getString("SQLError.54")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_SYNTAX_ERROR, Messages
- .getString("SQLError.55")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND, Messages
- .getString("SQLError.56")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_BASE_TABLE_OR_VIEW_ALREADY_EXISTS,
- Messages.getString("SQLError.57")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_BASE_TABLE_NOT_FOUND, Messages
- .getString("SQLError.58")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_INDEX_ALREADY_EXISTS, Messages
- .getString("SQLError.59")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_INDEX_NOT_FOUND, Messages
- .getString("SQLError.60")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_COLUMN_ALREADY_EXISTS, Messages
- .getString("SQLError.61")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_COLUMN_NOT_FOUND, Messages
- .getString("SQLError.62")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_NO_DEFAULT_FOR_COLUMN, Messages
- .getString("SQLError.63")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_GENERAL_ERROR, Messages
- .getString("SQLError.64")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_MEMORY_ALLOCATION_FAILURE, Messages
- .getString("SQLError.65")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_INVALID_COLUMN_NUMBER, Messages
- .getString("SQLError.66")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_ILLEGAL_ARGUMENT, Messages
- .getString("SQLError.67")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_DRIVER_NOT_CAPABLE, Messages
- .getString("SQLError.68")); //$NON-NLS-1$
- sqlStateMessages.put(SQL_STATE_TIMEOUT_EXPIRED, Messages
- .getString("SQLError.69")); //$NON-NLS-1$
-
- mysqlToSqlState = new Hashtable();
-
- //
- // Communications Errors
- //
- // ER_CON_COUNT_ERROR 1040
- // ER_BAD_HOST_ERROR 1042
- // ER_HANDSHAKE_ERROR 1043
- // ER_UNKNOWN_COM_ERROR 1047
- // ER_IPSOCK_ERROR 1081
- //
- mysqlToSqlState.put(Constants.integerValueOf(1040), SQL_STATE_CONNECTION_REJECTED);
- mysqlToSqlState.put(Constants.integerValueOf(1042), SQL_STATE_CONNECTION_REJECTED);
- mysqlToSqlState.put(Constants.integerValueOf(1043), SQL_STATE_CONNECTION_REJECTED);
- mysqlToSqlState.put(Constants.integerValueOf(1047),
- SQL_STATE_COMMUNICATION_LINK_FAILURE);
- mysqlToSqlState.put(Constants.integerValueOf(1081),
- SQL_STATE_COMMUNICATION_LINK_FAILURE);
-
- // ER_HOST_IS_BLOCKED 1129
- // ER_HOST_NOT_PRIVILEGED 1130
- mysqlToSqlState.put(Constants.integerValueOf(1129), SQL_STATE_CONNECTION_REJECTED);
- mysqlToSqlState.put(Constants.integerValueOf(1130), SQL_STATE_CONNECTION_REJECTED);
-
- //
- // Authentication Errors
- //
- // ER_ACCESS_DENIED_ERROR 1045
- //
- mysqlToSqlState.put(Constants.integerValueOf(1045), SQL_STATE_INVALID_AUTH_SPEC);
-
- //
- // Resource errors
- //
- // ER_CANT_CREATE_FILE 1004
- // ER_CANT_CREATE_TABLE 1005
- // ER_CANT_LOCK 1015
- // ER_DISK_FULL 1021
- // ER_CON_COUNT_ERROR 1040
- // ER_OUT_OF_RESOURCES 1041
- //
- // Out-of-memory errors
- //
- // ER_OUTOFMEMORY 1037
- // ER_OUT_OF_SORTMEMORY 1038
- //
- mysqlToSqlState.put(Constants.integerValueOf(1037),
- SQL_STATE_MEMORY_ALLOCATION_FAILURE);
- mysqlToSqlState.put(Constants.integerValueOf(1038),
- SQL_STATE_MEMORY_ALLOCATION_FAILURE);
-
- //
- // Syntax Errors
- //
- // ER_PARSE_ERROR 1064
- // ER_EMPTY_QUERY 1065
- //
- mysqlToSqlState.put(Constants.integerValueOf(1064), SQL_STATE_SYNTAX_ERROR);
- mysqlToSqlState.put(Constants.integerValueOf(1065), SQL_STATE_SYNTAX_ERROR);
-
- //
- // Invalid argument errors
- //
- // ER_WRONG_FIELD_WITH_GROUP 1055
- // ER_WRONG_GROUP_FIELD 1056
- // ER_WRONG_SUM_SELECT 1057
- // ER_TOO_LONG_IDENT 1059
- // ER_DUP_FIELDNAME 1060
- // ER_DUP_KEYNAME 1061
- // ER_DUP_ENTRY 1062
- // ER_WRONG_FIELD_SPEC 1063
- // ER_NONUNIQ_TABLE 1066
- // ER_INVALID_DEFAULT 1067
- // ER_MULTIPLE_PRI_KEY 1068
- // ER_TOO_MANY_KEYS 1069
- // ER_TOO_MANY_KEY_PARTS 1070
- // ER_TOO_LONG_KEY 1071
- // ER_KEY_COLUMN_DOES_NOT_EXIST 1072
- // ER_BLOB_USED_AS_KEY 1073
- // ER_TOO_BIG_FIELDLENGTH 1074
- // ER_WRONG_AUTO_KEY 1075
- // ER_NO_SUCH_INDEX 1082
- // ER_WRONG_FIELD_TERMINATORS 1083
- // ER_BLOBS_AND_NO_TERMINATED 1084
- //
- mysqlToSqlState.put(Constants.integerValueOf(1055), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1056), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1057), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1059), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1060), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1061), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1062), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1063), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1066), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1067), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1068), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1069), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1070), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1071), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1072), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1073), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1074), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1075), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1082), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1083), SQL_STATE_ILLEGAL_ARGUMENT);
- mysqlToSqlState.put(Constants.integerValueOf(1084), SQL_STATE_ILLEGAL_ARGUMENT);
-
- //
- // ER_WRONG_VALUE_COUNT 1058
- //
- mysqlToSqlState.put(Constants.integerValueOf(1058),
- SQL_STATE_INSERT_VALUE_LIST_NO_MATCH_COL_LIST);
-
- // ER_CANT_CREATE_DB 1006
- // ER_DB_CREATE_EXISTS 1007
- // ER_DB_DROP_EXISTS 1008
- // ER_DB_DROP_DELETE 1009
- // ER_DB_DROP_RMDIR 1010
- // ER_CANT_DELETE_FILE 1011
- // ER_CANT_FIND_SYSTEM_REC 1012
- // ER_CANT_GET_STAT 1013
- // ER_CANT_GET_WD 1014
- // ER_UNEXPECTED_EOF 1039
- // ER_CANT_OPEN_FILE 1016
- // ER_FILE_NOT_FOUND 1017
- // ER_CANT_READ_DIR 1018
- // ER_CANT_SET_WD 1019
- // ER_CHECKREAD 1020
- // ER_DUP_KEY 1022
- // ER_ERROR_ON_CLOSE 1023
- // ER_ERROR_ON_READ 1024
- // ER_ERROR_ON_RENAME 1025
- // ER_ERROR_ON_WRITE 1026
- // ER_FILE_USED 1027
- // ER_FILSORT_ABORT 1028
- // ER_FORM_NOT_FOUND 1029
- // ER_GET_ERRNO 1030
- // ER_ILLEGAL_HA 1031
- // ER_KEY_NOT_FOUND 1032
- // ER_NOT_FORM_FILE 1033
- // ER_DBACCESS_DENIED_ERROR 1044
- // ER_NO_DB_ERROR 1046
- // ER_BAD_NULL_ERROR 1048
- // ER_BAD_DB_ERROR 1049
- // ER_TABLE_EXISTS_ERROR 1050
- // ER_BAD_TABLE_ERROR 1051
- mysqlToSqlState.put(Constants.integerValueOf(1051),
- SQL_STATE_BASE_TABLE_OR_VIEW_NOT_FOUND);
-
- // ER_NON_UNIQ_ERROR 1052
- // ER_BAD_FIELD_ERROR 1054
- mysqlToSqlState.put(Constants.integerValueOf(1054), SQL_STATE_COLUMN_NOT_FOUND);
-
- // ER_TEXTFILE_NOT_READABLE 1085
- // ER_FILE_EXISTS_ERROR 1086
- // ER_LOAD_INFO 1087
- // ER_ALTER_INFO 1088
- // ER_WRONG_SUB_KEY 1089
- // ER_CANT_REMOVE_ALL_FIELDS 1090
- // ER_CANT_DROP_FIELD_OR_KEY 1091
- // ER_INSERT_INFO 1092
- // ER_INSERT_TABLE_USED 1093
- // ER_LOCK_DEADLOCK 1213
- mysqlToSqlState.put(Constants.integerValueOf(1205), SQL_STATE_DEADLOCK);
- mysqlToSqlState.put(Constants.integerValueOf(1213), SQL_STATE_DEADLOCK);
-
- mysqlToSql99State = new HashMap();
-
- mysqlToSql99State.put(Constants.integerValueOf(1205), SQL_STATE_DEADLOCK);
- mysqlToSql99State.put(Constants.integerValueOf(1213), SQL_STATE_DEADLOCK);
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_KEY),
- "23000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_OUTOFMEMORY),
- "HY001");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_OUT_OF_SORTMEMORY), "HY001");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_CON_COUNT_ERROR), "08004");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_BAD_HOST_ERROR),
- "08S01");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_HANDSHAKE_ERROR), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_DBACCESS_DENIED_ERROR), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_ACCESS_DENIED_ERROR), "28000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TABLE_EXISTS_ERROR), "42S01");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_BAD_TABLE_ERROR), "42S02");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NON_UNIQ_ERROR),
- "23000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_SERVER_SHUTDOWN), "08S01");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_BAD_FIELD_ERROR), "42S22");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_FIELD_WITH_GROUP), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_GROUP_FIELD), "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_SUM_SELECT), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_VALUE_COUNT), "21S01");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_LONG_IDENT),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_FIELDNAME),
- "42S21");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_KEYNAME),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_ENTRY),
- "23000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_FIELD_SPEC), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_PARSE_ERROR),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_EMPTY_QUERY),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NONUNIQ_TABLE),
- "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_INVALID_DEFAULT), "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_MULTIPLE_PRI_KEY), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_MANY_KEYS),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TOO_MANY_KEY_PARTS), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_LONG_KEY),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_KEY_COLUMN_DOES_NOT_EXITS), "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_BLOB_USED_AS_KEY), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TOO_BIG_FIELDLENGTH), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_AUTO_KEY),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_FORCING_CLOSE),
- "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_IPSOCK_ERROR),
- "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NO_SUCH_INDEX),
- "42S12");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_FIELD_TERMINATORS), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_BLOBS_AND_NO_TERMINATED), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_CANT_REMOVE_ALL_FIELDS), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_CANT_DROP_FIELD_OR_KEY), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_BLOB_CANT_HAVE_DEFAULT), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_DB_NAME),
- "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_TABLE_NAME), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_BIG_SELECT),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_UNKNOWN_PROCEDURE), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_PARAMCOUNT_TO_PROCEDURE), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_UNKNOWN_TABLE),
- "42S02");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_FIELD_SPECIFIED_TWICE), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_UNSUPPORTED_EXTENSION), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TABLE_MUST_HAVE_COLUMNS), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_UNKNOWN_CHARACTER_SET), "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_BIG_ROWSIZE), "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_OUTER_JOIN), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NULL_COLUMN_IN_INDEX), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_PASSWORD_ANONYMOUS_USER), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_PASSWORD_NOT_ALLOWED), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_PASSWORD_NO_MATCH), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_VALUE_COUNT_ON_ROW), "21S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_INVALID_USE_OF_NULL), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_REGEXP_ERROR),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_MIX_OF_GROUP_FUNC_AND_FIELDS), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NONEXISTING_GRANT), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TABLEACCESS_DENIED_ERROR), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_COLUMNACCESS_DENIED_ERROR), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_ILLEGAL_GRANT_FOR_TABLE), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_GRANT_WRONG_HOST_OR_USER), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NO_SUCH_TABLE),
- "42S02");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NONEXISTING_TABLE_GRANT), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NOT_ALLOWED_COMMAND), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_SYNTAX_ERROR),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_ABORTING_CONNECTION), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NET_PACKET_TOO_LARGE), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NET_READ_ERROR_FROM_PIPE), "08S01");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_NET_FCNTL_ERROR), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NET_PACKETS_OUT_OF_ORDER), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NET_UNCOMPRESS_ERROR), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NET_READ_ERROR),
- "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NET_READ_INTERRUPTED), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NET_ERROR_ON_WRITE), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NET_WRITE_INTERRUPTED), "08S01");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_LONG_STRING), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TABLE_CANT_HANDLE_BLOB), "42000");
- mysqlToSql99State
- .put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TABLE_CANT_HANDLE_AUTO_INCREMENT),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_COLUMN_NAME), "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_KEY_COLUMN), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_DUP_UNIQUE),
- "23000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_BLOB_KEY_WITHOUT_LENGTH), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_PRIMARY_CANT_HAVE_NULL), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_TOO_MANY_ROWS),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_REQUIRES_PRIMARY_KEY), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_CHECK_NO_SUCH_TABLE), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_CHECK_NOT_IMPLEMENTED), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_CANT_DO_THIS_DURING_AN_TRANSACTION),
- "25000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NEW_ABORTING_CONNECTION), "08S01");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_MASTER_NET_READ), "08S01");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_MASTER_NET_WRITE), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TOO_MANY_USER_CONNECTIONS), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_READ_ONLY_TRANSACTION), "25000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NO_PERMISSION_TO_CREATE_USER), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_LOCK_DEADLOCK),
- "40001");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NO_REFERENCED_ROW), "23000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_ROW_IS_REFERENCED), "23000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_CONNECT_TO_MASTER), "08S01");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),
- "21000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_USER_LIMIT_REACHED), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_NO_DEFAULT),
- "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_VALUE_FOR_VAR), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_TYPE_FOR_VAR), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_CANT_USE_OPTION_HERE), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NOT_SUPPORTED_YET), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_WRONG_FK_DEF),
- "42000");
- mysqlToSql99State.put(
- Constants.integerValueOf(MysqlErrorNumbers.ER_OPERAND_COLUMNS), "21000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_SUBQUERY_NO_1_ROW), "21000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_ILLEGAL_REFERENCE), "42S22");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_DERIVED_MUST_HAVE_ALIAS), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(MysqlErrorNumbers.ER_SELECT_REDUCED),
- "01000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_TABLENAME_NOT_ALLOWED_HERE), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_NOT_SUPPORTED_AUTH_MODE), "08004");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_SPATIAL_CANT_HAVE_NULL), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_COLLATION_CHARSET_MISMATCH), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WARN_TOO_FEW_RECORDS), "01000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WARN_TOO_MANY_RECORDS), "01000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WARN_NULL_TO_NOTNULL), "01000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WARN_DATA_OUT_OF_RANGE), "01000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WARN_DATA_TRUNCATED), "01000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_NAME_FOR_INDEX), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_WRONG_NAME_FOR_CATALOG), "42000");
- mysqlToSql99State.put(Constants.integerValueOf(
- MysqlErrorNumbers.ER_UNKNOWN_STORAGE_ENGINE), "42000");
- }
-
- /**
- * Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances.
- *
- * If 'forTruncationOnly' is true, only looks for truncation warnings, and
- * actually throws DataTruncation as an exception.
- *
- * @param connection
- * the connection to use for getting warnings.
- *
- * @return the SQLWarning chain (or null if no warnings)
- *
- * @throws SQLException
- * if the warnings could not be retrieved
- */
- static SQLWarning convertShowWarningsToSQLWarnings(Connection connection)
- throws SQLException {
- return convertShowWarningsToSQLWarnings(connection, 0, false);
- }
-
- /**
- * Turns output of 'SHOW WARNINGS' into JDBC SQLWarning instances.
- *
- * If 'forTruncationOnly' is true, only looks for truncation warnings, and
- * actually throws DataTruncation as an exception.
- *
- * @param connection
- * the connection to use for getting warnings.
- * @param warningCountIfKnown
- * the warning count (if known), otherwise set it to 0.
- * @param forTruncationOnly
- * if this method should only scan for data truncation warnings
- *
- * @return the SQLWarning chain (or null if no warnings)
- *
- * @throws SQLException
- * if the warnings could not be retrieved, or if data truncation
- * is being scanned for and truncations were found.
- */
- static SQLWarning convertShowWarningsToSQLWarnings(Connection connection,
- int warningCountIfKnown, boolean forTruncationOnly)
- throws SQLException {
- java.sql.Statement stmt = null;
- java.sql.ResultSet warnRs = null;
-
- SQLWarning currentWarning = null;
-
- try {
- if (warningCountIfKnown < 100) {
- stmt = connection.createStatement();
-
- if (stmt.getMaxRows() != 0) {
- stmt.setMaxRows(0);
- }
- } else {
- // stream large warning counts
- stmt = connection.createStatement(
- java.sql.ResultSet.TYPE_FORWARD_ONLY,
- java.sql.ResultSet.CONCUR_READ_ONLY);
- stmt.setFetchSize(Integer.MIN_VALUE);
- }
-
- /*
- * +---------+------+---------------------------------------------+ |
- * Level | Code | Message |
- * +---------+------+---------------------------------------------+ |
- * Warning | 1265 | Data truncated for column 'field1' at row 1 |
- * +---------+------+---------------------------------------------+
- */
- warnRs = stmt.executeQuery("SHOW WARNINGS"); //$NON-NLS-1$
-
- while (warnRs.next()) {
- int code = warnRs.getInt("Code"); //$NON-NLS-1$
-
- if (forTruncationOnly) {
- if (code == 1265 || code == 1264) {
- DataTruncation newTruncation = new MysqlDataTruncation(
- warnRs.getString("Message"), 0, false, false, 0, 0, code); //$NON-NLS-1$
-
- if (currentWarning == null) {
- currentWarning = newTruncation;
- } else {
- currentWarning.setNextWarning(newTruncation);
- }
- }
- } else {
- String level = warnRs.getString("Level"); //$NON-NLS-1$
- String message = warnRs.getString("Message"); //$NON-NLS-1$
-
- SQLWarning newWarning = new SQLWarning(message, SQLError
- .mysqlToSqlState(code, connection
- .getUseSqlStateCodes()), code);
-
- if (currentWarning == null) {
- currentWarning = newWarning;
- } else {
- currentWarning.setNextWarning(newWarning);
- }
- }
- }
-
- if (forTruncationOnly && (currentWarning != null)) {
- throw currentWarning;
- }
-
- return currentWarning;
- } finally {
- SQLException reThrow = null;
-
- if (warnRs != null) {
- try {
- warnRs.close();
- } catch (SQLException sqlEx) {
- reThrow = sqlEx;
- }
- }
-
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException sqlEx) {
- // ideally, we'd use chained exceptions here,
- // but we still support JDK-1.2.x with this driver
- // which doesn't have them....
- reThrow = sqlEx;
- }
- }
-
- if (reThrow != null) {
- throw reThrow;
- }
- }
- }
-
- public static void dumpSqlStatesMappingsAsXml() throws Exception {
- TreeMap allErrorNumbers = new TreeMap();
- Map mysqlErrorNumbersToNames = new HashMap();
-
- Integer errorNumber = null;
-
- //
- // First create a list of all 'known' error numbers that
- // are mapped.
- //
- for (Iterator mysqlErrorNumbers = mysqlToSql99State.keySet().iterator(); mysqlErrorNumbers
- .hasNext();) {
- errorNumber = (Integer) mysqlErrorNumbers.next();
- allErrorNumbers.put(errorNumber, errorNumber);
- }
-
- for (Iterator mysqlErrorNumbers = mysqlToSqlState.keySet().iterator(); mysqlErrorNumbers
- .hasNext();) {
- errorNumber = (Integer) mysqlErrorNumbers.next();
- allErrorNumbers.put(errorNumber, errorNumber);
- }
-
- //
- // Now create a list of the actual MySQL error numbers we know about
- //
- java.lang.reflect.Field[] possibleFields = MysqlErrorNumbers.class
- .getDeclaredFields();
-
- for (int i = 0; i < possibleFields.length; i++) {
- String fieldName = possibleFields[i].getName();
-
- if (fieldName.startsWith("ER_")) {
- mysqlErrorNumbersToNames.put(possibleFields[i].get(null),
- fieldName);
- }
- }
-
- System.out.println("");
-
- for (Iterator allErrorNumbersIter = allErrorNumbers.keySet().iterator(); allErrorNumbersIter
- .hasNext();) {
- errorNumber = (Integer) allErrorNumbersIter.next();
-
- String sql92State = mysqlToSql99(errorNumber.intValue());
- String oldSqlState = mysqlToXOpen(errorNumber.intValue());
-
- System.out.println(" ");
- }
-
- System.out.println("");
- }
-
- static String get(String stateCode) {
- return (String) sqlStateMessages.get(stateCode);
- }
-
- private static String mysqlToSql99(int errno) {
- Integer err = Constants.integerValueOf(errno);
-
- if (mysqlToSql99State.containsKey(err)) {
- return (String) mysqlToSql99State.get(err);
- }
-
- return "HY000";
- }
-
- /**
- * Map MySQL error codes to X/Open or SQL-92 error codes
- *
- * @param errno
- * the MySQL error code
- *
- * @return the corresponding X/Open or SQL-92 error code
- */
- static String mysqlToSqlState(int errno, boolean useSql92States) {
- if (useSql92States) {
- return mysqlToSql99(errno);
- }
-
- return mysqlToXOpen(errno);
- }
-
- private static String mysqlToXOpen(int errno) {
- Integer err = Constants.integerValueOf(errno);
-
- if (mysqlToSqlState.containsKey(err)) {
- return (String) mysqlToSqlState.get(err);
- }
-
- return SQL_STATE_GENERAL_ERROR;
- }
-
- /*
- * SQL State Class SQLNonTransientException Subclass 08
- * SQLNonTransientConnectionException 22 SQLDataException 23
- * SQLIntegrityConstraintViolationException N/A
- * SQLInvalidAuthorizationException 42 SQLSyntaxErrorException
- *
- * SQL State Class SQLTransientException Subclass 08
- * SQLTransientConnectionException 40 SQLTransactionRollbackException N/A
- * SQLTimeoutException
- */
-
- public static SQLException createSQLException(String message,
- String sqlState, ExceptionInterceptor interceptor) {
- return createSQLException(message, sqlState, 0, interceptor);
- }
-
- public static SQLException createSQLException(String message, ExceptionInterceptor interceptor) {
- return new SQLException(message);
- }
-
- public static SQLException createSQLException(String message, String sqlState, Throwable cause, ExceptionInterceptor interceptor) {
- if (THROWABLE_INIT_CAUSE_METHOD == null) {
- if (cause != null) {
- message = message + " due to " + cause.toString();
- }
- }
-
- SQLException sqlEx = createSQLException(message, sqlState, interceptor);
-
- if (cause != null && THROWABLE_INIT_CAUSE_METHOD != null) {
- try {
- THROWABLE_INIT_CAUSE_METHOD.invoke(sqlEx, new Object[] {cause});
- } catch (Throwable t) {
- // we're not going to muck with that here, since it's
- // an error condition anyway!
- }
- }
-
- return sqlEx;
- }
-
- public static SQLException createSQLException(String message,
- String sqlState, int vendorErrorCode, ExceptionInterceptor interceptor) {
- return createSQLException(message, sqlState, vendorErrorCode, false, interceptor);
- }
-
- public static SQLException createSQLException(String message,
- String sqlState, int vendorErrorCode, boolean isTransient, ExceptionInterceptor interceptor) {
- try {
- if (sqlState != null) {
- if (sqlState.startsWith("08")) {
- if (isTransient) {
- if (!Util.isJdbc4()) {
- return new MySQLTransientConnectionException(
- message, sqlState, vendorErrorCode);
- }
-
- return (SQLException) Util
- .getInstance(
- "com.mysql.jdbc.exceptions.jdbc4.MySQLTransientConnectionException",
- new Class[] { String.class,
- String.class, Integer.TYPE },
- new Object[] { message, sqlState,
- Constants.integerValueOf(vendorErrorCode) }, interceptor);
- }
-
- if (!Util.isJdbc4()) {
- return new MySQLNonTransientConnectionException(
- message, sqlState, vendorErrorCode);
- }
-
- return (SQLException) Util
- .getInstance(
- "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException",
- new Class[] { String.class, String.class,
- Integer.TYPE }, new Object[] {
- message, sqlState,
- Constants.integerValueOf(vendorErrorCode) }, interceptor);
- }
-
- if (sqlState.startsWith("22")) {
- if (!Util.isJdbc4()) {
- return new MySQLDataException(message, sqlState,
- vendorErrorCode);
- }
-
- return (SQLException) Util
- .getInstance(
- "com.mysql.jdbc.exceptions.jdbc4.MySQLDataException",
- new Class[] { String.class, String.class,
- Integer.TYPE }, new Object[] {
- message, sqlState,
- Constants.integerValueOf(vendorErrorCode) }, interceptor);
- }
-
- if (sqlState.startsWith("23")) {
-
- if (!Util.isJdbc4()) {
- return new MySQLIntegrityConstraintViolationException(
- message, sqlState, vendorErrorCode);
- }
-
- return (SQLException) Util
- .getInstance(
- "com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException",
- new Class[] { String.class, String.class,
- Integer.TYPE }, new Object[] {
- message, sqlState,
- Constants.integerValueOf(vendorErrorCode) }, interceptor);
- }
-
- if (sqlState.startsWith("42")) {
- if (!Util.isJdbc4()) {
- return new MySQLSyntaxErrorException(message, sqlState,
- vendorErrorCode);
- }
-
- return (SQLException) Util
- .getInstance(
- "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException",
- new Class[] { String.class, String.class,
- Integer.TYPE }, new Object[] {
- message, sqlState,
- Constants.integerValueOf(vendorErrorCode) }, interceptor);
- }
-
- if (sqlState.startsWith("40")) {
- if (!Util.isJdbc4()) {
- return new MySQLTransactionRollbackException(message,
- sqlState, vendorErrorCode);
- }
-
- return (SQLException) Util
- .getInstance(
- "com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException",
- new Class[] { String.class, String.class,
- Integer.TYPE }, new Object[] {
- message, sqlState,
- Constants.integerValueOf(vendorErrorCode) }, interceptor);
- }
- }
-
- return new SQLException(message, sqlState, vendorErrorCode);
- } catch (SQLException sqlEx) {
- return new SQLException(
- "Unable to create correct SQLException class instance, error class/codes may be incorrect. Reason: "
- + Util.stackTraceToString(sqlEx),
- SQL_STATE_GENERAL_ERROR);
- }
- }
-
- public static SQLException createCommunicationsException(ConnectionImpl conn, long lastPacketSentTimeMs,
- long lastPacketReceivedTimeMs,
- Exception underlyingException, ExceptionInterceptor interceptor) {
- SQLException exToReturn = null;
-
- if (!Util.isJdbc4()) {
- exToReturn = new CommunicationsException(conn, lastPacketSentTimeMs, lastPacketReceivedTimeMs, underlyingException);
- } else {
-
- try {
- exToReturn = (SQLException) Util.handleNewInstance(JDBC_4_COMMUNICATIONS_EXCEPTION_CTOR, new Object[] {
- conn, Constants.longValueOf(lastPacketSentTimeMs), Constants.longValueOf(lastPacketReceivedTimeMs), underlyingException}, interceptor);
- } catch (SQLException sqlEx) {
- // We should _never_ get this, but let's not swallow it either
-
- return sqlEx;
- }
- }
-
- if (THROWABLE_INIT_CAUSE_METHOD != null && underlyingException != null) {
- try {
- THROWABLE_INIT_CAUSE_METHOD.invoke(exToReturn, new Object[] {underlyingException});
- } catch (Throwable t) {
- // we're not going to muck with that here, since it's
- // an error condition anyway!
- }
- }
-
- return exToReturn;
- }
-
- /**
- * Creates a communications link failure message to be used
- * in CommunicationsException that (hopefully) has some better
- * information and suggestions based on heuristics.
- *
- * @param conn
- * @param lastPacketSentTimeMs
- * @param underlyingException
- * @param streamingResultSetInPlay
- * @return
- */
- public static String createLinkFailureMessageBasedOnHeuristics(
- ConnectionImpl conn,
- long lastPacketSentTimeMs,
- long lastPacketReceivedTimeMs,
- Exception underlyingException,
- boolean streamingResultSetInPlay) {
- long serverTimeoutSeconds = 0;
- boolean isInteractiveClient = false;
-
- if (conn != null) {
- isInteractiveClient = conn.getInteractiveClient();
-
- String serverTimeoutSecondsStr = null;
-
- if (isInteractiveClient) {
- serverTimeoutSecondsStr = conn
- .getServerVariable("interactive_timeout"); //$NON-NLS-1$
- } else {
- serverTimeoutSecondsStr = conn
- .getServerVariable("wait_timeout"); //$NON-NLS-1$
- }
-
- if (serverTimeoutSecondsStr != null) {
- try {
- serverTimeoutSeconds = Long
- .parseLong(serverTimeoutSecondsStr);
- } catch (NumberFormatException nfe) {
- serverTimeoutSeconds = 0;
- }
- }
- }
-
- StringBuffer exceptionMessageBuf = new StringBuffer();
-
- if (lastPacketSentTimeMs == 0) {
- lastPacketSentTimeMs = System.currentTimeMillis();
- }
-
- long timeSinceLastPacket = (System.currentTimeMillis() - lastPacketSentTimeMs) / 1000;
- long timeSinceLastPacketMs = (System.currentTimeMillis() - lastPacketSentTimeMs);
- long timeSinceLastPacketReceivedMs = (System.currentTimeMillis() - lastPacketReceivedTimeMs);
-
- int dueToTimeout = DUE_TO_TIMEOUT_FALSE;
-
- StringBuffer timeoutMessageBuf = null;
-
- if (streamingResultSetInPlay) {
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.ClientWasStreaming")); //$NON-NLS-1$
- } else {
- if (serverTimeoutSeconds != 0) {
- if (timeSinceLastPacket > serverTimeoutSeconds) {
- dueToTimeout = DUE_TO_TIMEOUT_TRUE;
-
- timeoutMessageBuf = new StringBuffer();
-
- timeoutMessageBuf.append(Messages
- .getString("CommunicationsException.2")); //$NON-NLS-1$
-
- if (!isInteractiveClient) {
- timeoutMessageBuf.append(Messages
- .getString("CommunicationsException.3")); //$NON-NLS-1$
- } else {
- timeoutMessageBuf.append(Messages
- .getString("CommunicationsException.4")); //$NON-NLS-1$
- }
-
- }
- } else if (timeSinceLastPacket > DEFAULT_WAIT_TIMEOUT_SECONDS) {
- dueToTimeout = DUE_TO_TIMEOUT_MAYBE;
-
- timeoutMessageBuf = new StringBuffer();
-
- timeoutMessageBuf.append(Messages
- .getString("CommunicationsException.5")); //$NON-NLS-1$
- timeoutMessageBuf.append(Messages
- .getString("CommunicationsException.6")); //$NON-NLS-1$
- timeoutMessageBuf.append(Messages
- .getString("CommunicationsException.7")); //$NON-NLS-1$
- timeoutMessageBuf.append(Messages
- .getString("CommunicationsException.8")); //$NON-NLS-1$
- }
-
- if (dueToTimeout == DUE_TO_TIMEOUT_TRUE
- || dueToTimeout == DUE_TO_TIMEOUT_MAYBE) {
-
- if (lastPacketReceivedTimeMs != 0) {
- Object[] timingInfo = {
- new Long(timeSinceLastPacketReceivedMs),
- new Long(timeSinceLastPacketMs)
- };
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.ServerPacketTimingInfo", //$NON-NLS-1$
- timingInfo));
- } else {
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.ServerPacketTimingInfoNoRecv", //$NON-NLS-1$
- new Object[] { new Long(timeSinceLastPacketMs)}));
- }
-
- if (timeoutMessageBuf != null) {
- exceptionMessageBuf.append(timeoutMessageBuf);
- }
-
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.11")); //$NON-NLS-1$
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.12")); //$NON-NLS-1$
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.13")); //$NON-NLS-1$
-
- } else {
- //
- // Attempt to determine the reason for the underlying exception
- // (we can only make a best-guess here)
- //
-
- if (underlyingException instanceof BindException) {
- if (conn.getLocalSocketAddress() != null
- && !Util.interfaceExists(conn
- .getLocalSocketAddress())) {
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.LocalSocketAddressNotAvailable")); //$NON-NLS-1$
- } else {
- // too many client connections???
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.TooManyClientConnections")); //$NON-NLS-1$
- }
- }
- }
- }
-
- if (exceptionMessageBuf.length() == 0) {
- // We haven't figured out a good reason, so copy it.
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.20")); //$NON-NLS-1$
-
- if (THROWABLE_INIT_CAUSE_METHOD == null &&
- underlyingException != null) {
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.21")); //$NON-NLS-1$
- exceptionMessageBuf.append(Util
- .stackTraceToString(underlyingException));
- }
-
- if (conn != null && conn.getMaintainTimeStats()
- && !conn.getParanoid()) {
- exceptionMessageBuf.append("\n\n"); //$NON-NLS-1$
- if (lastPacketReceivedTimeMs != 0) {
- Object[] timingInfo = {
- new Long(timeSinceLastPacketReceivedMs),
- new Long(timeSinceLastPacketMs)
- };
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.ServerPacketTimingInfo", //$NON-NLS-1$
- timingInfo));
- } else {
- exceptionMessageBuf.append(Messages
- .getString("CommunicationsException.ServerPacketTimingInfoNoRecv", //$NON-NLS-1$
- new Object[] { new Long(timeSinceLastPacketMs)}));
- }
- }
- }
-
- return exceptionMessageBuf.toString();
- }
-
- public static SQLException notImplemented() {
- if (Util.isJdbc4()) {
- try {
- return (SQLException) Class.forName(
- "java.sql.SQLFeatureNotSupportedException")
- .newInstance();
- } catch (Throwable t) {
- // proceed
- }
- }
-
- return new NotImplemented();
- }
-}
diff --git a/src/com/mysql/jdbc/Security.java b/src/com/mysql/jdbc/Security.java
deleted file mode 100644
index 951d9c0c0..000000000
--- a/src/com/mysql/jdbc/Security.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.UnsupportedEncodingException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * Methods for doing secure authentication with MySQL-4.1 and newer.
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-class Security {
- private static final char PVERSION41_CHAR = '*';
-
- private static final int SHA1_HASH_SIZE = 20;
-
- /**
- * Returns hex value for given char
- */
- private static int charVal(char c) {
- return ((c >= '0') && (c <= '9')) ? (c - '0')
- : (((c >= 'A') && (c <= 'Z')) ? (c - 'A' + 10) : (c - 'a' + 10));
- }
-
- /*
- * Convert password in salted form to binary string password and hash-salt
- * For old password this involes one more hashing
- *
- * SYNOPSIS get_hash_and_password() salt IN Salt to convert from pversion IN
- * Password version to use hash OUT Store zero ended hash here bin_password
- * OUT Store binary password here (no zero at the end)
- *
- * RETURN 0 for pre 4.1 passwords !0 password version char for newer
- * passwords
- */
-
- /**
- * Creates key from old password to decode scramble Used in 4.1
- * authentication with passwords stored pre-4.1 hashing.
- *
- * @param passwd
- * the password to create the key from
- *
- * @return 20 byte generated key
- *
- * @throws NoSuchAlgorithmException
- * if the message digest 'SHA-1' is not available.
- */
- static byte[] createKeyFromOldPassword(String passwd)
- throws NoSuchAlgorithmException {
- /* At first hash password to the string stored in password */
- passwd = makeScrambledPassword(passwd);
-
- /* Now convert it to the salt form */
- int[] salt = getSaltFromPassword(passwd);
-
- /* Finally get hash and bin password from salt */
- return getBinaryPassword(salt, false);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param salt
- * DOCUMENT ME!
- * @param usingNewPasswords
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws NoSuchAlgorithmException
- * if the message digest 'SHA-1' is not available.
- */
- static byte[] getBinaryPassword(int[] salt, boolean usingNewPasswords)
- throws NoSuchAlgorithmException {
- int val = 0;
-
- byte[] binaryPassword = new byte[SHA1_HASH_SIZE]; /*
- * Binary password
- * loop pointer
- */
-
- if (usingNewPasswords) /* New password version assumed */{
- int pos = 0;
-
- for (int i = 0; i < 4; i++) /* Iterate over these elements */{
- val = salt[i];
-
- for (int t = 3; t >= 0; t--) {
- binaryPassword[pos++] = (byte) (val & 255);
- val >>= 8; /* Scroll 8 bits to get next part */
- }
- }
-
- return binaryPassword;
- }
-
- int offset = 0;
-
- for (int i = 0; i < 2; i++) /* Iterate over these elements */{
- val = salt[i];
-
- for (int t = 3; t >= 0; t--) {
- binaryPassword[t + offset] = (byte) (val % 256);
- val >>= 8; /* Scroll 8 bits to get next part */
- }
-
- offset += 4;
- }
-
- MessageDigest md = MessageDigest.getInstance("SHA-1"); //$NON-NLS-1$
-
- md.update(binaryPassword, 0, 8);
-
- return md.digest();
- }
-
- private static int[] getSaltFromPassword(String password) {
- int[] result = new int[6];
-
- if ((password == null) || (password.length() == 0)) {
- return result;
- }
-
- if (password.charAt(0) == PVERSION41_CHAR) {
- // new password
- String saltInHex = password.substring(1, 5);
-
- int val = 0;
-
- for (int i = 0; i < 4; i++) {
- val = (val << 4) + charVal(saltInHex.charAt(i));
- }
-
- return result;
- }
-
- int resultPos = 0;
- int pos = 0;
- int length = password.length();
-
- while (pos < length) {
- int val = 0;
-
- for (int i = 0; i < 8; i++) {
- val = (val << 4) + charVal(password.charAt(pos++));
- }
-
- result[resultPos++] = val;
- }
-
- return result;
- }
-
- private static String longToHex(long val) {
- String longHex = Long.toHexString(val);
-
- int length = longHex.length();
-
- if (length < 8) {
- int padding = 8 - length;
- StringBuffer buf = new StringBuffer();
-
- for (int i = 0; i < padding; i++) {
- buf.append("0"); //$NON-NLS-1$
- }
-
- buf.append(longHex);
-
- return buf.toString();
- }
-
- return longHex.substring(0, 8);
- }
-
- /**
- * Creates password to be stored in user database from raw string.
- *
- * Handles Pre-MySQL 4.1 passwords.
- *
- * @param password
- * plaintext password
- *
- * @return scrambled password
- *
- * @throws NoSuchAlgorithmException
- * if the message digest 'SHA-1' is not available.
- */
- static String makeScrambledPassword(String password)
- throws NoSuchAlgorithmException {
- long[] passwordHash = Util.newHash(password);
- StringBuffer scramble = new StringBuffer();
-
- scramble.append(longToHex(passwordHash[0]));
- scramble.append(longToHex(passwordHash[1]));
-
- return scramble.toString();
- }
-
- /**
- * Encrypt/Decrypt function used for password encryption in authentication
- *
- * Simple XOR is used here but it is OK as we crypt random strings
- *
- * @param from
- * IN Data for encryption
- * @param to
- * OUT Encrypt data to the buffer (may be the same)
- * @param password
- * IN Password used for encryption (same length)
- * @param length
- * IN Length of data to encrypt
- */
- static void passwordCrypt(byte[] from, byte[] to, byte[] password,
- int length) {
- int pos = 0;
-
- while ((pos < from.length) && (pos < length)) {
- to[pos] = (byte) (from[pos] ^ password[pos]);
- pos++;
- }
- }
-
- /**
- * Stage one password hashing, used in MySQL 4.1 password handling
- *
- * @param password
- * plaintext password
- *
- * @return stage one hash of password
- *
- * @throws NoSuchAlgorithmException
- * if the message digest 'SHA-1' is not available.
- */
- static byte[] passwordHashStage1(String password)
- throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance("SHA-1"); //$NON-NLS-1$
- StringBuffer cleansedPassword = new StringBuffer();
-
- int passwordLength = password.length();
-
- for (int i = 0; i < passwordLength; i++) {
- char c = password.charAt(i);
-
- if ((c == ' ') || (c == '\t')) {
- continue; /* skip space in password */
- }
-
- cleansedPassword.append(c);
- }
-
- return md.digest(cleansedPassword.toString().getBytes());
- }
-
- /**
- * Stage two password hashing used in MySQL 4.1 password handling
- *
- * @param hash
- * from passwordHashStage1
- * @param salt
- * salt used for stage two hashing
- *
- * @return result of stage two password hash
- *
- * @throws NoSuchAlgorithmException
- * if the message digest 'SHA-1' is not available.
- */
- static byte[] passwordHashStage2(byte[] hashedPassword, byte[] salt)
- throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance("SHA-1"); //$NON-NLS-1$
-
- // hash 4 bytes of salt
- md.update(salt, 0, 4);
-
- md.update(hashedPassword, 0, SHA1_HASH_SIZE);
-
- return md.digest();
- }
-
- // SERVER: public_seed=create_random_string()
- // send(public_seed)
- //
- // CLIENT: recv(public_seed)
- // hash_stage1=sha1("password")
- // hash_stage2=sha1(hash_stage1)
- // reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
- //
- // // this three steps are done in scramble()
- //
- // send(reply)
- //
- //
- // SERVER: recv(reply)
- // hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
- // candidate_hash2=sha1(hash_stage1)
- // check(candidate_hash2==hash_stage2)
- static byte[] scramble411(String password, String seed, Connection conn)
- throws NoSuchAlgorithmException, UnsupportedEncodingException {
- MessageDigest md = MessageDigest.getInstance("SHA-1"); //$NON-NLS-1$
- String passwordEncoding = conn.getPasswordCharacterEncoding();
-
- byte[] passwordHashStage1 = md
- .digest((passwordEncoding == null || passwordEncoding.length() == 0) ? password
- .getBytes()
- : password.getBytes(passwordEncoding));
- md.reset();
-
- byte[] passwordHashStage2 = md.digest(passwordHashStage1);
- md.reset();
-
- byte[] seedAsBytes = seed.getBytes("ASCII"); // for debugging
- md.update(seedAsBytes);
- md.update(passwordHashStage2);
-
- byte[] toBeXord = md.digest();
-
- int numToXor = toBeXord.length;
-
- for (int i = 0; i < numToXor; i++) {
- toBeXord[i] = (byte) (toBeXord[i] ^ passwordHashStage1[i]);
- }
-
- return toBeXord;
- }
-
- /**
- * Prevent construction.
- */
- private Security() {
- super();
- }
-}
diff --git a/src/com/mysql/jdbc/ServerPreparedStatement.java b/src/com/mysql/jdbc/ServerPreparedStatement.java
deleted file mode 100644
index ba26c99c6..000000000
--- a/src/com/mysql/jdbc/ServerPreparedStatement.java
+++ /dev/null
@@ -1,2952 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.ParameterMetaData;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-import com.mysql.jdbc.exceptions.MySQLStatementCancelledException;
-import com.mysql.jdbc.exceptions.MySQLTimeoutException;
-import com.mysql.jdbc.profiler.ProfilerEvent;
-import com.mysql.jdbc.profiler.ProfilerEventHandlerFactory;
-
-/**
- * JDBC Interface for MySQL-4.1 and newer server-side PreparedStatements.
- *
- * @author Mark Matthews
- * @version $Id: ServerPreparedStatement.java,v 1.1.2.2 2005/05/17 14:58:56
- * mmatthews Exp $
- */
-public class ServerPreparedStatement extends PreparedStatement {
- private static final Constructor JDBC_4_SPS_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_SPS_CTOR = Class.forName("com.mysql.jdbc.JDBC4ServerPreparedStatement")
- .getConstructor(
- new Class[] { ConnectionImpl.class, String.class, String.class,
- Integer.TYPE, Integer.TYPE});
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_SPS_CTOR = null;
- }
- }
-
- protected static final int BLOB_STREAM_READ_BUF_SIZE = 8192;
-
- static class BatchedBindValues {
- BindValue[] batchedParameterValues;
-
- BatchedBindValues(BindValue[] paramVals) {
- int numParams = paramVals.length;
-
- this.batchedParameterValues = new BindValue[numParams];
-
- for (int i = 0; i < numParams; i++) {
- this.batchedParameterValues[i] = new BindValue(paramVals[i]);
- }
- }
- }
-
- public static class BindValue {
-
- long boundBeforeExecutionNum = 0;
-
- public long bindLength; /* Default length of data */
-
- int bufferType; /* buffer type */
-
- byte byteBinding;
-
- double doubleBinding;
-
- float floatBinding;
-
- int intBinding;
-
- public boolean isLongData; /* long data indicator */
-
- public boolean isNull; /* NULL indicator */
-
- boolean isSet = false; /* has this parameter been set? */
-
- long longBinding;
-
- short shortBinding;
-
- public Object value; /* The value to store */
-
- BindValue() {
- }
-
- BindValue(BindValue copyMe) {
- this.value = copyMe.value;
- this.isSet = copyMe.isSet;
- this.isLongData = copyMe.isLongData;
- this.isNull = copyMe.isNull;
- this.bufferType = copyMe.bufferType;
- this.bindLength = copyMe.bindLength;
- this.byteBinding = copyMe.byteBinding;
- this.shortBinding = copyMe.shortBinding;
- this.intBinding = copyMe.intBinding;
- this.longBinding = copyMe.longBinding;
- this.floatBinding = copyMe.floatBinding;
- this.doubleBinding = copyMe.doubleBinding;
- }
-
- void reset() {
- this.isSet = false;
- this.value = null;
- this.isLongData = false;
-
- this.byteBinding = 0;
- this.shortBinding = 0;
- this.intBinding = 0;
- this.longBinding = 0L;
- this.floatBinding = 0;
- this.doubleBinding = 0D;
- }
-
- public String toString() {
- return toString(false);
- }
-
- public String toString(boolean quoteIfNeeded) {
- if (this.isLongData) {
- return "' STREAM DATA '";
- }
-
- switch (this.bufferType) {
- case MysqlDefs.FIELD_TYPE_TINY:
- return String.valueOf(byteBinding);
- case MysqlDefs.FIELD_TYPE_SHORT:
- return String.valueOf(shortBinding);
- case MysqlDefs.FIELD_TYPE_LONG:
- return String.valueOf(intBinding);
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- return String.valueOf(longBinding);
- case MysqlDefs.FIELD_TYPE_FLOAT:
- return String.valueOf(floatBinding);
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- return String.valueOf(doubleBinding);
- case MysqlDefs.FIELD_TYPE_TIME:
- case MysqlDefs.FIELD_TYPE_DATE:
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- case MysqlDefs.FIELD_TYPE_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- if (quoteIfNeeded) {
- return "'" + String.valueOf(value) + "'";
- } else {
- return String.valueOf(value);
- }
- default:
- if (value instanceof byte[]) {
- return "byte data";
-
- } else {
- if (quoteIfNeeded) {
- return "'" + String.valueOf(value) + "'";
- } else {
- return String.valueOf(value);
- }
- }
- }
- }
-
- long getBoundLength() {
- if (isNull) {
- return 0;
- }
-
- if (isLongData) {
- return bindLength;
- }
-
- switch (bufferType) {
-
- case MysqlDefs.FIELD_TYPE_TINY:
- return 1;
- case MysqlDefs.FIELD_TYPE_SHORT:
- return 2;
- case MysqlDefs.FIELD_TYPE_LONG:
- return 4;
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- return 8;
- case MysqlDefs.FIELD_TYPE_FLOAT:
- return 4;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- return 8;
- case MysqlDefs.FIELD_TYPE_TIME:
- return 9;
- case MysqlDefs.FIELD_TYPE_DATE:
- return 7;
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- return 11;
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- case MysqlDefs.FIELD_TYPE_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- if (value instanceof byte[]) {
- return ((byte[]) value).length;
- } else {
- return ((String) value).length();
- }
- default:
- return 0;
- }
- }
- }
-
- /* 1 (length) + 2 (year) + 1 (month) + 1 (day) */
- private static final byte MAX_DATE_REP_LENGTH = (byte) 5;
-
- /*
- * 1 (length) + 2 (year) + 1 (month) + 1 (day) + 1 (hour) + 1 (minute) + 1
- * (second) + 4 (microseconds)
- */
- private static final byte MAX_DATETIME_REP_LENGTH = 12;
-
- /*
- * 1 (length) + 1 (is negative) + 4 (day count) + 1 (hour) + 1 (minute) + 1
- * (seconds) + 4 (microseconds)
- */
- private static final byte MAX_TIME_REP_LENGTH = 13;
-
- private boolean hasOnDuplicateKeyUpdate = false;
-
- private void storeTime(Buffer intoBuf, Time tm) throws SQLException {
-
- intoBuf.ensureCapacity(9);
- intoBuf.writeByte((byte) 8); // length
- intoBuf.writeByte((byte) 0); // neg flag
- intoBuf.writeLong(0); // tm->day, not used
-
- Calendar sessionCalendar = getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- java.util.Date oldTime = sessionCalendar.getTime();
- try {
- sessionCalendar.setTime(tm);
- intoBuf.writeByte((byte) sessionCalendar.get(Calendar.HOUR_OF_DAY));
- intoBuf.writeByte((byte) sessionCalendar.get(Calendar.MINUTE));
- intoBuf.writeByte((byte) sessionCalendar.get(Calendar.SECOND));
-
- // intoBuf.writeLongInt(0); // tm-second_part
- } finally {
- sessionCalendar.setTime(oldTime);
- }
- }
- }
-
- /**
- * Flag indicating whether or not the long parameters have been 'switched'
- * back to normal parameters. We can not execute() if clearParameters()
- * hasn't been called in this case.
- */
- private boolean detectedLongParameterSwitch = false;
-
- /**
- * The number of fields in the result set (if any) for this
- * PreparedStatement.
- */
- private int fieldCount;
-
- /** Has this prepared statement been marked invalid? */
- private boolean invalid = false;
-
- /** If this statement has been marked invalid, what was the reason? */
- private SQLException invalidationException;
-
- /** Does this query modify data? */
- private boolean isSelectQuery;
-
- private Buffer outByteBuffer;
-
- /** Bind values for individual fields */
- private BindValue[] parameterBindings;
-
- /** Field-level metadata for parameters */
- private Field[] parameterFields;
-
- /** Field-level metadata for result sets. */
- private Field[] resultFields;
-
- /** Do we need to send/resend types to the server? */
- private boolean sendTypesToServer = false;
-
- /** The ID that the server uses to identify this PreparedStatement */
- private long serverStatementId;
-
- /** The type used for string bindings, changes from version-to-version */
- private int stringTypeCode = MysqlDefs.FIELD_TYPE_STRING;
-
- private boolean serverNeedsResetBeforeEachExecution;
-
- /**
- * Creates a prepared statement instance -- We need to provide factory-style
- * methods so we can support both JDBC3 (and older) and JDBC4 runtimes,
- * otherwise the class verifier complains when it tries to load JDBC4-only
- * interface classes that are present in JDBC4 method signatures.
- */
-
- protected static ServerPreparedStatement getInstance(ConnectionImpl conn,
- String sql, String catalog, int resultSetType,
- int resultSetConcurrency) throws SQLException {
- if (!Util.isJdbc4()) {
- return new ServerPreparedStatement(conn, sql, catalog,
- resultSetType, resultSetConcurrency);
- }
-
- try {
- return (ServerPreparedStatement) JDBC_4_SPS_CTOR.newInstance(new Object[] { conn,
- sql, catalog, Constants.integerValueOf(resultSetType),
- Constants.integerValueOf(resultSetConcurrency) });
- } catch (IllegalArgumentException e) {
- throw new SQLException(e.toString(), SQLError.SQL_STATE_GENERAL_ERROR);
- } catch (InstantiationException e) {
- throw new SQLException(e.toString(), SQLError.SQL_STATE_GENERAL_ERROR);
- } catch (IllegalAccessException e) {
- throw new SQLException(e.toString(), SQLError.SQL_STATE_GENERAL_ERROR);
- } catch (InvocationTargetException e) {
- Throwable target = e.getTargetException();
-
- if (target instanceof SQLException) {
- throw (SQLException)target;
- }
-
- throw new SQLException(target.toString(), SQLError.SQL_STATE_GENERAL_ERROR);
- }
- }
-
- /**
- * Creates a new ServerPreparedStatement object.
- *
- * @param conn
- * the connection creating us.
- * @param sql
- * the SQL containing the statement to prepare.
- * @param catalog
- * the catalog in use when we were created.
- *
- * @throws SQLException
- * If an error occurs
- */
- protected ServerPreparedStatement(ConnectionImpl conn, String sql, String catalog,
- int resultSetType, int resultSetConcurrency)
- throws SQLException {
- super(conn, catalog);
-
- checkNullOrEmptyQuery(sql);
-
- this.hasOnDuplicateKeyUpdate = containsOnDuplicateKeyInString(sql);
-
- int startOfStatement = findStartOfStatement(sql);
-
- this.firstCharOfStmt = StringUtils.firstAlphaCharUc(sql, startOfStatement);
-
- this.isSelectQuery = 'S' == this.firstCharOfStmt;
-
- if (this.connection.versionMeetsMinimum(5, 0, 0)) {
- this.serverNeedsResetBeforeEachExecution =
- !this.connection.versionMeetsMinimum(5, 0, 3);
- } else {
- this.serverNeedsResetBeforeEachExecution =
- !this.connection.versionMeetsMinimum(4, 1, 10);
- }
-
- this.useAutoSlowLog = this.connection.getAutoSlowLog();
- this.useTrueBoolean = this.connection.versionMeetsMinimum(3, 21, 23);
- this.hasLimitClause = (StringUtils.indexOfIgnoreCase(sql, "LIMIT") != -1); //$NON-NLS-1$
-
- String statementComment = this.connection.getStatementComment();
-
- this.originalSql = (statementComment == null) ? sql : "/* "
- + statementComment + " */ " + sql;
-
- if (this.connection.versionMeetsMinimum(4, 1, 2)) {
- this.stringTypeCode = MysqlDefs.FIELD_TYPE_VAR_STRING;
- } else {
- this.stringTypeCode = MysqlDefs.FIELD_TYPE_STRING;
- }
-
- try {
- serverPrepare(sql);
- } catch (SQLException sqlEx) {
- realClose(false, true);
- // don't wrap SQLExceptions
- throw sqlEx;
- } catch (Exception ex) {
- realClose(false, true);
-
- SQLException sqlEx = SQLError.createSQLException(ex.toString(),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
-
- setResultSetType(resultSetType);
- setResultSetConcurrency(resultSetConcurrency);
-
- this.parameterTypes = new int[this.parameterCount];
- }
-
- /**
- * JDBC 2.0 Add a set of parameters to the batch.
- *
- * @exception SQLException
- * if a database-access error occurs.
- *
- * @see StatementImpl#addBatch
- */
- public synchronized void addBatch() throws SQLException {
- checkClosed();
-
- if (this.batchedArgs == null) {
- this.batchedArgs = new ArrayList();
- }
-
- this.batchedArgs.add(new BatchedBindValues(this.parameterBindings));
- }
-
- protected String asSql(boolean quoteStreamsAndUnknowns) throws SQLException {
-
- if (this.isClosed) {
- return "statement has been closed, no further internal information available";
- }
-
- PreparedStatement pStmtForSub = null;
-
- try {
- pStmtForSub = PreparedStatement.getInstance(this.connection,
- this.originalSql, this.currentCatalog);
-
- int numParameters = pStmtForSub.parameterCount;
- int ourNumParameters = this.parameterCount;
-
- for (int i = 0; (i < numParameters) && (i < ourNumParameters); i++) {
- if (this.parameterBindings[i] != null) {
- if (this.parameterBindings[i].isNull) {
- pStmtForSub.setNull(i + 1, Types.NULL);
- } else {
- BindValue bindValue = this.parameterBindings[i];
-
- //
- // Handle primitives first
- //
- switch (bindValue.bufferType) {
-
- case MysqlDefs.FIELD_TYPE_TINY:
- pStmtForSub.setByte(i + 1, bindValue.byteBinding);
- break;
- case MysqlDefs.FIELD_TYPE_SHORT:
- pStmtForSub.setShort(i + 1, bindValue.shortBinding);
- break;
- case MysqlDefs.FIELD_TYPE_LONG:
- pStmtForSub.setInt(i + 1, bindValue.intBinding);
- break;
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- pStmtForSub.setLong(i + 1, bindValue.longBinding);
- break;
- case MysqlDefs.FIELD_TYPE_FLOAT:
- pStmtForSub.setFloat(i + 1, bindValue.floatBinding);
- break;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- pStmtForSub.setDouble(i + 1,
- bindValue.doubleBinding);
- break;
- default:
- pStmtForSub.setObject(i + 1,
- this.parameterBindings[i].value);
- break;
- }
- }
- }
- }
-
- return pStmtForSub.asSql(quoteStreamsAndUnknowns);
- } finally {
- if (pStmtForSub != null) {
- try {
- pStmtForSub.close();
- } catch (SQLException sqlEx) {
- ; // ignore
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.Statement#checkClosed()
- */
- protected void checkClosed() throws SQLException {
- if (this.invalid) {
- throw this.invalidationException;
- }
-
- super.checkClosed();
- }
-
- /**
- * @see java.sql.PreparedStatement#clearParameters()
- */
- public void clearParameters() throws SQLException {
- checkClosed();
- clearParametersInternal(true);
- }
-
- private void clearParametersInternal(boolean clearServerParameters)
- throws SQLException {
- boolean hadLongData = false;
-
- if (this.parameterBindings != null) {
- for (int i = 0; i < this.parameterCount; i++) {
- if ((this.parameterBindings[i] != null)
- && this.parameterBindings[i].isLongData) {
- hadLongData = true;
- }
-
- this.parameterBindings[i].reset();
- }
- }
-
- if (clearServerParameters && hadLongData) {
- serverResetStatement();
-
- this.detectedLongParameterSwitch = false;
- }
- }
-
- protected boolean isCached = false;
-
- private boolean useAutoSlowLog;
-
- private Calendar serverTzCalendar;
-
- private Calendar defaultTzCalendar;
-
- protected void setClosed(boolean flag) {
- this.isClosed = flag;
- }
-
- /**
- * @see java.sql.Statement#close()
- */
- public synchronized void close() throws SQLException {
- if (this.isCached && !this.isClosed) {
- clearParameters();
-
- this.isClosed = true;
-
- this.connection.recachePreparedStatement(this);
- return;
- }
-
- realClose(true, true);
- }
-
- private void dumpCloseForTestcase() {
- StringBuffer buf = new StringBuffer();
- this.connection.generateConnectionCommentBlock(buf);
- buf.append("DEALLOCATE PREPARE debug_stmt_");
- buf.append(this.statementId);
- buf.append(";\n");
-
- this.connection.dumpTestcaseQuery(buf.toString());
- }
-
- private void dumpExecuteForTestcase() throws SQLException {
- StringBuffer buf = new StringBuffer();
-
- for (int i = 0; i < this.parameterCount; i++) {
- this.connection.generateConnectionCommentBlock(buf);
-
- buf.append("SET @debug_stmt_param");
- buf.append(this.statementId);
- buf.append("_");
- buf.append(i);
- buf.append("=");
-
- if (this.parameterBindings[i].isNull) {
- buf.append("NULL");
- } else {
- buf.append(this.parameterBindings[i].toString(true));
- }
-
- buf.append(";\n");
- }
-
- this.connection.generateConnectionCommentBlock(buf);
-
- buf.append("EXECUTE debug_stmt_");
- buf.append(this.statementId);
-
- if (this.parameterCount > 0) {
- buf.append(" USING ");
- for (int i = 0; i < this.parameterCount; i++) {
- if (i > 0) {
- buf.append(", ");
- }
-
- buf.append("@debug_stmt_param");
- buf.append(this.statementId);
- buf.append("_");
- buf.append(i);
-
- }
- }
-
- buf.append(";\n");
-
- this.connection.dumpTestcaseQuery(buf.toString());
- }
-
- private void dumpPrepareForTestcase() throws SQLException {
-
- StringBuffer buf = new StringBuffer(this.originalSql.length() + 64);
-
- this.connection.generateConnectionCommentBlock(buf);
-
- buf.append("PREPARE debug_stmt_");
- buf.append(this.statementId);
- buf.append(" FROM \"");
- buf.append(this.originalSql);
- buf.append("\";\n");
-
- this.connection.dumpTestcaseQuery(buf.toString());
- }
-
- protected int[] executeBatchSerially(int batchTimeout) throws SQLException {
- ConnectionImpl locallyScopedConn = this.connection;
-
- if (locallyScopedConn == null) {
- checkClosed();
- }
-
- if (locallyScopedConn.isReadOnly()) {
- throw SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.2") //$NON-NLS-1$
- + Messages.getString("ServerPreparedStatement.3"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- checkClosed();
-
- synchronized (locallyScopedConn.getMutex()) {
- clearWarnings();
-
- // Store this for later, we're going to 'swap' them out
- // as we execute each batched statement...
- BindValue[] oldBindValues = this.parameterBindings;
-
- try {
- int[] updateCounts = null;
-
- if (this.batchedArgs != null) {
- int nbrCommands = this.batchedArgs.size();
- updateCounts = new int[nbrCommands];
-
- if (this.retrieveGeneratedKeys) {
- this.batchedGeneratedKeys = new ArrayList(nbrCommands);
- }
-
- for (int i = 0; i < nbrCommands; i++) {
- updateCounts[i] = -3;
- }
-
- SQLException sqlEx = null;
-
- int commandIndex = 0;
-
- BindValue[] previousBindValuesForBatch = null;
-
- CancelTask timeoutTask = null;
-
- try {
- if (locallyScopedConn.getEnableQueryTimeouts() &&
- batchTimeout != 0
- && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- batchTimeout);
- }
-
- for (commandIndex = 0; commandIndex < nbrCommands; commandIndex++) {
- Object arg = this.batchedArgs.get(commandIndex);
-
- if (arg instanceof String) {
- updateCounts[commandIndex] = executeUpdate((String) arg);
- } else {
- this.parameterBindings = ((BatchedBindValues) arg).batchedParameterValues;
-
- try {
- // We need to check types each time, as
- // the user might have bound different
- // types in each addBatch()
-
- if (previousBindValuesForBatch != null) {
- for (int j = 0; j < this.parameterBindings.length; j++) {
- if (this.parameterBindings[j].bufferType != previousBindValuesForBatch[j].bufferType) {
- this.sendTypesToServer = true;
-
- break;
- }
- }
- }
-
- try {
- updateCounts[commandIndex] = executeUpdate(false, true);
- } finally {
- previousBindValuesForBatch = this.parameterBindings;
- }
-
- if (this.retrieveGeneratedKeys) {
- java.sql.ResultSet rs = null;
-
- try {
- // we don't want to use our version,
- // because we've altered the behavior of
- // ours to support batch updates
- // (catch-22)
- // Ideally, what we need here is
- // super.super.getGeneratedKeys()
- // but that construct doesn't exist in
- // Java, so that's why there's
- // this kludge.
- rs = getGeneratedKeysInternal();
-
- while (rs.next()) {
- this.batchedGeneratedKeys
- .add(new ByteArrayRow(new byte[][] { rs
- .getBytes(1) }, getExceptionInterceptor()));
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
- }
- } catch (SQLException ex) {
- updateCounts[commandIndex] = EXECUTE_FAILED;
-
- if (this.continueBatchOnError &&
- !(ex instanceof MySQLTimeoutException) &&
- !(ex instanceof MySQLStatementCancelledException)
- && !hasDeadlockOrTimeoutRolledBackTx(ex)) {
- sqlEx = ex;
- } else {
- int[] newUpdateCounts = new int[commandIndex];
- System.arraycopy(updateCounts, 0,
- newUpdateCounts, 0, commandIndex);
-
- throw new java.sql.BatchUpdateException(ex
- .getMessage(), ex.getSQLState(), ex
- .getErrorCode(), newUpdateCounts);
- }
- }
- }
- }
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- resetCancelledState();
- }
-
- if (sqlEx != null) {
- throw new java.sql.BatchUpdateException(sqlEx
- .getMessage(), sqlEx.getSQLState(), sqlEx
- .getErrorCode(), updateCounts);
- }
- }
-
- return (updateCounts != null) ? updateCounts : new int[0];
- } finally {
- this.parameterBindings = oldBindValues;
- this.sendTypesToServer = true;
-
- clearBatch();
- }
- }
- }
-
- /**
- * @see com.mysql.jdbc.PreparedStatement#executeInternal(int,
- * com.mysql.jdbc.Buffer, boolean, boolean)
- */
- protected com.mysql.jdbc.ResultSetInternalMethods executeInternal(int maxRowsToRetrieve,
- Buffer sendPacket, boolean createStreamingResultSet,
- boolean queryIsSelectOnly, Field[] metadataFromCache,
- boolean isBatch)
- throws SQLException {
- this.numberOfExecutions++;
-
- // We defer to server-side execution
- try {
- return serverExecute(maxRowsToRetrieve, createStreamingResultSet,
- metadataFromCache);
- } catch (SQLException sqlEx) {
- // don't wrap SQLExceptions
- if (this.connection.getEnablePacketDebug()) {
- this.connection.getIO().dumpPacketRingBuffer();
- }
-
- if (this.connection.getDumpQueriesOnException()) {
- String extractedSql = toString();
- StringBuffer messageBuf = new StringBuffer(extractedSql
- .length() + 32);
- messageBuf
- .append("\n\nQuery being executed when exception was thrown:\n\n");
- messageBuf.append(extractedSql);
-
- sqlEx = ConnectionImpl.appendMessageToException(sqlEx, messageBuf
- .toString(), getExceptionInterceptor());
- }
-
- throw sqlEx;
- } catch (Exception ex) {
- if (this.connection.getEnablePacketDebug()) {
- this.connection.getIO().dumpPacketRingBuffer();
- }
-
- SQLException sqlEx = SQLError.createSQLException(ex.toString(),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
-
- if (this.connection.getDumpQueriesOnException()) {
- String extractedSql = toString();
- StringBuffer messageBuf = new StringBuffer(extractedSql
- .length() + 32);
- messageBuf
- .append("\n\nQuery being executed when exception was thrown:\n\n");
- messageBuf.append(extractedSql);
-
- sqlEx = ConnectionImpl.appendMessageToException(sqlEx, messageBuf
- .toString(), getExceptionInterceptor());
- }
-
- sqlEx.initCause(ex);
-
- throw sqlEx;
- }
- }
-
- /**
- * @see com.mysql.jdbc.PreparedStatement#fillSendPacket()
- */
- protected Buffer fillSendPacket() throws SQLException {
- return null; // we don't use this type of packet
- }
-
- /**
- * @see com.mysql.jdbc.PreparedStatement#fillSendPacket(byte,
- * java.io.InputStream, boolean, int)
- */
- protected Buffer fillSendPacket(byte[][] batchedParameterStrings,
- InputStream[] batchedParameterStreams, boolean[] batchedIsStream,
- int[] batchedStreamLengths) throws SQLException {
- return null; // we don't use this type of packet
- }
-
- /**
- * Returns the structure representing the value that (can be)/(is)
- * bound at the given parameter index.
- *
- * @param parameterIndex 1-based
- * @param forLongData is this for a stream?
- * @return
- * @throws SQLException
- */
- protected BindValue getBinding(int parameterIndex, boolean forLongData)
- throws SQLException {
- checkClosed();
-
- if (this.parameterBindings.length == 0) {
- throw SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.8"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- parameterIndex--;
-
- if ((parameterIndex < 0)
- || (parameterIndex >= this.parameterBindings.length)) {
- throw SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.9") //$NON-NLS-1$
- + (parameterIndex + 1)
- + Messages.getString("ServerPreparedStatement.10") //$NON-NLS-1$
- + this.parameterBindings.length,
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- if (this.parameterBindings[parameterIndex] == null) {
- this.parameterBindings[parameterIndex] = new BindValue();
- } else {
- if (this.parameterBindings[parameterIndex].isLongData
- && !forLongData) {
- this.detectedLongParameterSwitch = true;
- }
- }
-
- this.parameterBindings[parameterIndex].isSet = true;
- this.parameterBindings[parameterIndex].boundBeforeExecutionNum = this.numberOfExecutions;
-
- return this.parameterBindings[parameterIndex];
- }
-
- /**
- * @see com.mysql.jdbc.PreparedStatement#getBytes(int)
- */
- byte[] getBytes(int parameterIndex) throws SQLException {
- BindValue bindValue = getBinding(parameterIndex, false);
-
- if (bindValue.isNull) {
- return null;
- } else if (bindValue.isLongData) {
- throw SQLError.notImplemented();
- } else {
- if (this.outByteBuffer == null) {
- this.outByteBuffer = new Buffer(this.connection
- .getNetBufferLength());
- }
-
- this.outByteBuffer.clear();
-
- int originalPosition = this.outByteBuffer.getPosition();
-
- storeBinding(this.outByteBuffer, bindValue, this.connection.getIO());
-
- int newPosition = this.outByteBuffer.getPosition();
-
- int length = newPosition - originalPosition;
-
- byte[] valueAsBytes = new byte[length];
-
- System.arraycopy(this.outByteBuffer.getByteBuffer(),
- originalPosition, valueAsBytes, 0, length);
-
- return valueAsBytes;
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#getMetaData()
- */
- public java.sql.ResultSetMetaData getMetaData() throws SQLException {
- checkClosed();
-
- if (this.resultFields == null) {
- return null;
- }
-
- return new ResultSetMetaData(this.resultFields,
- this.connection.getUseOldAliasMetadataBehavior(), getExceptionInterceptor());
- }
-
- /**
- * @see java.sql.PreparedStatement#getParameterMetaData()
- */
- public ParameterMetaData getParameterMetaData() throws SQLException {
- checkClosed();
-
- if (this.parameterMetaData == null) {
- this.parameterMetaData = new MysqlParameterMetadata(
- this.parameterFields, this.parameterCount, getExceptionInterceptor());
- }
-
- return this.parameterMetaData;
- }
-
- /**
- * @see com.mysql.jdbc.PreparedStatement#isNull(int)
- */
- boolean isNull(int paramIndex) {
- throw new IllegalArgumentException(Messages
- .getString("ServerPreparedStatement.7")); //$NON-NLS-1$
- }
-
- /**
- * Closes this connection and frees all resources.
- *
- * @param calledExplicitly
- * was this called from close()?
- *
- * @throws SQLException
- * if an error occurs
- */
- protected void realClose(boolean calledExplicitly,
- boolean closeOpenResults) throws SQLException {
- if (this.isClosed) {
- return;
- }
-
- if (this.connection != null) {
- if (this.connection.getAutoGenerateTestcaseScript()) {
- dumpCloseForTestcase();
- }
-
- //
- // Don't communicate with the server if we're being
- // called from the finalizer...
- //
- // This will leak server resources, but if we don't do this,
- // we'll deadlock (potentially, because there's no guarantee
- // when, what order, and what concurrency finalizers will be
- // called with). Well-behaved programs won't rely on finalizers
- // to clean up their statements.
- //
-
- SQLException exceptionDuringClose = null;
-
- if (calledExplicitly && !this.connection.isClosed()) {
- synchronized (this.connection.getMutex()) {
- try {
-
- MysqlIO mysql = this.connection.getIO();
-
- Buffer packet = mysql.getSharedSendPacket();
-
- packet.writeByte((byte) MysqlDefs.COM_CLOSE_STATEMENT);
- packet.writeLong(this.serverStatementId);
-
- mysql.sendCommand(MysqlDefs.COM_CLOSE_STATEMENT, null,
- packet, true, null, 0);
- } catch (SQLException sqlEx) {
- exceptionDuringClose = sqlEx;
- }
- }
- }
-
- super.realClose(calledExplicitly, closeOpenResults);
-
- clearParametersInternal(false);
- this.parameterBindings = null;
-
- this.parameterFields = null;
- this.resultFields = null;
-
- if (exceptionDuringClose != null) {
- throw exceptionDuringClose;
- }
- }
- }
-
- /**
- * Used by Connection when auto-reconnecting to retrieve 'lost' prepared
- * statements.
- *
- * @throws SQLException
- * if an error occurs.
- */
- protected void rePrepare() throws SQLException {
- this.invalidationException = null;
-
- try {
- serverPrepare(this.originalSql);
- } catch (SQLException sqlEx) {
- // don't wrap SQLExceptions
- this.invalidationException = sqlEx;
- } catch (Exception ex) {
- this.invalidationException = SQLError.createSQLException(ex.toString(),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- this.invalidationException.initCause(ex);
- }
-
- if (this.invalidationException != null) {
- this.invalid = true;
-
- this.parameterBindings = null;
-
- this.parameterFields = null;
- this.resultFields = null;
-
- if (this.results != null) {
- try {
- this.results.close();
- } catch (Exception ex) {
- ;
- }
- }
-
- if (this.connection != null) {
- if (this.maxRowsChanged) {
- this.connection.unsetMaxRows(this);
- }
-
- if (!this.connection.getDontTrackOpenResources()) {
- this.connection.unregisterStatement(this);
- }
- }
- }
- }
-
- /**
- * Tells the server to execute this prepared statement with the current
- * parameter bindings.
- *
- *
- *
- *
- * - Server gets the command 'COM_EXECUTE' to execute the
- * previously prepared query. If there is any param markers;
- * then client will send the data in the following format:
- *
- * [COM_EXECUTE:1]
- * [STMT_ID:4]
- * [NULL_BITS:(param_count+7)/8)]
- * [TYPES_SUPPLIED_BY_CLIENT(0/1):1]
- * [[length]data]
- * [[length]data] .. [[length]data].
- *
- * (Note: Except for string/binary types; all other types will not be
- * supplied with length field)
- *
- *
- *
- *
- * @param maxRowsToRetrieve
- * DOCUMENT ME!
- * @param createStreamingResultSet
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- */
- private com.mysql.jdbc.ResultSetInternalMethods serverExecute(int maxRowsToRetrieve,
- boolean createStreamingResultSet,
- Field[] metadataFromCache) throws SQLException {
- synchronized (this.connection.getMutex()) {
- if (this.detectedLongParameterSwitch) {
- // Check when values were bound
- boolean firstFound = false;
- long boundTimeToCheck = 0;
-
- for (int i = 0; i < this.parameterCount - 1; i++) {
- if (this.parameterBindings[i].isLongData) {
- if (firstFound && boundTimeToCheck !=
- this.parameterBindings[i].boundBeforeExecutionNum) {
- throw SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.11") //$NON-NLS-1$
- + Messages.getString("ServerPreparedStatement.12"), //$NON-NLS-1$
- SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, getExceptionInterceptor());
- } else {
- firstFound = true;
- boundTimeToCheck = this.parameterBindings[i].boundBeforeExecutionNum;
- }
- }
- }
-
- // Okay, we've got all "newly"-bound streams, so reset
- // server-side state to clear out previous bindings
-
- serverResetStatement();
- }
-
-
- // Check bindings
- for (int i = 0; i < this.parameterCount; i++) {
- if (!this.parameterBindings[i].isSet) {
- throw SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.13") + (i + 1) //$NON-NLS-1$
- + Messages.getString("ServerPreparedStatement.14"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- //
- // Send all long data
- //
- for (int i = 0; i < this.parameterCount; i++) {
- if (this.parameterBindings[i].isLongData) {
- serverLongData(i, this.parameterBindings[i]);
- }
- }
-
- if (this.connection.getAutoGenerateTestcaseScript()) {
- dumpExecuteForTestcase();
- }
-
- //
- // store the parameter values
- //
- MysqlIO mysql = this.connection.getIO();
-
- Buffer packet = mysql.getSharedSendPacket();
-
- packet.clear();
- packet.writeByte((byte) MysqlDefs.COM_EXECUTE);
- packet.writeLong(this.serverStatementId);
-
- boolean usingCursor = false;
-
- if (this.connection.versionMeetsMinimum(4, 1, 2)) {
- // we only create cursor-backed result sets if
- // a) The query is a SELECT
- // b) The server supports it
- // c) We know it is forward-only (note this doesn't
- // preclude updatable result sets)
- // d) The user has set a fetch size
- if (this.resultFields != null &&
- this.connection.isCursorFetchEnabled()
- && getResultSetType() == ResultSet.TYPE_FORWARD_ONLY
- && getResultSetConcurrency() == ResultSet.CONCUR_READ_ONLY
- && getFetchSize() > 0) {
- packet.writeByte(MysqlDefs.OPEN_CURSOR_FLAG);
- usingCursor = true;
- } else {
- packet.writeByte((byte) 0); // placeholder for flags
- }
-
- packet.writeLong(1); // placeholder for parameter
- // iterations
- }
-
- /* Reserve place for null-marker bytes */
- int nullCount = (this.parameterCount + 7) / 8;
-
- // if (mysql.versionMeetsMinimum(4, 1, 2)) {
- // nullCount = (this.parameterCount + 9) / 8;
- // }
- int nullBitsPosition = packet.getPosition();
-
- for (int i = 0; i < nullCount; i++) {
- packet.writeByte((byte) 0);
- }
-
- byte[] nullBitsBuffer = new byte[nullCount];
-
- /* In case if buffers (type) altered, indicate to server */
- packet.writeByte(this.sendTypesToServer ? (byte) 1 : (byte) 0);
-
- if (this.sendTypesToServer) {
- /*
- * Store types of parameters in first in first package that is
- * sent to the server.
- */
- for (int i = 0; i < this.parameterCount; i++) {
- packet.writeInt(this.parameterBindings[i].bufferType);
- }
- }
-
- //
- // store the parameter values
- //
- for (int i = 0; i < this.parameterCount; i++) {
- if (!this.parameterBindings[i].isLongData) {
- if (!this.parameterBindings[i].isNull) {
- storeBinding(packet, this.parameterBindings[i], mysql);
- } else {
- nullBitsBuffer[i / 8] |= (1 << (i & 7));
- }
- }
- }
-
- //
- // Go back and write the NULL flags
- // to the beginning of the packet
- //
- int endPosition = packet.getPosition();
- packet.setPosition(nullBitsPosition);
- packet.writeBytesNoNull(nullBitsBuffer);
- packet.setPosition(endPosition);
-
- long begin = 0;
-
- boolean logSlowQueries = this.connection.getLogSlowQueries();
- boolean gatherPerformanceMetrics = this.connection
- .getGatherPerformanceMetrics();
-
- if (this.profileSQL || logSlowQueries || gatherPerformanceMetrics) {
- begin = mysql.getCurrentTimeNanosOrMillis();
- }
-
- resetCancelledState();
-
- CancelTask timeoutTask = null;
-
- try {
- if (this.connection.getEnableQueryTimeouts() &&
- this.timeoutInMillis != 0
- && this.connection.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- this.connection.getCancelTimer().schedule(timeoutTask,
- this.timeoutInMillis);
- }
-
- Buffer resultPacket = mysql.sendCommand(MysqlDefs.COM_EXECUTE,
- null, packet, false, null, 0);
-
- long queryEndTime = 0L;
-
- if (logSlowQueries || gatherPerformanceMetrics || this.profileSQL) {
- queryEndTime = mysql.getCurrentTimeNanosOrMillis();
- }
-
- if (timeoutTask != null) {
- timeoutTask.cancel();
-
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask = null;
- }
-
- synchronized (this.cancelTimeoutMutex) {
- if (this.wasCancelled) {
- SQLException cause = null;
-
- if (this.wasCancelledByTimeout) {
- cause = new MySQLTimeoutException();
- } else {
- cause = new MySQLStatementCancelledException();
- }
-
- resetCancelledState();
-
- throw cause;
- }
- }
-
- boolean queryWasSlow = false;
-
- if (logSlowQueries || gatherPerformanceMetrics) {
- long elapsedTime = queryEndTime - begin;
-
- if (logSlowQueries) {
- if (this.useAutoSlowLog) {
- queryWasSlow = elapsedTime > this.connection.getSlowQueryThresholdMillis();
- } else {
- queryWasSlow = this.connection.isAbonormallyLongQuery(elapsedTime);
-
- this.connection.reportQueryTime(elapsedTime);
- }
- }
-
- if (queryWasSlow) {
-
- StringBuffer mesgBuf = new StringBuffer(
- 48 + this.originalSql.length());
- mesgBuf.append(Messages
- .getString("ServerPreparedStatement.15")); //$NON-NLS-1$
- mesgBuf.append(mysql.getSlowQueryThreshold());
- mesgBuf.append(Messages
- .getString("ServerPreparedStatement.15a")); //$NON-NLS-1$
- mesgBuf.append(elapsedTime);
- mesgBuf.append(Messages
- .getString("ServerPreparedStatement.16")); //$NON-NLS-1$
-
- mesgBuf.append("as prepared: ");
- mesgBuf.append(this.originalSql);
- mesgBuf.append("\n\n with parameters bound:\n\n");
- mesgBuf.append(asSql(true));
-
- this.eventSink
- .consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_SLOW_QUERY,
- "", this.currentCatalog, this.connection.getId(), //$NON-NLS-1$
- getId(), 0, System.currentTimeMillis(),
- elapsedTime, mysql
- .getQueryTimingUnits(), null,
- new Throwable(), mesgBuf.toString()));
- }
-
- if (gatherPerformanceMetrics) {
- this.connection.registerQueryExecutionTime(elapsedTime);
- }
- }
-
- this.connection.incrementNumberOfPreparedExecutes();
-
- if (this.profileSQL) {
- this.eventSink = ProfilerEventHandlerFactory
- .getInstance(this.connection);
-
- this.eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_EXECUTE,
- "", this.currentCatalog, //$NON-NLS-1$
- this.connectionId, this.statementId, -1, System
- .currentTimeMillis(), (int) (mysql
- .getCurrentTimeNanosOrMillis() - begin),
- mysql.getQueryTimingUnits(), null, new Throwable(),
- truncateQueryToLog(asSql(true))));
- }
-
- com.mysql.jdbc.ResultSetInternalMethods rs = mysql.readAllResults(this,
- maxRowsToRetrieve, this.resultSetType,
- this.resultSetConcurrency, createStreamingResultSet,
- this.currentCatalog, resultPacket, true, this.fieldCount,
- metadataFromCache);
-
- if (this.profileSQL) {
- long fetchEndTime = mysql.getCurrentTimeNanosOrMillis();
-
- this.eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_FETCH,
- "", this.currentCatalog, this.connection.getId(), //$NON-NLS-1$
- getId(), 0 /* FIXME rs.resultId */, System.currentTimeMillis(),
- (fetchEndTime - queryEndTime), mysql
- .getQueryTimingUnits(), null,
- new Throwable(), null));
- }
-
- if (queryWasSlow && this.connection.getExplainSlowQueries()) {
- String queryAsString = asSql(true);
-
- mysql.explainSlowQuery(queryAsString.getBytes(),
- queryAsString);
- }
-
- if (!createStreamingResultSet &&
- this.serverNeedsResetBeforeEachExecution) {
- serverResetStatement(); // clear any long data...
- }
-
-
- this.sendTypesToServer = false;
- this.results = rs;
-
- if (mysql.hadWarnings()) {
- mysql.scanForAndThrowDataTruncation();
- }
-
- return rs;
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
- }
- }
- }
-
- /**
- * Sends stream-type data parameters to the server.
- *
- *
- *
- * Long data handling:
- *
- * - Server gets the long data in pieces with command type 'COM_LONG_DATA'.
- * - The packet recieved will have the format as:
- * [COM_LONG_DATA: 1][STMT_ID:4][parameter_number:2][type:2][data]
- * - Checks if the type is specified by client, and if yes reads the type,
- * and stores the data in that format.
- * - It's up to the client to check for read data ended. The server doesn't
- * care; and also server doesn't notify to the client that it got the
- * data or not; if there is any error; then during execute; the error
- * will be returned
- *
- *
- *
- * @param parameterIndex
- * DOCUMENT ME!
- * @param longData
- * DOCUMENT ME!
- *
- * @throws SQLException
- * if an error occurs.
- */
- private void serverLongData(int parameterIndex, BindValue longData)
- throws SQLException {
- synchronized (this.connection.getMutex()) {
- MysqlIO mysql = this.connection.getIO();
-
- Buffer packet = mysql.getSharedSendPacket();
-
- Object value = longData.value;
-
- if (value instanceof byte[]) {
- packet.clear();
- packet.writeByte((byte) MysqlDefs.COM_LONG_DATA);
- packet.writeLong(this.serverStatementId);
- packet.writeInt((parameterIndex));
-
- packet.writeBytesNoNull((byte[]) longData.value);
-
- mysql.sendCommand(MysqlDefs.COM_LONG_DATA, null, packet, true,
- null, 0);
- } else if (value instanceof InputStream) {
- storeStream(mysql, parameterIndex, packet, (InputStream) value);
- } else if (value instanceof java.sql.Blob) {
- storeStream(mysql, parameterIndex, packet,
- ((java.sql.Blob) value).getBinaryStream());
- } else if (value instanceof Reader) {
- storeReader(mysql, parameterIndex, packet, (Reader) value);
- } else {
- throw SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.18") //$NON-NLS-1$
- + value.getClass().getName() + "'", //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
- }
-
- private void serverPrepare(String sql) throws SQLException {
- synchronized (this.connection.getMutex()) {
- MysqlIO mysql = this.connection.getIO();
-
- if (this.connection.getAutoGenerateTestcaseScript()) {
- dumpPrepareForTestcase();
- }
-
- try {
- long begin = 0;
-
- if (StringUtils.startsWithIgnoreCaseAndWs(sql, "LOAD DATA")) { //$NON-NLS-1$
- this.isLoadDataQuery = true;
- } else {
- this.isLoadDataQuery = false;
- }
-
- if (this.connection.getProfileSql()) {
- begin = System.currentTimeMillis();
- }
-
- String characterEncoding = null;
- String connectionEncoding = this.connection.getEncoding();
-
- if (!this.isLoadDataQuery && this.connection.getUseUnicode()
- && (connectionEncoding != null)) {
- characterEncoding = connectionEncoding;
- }
-
- Buffer prepareResultPacket = mysql.sendCommand(
- MysqlDefs.COM_PREPARE, sql, null, false,
- characterEncoding, 0);
-
- if (this.connection.versionMeetsMinimum(4, 1, 1)) {
- // 4.1.1 and newer use the first byte
- // as an 'ok' or 'error' flag, so move
- // the buffer pointer past it to
- // start reading the statement id.
- prepareResultPacket.setPosition(1);
- } else {
- // 4.1.0 doesn't use the first byte as an
- // 'ok' or 'error' flag
- prepareResultPacket.setPosition(0);
- }
-
- this.serverStatementId = prepareResultPacket.readLong();
- this.fieldCount = prepareResultPacket.readInt();
- this.parameterCount = prepareResultPacket.readInt();
- this.parameterBindings = new BindValue[this.parameterCount];
-
- for (int i = 0; i < this.parameterCount; i++) {
- this.parameterBindings[i] = new BindValue();
- }
-
- this.connection.incrementNumberOfPrepares();
-
- if (this.profileSQL) {
- this.eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_PREPARE,
- "", this.currentCatalog, //$NON-NLS-1$
- this.connectionId, this.statementId, -1,
- System.currentTimeMillis(),
- mysql.getCurrentTimeNanosOrMillis() - begin,
- mysql.getQueryTimingUnits(), null,
- new Throwable(), truncateQueryToLog(sql)));
- }
-
- if (this.parameterCount > 0) {
- if (this.connection.versionMeetsMinimum(4, 1, 2)
- && !mysql.isVersion(5, 0, 0)) {
- this.parameterFields = new Field[this.parameterCount];
-
- Buffer metaDataPacket = mysql.readPacket();
-
- int i = 0;
-
- while (!metaDataPacket.isLastDataPacket()
- && (i < this.parameterCount)) {
- this.parameterFields[i++] = mysql.unpackField(
- metaDataPacket, false);
- metaDataPacket = mysql.readPacket();
- }
- }
- }
-
- if (this.fieldCount > 0) {
- this.resultFields = new Field[this.fieldCount];
-
- Buffer fieldPacket = mysql.readPacket();
-
- int i = 0;
-
- // Read in the result set column information
- while (!fieldPacket.isLastDataPacket()
- && (i < this.fieldCount)) {
- this.resultFields[i++] = mysql.unpackField(fieldPacket,
- false);
- fieldPacket = mysql.readPacket();
- }
- }
- } catch (SQLException sqlEx) {
- if (this.connection.getDumpQueriesOnException()) {
- StringBuffer messageBuf = new StringBuffer(this.originalSql
- .length() + 32);
- messageBuf
- .append("\n\nQuery being prepared when exception was thrown:\n\n");
- messageBuf.append(this.originalSql);
-
- sqlEx = ConnectionImpl.appendMessageToException(sqlEx,
- messageBuf.toString(), getExceptionInterceptor());
- }
-
- throw sqlEx;
- } finally {
- // Leave the I/O channel in a known state...there might be
- // packets out there
- // that we're not interested in
- this.connection.getIO().clearInputStream();
- }
- }
- }
-
- private String truncateQueryToLog(String sql) {
- String query = null;
-
- if (sql.length() > this.connection.getMaxQuerySizeToLog()) {
- StringBuffer queryBuf = new StringBuffer(
- this.connection.getMaxQuerySizeToLog() + 12);
- queryBuf.append(sql.substring(0, this.connection.getMaxQuerySizeToLog()));
- queryBuf.append(Messages.getString("MysqlIO.25"));
-
- query = queryBuf.toString();
- } else {
- query = sql;
- }
-
- return query;
- }
-
- private void serverResetStatement() throws SQLException {
- synchronized (this.connection.getMutex()) {
-
- MysqlIO mysql = this.connection.getIO();
-
- Buffer packet = mysql.getSharedSendPacket();
-
- packet.clear();
- packet.writeByte((byte) MysqlDefs.COM_RESET_STMT);
- packet.writeLong(this.serverStatementId);
-
- try {
- mysql.sendCommand(MysqlDefs.COM_RESET_STMT, null, packet,
- !this.connection.versionMeetsMinimum(4, 1, 2), null, 0);
- } catch (SQLException sqlEx) {
- throw sqlEx;
- } catch (Exception ex) {
- SQLException sqlEx = SQLError.createSQLException(ex.toString(),
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(ex);
-
- throw sqlEx;
- } finally {
- mysql.clearInputStream();
- }
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)
- */
- public void setArray(int i, Array x) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream,
- * int)
- */
- public void setAsciiStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- checkClosed();
-
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- BindValue binding = getBinding(parameterIndex, true);
- setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
-
- binding.value = x;
- binding.isNull = false;
- binding.isLongData = true;
-
- if (this.connection.getUseStreamLengthsInPrepStmts()) {
- binding.bindLength = length;
- } else {
- binding.bindLength = -1;
- }
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)
- */
- public void setBigDecimal(int parameterIndex, BigDecimal x)
- throws SQLException {
- checkClosed();
-
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.DECIMAL);
- } else {
-
- BindValue binding = getBinding(parameterIndex, false);
-
- if (this.connection.versionMeetsMinimum(5, 0, 3)) {
- setType(binding, MysqlDefs.FIELD_TYPE_NEW_DECIMAL);
- } else {
- setType(binding, this.stringTypeCode);
- }
-
- binding.value = StringUtils
- .fixDecimalExponent(StringUtils.consistentToString(x));
- binding.isNull = false;
- binding.isLongData = false;
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream,
- * int)
- */
- public void setBinaryStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- checkClosed();
-
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- BindValue binding = getBinding(parameterIndex, true);
- setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
-
- binding.value = x;
- binding.isNull = false;
- binding.isLongData = true;
-
- if (this.connection.getUseStreamLengthsInPrepStmts()) {
- binding.bindLength = length;
- } else {
- binding.bindLength = -1;
- }
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)
- */
- public void setBlob(int parameterIndex, Blob x) throws SQLException {
- checkClosed();
-
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- BindValue binding = getBinding(parameterIndex, true);
- setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
-
- binding.value = x;
- binding.isNull = false;
- binding.isLongData = true;
-
- if (this.connection.getUseStreamLengthsInPrepStmts()) {
- binding.bindLength = x.length();
- } else {
- binding.bindLength = -1;
- }
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setBoolean(int, boolean)
- */
- public void setBoolean(int parameterIndex, boolean x) throws SQLException {
- setByte(parameterIndex, (x ? (byte) 1 : (byte) 0));
- }
-
- /**
- * @see java.sql.PreparedStatement#setByte(int, byte)
- */
- public void setByte(int parameterIndex, byte x) throws SQLException {
- checkClosed();
-
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_TINY);
-
- binding.value = null;
- binding.byteBinding = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setBytes(int, byte)
- */
- public void setBytes(int parameterIndex, byte[] x) throws SQLException {
- checkClosed();
-
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_VAR_STRING);
-
- binding.value = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader,
- * int)
- */
- public void setCharacterStream(int parameterIndex, Reader reader, int length)
- throws SQLException {
- checkClosed();
-
- if (reader == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- BindValue binding = getBinding(parameterIndex, true);
- setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
-
- binding.value = reader;
- binding.isNull = false;
- binding.isLongData = true;
-
- if (this.connection.getUseStreamLengthsInPrepStmts()) {
- binding.bindLength = length;
- } else {
- binding.bindLength = -1;
- }
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)
- */
- public void setClob(int parameterIndex, Clob x) throws SQLException {
- checkClosed();
-
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.BINARY);
- } else {
- BindValue binding = getBinding(parameterIndex, true);
- setType(binding, MysqlDefs.FIELD_TYPE_BLOB);
-
- binding.value = x.getCharacterStream();
- binding.isNull = false;
- binding.isLongData = true;
-
- if (this.connection.getUseStreamLengthsInPrepStmts()) {
- binding.bindLength = x.length();
- } else {
- binding.bindLength = -1;
- }
- }
- }
-
- /**
- * Set a parameter to a java.sql.Date value. The driver converts this to a
- * SQL DATE value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public void setDate(int parameterIndex, Date x) throws SQLException {
- setDate(parameterIndex, x, null);
- }
-
- /**
- * Set a parameter to a java.sql.Date value. The driver converts this to a
- * SQL DATE value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- * @param cal
- * the calendar to interpret the date with
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public void setDate(int parameterIndex, Date x, Calendar cal)
- throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.DATE);
- } else {
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_DATE);
-
- binding.value = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
- }
-
- /**
- * @see java.sql.PreparedStatement#setDouble(int, double)
- */
- public void setDouble(int parameterIndex, double x) throws SQLException {
- checkClosed();
-
- if (!this.connection.getAllowNanAndInf()
- && (x == Double.POSITIVE_INFINITY
- || x == Double.NEGATIVE_INFINITY || Double.isNaN(x))) {
- throw SQLError.createSQLException("'" + x
- + "' is not a valid numeric or approximate numeric value",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
-
- }
-
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_DOUBLE);
-
- binding.value = null;
- binding.doubleBinding = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setFloat(int, float)
- */
- public void setFloat(int parameterIndex, float x) throws SQLException {
- checkClosed();
-
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_FLOAT);
-
- binding.value = null;
- binding.floatBinding = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setInt(int, int)
- */
- public void setInt(int parameterIndex, int x) throws SQLException {
- checkClosed();
-
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_LONG);
-
- binding.value = null;
- binding.intBinding = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setLong(int, long)
- */
- public void setLong(int parameterIndex, long x) throws SQLException {
- checkClosed();
-
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_LONGLONG);
-
- binding.value = null;
- binding.longBinding = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setNull(int, int)
- */
- public void setNull(int parameterIndex, int sqlType) throws SQLException {
- checkClosed();
-
- BindValue binding = getBinding(parameterIndex, false);
-
- //
- // Don't re-set types, but use something if this
- // parameter was never specified
- //
- if (binding.bufferType == 0) {
- setType(binding, MysqlDefs.FIELD_TYPE_NULL);
- }
-
- binding.value = null;
- binding.isNull = true;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)
- */
- public void setNull(int parameterIndex, int sqlType, String typeName)
- throws SQLException {
- checkClosed();
-
- BindValue binding = getBinding(parameterIndex, false);
-
- //
- // Don't re-set types, but use something if this
- // parameter was never specified
- //
- if (binding.bufferType == 0) {
- setType(binding, MysqlDefs.FIELD_TYPE_NULL);
- }
-
- binding.value = null;
- binding.isNull = true;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)
- */
- public void setRef(int i, Ref x) throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * @see java.sql.PreparedStatement#setShort(int, short)
- */
- public void setShort(int parameterIndex, short x) throws SQLException {
- checkClosed();
-
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_SHORT);
-
- binding.value = null;
- binding.shortBinding = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
-
- /**
- * @see java.sql.PreparedStatement#setString(int, java.lang.String)
- */
- public void setString(int parameterIndex, String x) throws SQLException {
- checkClosed();
-
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.CHAR);
- } else {
- BindValue binding = getBinding(parameterIndex, false);
-
- setType(binding, this.stringTypeCode);
-
- binding.value = x;
- binding.isNull = false;
- binding.isLongData = false;
- }
- }
-
- /**
- * Set a parameter to a java.sql.Time value.
- *
- * @param parameterIndex
- * the first parameter is 1...));
- * @param x
- * the parameter value
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public void setTime(int parameterIndex, java.sql.Time x)
- throws SQLException {
- setTimeInternal(parameterIndex, x, null, this.connection.getDefaultTimeZone(), false);
- }
-
- /**
- * Set a parameter to a java.sql.Time value. The driver converts this to a
- * SQL TIME value when it sends it to the database, using the given
- * timezone.
- *
- * @param parameterIndex
- * the first parameter is 1...));
- * @param x
- * the parameter value
- * @param cal
- * the timezone to use
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public void setTime(int parameterIndex, java.sql.Time x, Calendar cal)
- throws SQLException {
- setTimeInternal(parameterIndex, x, cal, cal.getTimeZone(), true);
- }
-
- /**
- * Set a parameter to a java.sql.Time value. The driver converts this to a
- * SQL TIME value when it sends it to the database, using the given
- * timezone.
- *
- * @param parameterIndex
- * the first parameter is 1...));
- * @param x
- * the parameter value
- * @param tz
- * the timezone to use
- *
- * @throws SQLException
- * if a database access error occurs
- */
- public void setTimeInternal(int parameterIndex, java.sql.Time x,
- Calendar targetCalendar,
- TimeZone tz, boolean rollForward) throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.TIME);
- } else {
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_TIME);
-
- if (!this.useLegacyDatetimeCode) {
- binding.value = x;
- } else {
- Calendar sessionCalendar = getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- binding.value = TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- x, tz,
- this.connection.getServerTimezoneTZ(),
- rollForward);
- }
- }
-
- binding.isNull = false;
- binding.isLongData = false;
- }
- }
-
- /**
- * Set a parameter to a java.sql.Timestamp value. The driver converts this
- * to a SQL TIMESTAMP value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- *
- * @throws SQLException
- * if a database-access error occurs.
- */
- public void setTimestamp(int parameterIndex, java.sql.Timestamp x)
- throws SQLException {
- setTimestampInternal(parameterIndex, x, null, this.connection.getDefaultTimeZone(), false);
- }
-
- /**
- * Set a parameter to a java.sql.Timestamp value. The driver converts this
- * to a SQL TIMESTAMP value when it sends it to the database.
- *
- * @param parameterIndex
- * the first parameter is 1, the second is 2, ...
- * @param x
- * the parameter value
- * @param cal
- * the timezone to use
- *
- * @throws SQLException
- * if a database-access error occurs.
- */
- public void setTimestamp(int parameterIndex, java.sql.Timestamp x,
- Calendar cal) throws SQLException {
- setTimestampInternal(parameterIndex, x, cal, cal.getTimeZone(), true);
- }
-
- protected void setTimestampInternal(int parameterIndex,
- java.sql.Timestamp x, Calendar targetCalendar,
- TimeZone tz, boolean rollForward)
- throws SQLException {
- if (x == null) {
- setNull(parameterIndex, java.sql.Types.TIMESTAMP);
- } else {
- BindValue binding = getBinding(parameterIndex, false);
- setType(binding, MysqlDefs.FIELD_TYPE_DATETIME);
-
- if (!this.useLegacyDatetimeCode) {
- binding.value = x;
- } else {
- Calendar sessionCalendar = this.connection.getUseJDBCCompliantTimezoneShift() ?
- this.connection.getUtcCalendar() :
- getCalendarInstanceForSessionOrNew();
-
- synchronized (sessionCalendar) {
- binding.value = TimeUtil.changeTimezone(this.connection,
- sessionCalendar,
- targetCalendar,
- x, tz,
- this.connection.getServerTimezoneTZ(),
- rollForward);
- }
-
- binding.isNull = false;
- binding.isLongData = false;
- }
- }
- }
-
- protected void setType(BindValue oldValue, int bufferType) {
- if (oldValue.bufferType != bufferType) {
- this.sendTypesToServer = true;
- }
-
- oldValue.bufferType = bufferType;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param parameterIndex
- * DOCUMENT ME!
- * @param x
- * DOCUMENT ME!
- * @param length
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- * @throws NotImplemented
- * DOCUMENT ME!
- *
- * @see java.sql.PreparedStatement#setUnicodeStream(int,
- * java.io.InputStream, int)
- * @deprecated
- */
- public void setUnicodeStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- checkClosed();
-
- throw SQLError.notImplemented();
- }
-
- /**
- * @see java.sql.PreparedStatement#setURL(int, java.net.URL)
- */
- public void setURL(int parameterIndex, URL x) throws SQLException {
- checkClosed();
-
- setString(parameterIndex, x.toString());
- }
-
- /**
- * Method storeBinding.
- *
- * @param packet
- * @param bindValue
- * @param mysql
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- private void storeBinding(Buffer packet, BindValue bindValue, MysqlIO mysql)
- throws SQLException {
- try {
- Object value = bindValue.value;
-
- //
- // Handle primitives first
- //
- switch (bindValue.bufferType) {
-
- case MysqlDefs.FIELD_TYPE_TINY:
- packet.writeByte(bindValue.byteBinding);
- return;
- case MysqlDefs.FIELD_TYPE_SHORT:
- packet.ensureCapacity(2);
- packet.writeInt(bindValue.shortBinding);
- return;
- case MysqlDefs.FIELD_TYPE_LONG:
- packet.ensureCapacity(4);
- packet.writeLong(bindValue.intBinding);
- return;
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- packet.ensureCapacity(8);
- packet.writeLongLong(bindValue.longBinding);
- return;
- case MysqlDefs.FIELD_TYPE_FLOAT:
- packet.ensureCapacity(4);
- packet.writeFloat(bindValue.floatBinding);
- return;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- packet.ensureCapacity(8);
- packet.writeDouble(bindValue.doubleBinding);
- return;
- case MysqlDefs.FIELD_TYPE_TIME:
- storeTime(packet, (Time) value);
- return;
- case MysqlDefs.FIELD_TYPE_DATE:
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- storeDateTime(packet, (java.util.Date) value, mysql, bindValue.bufferType);
- return;
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- case MysqlDefs.FIELD_TYPE_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- if (value instanceof byte[]) {
- packet.writeLenBytes((byte[]) value);
- } else if (!this.isLoadDataQuery) {
- packet.writeLenString((String) value, this.charEncoding,
- this.connection.getServerCharacterEncoding(),
- this.charConverter, this.connection
- .parserKnowsUnicode(),
- this.connection);
- } else {
- packet.writeLenBytes(((String) value).getBytes());
- }
-
- return;
- }
-
-
- } catch (UnsupportedEncodingException uEE) {
- throw SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.22") //$NON-NLS-1$
- + this.connection.getEncoding() + "'", //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- }
- }
-
- private void storeDateTime412AndOlder(Buffer intoBuf, java.util.Date dt, int bufferType)
- throws SQLException {
-
- Calendar sessionCalendar = null;
-
- if (!this.useLegacyDatetimeCode) {
- if (bufferType == MysqlDefs.FIELD_TYPE_DATE) {
- sessionCalendar = getDefaultTzCalendar();
- } else {
- sessionCalendar = getServerTzCalendar();
- }
- } else {
- sessionCalendar = (dt instanceof Timestamp &&
- this.connection.getUseJDBCCompliantTimezoneShift()) ?
- this.connection.getUtcCalendar() : getCalendarInstanceForSessionOrNew();
- }
-
- synchronized (sessionCalendar) {
- java.util.Date oldTime = sessionCalendar.getTime();
-
- try {
- intoBuf.ensureCapacity(8);
- intoBuf.writeByte((byte) 7); // length
-
- sessionCalendar.setTime(dt);
-
- int year = sessionCalendar.get(Calendar.YEAR);
- int month = sessionCalendar.get(Calendar.MONTH) + 1;
- int date = sessionCalendar.get(Calendar.DATE);
-
- intoBuf.writeInt(year);
- intoBuf.writeByte((byte) month);
- intoBuf.writeByte((byte) date);
-
- if (dt instanceof java.sql.Date) {
- intoBuf.writeByte((byte) 0);
- intoBuf.writeByte((byte) 0);
- intoBuf.writeByte((byte) 0);
- } else {
- intoBuf.writeByte((byte) sessionCalendar
- .get(Calendar.HOUR_OF_DAY));
- intoBuf.writeByte((byte) sessionCalendar
- .get(Calendar.MINUTE));
- intoBuf.writeByte((byte) sessionCalendar
- .get(Calendar.SECOND));
- }
- } finally {
- sessionCalendar.setTime(oldTime);
- }
- }
- }
-
- private void storeDateTime(Buffer intoBuf, java.util.Date dt, MysqlIO mysql, int bufferType)
- throws SQLException {
- if (this.connection.versionMeetsMinimum(4, 1, 3)) {
- storeDateTime413AndNewer(intoBuf, dt, bufferType);
- } else {
- storeDateTime412AndOlder(intoBuf, dt, bufferType);
- }
- }
-
- private void storeDateTime413AndNewer(Buffer intoBuf, java.util.Date dt, int bufferType)
- throws SQLException {
- Calendar sessionCalendar = null;
-
- if (!this.useLegacyDatetimeCode) {
- if (bufferType == MysqlDefs.FIELD_TYPE_DATE) {
- sessionCalendar = getDefaultTzCalendar();
- } else {
- sessionCalendar = getServerTzCalendar();
- }
- } else {
- sessionCalendar = (dt instanceof Timestamp &&
- this.connection.getUseJDBCCompliantTimezoneShift()) ?
- this.connection.getUtcCalendar() : getCalendarInstanceForSessionOrNew();
- }
-
- synchronized (sessionCalendar) {
- java.util.Date oldTime = sessionCalendar.getTime();
-
- try {
- sessionCalendar.setTime(dt);
-
- if (dt instanceof java.sql.Date) {
- sessionCalendar.set(Calendar.HOUR_OF_DAY, 0);
- sessionCalendar.set(Calendar.MINUTE, 0);
- sessionCalendar.set(Calendar.SECOND, 0);
- }
-
- byte length = (byte) 7;
-
- if (dt instanceof java.sql.Timestamp) {
- length = (byte) 11;
- }
-
- intoBuf.ensureCapacity(length);
-
- intoBuf.writeByte(length); // length
-
- int year = sessionCalendar.get(Calendar.YEAR);
- int month = sessionCalendar.get(Calendar.MONTH) + 1;
- int date = sessionCalendar.get(Calendar.DAY_OF_MONTH);
-
- intoBuf.writeInt(year);
- intoBuf.writeByte((byte) month);
- intoBuf.writeByte((byte) date);
-
- if (dt instanceof java.sql.Date) {
- intoBuf.writeByte((byte) 0);
- intoBuf.writeByte((byte) 0);
- intoBuf.writeByte((byte) 0);
- } else {
- intoBuf.writeByte((byte) sessionCalendar
- .get(Calendar.HOUR_OF_DAY));
- intoBuf.writeByte((byte) sessionCalendar
- .get(Calendar.MINUTE));
- intoBuf.writeByte((byte) sessionCalendar
- .get(Calendar.SECOND));
- }
-
- if (length == 11) {
- // MySQL expects microseconds, not nanos
- intoBuf.writeLong(((java.sql.Timestamp) dt).getNanos() / 1000);
- }
-
- } finally {
- sessionCalendar.setTime(oldTime);
- }
- }
- }
-
- private Calendar getServerTzCalendar() {
- synchronized (this) {
- if (serverTzCalendar == null) {
- serverTzCalendar = new GregorianCalendar(this.connection.getServerTimezoneTZ());
- }
-
- return this.serverTzCalendar;
- }
- }
-
- private Calendar getDefaultTzCalendar() {
- synchronized (this) {
- if (defaultTzCalendar == null) {
- defaultTzCalendar = new GregorianCalendar(TimeZone.getDefault());
- }
-
- return this.defaultTzCalendar;
- }
- }
-
- //
- // TO DO: Investigate using NIO to do this faster
- //
- private void storeReader(MysqlIO mysql, int parameterIndex, Buffer packet,
- Reader inStream) throws SQLException {
- String forcedEncoding = this.connection.getClobCharacterEncoding();
-
- String clobEncoding =
- (forcedEncoding == null ? this.connection.getEncoding() : forcedEncoding);
-
- int maxBytesChar = 2;
-
- if (clobEncoding != null) {
- if (!clobEncoding.equals("UTF-16")) {
- maxBytesChar = this.connection.getMaxBytesPerChar(clobEncoding);
-
- if (maxBytesChar == 1) {
- maxBytesChar = 2; // for safety
- }
- } else {
- maxBytesChar = 4;
- }
- }
-
- char[] buf = new char[BLOB_STREAM_READ_BUF_SIZE / maxBytesChar];
-
- int numRead = 0;
-
- int bytesInPacket = 0;
- int totalBytesRead = 0;
- int bytesReadAtLastSend = 0;
- int packetIsFullAt = this.connection.getBlobSendChunkSize();
-
-
-
- try {
- packet.clear();
- packet.writeByte((byte) MysqlDefs.COM_LONG_DATA);
- packet.writeLong(this.serverStatementId);
- packet.writeInt((parameterIndex));
-
- boolean readAny = false;
-
- while ((numRead = inStream.read(buf)) != -1) {
- readAny = true;
-
- byte[] valueAsBytes = StringUtils.getBytes(buf, null,
- clobEncoding, this.connection
- .getServerCharacterEncoding(), 0, numRead,
- this.connection.parserKnowsUnicode(), getExceptionInterceptor());
-
- packet.writeBytesNoNull(valueAsBytes, 0, valueAsBytes.length);
-
- bytesInPacket += valueAsBytes.length;
- totalBytesRead += valueAsBytes.length;
-
- if (bytesInPacket >= packetIsFullAt) {
- bytesReadAtLastSend = totalBytesRead;
-
- mysql.sendCommand(MysqlDefs.COM_LONG_DATA, null, packet,
- true, null, 0);
-
- bytesInPacket = 0;
- packet.clear();
- packet.writeByte((byte) MysqlDefs.COM_LONG_DATA);
- packet.writeLong(this.serverStatementId);
- packet.writeInt((parameterIndex));
- }
- }
-
- if (totalBytesRead != bytesReadAtLastSend) {
- mysql.sendCommand(MysqlDefs.COM_LONG_DATA, null, packet, true,
- null, 0);
- }
-
- if (!readAny) {
- mysql.sendCommand(MysqlDefs.COM_LONG_DATA, null, packet, true,
- null, 0);
- }
- } catch (IOException ioEx) {
- SQLException sqlEx = SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.24") //$NON-NLS-1$
- + ioEx.toString(), SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(ioEx);
-
- throw sqlEx;
- } finally {
- if (this.connection.getAutoClosePStmtStreams()) {
- if (inStream != null) {
- try {
- inStream.close();
- } catch (IOException ioEx) {
- ; // ignore
- }
- }
- }
- }
- }
-
- private void storeStream(MysqlIO mysql, int parameterIndex, Buffer packet,
- InputStream inStream) throws SQLException {
- byte[] buf = new byte[BLOB_STREAM_READ_BUF_SIZE];
-
- int numRead = 0;
-
- try {
- int bytesInPacket = 0;
- int totalBytesRead = 0;
- int bytesReadAtLastSend = 0;
- int packetIsFullAt = this.connection.getBlobSendChunkSize();
-
- packet.clear();
- packet.writeByte((byte) MysqlDefs.COM_LONG_DATA);
- packet.writeLong(this.serverStatementId);
- packet.writeInt((parameterIndex));
-
- boolean readAny = false;
-
- while ((numRead = inStream.read(buf)) != -1) {
-
- readAny = true;
-
- packet.writeBytesNoNull(buf, 0, numRead);
- bytesInPacket += numRead;
- totalBytesRead += numRead;
-
- if (bytesInPacket >= packetIsFullAt) {
- bytesReadAtLastSend = totalBytesRead;
-
- mysql.sendCommand(MysqlDefs.COM_LONG_DATA, null, packet,
- true, null, 0);
-
- bytesInPacket = 0;
- packet.clear();
- packet.writeByte((byte) MysqlDefs.COM_LONG_DATA);
- packet.writeLong(this.serverStatementId);
- packet.writeInt((parameterIndex));
- }
- }
-
- if (totalBytesRead != bytesReadAtLastSend) {
- mysql.sendCommand(MysqlDefs.COM_LONG_DATA, null, packet, true,
- null, 0);
- }
-
- if (!readAny) {
- mysql.sendCommand(MysqlDefs.COM_LONG_DATA, null, packet, true,
- null, 0);
- }
- } catch (IOException ioEx) {
- SQLException sqlEx = SQLError.createSQLException(Messages
- .getString("ServerPreparedStatement.25") //$NON-NLS-1$
- + ioEx.toString(), SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(ioEx);
-
- throw sqlEx;
- } finally {
- if (this.connection.getAutoClosePStmtStreams()) {
- if (inStream != null) {
- try {
- inStream.close();
- } catch (IOException ioEx) {
- ; // ignore
- }
- }
- }
- }
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer toStringBuf = new StringBuffer();
-
- toStringBuf.append("com.mysql.jdbc.ServerPreparedStatement["); //$NON-NLS-1$
- toStringBuf.append(this.serverStatementId);
- toStringBuf.append("] - "); //$NON-NLS-1$
-
- try {
- toStringBuf.append(asSql());
- } catch (SQLException sqlEx) {
- toStringBuf.append(Messages.getString("ServerPreparedStatement.6")); //$NON-NLS-1$
- toStringBuf.append(sqlEx);
- }
-
- return toStringBuf.toString();
- }
-
- protected long getServerStatementId() {
- return serverStatementId;
- }
-
- private boolean hasCheckedRewrite = false;
- private boolean canRewrite = false;
-
- public synchronized boolean canRewriteAsMultiValueInsertAtSqlLevel() throws SQLException {
- if (!hasCheckedRewrite) {
- this.hasCheckedRewrite = true;
- this.canRewrite = canRewrite(this.originalSql, isOnDuplicateKeyUpdate(), getLocationOfOnDuplicateKeyUpdate(), 0);
- // We need to client-side parse this to get the VALUES clause, etc.
- this.parseInfo = new ParseInfo(this.originalSql, this.connection, this.connection.getMetaData(), this.charEncoding, this.charConverter);
- }
-
- return this.canRewrite;
- }
-
-
- public synchronized boolean canRewriteAsMultivalueInsertStatement() throws SQLException {
- if (!canRewriteAsMultiValueInsertAtSqlLevel()) {
- return false;
- }
-
- BindValue[] currentBindValues = null;
- BindValue[] previousBindValues = null;
-
- int nbrCommands = this.batchedArgs.size();
-
- // Can't have type changes between sets of bindings for this to work...
-
- for (int commandIndex = 0; commandIndex < nbrCommands; commandIndex++) {
- Object arg = this.batchedArgs.get(commandIndex);
-
- if (!(arg instanceof String)) {
-
- currentBindValues = ((BatchedBindValues) arg).batchedParameterValues;
-
- // We need to check types each time, as
- // the user might have bound different
- // types in each addBatch()
-
- if (previousBindValues != null) {
- for (int j = 0; j < this.parameterBindings.length; j++) {
- if (currentBindValues[j].bufferType != previousBindValues[j].bufferType) {
- return false;
- }
- }
- }
- }
- }
-
-
-
- return true;
- }
-
- private int locationOfOnDuplicateKeyUpdate = -2;
-
- protected synchronized int getLocationOfOnDuplicateKeyUpdate() {
- if (this.locationOfOnDuplicateKeyUpdate == -2) {
- this.locationOfOnDuplicateKeyUpdate = getOnDuplicateKeyLocation(this.originalSql);
- }
-
- return this.locationOfOnDuplicateKeyUpdate;
- }
-
- protected synchronized boolean isOnDuplicateKeyUpdate() {
- return getLocationOfOnDuplicateKeyUpdate() != -1;
- }
-
-
-
-
- /**
- * Computes the maximum parameter set size, and entire batch size given
- * the number of arguments in the batch.
- */
- protected long[] computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs) {
- long sizeOfEntireBatch = 1 + /* com_execute */ + 4 /* stmt id */ + 1 /* flags */ + 4 /* batch count padding */;
- long maxSizeOfParameterSet = 0;
-
- for (int i = 0; i < numBatchedArgs; i++) {
- BindValue[] paramArg = ((BatchedBindValues) this.batchedArgs.get(i)).batchedParameterValues;
-
- long sizeOfParameterSet = 0;
-
- sizeOfParameterSet += (this.parameterCount + 7) / 8; // for isNull
-
- sizeOfParameterSet += this.parameterCount * 2; // have to send types
-
- for (int j = 0; j < this.parameterBindings.length; j++) {
- if (!paramArg[j].isNull) {
-
- long size = paramArg[j].getBoundLength();
-
- if (paramArg[j].isLongData) {
- if (size != -1) {
- sizeOfParameterSet += size;
- }
- } else {
- sizeOfParameterSet += size;
- }
- }
- }
-
- sizeOfEntireBatch += sizeOfParameterSet;
-
- if (sizeOfParameterSet > maxSizeOfParameterSet) {
- maxSizeOfParameterSet = sizeOfParameterSet;
- }
- }
-
- return new long[] {maxSizeOfParameterSet, sizeOfEntireBatch};
- }
-
- protected int setOneBatchedParameterSet(
- java.sql.PreparedStatement batchedStatement, int batchedParamIndex,
- Object paramSet) throws SQLException {
- BindValue[] paramArg = ((BatchedBindValues) paramSet).batchedParameterValues;
-
- for (int j = 0; j < paramArg.length; j++) {
- if (paramArg[j].isNull) {
- batchedStatement.setNull(batchedParamIndex++, Types.NULL);
- } else {
- if (paramArg[j].isLongData) {
- Object value = paramArg[j].value;
-
- if (value instanceof InputStream) {
- batchedStatement.setBinaryStream(batchedParamIndex++,
- (InputStream) value,
- (int) paramArg[j].bindLength);
- } else {
- batchedStatement.setCharacterStream(
- batchedParamIndex++, (Reader) value,
- (int) paramArg[j].bindLength);
- }
- } else {
-
- switch (paramArg[j].bufferType) {
-
- case MysqlDefs.FIELD_TYPE_TINY:
- batchedStatement.setByte(batchedParamIndex++,
- paramArg[j].byteBinding);
- break;
- case MysqlDefs.FIELD_TYPE_SHORT:
- batchedStatement.setShort(batchedParamIndex++,
- paramArg[j].shortBinding);
- break;
- case MysqlDefs.FIELD_TYPE_LONG:
- batchedStatement.setInt(batchedParamIndex++,
- paramArg[j].intBinding);
- break;
- case MysqlDefs.FIELD_TYPE_LONGLONG:
- batchedStatement.setLong(batchedParamIndex++,
- paramArg[j].longBinding);
- break;
- case MysqlDefs.FIELD_TYPE_FLOAT:
- batchedStatement.setFloat(batchedParamIndex++,
- paramArg[j].floatBinding);
- break;
- case MysqlDefs.FIELD_TYPE_DOUBLE:
- batchedStatement.setDouble(batchedParamIndex++,
- paramArg[j].doubleBinding);
- break;
- case MysqlDefs.FIELD_TYPE_TIME:
- batchedStatement.setTime(batchedParamIndex++,
- (Time) paramArg[j].value);
- break;
- case MysqlDefs.FIELD_TYPE_DATE:
- batchedStatement.setDate(batchedParamIndex++,
- (Date) paramArg[j].value);
- break;
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
- batchedStatement.setTimestamp(batchedParamIndex++,
- (Timestamp) paramArg[j].value);
- break;
- case MysqlDefs.FIELD_TYPE_VAR_STRING:
- case MysqlDefs.FIELD_TYPE_STRING:
- case MysqlDefs.FIELD_TYPE_VARCHAR:
- case MysqlDefs.FIELD_TYPE_DECIMAL:
- case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
- Object value = paramArg[j].value;
-
- if (value instanceof byte[]) {
- batchedStatement.setBytes(batchedParamIndex,
- (byte[]) value);
- } else {
- batchedStatement.setString(batchedParamIndex,
- (String) value);
- }
-
- // If we ended up here as a multi-statement, we're not working with a server prepared statement
-
- if (batchedStatement instanceof ServerPreparedStatement) {
- BindValue asBound = ((ServerPreparedStatement) batchedStatement)
- .getBinding(
- batchedParamIndex,
- false);
- asBound.bufferType = paramArg[j].bufferType;
- }
-
- batchedParamIndex++;
-
- break;
- default:
- throw new IllegalArgumentException(
- "Unknown type when re-binding parameter into batched statement for parameter index "
- + batchedParamIndex);
- }
- }
- }
- }
-
- return batchedParamIndex;
- }
-
- protected boolean containsOnDuplicateKeyUpdateInSQL() {
- return this.hasOnDuplicateKeyUpdate;
- }
-
- protected PreparedStatement prepareBatchedInsertSQL(ConnectionImpl localConn, int numBatches) throws SQLException {
- try {
- PreparedStatement pstmt = new ServerPreparedStatement(localConn, this.parseInfo.getSqlForBatch(numBatches), this.currentCatalog, this.resultSetConcurrency, this.resultSetType);
- pstmt.setRetrieveGeneratedKeys(this.retrieveGeneratedKeys);
-
- return pstmt;
- } catch (UnsupportedEncodingException e) {
- SQLException sqlEx = SQLError.createSQLException("Unable to prepare batch statement", SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
- sqlEx.initCause(e);
-
- throw sqlEx;
- }
-
- }
-}
diff --git a/src/com/mysql/jdbc/SingleByteCharsetConverter.java b/src/com/mysql/jdbc/SingleByteCharsetConverter.java
deleted file mode 100644
index 3e7ea87e3..000000000
--- a/src/com/mysql/jdbc/SingleByteCharsetConverter.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.UnsupportedEncodingException;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Converter for char[]->byte[] and byte[]->char[] for single-byte character
- * sets.
- *
- * Much faster (5-6x) than the built-in solution that ships with the JVM, even
- * with JDK-1.4.x and NewIo.
- *
- * @author Mark Matthews
- */
-public class SingleByteCharsetConverter {
-
- private static final int BYTE_RANGE = (1 + Byte.MAX_VALUE) - Byte.MIN_VALUE;
- private static byte[] allBytes = new byte[BYTE_RANGE];
- private static final Map CONVERTER_MAP = new HashMap();
-
- private final static byte[] EMPTY_BYTE_ARRAY = new byte[0];
-
- // The initial charToByteMap, with all char mappings mapped
- // to (byte) '?', so that unknown characters are mapped to '?'
- // instead of '\0' (which means end-of-string to MySQL).
- private static byte[] unknownCharsMap = new byte[65536];
-
- static {
- for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
- allBytes[i - Byte.MIN_VALUE] = (byte) i;
- }
-
- for (int i = 0; i < unknownCharsMap.length; i++) {
- unknownCharsMap[i] = (byte) '?'; // use something 'sane' for
- // unknown chars
- }
- }
-
- // ~ Instance fields
- // --------------------------------------------------------
-
- /**
- * Get a converter for the given encoding name
- *
- * @param encodingName
- * the Java character encoding name
- *
- * @return a converter for the given encoding name
- * @throws UnsupportedEncodingException
- * if the character encoding is not supported
- */
- public static synchronized SingleByteCharsetConverter getInstance(
- String encodingName, Connection conn)
- throws UnsupportedEncodingException, SQLException {
- SingleByteCharsetConverter instance = (SingleByteCharsetConverter) CONVERTER_MAP
- .get(encodingName);
-
- if (instance == null) {
- instance = initCharset(encodingName);
- }
-
- return instance;
- }
-
- /**
- * Initialize the shared instance of a converter for the given character
- * encoding.
- *
- * @param javaEncodingName
- * the Java name for the character set to initialize
- * @return a converter for the given character set
- * @throws UnsupportedEncodingException
- * if the character encoding is not supported
- */
- public static SingleByteCharsetConverter initCharset(String javaEncodingName)
- throws UnsupportedEncodingException, SQLException {
- if (CharsetMapping.isMultibyteCharset(javaEncodingName)) {
- return null;
- }
-
- SingleByteCharsetConverter converter = new SingleByteCharsetConverter(
- javaEncodingName);
-
- CONVERTER_MAP.put(javaEncodingName, converter);
-
- return converter;
- }
-
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Convert the byte buffer from startPos to a length of length to a string
- * using the default platform encoding.
- *
- * @param buffer
- * the bytes to convert
- * @param startPos
- * the index to start at
- * @param length
- * the number of bytes to convert
- * @return the String representation of the given bytes
- */
- public static String toStringDefaultEncoding(byte[] buffer, int startPos,
- int length) {
- return new String(buffer, startPos, length);
- }
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- private char[] byteToChars = new char[BYTE_RANGE];
-
- private byte[] charToByteMap = new byte[65536];
-
- /**
- * Prevent instantiation, called out of static method initCharset().
- *
- * @param encodingName
- * a JVM character encoding
- * @throws UnsupportedEncodingException
- * if the JVM does not support the encoding
- */
- private SingleByteCharsetConverter(String encodingName)
- throws UnsupportedEncodingException {
- String allBytesString = new String(allBytes, 0, BYTE_RANGE,
- encodingName);
- int allBytesLen = allBytesString.length();
-
- System.arraycopy(unknownCharsMap, 0, this.charToByteMap, 0,
- this.charToByteMap.length);
-
- for (int i = 0; i < BYTE_RANGE && i < allBytesLen; i++) {
- char c = allBytesString.charAt(i);
- this.byteToChars[i] = c;
- this.charToByteMap[c] = allBytes[i];
- }
- }
-
- public final byte[] toBytes(char[] c) {
- if (c == null) {
- return null;
- }
-
- int length = c.length;
- byte[] bytes = new byte[length];
-
- for (int i = 0; i < length; i++) {
- bytes[i] = this.charToByteMap[c[i]];
- }
-
- return bytes;
- }
-
- public final byte[] toBytesWrapped(char[] c, char beginWrap, char endWrap) {
- if (c == null) {
- return null;
- }
-
- int length = c.length + 2;
- int charLength = c.length;
-
- byte[] bytes = new byte[length];
- bytes[0] = this.charToByteMap[beginWrap];
-
- for (int i = 0; i < charLength; i++) {
- bytes[i + 1] = this.charToByteMap[c[i]];
- }
-
- bytes[length - 1] = this.charToByteMap[endWrap];
-
- return bytes;
- }
-
- public final byte[] toBytes(char[] chars, int offset, int length) {
- if (chars == null) {
- return null;
- }
-
- if (length == 0) {
- return EMPTY_BYTE_ARRAY;
- }
-
- byte[] bytes = new byte[length];
-
- for (int i = 0; (i < length); i++) {
- bytes[i] = this.charToByteMap[chars[i + offset]];
- }
-
- return bytes;
- }
-
- /**
- * Convert the given string to an array of bytes.
- *
- * @param s
- * the String to convert
- * @return the bytes that make up the String
- */
- public final byte[] toBytes(String s) {
- if (s == null) {
- return null;
- }
-
- int length = s.length();
- byte[] bytes = new byte[length];
-
- for (int i = 0; i < length; i++) {
- bytes[i] = this.charToByteMap[s.charAt(i)];
- }
-
- return bytes;
- }
-
- public final byte[] toBytesWrapped(String s, char beginWrap, char endWrap) {
- if (s == null) {
- return null;
- }
-
- int stringLength = s.length();
-
- int length = stringLength + 2;
-
- byte[] bytes = new byte[length];
-
- bytes[0] = this.charToByteMap[beginWrap];
-
- for (int i = 0; i < stringLength; i++) {
- bytes[i + 1] = this.charToByteMap[s.charAt(i)];
- }
-
- bytes[length - 1] = this.charToByteMap[endWrap];
-
- return bytes;
- }
-
- /**
- * Convert the given string to an array of bytes.
- *
- * @param s
- * the String to convert
- * @param offset
- * the offset to start at
- * @param length
- * length (max) to convert
- *
- * @return the bytes that make up the String
- */
- public final byte[] toBytes(String s, int offset, int length) {
- if (s == null) {
- return null;
- }
-
- if (length == 0) {
- return EMPTY_BYTE_ARRAY;
- }
-
- byte[] bytes = new byte[length];
-
- for (int i = 0; (i < length); i++) {
- char c = s.charAt(i + offset);
- bytes[i] = this.charToByteMap[c];
- }
-
- return bytes;
- }
-
- /**
- * Convert the byte buffer to a string using this instance's character
- * encoding.
- *
- * @param buffer
- * the bytes to convert to a String
- * @return the converted String
- */
- public final String toString(byte[] buffer) {
- return toString(buffer, 0, buffer.length);
- }
-
- /**
- * Convert the byte buffer from startPos to a length of length to a string
- * using this instance's character encoding.
- *
- * @param buffer
- * the bytes to convert
- * @param startPos
- * the index to start at
- * @param length
- * the number of bytes to convert
- * @return the String representation of the given bytes
- */
- public final String toString(byte[] buffer, int startPos, int length) {
- char[] charArray = new char[length];
- int readpoint = startPos;
-
- for (int i = 0; i < length; i++) {
- charArray[i] = this.byteToChars[buffer[readpoint] - Byte.MIN_VALUE];
- readpoint++;
- }
-
- return new String(charArray);
- }
-}
diff --git a/src/com/mysql/jdbc/SocketFactory.java b/src/com/mysql/jdbc/SocketFactory.java
deleted file mode 100644
index 6bb401063..000000000
--- a/src/com/mysql/jdbc/SocketFactory.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.Properties;
-
-/**
- * Interface to allow pluggable socket creation in the driver
- *
- * @author Mark Matthews
- */
-public interface SocketFactory {
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * Called by the driver after issuing the MySQL protocol handshake and
- * reading the results of the handshake.
- *
- * @throws SocketException
- * if a socket error occurs
- * @throws IOException
- * if an I/O error occurs
- *
- * @return the socket to use after the handshake
- */
- Socket afterHandshake() throws SocketException, IOException;
-
- /**
- * Called by the driver before issuing the MySQL protocol handshake. Should
- * return the socket instance that should be used during the handshake.
- *
- * @throws SocketException
- * if a socket error occurs
- * @throws IOException
- * if an I/O error occurs
- *
- * @return the socket to use before the handshake
- */
- Socket beforeHandshake() throws SocketException, IOException;
-
- /**
- * Creates a new socket using the given properties. Properties are parsed by
- * the driver from the URL. All properties other than sensitive ones (user
- * and password) are passed to this method. The driver will instantiate the
- * socket factory with the class name given in the property
- * "socketFactory", where the standard is
- * com.mysql.jdbc.StandardSocketFactory Implementing classes
- * are responsible for handling synchronization of this method (if needed).
- *
- * @param host
- * the hostname passed in the JDBC URL. It will be a single
- * hostname, as the driver parses multi-hosts (for failover) and
- * calls this method for each host connection attempt.
- *
- * @param portNumber
- * the port number to connect to (if required).
- *
- * @param props
- * properties passed to the driver via the URL and/or properties
- * instance.
- *
- * @return a socket connected to the given host
- * @throws SocketException
- * if a socket error occurs
- * @throws IOException
- * if an I/O error occurs
- */
- Socket connect(String host, int portNumber, Properties props)
- throws SocketException, IOException;
-}
diff --git a/src/com/mysql/jdbc/StandardSocketFactory.java b/src/com/mysql/jdbc/StandardSocketFactory.java
deleted file mode 100644
index f37954e05..000000000
--- a/src/com/mysql/jdbc/StandardSocketFactory.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.Properties;
-
-/**
- * Socket factory for vanilla TCP/IP sockets (the standard)
- *
- * @author Mark Matthews
- */
-public class StandardSocketFactory implements SocketFactory {
-
- public static final String TCP_NO_DELAY_PROPERTY_NAME = "tcpNoDelay";
-
- public static final String TCP_KEEP_ALIVE_DEFAULT_VALUE = "true";
-
- public static final String TCP_KEEP_ALIVE_PROPERTY_NAME = "tcpKeepAlive";
-
- public static final String TCP_RCV_BUF_PROPERTY_NAME = "tcpRcvBuf";
-
- public static final String TCP_SND_BUF_PROPERTY_NAME = "tcpSndBuf";
-
- public static final String TCP_TRAFFIC_CLASS_PROPERTY_NAME = "tcpTrafficClass";
-
- public static final String TCP_RCV_BUF_DEFAULT_VALUE = "0";
-
- public static final String TCP_SND_BUF_DEFAULT_VALUE = "0";
-
- public static final String TCP_TRAFFIC_CLASS_DEFAULT_VALUE = "0";
-
- public static final String TCP_NO_DELAY_DEFAULT_VALUE = "true";
-
- /** Use reflection for pre-1.4 VMs */
-
- private static Method setTraficClassMethod;
-
- static {
- try {
- setTraficClassMethod = Socket.class.getMethod("setTrafficClass",
- new Class[] { Integer.TYPE });
- } catch (SecurityException e) {
- setTraficClassMethod = null;
- } catch (NoSuchMethodException e) {
- setTraficClassMethod = null;
- }
- }
-
- /** The hostname to connect to */
- protected String host = null;
-
- /** The port number to connect to */
- protected int port = 3306;
-
- /** The underlying TCP/IP socket to use */
- protected Socket rawSocket = null;
-
- /**
- * Called by the driver after issuing the MySQL protocol handshake and
- * reading the results of the handshake.
- *
- * @throws SocketException
- * if a socket error occurs
- * @throws IOException
- * if an I/O error occurs
- *
- * @return The socket to use after the handshake
- */
- public Socket afterHandshake() throws SocketException, IOException {
- return this.rawSocket;
- }
-
- /**
- * Called by the driver before issuing the MySQL protocol handshake. Should
- * return the socket instance that should be used during the handshake.
- *
- * @throws SocketException
- * if a socket error occurs
- * @throws IOException
- * if an I/O error occurs
- *
- * @return the socket to use before the handshake
- */
- public Socket beforeHandshake() throws SocketException, IOException {
- return this.rawSocket;
- }
-
- /**
- * Configures socket properties based on properties from the connection
- * (tcpNoDelay, snd/rcv buf, traffic class, etc).
- *
- * @param props
- * @throws SocketException
- * @throws IOException
- */
- private void configureSocket(Socket sock, Properties props) throws SocketException,
- IOException {
- try {
- sock.setTcpNoDelay(Boolean.valueOf(
- props.getProperty(TCP_NO_DELAY_PROPERTY_NAME,
- TCP_NO_DELAY_DEFAULT_VALUE)).booleanValue());
-
- String keepAlive = props.getProperty(TCP_KEEP_ALIVE_PROPERTY_NAME,
- TCP_KEEP_ALIVE_DEFAULT_VALUE);
-
- if (keepAlive != null && keepAlive.length() > 0) {
- sock.setKeepAlive(Boolean.valueOf(keepAlive)
- .booleanValue());
- }
-
- int receiveBufferSize = Integer.parseInt(props.getProperty(
- TCP_RCV_BUF_PROPERTY_NAME, TCP_RCV_BUF_DEFAULT_VALUE));
-
- if (receiveBufferSize > 0) {
- sock.setReceiveBufferSize(receiveBufferSize);
- }
-
- int sendBufferSize = Integer.parseInt(props.getProperty(
- TCP_SND_BUF_PROPERTY_NAME, TCP_SND_BUF_DEFAULT_VALUE));
-
- if (sendBufferSize > 0) {
- sock.setSendBufferSize(sendBufferSize);
- }
-
- int trafficClass = Integer.parseInt(props.getProperty(
- TCP_TRAFFIC_CLASS_PROPERTY_NAME,
- TCP_TRAFFIC_CLASS_DEFAULT_VALUE));
-
- if (trafficClass > 0 && setTraficClassMethod != null) {
- setTraficClassMethod.invoke(sock,
- new Object[] { new Integer(trafficClass) });
- }
- } catch (Throwable t) {
- unwrapExceptionToProperClassAndThrowIt(t);
- }
- }
-
- /**
- * @see com.mysql.jdbc.SocketFactory#createSocket(Properties)
- */
- public Socket connect(String hostname, int portNumber, Properties props)
- throws SocketException, IOException {
-
- if (props != null) {
- this.host = hostname;
-
- this.port = portNumber;
-
- Method connectWithTimeoutMethod = null;
- Method socketBindMethod = null;
- Class socketAddressClass = null;
-
- String localSocketHostname = props
- .getProperty("localSocketAddress");
-
- String connectTimeoutStr = props.getProperty("connectTimeout");
-
- int connectTimeout = 0;
-
- boolean wantsTimeout = (connectTimeoutStr != null
- && connectTimeoutStr.length() > 0 && !connectTimeoutStr
- .equals("0"));
-
- boolean wantsLocalBind = (localSocketHostname != null && localSocketHostname
- .length() > 0);
-
- boolean needsConfigurationBeforeConnect = socketNeedsConfigurationBeforeConnect(props);
-
- if (wantsTimeout || wantsLocalBind || needsConfigurationBeforeConnect) {
-
- if (connectTimeoutStr != null) {
- try {
- connectTimeout = Integer.parseInt(connectTimeoutStr);
- } catch (NumberFormatException nfe) {
- throw new SocketException("Illegal value '"
- + connectTimeoutStr + "' for connectTimeout");
- }
- }
-
- try {
- // Have to do this with reflection, otherwise older JVMs
- // croak
- socketAddressClass = Class
- .forName("java.net.SocketAddress");
-
- connectWithTimeoutMethod = Socket.class.getMethod(
- "connect", new Class[] { socketAddressClass,
- Integer.TYPE });
-
- socketBindMethod = Socket.class.getMethod("bind",
- new Class[] { socketAddressClass });
-
- } catch (NoClassDefFoundError noClassDefFound) {
- // ignore, we give a better error below if needed
- } catch (NoSuchMethodException noSuchMethodEx) {
- // ignore, we give a better error below if needed
- } catch (Throwable catchAll) {
- // ignore, we give a better error below if needed
- }
-
- if (wantsLocalBind && socketBindMethod == null) {
- throw new SocketException(
- "Can't specify \"localSocketAddress\" on JVMs older than 1.4");
- }
-
- if (wantsTimeout && connectWithTimeoutMethod == null) {
- throw new SocketException(
- "Can't specify \"connectTimeout\" on JVMs older than 1.4");
- }
- }
-
- if (this.host != null) {
- if (!(wantsLocalBind || wantsTimeout || needsConfigurationBeforeConnect)) {
- InetAddress[] possibleAddresses = InetAddress
- .getAllByName(this.host);
-
- Throwable caughtWhileConnecting = null;
-
- // Need to loop through all possible addresses, in case
- // someone has IPV6 configured (SuSE, for example...)
-
- for (int i = 0; i < possibleAddresses.length; i++) {
- try {
- this.rawSocket = new Socket(possibleAddresses[i],
- port);
-
- configureSocket(this.rawSocket, props);
-
- break;
- } catch (Exception ex) {
- caughtWhileConnecting = ex;
- }
- }
-
- if (rawSocket == null) {
- unwrapExceptionToProperClassAndThrowIt(caughtWhileConnecting);
- }
- } else {
- // must explicitly state this due to classloader issues
- // when running on older JVMs :(
- try {
-
- InetAddress[] possibleAddresses = InetAddress
- .getAllByName(this.host);
-
- Throwable caughtWhileConnecting = null;
-
- Object localSockAddr = null;
-
- Class inetSocketAddressClass = null;
-
- Constructor addrConstructor = null;
-
- try {
- inetSocketAddressClass = Class
- .forName("java.net.InetSocketAddress");
-
- addrConstructor = inetSocketAddressClass
- .getConstructor(new Class[] {
- InetAddress.class, Integer.TYPE });
-
- if (wantsLocalBind) {
- localSockAddr = addrConstructor
- .newInstance(new Object[] {
- InetAddress
- .getByName(localSocketHostname),
- new Integer(0 /*
- * use ephemeral
- * port
- */) });
-
- }
- } catch (Throwable ex) {
- unwrapExceptionToProperClassAndThrowIt(ex);
- }
-
- // Need to loop through all possible addresses, in case
- // someone has IPV6 configured (SuSE, for example...)
-
- for (int i = 0; i < possibleAddresses.length; i++) {
-
- try {
- this.rawSocket = new Socket();
-
- configureSocket(this.rawSocket, props);
-
- Object sockAddr = addrConstructor
- .newInstance(new Object[] {
- possibleAddresses[i],
- new Integer(port) });
- // bind to the local port, null is 'ok', it
- // means
- // use the ephemeral port
- socketBindMethod.invoke(rawSocket,
- new Object[] { localSockAddr });
-
- connectWithTimeoutMethod.invoke(rawSocket,
- new Object[] { sockAddr,
- new Integer(connectTimeout) });
-
- break;
- } catch (Exception ex) {
- this.rawSocket = null;
-
- caughtWhileConnecting = ex;
- }
- }
-
- if (this.rawSocket == null) {
- unwrapExceptionToProperClassAndThrowIt(caughtWhileConnecting);
- }
-
- } catch (Throwable t) {
- unwrapExceptionToProperClassAndThrowIt(t);
- }
- }
-
- return this.rawSocket;
- }
- }
-
- throw new SocketException("Unable to create socket");
- }
-
- /**
- * Does the configureSocket() need to be called before the socket is
- * connect()d based on the properties supplied?
- *
- */
- private boolean socketNeedsConfigurationBeforeConnect(Properties props) {
- int receiveBufferSize = Integer.parseInt(props.getProperty(
- TCP_RCV_BUF_PROPERTY_NAME, TCP_RCV_BUF_DEFAULT_VALUE));
-
- if (receiveBufferSize > 0) {
- return true;
- }
-
- int sendBufferSize = Integer.parseInt(props.getProperty(
- TCP_SND_BUF_PROPERTY_NAME, TCP_SND_BUF_DEFAULT_VALUE));
-
- if (sendBufferSize > 0) {
- return true;
- }
-
- int trafficClass = Integer.parseInt(props.getProperty(
- TCP_TRAFFIC_CLASS_PROPERTY_NAME,
- TCP_TRAFFIC_CLASS_DEFAULT_VALUE));
-
- if (trafficClass > 0 && setTraficClassMethod != null) {
- return true;
- }
-
- return false;
- }
-
- private void unwrapExceptionToProperClassAndThrowIt(
- Throwable caughtWhileConnecting) throws SocketException,
- IOException {
- if (caughtWhileConnecting instanceof InvocationTargetException) {
-
- // Replace it with the target, don't use 1.4 chaining as this still
- // needs to run on older VMs
- caughtWhileConnecting = ((InvocationTargetException) caughtWhileConnecting)
- .getTargetException();
- }
-
- if (caughtWhileConnecting instanceof SocketException) {
- throw (SocketException) caughtWhileConnecting;
- }
-
- if (caughtWhileConnecting instanceof IOException) {
- throw (IOException) caughtWhileConnecting;
- }
-
- throw new SocketException(caughtWhileConnecting.toString());
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/Statement.java b/src/com/mysql/jdbc/Statement.java
deleted file mode 100644
index 5590995eb..000000000
--- a/src/com/mysql/jdbc/Statement.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008-2009 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * This interface contains methods that are considered the "vendor extension"
- * to the JDBC API for MySQL's implementation of java.sql.Statement.
- *
- * For those looking further into the driver implementation, it is not
- * an API that is used for plugability of implementations inside our driver
- * (which is why there are still references to StatementImpl throughout the
- * code).
- *
- * @version $Id: $
- *
- */
-public interface Statement extends java.sql.Statement {
-
- /**
- * Workaround for containers that 'check' for sane values of
- * Statement.setFetchSize() so that applications can use
- * the Java variant of libmysql's mysql_use_result() behavior.
- *
- * @throws SQLException
- */
- public abstract void enableStreamingResults() throws SQLException;
-
- /**
- * Resets this statements fetch size and result set type to the values
- * they had before enableStreamingResults() was called.
- *
- * @throws SQLException
- */
- public abstract void disableStreamingResults() throws SQLException;
-
- /**
- * Sets an InputStream instance that will be used to send data
- * to the MySQL server for a "LOAD DATA LOCAL INFILE" statement
- * rather than a FileInputStream or URLInputStream that represents
- * the path given as an argument to the statement.
- *
- * This stream will be read to completion upon execution of a
- * "LOAD DATA LOCAL INFILE" statement, and will automatically
- * be closed by the driver, so it needs to be reset
- * before each call to execute*() that would cause the MySQL
- * server to request data to fulfill the request for
- * "LOAD DATA LOCAL INFILE".
- *
- * If this value is set to NULL, the driver will revert to using
- * a FileInputStream or URLInputStream as required.
- */
- public abstract void setLocalInfileInputStream(InputStream stream);
-
- /**
- * Returns the InputStream instance that will be used to send
- * data in response to a "LOAD DATA LOCAL INFILE" statement.
- *
- * This method returns NULL if no such stream has been set
- * via setLocalInfileInputStream().
- */
- public abstract InputStream getLocalInfileInputStream();
-
- public void setPingTarget(PingTarget pingTarget);
-
- public ExceptionInterceptor getExceptionInterceptor();
-
- /**
- * Callback for result set instances to remove them from the Set that
- * tracks them per-statement
- */
-
- public abstract void removeOpenResultSet(ResultSet rs);
-
- /**
- * Returns the number of open result sets for this statement.
- * @return
- */
- public abstract int getOpenResultSetCount();
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/StatementImpl.java b/src/com/mysql/jdbc/StatementImpl.java
deleted file mode 100644
index 21aa12da2..000000000
--- a/src/com/mysql/jdbc/StatementImpl.java
+++ /dev/null
@@ -1,2760 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008-2009 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.sql.BatchUpdateException;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TimerTask;
-
-import com.mysql.jdbc.exceptions.DeadlockTimeoutRollbackMarker;
-import com.mysql.jdbc.exceptions.MySQLStatementCancelledException;
-import com.mysql.jdbc.exceptions.MySQLTimeoutException;
-import com.mysql.jdbc.profiler.ProfilerEvent;
-import com.mysql.jdbc.profiler.ProfilerEventHandler;
-import com.mysql.jdbc.profiler.ProfilerEventHandlerFactory;
-
-/**
- * A Statement object is used for executing a static SQL statement and obtaining
- * the results produced by it.
- *
- *
- * Only one ResultSet per Statement can be open at any point in time. Therefore,
- * if the reading of one ResultSet is interleaved with the reading of another,
- * each must have been generated by different Statements. All statement execute
- * methods implicitly close a statement's current ResultSet if an open one
- * exists.
- *
- *
- * @author Mark Matthews
- * @version $Id: Statement.java 4624 2005-11-28 14:24:29 -0600 (Mon, 28 Nov
- * 2005) mmatthews $
- *
- * @see java.sql.Statement
- * @see ResultSetInternalMethods
- */
-public class StatementImpl implements Statement {
- protected static final String PING_MARKER = "/* ping */";
- /**
- * Thread used to implement query timeouts...Eventually we could be more
- * efficient and have one thread with timers, but this is a straightforward
- * and simple way to implement a feature that isn't used all that often.
- */
- class CancelTask extends TimerTask {
-
- long connectionId = 0;
- SQLException caughtWhileCancelling = null;
- StatementImpl toCancel;
-
- CancelTask(StatementImpl cancellee) throws SQLException {
- connectionId = connection.getIO().getThreadId();
- toCancel = cancellee;
- }
-
- public void run() {
-
- Thread cancelThread = new Thread() {
-
- public void run() {
- if (connection.getQueryTimeoutKillsConnection()) {
- try {
- toCancel.wasCancelled = true;
- toCancel.wasCancelledByTimeout = true;
- connection.realClose(false, false, true,
- new MySQLStatementCancelledException(Messages.getString("Statement.ConnectionKilledDueToTimeout")));
- } catch (NullPointerException npe) {
- // not worth guarding against
- } catch (SQLException sqlEx) {
- caughtWhileCancelling = sqlEx;
- }
- } else {
- Connection cancelConn = null;
- java.sql.Statement cancelStmt = null;
-
- try {
- synchronized (cancelTimeoutMutex) {
- cancelConn = connection.duplicate();
- cancelStmt = cancelConn.createStatement();
- cancelStmt.execute("KILL QUERY " + connectionId);
- toCancel.wasCancelled = true;
- toCancel.wasCancelledByTimeout = true;
- }
- } catch (SQLException sqlEx) {
- caughtWhileCancelling = sqlEx;
- } catch (NullPointerException npe) {
- // Case when connection closed while starting to cancel
- // We can't easily synchronize this, because then one thread
- // can't cancel() a running query
-
- // ignore, we shouldn't re-throw this, because the connection's
- // already closed, so the statement has been timed out.
- } finally {
- if (cancelStmt != null) {
- try {
- cancelStmt.close();
- } catch (SQLException sqlEx) {
- throw new RuntimeException(sqlEx.toString());
- }
- }
-
- if (cancelConn != null) {
- try {
- cancelConn.close();
- } catch (SQLException sqlEx) {
- throw new RuntimeException(sqlEx.toString());
- }
- }
- }
- }
- }
- };
-
- cancelThread.start();
- }
- }
-
- /** Mutex to prevent race between returning query results and noticing
- that we're timed-out or cancelled. */
-
- protected Object cancelTimeoutMutex = new Object();
-
- /** Used to generate IDs when profiling. */
- protected static int statementCounter = 1;
-
- public final static byte USES_VARIABLES_FALSE = 0;
-
- public final static byte USES_VARIABLES_TRUE = 1;
-
- public final static byte USES_VARIABLES_UNKNOWN = -1;
-
- protected boolean wasCancelled = false;
- protected boolean wasCancelledByTimeout = false;
-
- /** Holds batched commands */
- protected List batchedArgs;
-
- /** The character converter to use (if available) */
- protected SingleByteCharsetConverter charConverter = null;
-
- /** The character encoding to use (if available) */
- protected String charEncoding = null;
-
- /** The connection that created us */
- protected ConnectionImpl connection = null;
-
- protected long connectionId = 0;
-
- /** The catalog in use */
- protected String currentCatalog = null;
-
- /** Should we process escape codes? */
- protected boolean doEscapeProcessing = true;
-
- /** If we're profiling, where should events go to? */
- protected ProfilerEventHandler eventSink = null;
-
- /** The number of rows to fetch at a time (currently ignored) */
- private int fetchSize = 0;
-
- /** Has this statement been closed? */
- protected boolean isClosed = false;
-
- /** The auto_increment value for the last insert */
- protected long lastInsertId = -1;
-
- /** The max field size for this statement */
- protected int maxFieldSize = MysqlIO.getMaxBuf();
-
- /**
- * The maximum number of rows to return for this statement (-1 means _all_
- * rows)
- */
- protected int maxRows = -1;
-
- /** Has someone changed this for this statement? */
- protected boolean maxRowsChanged = false;
-
- /** Set of currently-open ResultSets */
- protected Set openResults = new HashSet();
-
- /** Are we in pedantic mode? */
- protected boolean pedantic = false;
-
- /**
- * Where this statement was created, only used if profileSql or
- * useUsageAdvisor set to true.
- */
- protected Throwable pointOfOrigin;
-
- /** Should we profile? */
- protected boolean profileSQL = false;
-
- /** The current results */
- protected ResultSetInternalMethods results = null;
-
- /** The concurrency for this result set (updatable or not) */
- protected int resultSetConcurrency = 0;
-
- /** The type of this result set (scroll sensitive or in-sensitive) */
- protected int resultSetType = 0;
-
- /** Used to identify this statement when profiling. */
- protected int statementId;
-
- /** The timeout for a query */
- protected int timeoutInMillis = 0;
-
- /** The update count for this statement */
- protected long updateCount = -1;
-
- /** Should we use the usage advisor? */
- protected boolean useUsageAdvisor = false;
-
- /** The warnings chain. */
- protected SQLWarning warningChain = null;
-
- /**
- * Should this statement hold results open over .close() irregardless of
- * connection's setting?
- */
- protected boolean holdResultsOpenOverClose = false;
-
- protected ArrayList batchedGeneratedKeys = null;
-
- protected boolean retrieveGeneratedKeys = false;
-
- protected boolean continueBatchOnError = false;
-
- protected PingTarget pingTarget = null;
-
- protected boolean useLegacyDatetimeCode;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- /** Whether or not the last query was of the form ON DUPLICATE KEY UPDATE */
- protected boolean lastQueryIsOnDupKeyUpdate = false;
-
- /**
- * Constructor for a Statement.
- *
- * @param c
- * the Connection instantation that creates us
- * @param catalog
- * the database name in use when we were created
- *
- * @throws SQLException
- * if an error occurs.
- */
- public StatementImpl(ConnectionImpl c, String catalog) throws SQLException {
- if ((c == null) || c.isClosed()) {
- throw SQLError.createSQLException(
- Messages.getString("Statement.0"), //$NON-NLS-1$
- SQLError.SQL_STATE_CONNECTION_NOT_OPEN, null); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- this.connection = c;
- this.connectionId = this.connection.getId();
- this.exceptionInterceptor = c.getExceptionInterceptor();
-
- this.currentCatalog = catalog;
- this.pedantic = this.connection.getPedantic();
- this.continueBatchOnError = this.connection.getContinueBatchOnError();
- this.useLegacyDatetimeCode = this.connection.getUseLegacyDatetimeCode();
-
- if (!this.connection.getDontTrackOpenResources()) {
- this.connection.registerStatement(this);
- }
-
- //
- // Adjust, if we know it
- //
-
- if (this.connection != null) {
- this.maxFieldSize = this.connection.getMaxAllowedPacket();
-
- int defaultFetchSize = this.connection.getDefaultFetchSize();
-
- if (defaultFetchSize != 0) {
- setFetchSize(defaultFetchSize);
- }
- }
-
- if (this.connection.getUseUnicode()) {
- this.charEncoding = this.connection.getEncoding();
-
- this.charConverter = this.connection
- .getCharsetConverter(this.charEncoding);
- }
-
- boolean profiling = this.connection.getProfileSql()
- || this.connection.getUseUsageAdvisor() || this.connection.getLogSlowQueries();
-
- if (this.connection.getAutoGenerateTestcaseScript() || profiling) {
- this.statementId = statementCounter++;
- }
-
- if (profiling) {
- this.pointOfOrigin = new Throwable();
- this.profileSQL = this.connection.getProfileSql();
- this.useUsageAdvisor = this.connection.getUseUsageAdvisor();
- this.eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);
- }
-
- int maxRowsConn = this.connection.getMaxRows();
-
- if (maxRowsConn != -1) {
- setMaxRows(maxRowsConn);
- }
-
- this.holdResultsOpenOverClose = this.connection.getHoldResultsOpenOverStatementClose();
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param sql
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public synchronized void addBatch(String sql) throws SQLException {
- if (this.batchedArgs == null) {
- this.batchedArgs = new ArrayList();
- }
-
- if (sql != null) {
- this.batchedArgs.add(sql);
- }
- }
-
- /**
- * Cancels this Statement object if both the DBMS and driver support
- * aborting an SQL statement. This method can be used by one thread to
- * cancel a statement that is being executed by another thread.
- */
- public void cancel() throws SQLException {
- if (!this.isClosed &&
- this.connection != null &&
- this.connection.versionMeetsMinimum(5, 0, 0)) {
- Connection cancelConn = null;
- java.sql.Statement cancelStmt = null;
-
- try {
- cancelConn = this.connection.duplicate();
- cancelStmt = cancelConn.createStatement();
- cancelStmt.execute("KILL QUERY "
- + this.connection.getIO().getThreadId());
- this.wasCancelled = true;
- } finally {
- if (cancelStmt != null) {
- cancelStmt.close();
- }
-
- if (cancelConn != null) {
- cancelConn.close();
- }
- }
-
- }
- }
-
- // --------------------------JDBC 2.0-----------------------------
-
- /**
- * Checks if closed() has been called, and throws an exception if so
- *
- * @throws SQLException
- * if this statement has been closed
- */
- protected void checkClosed() throws SQLException {
- if (this.isClosed) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.49"), //$NON-NLS-1$
- SQLError.SQL_STATE_CONNECTION_NOT_OPEN, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * Checks if the given SQL query with the given first non-ws char is a DML
- * statement. Throws an exception if it is.
- *
- * @param sql
- * the SQL to check
- * @param firstStatementChar
- * the UC first non-ws char of the statement
- *
- * @throws SQLException
- * if the statement contains DML
- */
- protected void checkForDml(String sql, char firstStatementChar)
- throws SQLException {
- if ((firstStatementChar == 'I') || (firstStatementChar == 'U')
- || (firstStatementChar == 'D') || (firstStatementChar == 'A')
- || (firstStatementChar == 'C')) {
- String noCommentSql = StringUtils.stripComments(sql,
- "'\"", "'\"", true, false, true, true);
-
- if (StringUtils.startsWithIgnoreCaseAndWs(noCommentSql, "INSERT") //$NON-NLS-1$
- || StringUtils.startsWithIgnoreCaseAndWs(noCommentSql, "UPDATE") //$NON-NLS-1$
- || StringUtils.startsWithIgnoreCaseAndWs(noCommentSql, "DELETE") //$NON-NLS-1$
- || StringUtils.startsWithIgnoreCaseAndWs(noCommentSql, "DROP") //$NON-NLS-1$
- || StringUtils.startsWithIgnoreCaseAndWs(noCommentSql, "CREATE") //$NON-NLS-1$
- || StringUtils.startsWithIgnoreCaseAndWs(noCommentSql, "ALTER")) { //$NON-NLS-1$
- throw SQLError.createSQLException(Messages
- .getString("Statement.57"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Method checkNullOrEmptyQuery.
- *
- * @param sql
- * the SQL to check
- *
- * @throws SQLException
- * if query is null or empty.
- */
- protected void checkNullOrEmptyQuery(String sql) throws SQLException {
- if (sql == null) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.59"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (sql.length() == 0) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.61"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * JDBC 2.0 Make the set of commands in the current batch empty. This method
- * is optional.
- *
- * @exception SQLException
- * if a database-access error occurs, or the driver does not
- * support batch statements
- */
- public synchronized void clearBatch() throws SQLException {
- if (this.batchedArgs != null) {
- this.batchedArgs.clear();
- }
- }
-
- /**
- * After this call, getWarnings returns null until a new warning is reported
- * for this Statement.
- *
- * @exception SQLException
- * if a database access error occurs (why?)
- */
- public void clearWarnings() throws SQLException {
- this.warningChain = null;
- }
-
- /**
- * In many cases, it is desirable to immediately release a Statement's
- * database and JDBC resources instead of waiting for this to happen when it
- * is automatically closed. The close method provides this immediate
- * release.
- *
- *
- * Note: A Statement is automatically closed when it is garbage
- * collected. When a Statement is closed, its current ResultSet, if one
- * exists, is also closed.
- *
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public synchronized void close() throws SQLException {
- realClose(true, true);
- }
-
- /**
- * Close any open result sets that have been 'held open'
- */
- protected synchronized void closeAllOpenResults() {
- if (this.openResults != null) {
- for (Iterator iter = this.openResults.iterator(); iter.hasNext();) {
- ResultSetInternalMethods element = (ResultSetInternalMethods) iter.next();
-
- try {
- element.realClose(false);
- } catch (SQLException sqlEx) {
- AssertionFailedException.shouldNotHappen(sqlEx);
- }
- }
-
- this.openResults.clear();
- }
- }
-
- public synchronized void removeOpenResultSet(ResultSet rs) {
- if (this.openResults != null) {
- this.openResults.remove(rs);
- }
- }
-
- public synchronized int getOpenResultSetCount() {
- if (this.openResults != null) {
- return this.openResults.size();
- }
-
- return 0;
- }
-
- /**
- * @param sql
- * @return
- */
- private ResultSetInternalMethods createResultSetUsingServerFetch(String sql)
- throws SQLException {
- java.sql.PreparedStatement pStmt = this.connection.prepareStatement(
- sql, this.resultSetType, this.resultSetConcurrency);
-
- pStmt.setFetchSize(this.fetchSize);
-
- if (this.maxRows > -1) {
- pStmt.setMaxRows(this.maxRows);
- }
-
- pStmt.execute();
-
- //
- // Need to be able to get resultset irrespective if we issued DML or
- // not to make this work.
- //
- ResultSetInternalMethods rs = ((com.mysql.jdbc.StatementImpl) pStmt)
- .getResultSetInternal();
-
- rs
- .setStatementUsedForFetchingRows((com.mysql.jdbc.PreparedStatement) pStmt);
-
- this.results = rs;
-
- return rs;
- }
-
- /**
- * We only stream result sets when they are forward-only, read-only, and the
- * fetch size has been set to Integer.MIN_VALUE
- *
- * @return true if this result set should be streamed row at-a-time, rather
- * than read all at once.
- */
- protected boolean createStreamingResultSet() {
- return ((this.resultSetType == java.sql.ResultSet.TYPE_FORWARD_ONLY)
- && (this.resultSetConcurrency == java.sql.ResultSet.CONCUR_READ_ONLY) && (this.fetchSize == Integer.MIN_VALUE));
- }
-
- private int originalResultSetType = 0;
- private int originalFetchSize = 0;
-
- /* (non-Javadoc)
- * @see com.mysql.jdbc.IStatement#enableStreamingResults()
- */
- public void enableStreamingResults() throws SQLException {
- this.originalResultSetType = this.resultSetType;
- this.originalFetchSize = this.fetchSize;
-
- setFetchSize(Integer.MIN_VALUE);
- setResultSetType(ResultSet.TYPE_FORWARD_ONLY);
- }
-
- public void disableStreamingResults() throws SQLException {
- if (this.fetchSize == Integer.MIN_VALUE &&
- this.resultSetType == ResultSet.TYPE_FORWARD_ONLY) {
- setFetchSize(this.originalFetchSize);
- setResultSetType(this.originalResultSetType);
- }
- }
-
- /**
- * Execute a SQL statement that may return multiple results. We don't have
- * to worry about this since we do not support multiple ResultSets. You can
- * use getResultSet or getUpdateCount to retrieve the result.
- *
- * @param sql
- * any SQL statement
- *
- * @return true if the next result is a ResulSet, false if it is an update
- * count or there are no more results
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public boolean execute(String sql) throws SQLException {
- return execute(sql, false);
- }
-
- private boolean execute(String sql, boolean returnGeneratedKeys) throws SQLException {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- this.retrieveGeneratedKeys = returnGeneratedKeys;
- lastQueryIsOnDupKeyUpdate = false;
- if (returnGeneratedKeys)
- lastQueryIsOnDupKeyUpdate = containsOnDuplicateKeyInString(sql);
-
- resetCancelledState();
-
- checkNullOrEmptyQuery(sql);
-
- checkClosed();
-
- char firstNonWsChar = StringUtils.firstAlphaCharUc(sql, findStartOfStatement(sql));
-
- boolean isSelect = true;
-
- if (firstNonWsChar != 'S') {
- isSelect = false;
-
- if (locallyScopedConn.isReadOnly()) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.27") //$NON-NLS-1$
- + Messages.getString("Statement.28"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- boolean doStreaming = createStreamingResultSet();
-
- // Adjust net_write_timeout to a higher value if we're
- // streaming result sets. More often than not, someone runs into
- // an issue where they blow net_write_timeout when using this
- // feature, and if they're willing to hold a result set open
- // for 30 seconds or more, one more round-trip isn't going to hurt
- //
- // This is reset by RowDataDynamic.close().
-
- if (doStreaming
- && this.connection.getNetTimeoutForStreamingResults() > 0) {
- executeSimpleNonQuery(locallyScopedConn, "SET net_write_timeout="
- + this.connection.getNetTimeoutForStreamingResults());
- }
-
- if (this.doEscapeProcessing) {
- Object escapedSqlResult = EscapeProcessor.escapeSQL(sql,
- locallyScopedConn.serverSupportsConvertFn(), locallyScopedConn);
-
- if (escapedSqlResult instanceof String) {
- sql = (String) escapedSqlResult;
- } else {
- sql = ((EscapeProcessorResult) escapedSqlResult).escapedSql;
- }
- }
-
- if (this.results != null) {
- if (!locallyScopedConn.getHoldResultsOpenOverStatementClose()) {
- this.results.realClose(false);
- }
- }
-
- if (sql.charAt(0) == '/') {
- if (sql.startsWith(PING_MARKER)) {
- doPingInstead();
-
- return true;
- }
- }
-
- CachedResultSetMetaData cachedMetaData = null;
-
- ResultSetInternalMethods rs = null;
-
- // If there isn't a limit clause in the SQL
- // then limit the number of rows to return in
- // an efficient manner. Only do this if
- // setMaxRows() hasn't been used on any Statements
- // generated from the current Connection (saves
- // a query, and network traffic).
-
- this.batchedGeneratedKeys = null;
-
- if (useServerFetch()) {
- rs = createResultSetUsingServerFetch(sql);
- } else {
- CancelTask timeoutTask = null;
-
- String oldCatalog = null;
-
- try {
- if (locallyScopedConn.getEnableQueryTimeouts() &&
- this.timeoutInMillis != 0
- && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- this.timeoutInMillis);
- }
-
-
-
- if (!locallyScopedConn.getCatalog().equals(
- this.currentCatalog)) {
- oldCatalog = locallyScopedConn.getCatalog();
- locallyScopedConn.setCatalog(this.currentCatalog);
- }
-
- //
- // Check if we have cached metadata for this query...
- //
-
- Field[] cachedFields = null;
-
- if (locallyScopedConn.getCacheResultSetMetadata()) {
- cachedMetaData = locallyScopedConn.getCachedMetaData(sql);
-
- if (cachedMetaData != null) {
- cachedFields = cachedMetaData.fields;
- }
- }
-
- //
- // Only apply max_rows to selects
- //
- if (locallyScopedConn.useMaxRows()) {
- int rowLimit = -1;
-
- if (isSelect) {
- if (StringUtils.indexOfIgnoreCase(sql, "LIMIT") != -1) { //$NON-NLS-1$
- rowLimit = this.maxRows;
- } else {
- if (this.maxRows <= 0) {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- } else {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT="
- + this.maxRows);
- }
- }
- } else {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- }
-
- // Finally, execute the query
- rs = locallyScopedConn.execSQL(this, sql, rowLimit, null,
- this.resultSetType, this.resultSetConcurrency,
- doStreaming,
- this.currentCatalog, cachedFields);
- } else {
- rs = locallyScopedConn.execSQL(this, sql, -1, null,
- this.resultSetType, this.resultSetConcurrency,
- doStreaming,
- this.currentCatalog, cachedFields);
- }
-
- if (timeoutTask != null) {
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask.cancel();
- timeoutTask = null;
- }
-
- synchronized (this.cancelTimeoutMutex) {
- if (this.wasCancelled) {
- SQLException cause = null;
-
- if (this.wasCancelledByTimeout) {
- cause = new MySQLTimeoutException();
- } else {
- cause = new MySQLStatementCancelledException();
- }
-
- resetCancelledState();
-
- throw cause;
- }
- }
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- if (oldCatalog != null) {
- locallyScopedConn.setCatalog(oldCatalog);
- }
- }
- }
-
- if (rs != null) {
- this.lastInsertId = rs.getUpdateID();
-
- this.results = rs;
-
- rs.setFirstCharOfQuery(firstNonWsChar);
-
- if (rs.reallyResult()) {
- if (cachedMetaData != null) {
- locallyScopedConn.initializeResultsMetadataFromCache(sql, cachedMetaData,
- this.results);
- } else {
- if (this.connection.getCacheResultSetMetadata()) {
- locallyScopedConn.initializeResultsMetadataFromCache(sql,
- null /* will be created */, this.results);
- }
- }
- }
- }
-
- return ((rs != null) && rs.reallyResult());
- }
- }
-
- protected synchronized void resetCancelledState() {
- if (this.cancelTimeoutMutex == null) {
- return;
- }
-
- synchronized (this.cancelTimeoutMutex) {
- this.wasCancelled = false;
- this.wasCancelledByTimeout = false;
- }
- }
-
- /**
- * @see StatementImpl#execute(String, int)
- */
- public boolean execute(String sql, int returnGeneratedKeys)
- throws SQLException {
-
-
- if (returnGeneratedKeys == java.sql.Statement.RETURN_GENERATED_KEYS) {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- // If this is a 'REPLACE' query, we need to be able to parse
- // the 'info' message returned from the server to determine
- // the actual number of keys generated.
- boolean readInfoMsgState = this.connection
- .isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
-
- try {
- return execute(sql, true);
- } finally {
- locallyScopedConn.setReadInfoMsgEnabled(readInfoMsgState);
- }
- }
- }
-
- return execute(sql);
- }
-
- /**
- * @see StatementImpl#execute(String, int[])
- */
- public boolean execute(String sql, int[] generatedKeyIndices)
- throws SQLException {
- if ((generatedKeyIndices != null) && (generatedKeyIndices.length > 0)) {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- this.retrieveGeneratedKeys = true;
-
- // If this is a 'REPLACE' query, we need to be able to parse
- // the 'info' message returned from the server to determine
- // the actual number of keys generated.
- boolean readInfoMsgState = locallyScopedConn
- .isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
-
- try {
- return execute(sql, true);
- } finally {
- locallyScopedConn.setReadInfoMsgEnabled(readInfoMsgState);
- }
- }
- }
-
- return execute(sql);
- }
-
- /**
- * @see StatementImpl#execute(String, String[])
- */
- public boolean execute(String sql, String[] generatedKeyNames)
- throws SQLException {
- if ((generatedKeyNames != null) && (generatedKeyNames.length > 0)) {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- this.retrieveGeneratedKeys = true;
- // If this is a 'REPLACE' query, we need to be able to parse
- // the 'info' message returned from the server to determine
- // the actual number of keys generated.
- boolean readInfoMsgState = this.connection
- .isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
-
- try {
- return execute(sql, true);
- } finally {
- locallyScopedConn.setReadInfoMsgEnabled(readInfoMsgState);
- }
- }
- }
-
- return execute(sql);
- }
-
- /**
- * JDBC 2.0 Submit a batch of commands to the database for execution. This
- * method is optional.
- *
- * @return an array of update counts containing one element for each command
- * in the batch. The array is ordered according to the order in
- * which commands were inserted into the batch
- *
- * @exception SQLException
- * if a database-access error occurs, or the driver does not
- * support batch statements
- * @throws java.sql.BatchUpdateException
- * DOCUMENT ME!
- */
- public synchronized int[] executeBatch() throws SQLException {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- if (locallyScopedConn.isReadOnly()) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.34") //$NON-NLS-1$
- + Messages.getString("Statement.35"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (this.results != null) {
- if (!locallyScopedConn.getHoldResultsOpenOverStatementClose()) {
- this.results.realClose(false);
- }
- }
-
- synchronized (locallyScopedConn.getMutex()) {
- if (this.batchedArgs == null || this.batchedArgs.size() == 0) {
- return new int[0];
- }
-
- // we timeout the entire batch, not individual statements
- int individualStatementTimeout = this.timeoutInMillis;
- this.timeoutInMillis = 0;
-
- CancelTask timeoutTask = null;
-
- try {
- resetCancelledState();
-
- this.retrieveGeneratedKeys = true; // The JDBC spec doesn't forbid this, but doesn't provide for it either...we do..
-
- int[] updateCounts = null;
-
-
- if (this.batchedArgs != null) {
- int nbrCommands = this.batchedArgs.size();
-
- this.batchedGeneratedKeys = new ArrayList(this.batchedArgs.size());
-
- boolean multiQueriesEnabled = locallyScopedConn.getAllowMultiQueries();
-
- if (locallyScopedConn.versionMeetsMinimum(4, 1, 1) &&
- (multiQueriesEnabled ||
- (locallyScopedConn.getRewriteBatchedStatements() &&
- nbrCommands > 4))) {
- return executeBatchUsingMultiQueries(multiQueriesEnabled, nbrCommands, individualStatementTimeout);
- }
-
- if (locallyScopedConn.getEnableQueryTimeouts() &&
- individualStatementTimeout != 0
- && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- individualStatementTimeout);
- }
-
- updateCounts = new int[nbrCommands];
-
- for (int i = 0; i < nbrCommands; i++) {
- updateCounts[i] = -3;
- }
-
- SQLException sqlEx = null;
-
- int commandIndex = 0;
-
- for (commandIndex = 0; commandIndex < nbrCommands; commandIndex++) {
- try {
- String sql = (String) this.batchedArgs.get(commandIndex);
- updateCounts[commandIndex] = executeUpdate(sql, true, true);
- // limit one generated key per OnDuplicateKey statement
- getBatchedGeneratedKeys(containsOnDuplicateKeyInString(sql) ? 1 : 0);
- } catch (SQLException ex) {
- updateCounts[commandIndex] = EXECUTE_FAILED;
-
- if (this.continueBatchOnError &&
- !(ex instanceof MySQLTimeoutException) &&
- !(ex instanceof MySQLStatementCancelledException) &&
- !hasDeadlockOrTimeoutRolledBackTx(ex)) {
- sqlEx = ex;
- } else {
- int[] newUpdateCounts = new int[commandIndex];
-
- if (hasDeadlockOrTimeoutRolledBackTx(ex)) {
- for (int i = 0; i < newUpdateCounts.length; i++) {
- newUpdateCounts[i] = Statement.EXECUTE_FAILED;
- }
- } else {
- System.arraycopy(updateCounts, 0,
- newUpdateCounts, 0, commandIndex);
- }
-
- throw new java.sql.BatchUpdateException(ex
- .getMessage(), ex.getSQLState(), ex
- .getErrorCode(), newUpdateCounts);
- }
- }
- }
-
- if (sqlEx != null) {
- throw new java.sql.BatchUpdateException(sqlEx
- .getMessage(), sqlEx.getSQLState(), sqlEx
- .getErrorCode(), updateCounts);
- }
- }
-
- if (timeoutTask != null) {
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask.cancel();
- timeoutTask = null;
- }
-
- return (updateCounts != null) ? updateCounts : new int[0];
- } finally {
-
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- resetCancelledState();
-
- this.timeoutInMillis = individualStatementTimeout;
-
- clearBatch();
- }
- }
- }
-
- protected final boolean hasDeadlockOrTimeoutRolledBackTx(SQLException ex) {
- int vendorCode = ex.getErrorCode();
-
- switch (vendorCode) {
- case MysqlErrorNumbers.ER_LOCK_DEADLOCK:
- case MysqlErrorNumbers.ER_LOCK_TABLE_FULL:
- return true;
- case MysqlErrorNumbers.ER_LOCK_WAIT_TIMEOUT:
- try {
- return !this.connection.versionMeetsMinimum(5, 0, 13);
- } catch (SQLException sqlEx) {
- // won't actually be thrown in this case
- return false;
- }
- default:
- return false;
- }
- }
-
- /**
- * Rewrites batch into a single query to send to the server. This method
- * will constrain each batch to be shorter than max_allowed_packet on the
- * server.
- *
- * @return update counts in the same manner as executeBatch()
- * @throws SQLException
- */
- private int[] executeBatchUsingMultiQueries(boolean multiQueriesEnabled,
- int nbrCommands, int individualStatementTimeout) throws SQLException {
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- if (!multiQueriesEnabled) {
- locallyScopedConn.getIO().enableMultiQueries();
- }
-
- java.sql.Statement batchStmt = null;
-
- CancelTask timeoutTask = null;
-
- try {
- int[] updateCounts = new int[nbrCommands];
-
- for (int i = 0; i < nbrCommands; i++) {
- updateCounts[i] = -3;
- }
-
- int commandIndex = 0;
-
- StringBuffer queryBuf = new StringBuffer();
-
- batchStmt = locallyScopedConn.createStatement();
-
- if (locallyScopedConn.getEnableQueryTimeouts() &&
- individualStatementTimeout != 0
- && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask((StatementImpl)batchStmt);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- individualStatementTimeout);
- }
-
- int counter = 0;
-
- int numberOfBytesPerChar = 1;
-
- String connectionEncoding = locallyScopedConn.getEncoding();
-
- if (StringUtils.startsWithIgnoreCase(connectionEncoding, "utf")) {
- numberOfBytesPerChar = 3;
- } else if (CharsetMapping.isMultibyteCharset(connectionEncoding)) {
- numberOfBytesPerChar = 2;
- }
-
- int escapeAdjust = 1;
-
- if (this.doEscapeProcessing) {
- escapeAdjust = 2; /* We assume packet _could_ grow by this amount, as we're not
- sure how big statement will end up after
- escape processing */
- }
-
- SQLException sqlEx = null;
-
- int argumentSetsInBatchSoFar = 0;
-
- for (commandIndex = 0; commandIndex < nbrCommands; commandIndex++) {
- String nextQuery = (String) this.batchedArgs.get(commandIndex);
-
- if (((((queryBuf.length() + nextQuery.length())
- * numberOfBytesPerChar) + 1 /* for semicolon */
- + MysqlIO.HEADER_LENGTH) * escapeAdjust) + 32 > this.connection
- .getMaxAllowedPacket()) {
- try {
- batchStmt.execute(queryBuf.toString(), Statement.RETURN_GENERATED_KEYS);
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(commandIndex,
- argumentSetsInBatchSoFar, updateCounts, ex);
- }
-
- counter = processMultiCountsAndKeys((StatementImpl)batchStmt, counter,
- updateCounts);
-
- queryBuf = new StringBuffer();
- argumentSetsInBatchSoFar = 0;
- }
-
- queryBuf.append(nextQuery);
- queryBuf.append(";");
- argumentSetsInBatchSoFar++;
- }
-
- if (queryBuf.length() > 0) {
- try {
- batchStmt.execute(queryBuf.toString(), Statement.RETURN_GENERATED_KEYS);
- } catch (SQLException ex) {
- sqlEx = handleExceptionForBatch(commandIndex - 1,
- argumentSetsInBatchSoFar, updateCounts, ex);
- }
-
- counter = processMultiCountsAndKeys((StatementImpl)batchStmt, counter,
- updateCounts);
- }
-
- if (timeoutTask != null) {
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask.cancel();
- timeoutTask = null;
- }
-
- if (sqlEx != null) {
- throw new java.sql.BatchUpdateException(sqlEx
- .getMessage(), sqlEx.getSQLState(), sqlEx
- .getErrorCode(), updateCounts);
- }
-
- return (updateCounts != null) ? updateCounts : new int[0];
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- resetCancelledState();
-
- try {
- if (batchStmt != null) {
- batchStmt.close();
- }
- } finally {
- if (!multiQueriesEnabled) {
- locallyScopedConn.getIO().disableMultiQueries();
- }
- }
- }
- }
-
- protected int processMultiCountsAndKeys(
- StatementImpl batchedStatement,
- int updateCountCounter, int[] updateCounts) throws SQLException {
- updateCounts[updateCountCounter++] = batchedStatement.getUpdateCount();
-
- boolean doGenKeys = this.batchedGeneratedKeys != null;
-
- byte[][] row = null;
-
- if (doGenKeys) {
- long generatedKey = batchedStatement.getLastInsertID();
-
- row = new byte[1][];
- row[0] = Long.toString(generatedKey).getBytes();
- this.batchedGeneratedKeys.add(new ByteArrayRow(row, getExceptionInterceptor()));
- }
-
- while (batchedStatement.getMoreResults()
- || batchedStatement.getUpdateCount() != -1) {
- updateCounts[updateCountCounter++] = batchedStatement.getUpdateCount();
-
- if (doGenKeys) {
- long generatedKey = batchedStatement.getLastInsertID();
-
- row = new byte[1][];
- row[0] = Long.toString(generatedKey).getBytes();
- this.batchedGeneratedKeys.add(new ByteArrayRow(row, getExceptionInterceptor()));
- }
- }
-
- return updateCountCounter;
- }
-
- protected SQLException handleExceptionForBatch(int endOfBatchIndex,
- int numValuesPerBatch, int[] updateCounts, SQLException ex)
- throws BatchUpdateException {
- SQLException sqlEx;
-
- for (int j = endOfBatchIndex; j > endOfBatchIndex - numValuesPerBatch; j--) {
- updateCounts[j] = EXECUTE_FAILED;
- }
-
- if (this.continueBatchOnError &&
- !(ex instanceof MySQLTimeoutException) &&
- !(ex instanceof MySQLStatementCancelledException) &&
- !hasDeadlockOrTimeoutRolledBackTx(ex)) {
- sqlEx = ex;
- } else {
- int[] newUpdateCounts = new int[endOfBatchIndex];
- System.arraycopy(updateCounts, 0,
- newUpdateCounts, 0, endOfBatchIndex);
-
- throw new java.sql.BatchUpdateException(ex
- .getMessage(), ex.getSQLState(), ex
- .getErrorCode(), newUpdateCounts);
- }
-
- return sqlEx;
- }
-
- /**
- * Execute a SQL statement that retruns a single ResultSet
- *
- * @param sql
- * typically a static SQL SELECT statement
- *
- * @return a ResulSet that contains the data produced by the query
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public java.sql.ResultSet executeQuery(String sql)
- throws SQLException {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- this.retrieveGeneratedKeys = false;
-
- resetCancelledState();
-
- checkNullOrEmptyQuery(sql);
-
- boolean doStreaming = createStreamingResultSet();
-
- // Adjust net_write_timeout to a higher value if we're
- // streaming result sets. More often than not, someone runs into
- // an issue where they blow net_write_timeout when using this
- // feature, and if they're willing to hold a result set open
- // for 30 seconds or more, one more round-trip isn't going to hurt
- //
- // This is reset by RowDataDynamic.close().
-
- if (doStreaming
- && this.connection.getNetTimeoutForStreamingResults() > 0) {
- executeSimpleNonQuery(locallyScopedConn, "SET net_write_timeout="
- + this.connection.getNetTimeoutForStreamingResults());
- }
-
- if (this.doEscapeProcessing) {
- Object escapedSqlResult = EscapeProcessor.escapeSQL(sql,
- locallyScopedConn.serverSupportsConvertFn(), this.connection);
-
- if (escapedSqlResult instanceof String) {
- sql = (String) escapedSqlResult;
- } else {
- sql = ((EscapeProcessorResult) escapedSqlResult).escapedSql;
- }
- }
-
- char firstStatementChar = StringUtils.firstNonWsCharUc(sql,
- findStartOfStatement(sql));
-
- if (sql.charAt(0) == '/') {
- if (sql.startsWith(PING_MARKER)) {
- doPingInstead();
-
- return this.results;
- }
- }
-
- checkForDml(sql, firstStatementChar);
-
- if (this.results != null) {
- if (!locallyScopedConn.getHoldResultsOpenOverStatementClose()) {
- this.results.realClose(false);
- }
- }
-
- CachedResultSetMetaData cachedMetaData = null;
-
- // If there isn't a limit clause in the SQL
- // then limit the number of rows to return in
- // an efficient manner. Only do this if
- // setMaxRows() hasn't been used on any Statements
- // generated from the current Connection (saves
- // a query, and network traffic).
-
- if (useServerFetch()) {
- this.results = createResultSetUsingServerFetch(sql);
-
- return this.results;
- }
-
- CancelTask timeoutTask = null;
-
- String oldCatalog = null;
-
- try {
- if (locallyScopedConn.getEnableQueryTimeouts() &&
- this.timeoutInMillis != 0
- && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- this.timeoutInMillis);
- }
-
- if (!locallyScopedConn.getCatalog().equals(this.currentCatalog)) {
- oldCatalog = locallyScopedConn.getCatalog();
- locallyScopedConn.setCatalog(this.currentCatalog);
- }
-
- //
- // Check if we have cached metadata for this query...
- //
-
- Field[] cachedFields = null;
-
- if (locallyScopedConn.getCacheResultSetMetadata()) {
- cachedMetaData = locallyScopedConn.getCachedMetaData(sql);
-
- if (cachedMetaData != null) {
- cachedFields = cachedMetaData.fields;
- }
- }
-
- if (locallyScopedConn.useMaxRows()) {
- // We need to execute this all together
- // So synchronize on the Connection's mutex (because
- // even queries going through there synchronize
- // on the connection
- if (StringUtils.indexOfIgnoreCase(sql, "LIMIT") != -1) { //$NON-NLS-1$
- this.results = locallyScopedConn.execSQL(this, sql,
- this.maxRows, null, this.resultSetType,
- this.resultSetConcurrency,
- doStreaming,
- this.currentCatalog, cachedFields);
- } else {
- if (this.maxRows <= 0) {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- } else {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=" + this.maxRows);
- }
-
- this.results = locallyScopedConn.execSQL(this, sql, -1,
- null, this.resultSetType,
- this.resultSetConcurrency,
- doStreaming,
- this.currentCatalog, cachedFields);
-
- if (oldCatalog != null) {
- locallyScopedConn.setCatalog(oldCatalog);
- }
- }
- } else {
- this.results = locallyScopedConn.execSQL(this, sql, -1, null,
- this.resultSetType, this.resultSetConcurrency,
- doStreaming,
- this.currentCatalog, cachedFields);
- }
-
- if (timeoutTask != null) {
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask.cancel();
- timeoutTask = null;
- }
-
- synchronized (this.cancelTimeoutMutex) {
- if (this.wasCancelled) {
- SQLException cause = null;
-
- if (this.wasCancelledByTimeout) {
- cause = new MySQLTimeoutException();
- } else {
- cause = new MySQLStatementCancelledException();
- }
-
- resetCancelledState();
-
- throw cause;
- }
- }
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- if (oldCatalog != null) {
- locallyScopedConn.setCatalog(oldCatalog);
- }
- }
-
- this.lastInsertId = this.results.getUpdateID();
-
- if (cachedMetaData != null) {
- locallyScopedConn.initializeResultsMetadataFromCache(sql, cachedMetaData,
- this.results);
- } else {
- if (this.connection.getCacheResultSetMetadata()) {
- locallyScopedConn.initializeResultsMetadataFromCache(sql,
- null /* will be created */, this.results);
- }
- }
-
- return this.results;
- }
- }
-
- protected void doPingInstead() throws SQLException {
- if (this.pingTarget != null) {
- this.pingTarget.doPing();
- } else {
- this.connection.ping();
- }
-
- ResultSetInternalMethods fakeSelectOneResultSet = generatePingResultSet();
- this.results = fakeSelectOneResultSet;
- }
-
- protected ResultSetInternalMethods generatePingResultSet() throws SQLException {
- Field[] fields = { new Field(null, "1", Types.BIGINT, 1) };
- ArrayList rows = new ArrayList();
- byte[] colVal = new byte[] { (byte) '1' };
-
- rows.add(new ByteArrayRow(new byte[][] { colVal }, getExceptionInterceptor()));
-
- return (ResultSetInternalMethods) DatabaseMetaData.buildResultSet(fields, rows,
- this.connection);
- }
-
- protected void executeSimpleNonQuery(ConnectionImpl c, String nonQuery)
- throws SQLException {
- c.execSQL(this, nonQuery,
- -1, null, ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_READ_ONLY, false, this.currentCatalog,
- null, false).close();
- }
-
- /**
- * Execute a SQL INSERT, UPDATE or DELETE statement. In addition SQL
- * statements that return nothing such as SQL DDL statements can be executed
- * Any IDs generated for AUTO_INCREMENT fields can be retrieved by casting
- * this Statement to org.gjt.mm.mysql.Statement and calling the
- * getLastInsertID() method.
- *
- * @param sql
- * a SQL statement
- *
- * @return either a row count, or 0 for SQL commands
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public int executeUpdate(String sql) throws SQLException {
- return executeUpdate(sql, false, false);
- }
-
- protected int executeUpdate(String sql, boolean isBatch, boolean returnGeneratedKeys)
- throws SQLException {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- char firstStatementChar = StringUtils.firstAlphaCharUc(sql,
- findStartOfStatement(sql));
-
- ResultSetInternalMethods rs = null;
-
- synchronized (locallyScopedConn.getMutex()) {
- this.retrieveGeneratedKeys = returnGeneratedKeys;
-
- resetCancelledState();
-
- checkNullOrEmptyQuery(sql);
-
- if (this.doEscapeProcessing) {
- Object escapedSqlResult = EscapeProcessor.escapeSQL(sql,
- this.connection.serverSupportsConvertFn(), this.connection);
-
- if (escapedSqlResult instanceof String) {
- sql = (String) escapedSqlResult;
- } else {
- sql = ((EscapeProcessorResult) escapedSqlResult).escapedSql;
- }
- }
-
- if (locallyScopedConn.isReadOnly()) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.42") //$NON-NLS-1$
- + Messages.getString("Statement.43"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (StringUtils.startsWithIgnoreCaseAndWs(sql, "select")) { //$NON-NLS-1$
- throw SQLError.createSQLException(Messages
- .getString("Statement.46"), //$NON-NLS-1$
- "01S03", getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (this.results != null) {
- if (!locallyScopedConn.getHoldResultsOpenOverStatementClose()) {
- this.results.realClose(false);
- }
- }
-
- // The checking and changing of catalogs
- // must happen in sequence, so synchronize
- // on the same mutex that _conn is using
-
- CancelTask timeoutTask = null;
-
- String oldCatalog = null;
-
- try {
- if (locallyScopedConn.getEnableQueryTimeouts() &&
- this.timeoutInMillis != 0
- && locallyScopedConn.versionMeetsMinimum(5, 0, 0)) {
- timeoutTask = new CancelTask(this);
- ConnectionImpl.getCancelTimer().schedule(timeoutTask,
- this.timeoutInMillis);
- }
-
- if (!locallyScopedConn.getCatalog().equals(this.currentCatalog)) {
- oldCatalog = locallyScopedConn.getCatalog();
- locallyScopedConn.setCatalog(this.currentCatalog);
- }
-
- //
- // Only apply max_rows to selects
- //
- if (locallyScopedConn.useMaxRows()) {
- executeSimpleNonQuery(locallyScopedConn,
- "SET OPTION SQL_SELECT_LIMIT=DEFAULT");
- }
-
- rs = locallyScopedConn.execSQL(this, sql, -1, null,
- java.sql.ResultSet.TYPE_FORWARD_ONLY,
- java.sql.ResultSet.CONCUR_READ_ONLY, false,
- this.currentCatalog,
- null /* force read of field info on DML */,
- isBatch);
-
- if (timeoutTask != null) {
- if (timeoutTask.caughtWhileCancelling != null) {
- throw timeoutTask.caughtWhileCancelling;
- }
-
- timeoutTask.cancel();
- timeoutTask = null;
- }
-
- synchronized (this.cancelTimeoutMutex) {
- if (this.wasCancelled) {
- SQLException cause = null;
-
- if (this.wasCancelledByTimeout) {
- cause = new MySQLTimeoutException();
- } else {
- cause = new MySQLStatementCancelledException();
- }
-
- resetCancelledState();
-
- throw cause;
- }
- }
- } finally {
- if (timeoutTask != null) {
- timeoutTask.cancel();
- }
-
- if (oldCatalog != null) {
- locallyScopedConn.setCatalog(oldCatalog);
- }
- }
- }
-
- this.results = rs;
-
- rs.setFirstCharOfQuery(firstStatementChar);
-
- this.updateCount = rs.getUpdateCount();
-
- int truncatedUpdateCount = 0;
-
- if (this.updateCount > Integer.MAX_VALUE) {
- truncatedUpdateCount = Integer.MAX_VALUE;
- } else {
- truncatedUpdateCount = (int) this.updateCount;
- }
-
- this.lastInsertId = rs.getUpdateID();
-
- return truncatedUpdateCount;
- }
-
-
- /**
- * @see StatementImpl#executeUpdate(String, int)
- */
- public int executeUpdate(String sql, int returnGeneratedKeys)
- throws SQLException {
- if (returnGeneratedKeys == java.sql.Statement.RETURN_GENERATED_KEYS) {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- // If this is a 'REPLACE' query, we need to be able to parse
- // the 'info' message returned from the server to determine
- // the actual number of keys generated.
- boolean readInfoMsgState = locallyScopedConn
- .isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
-
- try {
- return executeUpdate(sql, false, true);
- } finally {
- locallyScopedConn.setReadInfoMsgEnabled(readInfoMsgState);
- }
- }
- }
-
- return executeUpdate(sql);
- }
-
- /**
- * @see StatementImpl#executeUpdate(String, int[])
- */
- public int executeUpdate(String sql, int[] generatedKeyIndices)
- throws SQLException {
- if ((generatedKeyIndices != null) && (generatedKeyIndices.length > 0)) {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- // If this is a 'REPLACE' query, we need to be able to parse
- // the 'info' message returned from the server to determine
- // the actual number of keys generated.
- boolean readInfoMsgState = locallyScopedConn
- .isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
-
- try {
- return executeUpdate(sql, false, true);
- } finally {
- locallyScopedConn.setReadInfoMsgEnabled(readInfoMsgState);
- }
- }
- }
-
- return executeUpdate(sql);
- }
-
- /**
- * @see StatementImpl#executeUpdate(String, String[])
- */
- public int executeUpdate(String sql, String[] generatedKeyNames)
- throws SQLException {
- if ((generatedKeyNames != null) && (generatedKeyNames.length > 0)) {
- checkClosed();
-
- ConnectionImpl locallyScopedConn = this.connection;
-
- synchronized (locallyScopedConn.getMutex()) {
- // If this is a 'REPLACE' query, we need to be able to parse
- // the 'info' message returned from the server to determine
- // the actual number of keys generated.
- boolean readInfoMsgState = this.connection
- .isReadInfoMsgEnabled();
- locallyScopedConn.setReadInfoMsgEnabled(true);
-
- try {
- return executeUpdate(sql, false, true);
- } finally {
- locallyScopedConn.setReadInfoMsgEnabled(readInfoMsgState);
- }
- }
- }
-
- return executeUpdate(sql);
- }
-
- /**
- * Optimization to only use one calendar per-session, or calculate it for
- * each call, depending on user configuration
- */
- protected Calendar getCalendarInstanceForSessionOrNew() {
- if (this.connection != null) {
- return this.connection.getCalendarInstanceForSessionOrNew();
- } else {
- // punt, no connection around
- return new GregorianCalendar();
- }
- }
-
- /**
- * JDBC 2.0 Return the Connection that produced the Statement.
- *
- * @return the Connection that produced the Statement
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.sql.Connection getConnection() throws SQLException {
- return this.connection;
- }
-
- /**
- * JDBC 2.0 Determine the fetch direction.
- *
- * @return the default fetch direction
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public int getFetchDirection() throws SQLException {
- return java.sql.ResultSet.FETCH_FORWARD;
- }
-
- /**
- * JDBC 2.0 Determine the default fetch size.
- *
- * @return the number of rows to fetch at a time
- *
- * @throws SQLException
- * if an error occurs
- */
- public int getFetchSize() throws SQLException {
- return this.fetchSize;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public synchronized java.sql.ResultSet getGeneratedKeys()
- throws SQLException {
- if (!this.retrieveGeneratedKeys) {
- throw SQLError.createSQLException(Messages.getString("Statement.GeneratedKeysNotRequested"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
-
- if (this.batchedGeneratedKeys == null) {
- if (lastQueryIsOnDupKeyUpdate)
- return getGeneratedKeysInternal(1);
- else
- return getGeneratedKeysInternal();
- }
-
- Field[] fields = new Field[1];
- fields[0] = new Field("", "GENERATED_KEY", Types.BIGINT, 17); //$NON-NLS-1$ //$NON-NLS-2$
- fields[0].setConnection(this.connection);
-
- return com.mysql.jdbc.ResultSetImpl.getInstance(this.currentCatalog, fields,
- new RowDataStatic(this.batchedGeneratedKeys), this.connection,
- this, false);
- }
-
- /*
- * Needed because there's no concept of super.super to get to this
- * implementation from ServerPreparedStatement when dealing with batched
- * updates.
- */
- protected java.sql.ResultSet getGeneratedKeysInternal()
- throws SQLException {
- int numKeys = getUpdateCount();
- return getGeneratedKeysInternal(numKeys);
- }
-
- protected synchronized java.sql.ResultSet getGeneratedKeysInternal(int numKeys)
- throws SQLException {
- Field[] fields = new Field[1];
- fields[0] = new Field("", "GENERATED_KEY", Types.BIGINT, 17); //$NON-NLS-1$ //$NON-NLS-2$
- fields[0].setConnection(this.connection);
- fields[0].setUseOldNameMetadata(true);
-
- ArrayList rowSet = new ArrayList();
-
- long beginAt = getLastInsertID();
-
- if (beginAt < 0) { // looking at an UNSIGNED BIGINT that has overflowed
- fields[0].setUnsigned();
- }
-
- if (this.results != null) {
- String serverInfo = this.results.getServerInfo();
-
- //
- // Only parse server info messages for 'REPLACE'
- // queries
- //
- if ((numKeys > 0) && (this.results.getFirstCharOfQuery() == 'R')
- && (serverInfo != null) && (serverInfo.length() > 0)) {
- numKeys = getRecordCountFromInfo(serverInfo);
- }
-
- if ((beginAt != 0 /* BIGINT UNSIGNED can wrap the protocol representation */) && (numKeys > 0)) {
- for (int i = 0; i < numKeys; i++) {
- byte[][] row = new byte[1][];
- if (beginAt > 0) {
- row[0] = Long.toString(beginAt).getBytes();
- } else {
- byte[] asBytes = new byte[8];
- asBytes[7] = (byte) (beginAt & 0xff);
- asBytes[6] = (byte) (beginAt >>> 8);
- asBytes[5] = (byte) (beginAt >>> 16);
- asBytes[4] = (byte) (beginAt >>> 24);
- asBytes[3] = (byte) (beginAt >>> 32);
- asBytes[2] = (byte) (beginAt >>> 40);
- asBytes[1] = (byte) (beginAt >>> 48);
- asBytes[0] = (byte) (beginAt >>> 56);
-
- BigInteger val = new BigInteger(1, asBytes);
-
- row[0] = val.toString().getBytes();
- }
- rowSet.add(new ByteArrayRow(row, getExceptionInterceptor()));
- beginAt += this.connection.getAutoIncrementIncrement();
- }
- }
- }
-
- com.mysql.jdbc.ResultSetImpl gkRs = com.mysql.jdbc.ResultSetImpl.getInstance(this.currentCatalog, fields,
- new RowDataStatic(rowSet), this.connection, this, false);
-
- this.openResults.add(gkRs);
-
- return gkRs;
- }
-
- /**
- * Returns the id used when profiling
- *
- * @return the id used when profiling.
- */
- protected int getId() {
- return this.statementId;
- }
-
- /**
- * getLastInsertID returns the value of the auto_incremented key after an
- * executeQuery() or excute() call.
- *
- *
- * This gets around the un-threadsafe behavior of "select LAST_INSERT_ID()"
- * which is tied to the Connection that created this Statement, and
- * therefore could have had many INSERTS performed before one gets a chance
- * to call "select LAST_INSERT_ID()".
- *
- *
- * @return the last update ID.
- */
- public long getLastInsertID() {
- return this.lastInsertId;
- }
-
- /**
- * getLongUpdateCount returns the current result as an update count, if the
- * result is a ResultSet or there are no more results, -1 is returned. It
- * should only be called once per result.
- *
- *
- * This method returns longs as MySQL server versions newer than 3.22.4
- * return 64-bit values for update counts
- *
- *
- * @return the current update count.
- */
- public long getLongUpdateCount() {
- if (this.results == null) {
- return -1;
- }
-
- if (this.results.reallyResult()) {
- return -1;
- }
-
- return this.updateCount;
- }
-
- /**
- * The maxFieldSize limit (in bytes) is the maximum amount of data returned
- * for any column value; it only applies to BINARY, VARBINARY,
- * LONGVARBINARY, CHAR, VARCHAR and LONGVARCHAR columns. If the limit is
- * exceeded, the excess data is silently discarded.
- *
- * @return the current max column size limit; zero means unlimited
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public int getMaxFieldSize() throws SQLException {
- return this.maxFieldSize;
- }
-
- /**
- * The maxRows limit is set to limit the number of rows that any ResultSet
- * can contain. If the limit is exceeded, the excess rows are silently
- * dropped.
- *
- * @return the current maximum row limit; zero means unlimited
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public int getMaxRows() throws SQLException {
- if (this.maxRows <= 0) {
- return 0;
- }
-
- return this.maxRows;
- }
-
- /**
- * getMoreResults moves to a Statement's next result. If it returns true,
- * this result is a ResulSet.
- *
- * @return true if the next ResultSet is valid
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public boolean getMoreResults() throws SQLException {
- return getMoreResults(CLOSE_CURRENT_RESULT);
- }
-
- /**
- * @see StatementImpl#getMoreResults(int)
- */
- public synchronized boolean getMoreResults(int current) throws SQLException {
-
- if (this.results == null) {
- return false;
- }
-
- boolean streamingMode = createStreamingResultSet();
-
- if (streamingMode) {
- if (this.results.reallyResult()) {
- while (this.results.next()); // need to drain remaining rows to get to server status
- // which tells us whether more results actually exist or not
- }
- }
-
- ResultSetInternalMethods nextResultSet = this.results.getNextResultSet();
-
- switch (current) {
- case java.sql.Statement.CLOSE_CURRENT_RESULT:
-
- if (this.results != null) {
- if (!streamingMode) {
- this.results.close();
- }
-
- this.results.clearNextResult();
- }
-
- break;
-
- case java.sql.Statement.CLOSE_ALL_RESULTS:
-
- if (this.results != null) {
- if (!streamingMode) {
- this.results.close();
- }
-
- this.results.clearNextResult();
- }
-
- closeAllOpenResults();
-
- break;
-
- case java.sql.Statement.KEEP_CURRENT_RESULT:
- if (!this.connection.getDontTrackOpenResources()) {
- this.openResults.add(this.results);
- }
-
- this.results.clearNextResult(); // nobody besides us should
- // ever need this value...
- break;
-
- default:
- throw SQLError.createSQLException(Messages
- .getString("Statement.19"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- this.results = nextResultSet;
-
- if (this.results == null) {
- this.updateCount = -1;
- this.lastInsertId = -1;
- } else if (this.results.reallyResult()) {
- this.updateCount = -1;
- this.lastInsertId = -1;
- } else {
- this.updateCount = this.results.getUpdateCount();
- this.lastInsertId = this.results.getUpdateID();
- }
-
- return ((this.results != null) && this.results.reallyResult()) ? true
- : false;
- }
-
- /**
- * The queryTimeout limit is the number of seconds the driver will wait for
- * a Statement to execute. If the limit is exceeded, a SQLException is
- * thrown.
- *
- * @return the current query timeout limit in seconds; 0 = unlimited
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public int getQueryTimeout() throws SQLException {
- return this.timeoutInMillis / 1000;
- }
-
- /**
- * Parses actual record count from 'info' message
- *
- * @param serverInfo
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- private int getRecordCountFromInfo(String serverInfo) {
- StringBuffer recordsBuf = new StringBuffer();
- int recordsCount = 0;
- int duplicatesCount = 0;
-
- char c = (char) 0;
-
- int length = serverInfo.length();
- int i = 0;
-
- for (; i < length; i++) {
- c = serverInfo.charAt(i);
-
- if (Character.isDigit(c)) {
- break;
- }
- }
-
- recordsBuf.append(c);
- i++;
-
- for (; i < length; i++) {
- c = serverInfo.charAt(i);
-
- if (!Character.isDigit(c)) {
- break;
- }
-
- recordsBuf.append(c);
- }
-
- recordsCount = Integer.parseInt(recordsBuf.toString());
-
- StringBuffer duplicatesBuf = new StringBuffer();
-
- for (; i < length; i++) {
- c = serverInfo.charAt(i);
-
- if (Character.isDigit(c)) {
- break;
- }
- }
-
- duplicatesBuf.append(c);
- i++;
-
- for (; i < length; i++) {
- c = serverInfo.charAt(i);
-
- if (!Character.isDigit(c)) {
- break;
- }
-
- duplicatesBuf.append(c);
- }
-
- duplicatesCount = Integer.parseInt(duplicatesBuf.toString());
-
- return recordsCount - duplicatesCount;
- }
-
- /**
- * getResultSet returns the current result as a ResultSet. It should only be
- * called once per result.
- *
- * @return the current result set; null if there are no more
- *
- * @exception SQLException
- * if a database access error occurs (why?)
- */
- public java.sql.ResultSet getResultSet() throws SQLException {
- return ((this.results != null) && this.results.reallyResult()) ? (java.sql.ResultSet) this.results
- : null;
- }
-
- /**
- * JDBC 2.0 Determine the result set concurrency.
- *
- * @return CONCUR_UPDATABLE or CONCUR_READONLY
- *
- * @throws SQLException
- * if an error occurs
- */
- public int getResultSetConcurrency() throws SQLException {
- return this.resultSetConcurrency;
- }
-
- /**
- * @see StatementImpl#getResultSetHoldability()
- */
- public int getResultSetHoldability() throws SQLException {
- return java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
- }
-
- protected ResultSetInternalMethods getResultSetInternal() {
- return this.results;
- }
-
- /**
- * JDBC 2.0 Determine the result set type.
- *
- * @return the ResultSet type (SCROLL_SENSITIVE or SCROLL_INSENSITIVE)
- *
- * @throws SQLException
- * if an error occurs.
- */
- public int getResultSetType() throws SQLException {
- return this.resultSetType;
- }
-
- /**
- * getUpdateCount returns the current result as an update count, if the
- * result is a ResultSet or there are no more results, -1 is returned. It
- * should only be called once per result.
- *
- * @return the current result as an update count.
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public int getUpdateCount() throws SQLException {
- if (this.results == null) {
- return -1;
- }
-
- if (this.results.reallyResult()) {
- return -1;
- }
-
- int truncatedUpdateCount = 0;
-
- if (this.results.getUpdateCount() > Integer.MAX_VALUE) {
- truncatedUpdateCount = Integer.MAX_VALUE;
- } else {
- truncatedUpdateCount = (int) this.results.getUpdateCount();
- }
-
- return truncatedUpdateCount;
- }
-
- /**
- * The first warning reported by calls on this Statement is returned. A
- * Statement's execute methods clear its java.sql.SQLWarning chain.
- * Subsequent Statement warnings will be chained to this
- * java.sql.SQLWarning.
- *
- *
- * The Warning chain is automatically cleared each time a statement is
- * (re)executed.
- *
- *
- *
- * Note: If you are processing a ResultSet then any warnings
- * associated with ResultSet reads will be chained on the ResultSet object.
- *
- *
- * @return the first java.sql.SQLWarning or null
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public java.sql.SQLWarning getWarnings() throws SQLException {
- checkClosed();
-
- if (this.connection != null && !this.connection.isClosed()
- && this.connection.versionMeetsMinimum(4, 1, 0)) {
- SQLWarning pendingWarningsFromServer = SQLError
- .convertShowWarningsToSQLWarnings(this.connection);
-
- if (this.warningChain != null) {
- this.warningChain.setNextWarning(pendingWarningsFromServer);
- } else {
- this.warningChain = pendingWarningsFromServer;
- }
-
- return this.warningChain;
- }
-
- return this.warningChain;
- }
-
- /**
- * Closes this statement, and frees resources.
- *
- * @param calledExplicitly
- * was this called from close()?
- *
- * @throws SQLException
- * if an error occurs
- */
- protected synchronized void realClose(boolean calledExplicitly, boolean closeOpenResults)
- throws SQLException {
- if (this.isClosed) {
- return;
- }
-
- if (this.useUsageAdvisor) {
- if (!calledExplicitly) {
- String message = Messages.getString("Statement.63") //$NON-NLS-1$
- + Messages.getString("Statement.64"); //$NON-NLS-1$
-
- this.eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN,
- "", //$NON-NLS-1$
- this.currentCatalog, this.connectionId, this.getId(),
- -1, System.currentTimeMillis(), 0,
- Constants.MILLIS_I18N, null, this.pointOfOrigin,
- message));
- }
- }
-
- if (closeOpenResults) {
- closeOpenResults = !this.holdResultsOpenOverClose;
- }
-
- if (closeOpenResults) {
- if (this.results != null) {
-
- try {
- this.results.close();
- } catch (Exception ex) {
- ;
- }
- }
-
- closeAllOpenResults();
- }
-
- if (this.connection != null) {
- if (this.maxRowsChanged) {
- this.connection.unsetMaxRows(this);
- }
-
- if (!this.connection.getDontTrackOpenResources()) {
- this.connection.unregisterStatement(this);
- }
- }
-
- this.isClosed = true;
-
- this.results = null;
- this.connection = null;
- this.warningChain = null;
- this.openResults = null;
- this.batchedGeneratedKeys = null;
- this.localInfileInputStream = null;
- this.pingTarget = null;
- }
-
- /**
- * setCursorName defines the SQL cursor name that will be used by subsequent
- * execute methods. This name can then be used in SQL positioned
- * update/delete statements to identify the current row in the ResultSet
- * generated by this statement. If a database doesn't support positioned
- * update/delete, this method is a no-op.
- *
- *
- * Note: This MySQL driver does not support cursors.
- *
- *
- * @param name
- * the new cursor name
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setCursorName(String name) throws SQLException {
- // No-op
- }
-
- /**
- * If escape scanning is on (the default), the driver will do escape
- * substitution before sending the SQL to the database.
- *
- * @param enable
- * true to enable; false to disable
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setEscapeProcessing(boolean enable)
- throws SQLException {
- this.doEscapeProcessing = enable;
- }
-
- /**
- * JDBC 2.0 Give a hint as to the direction in which the rows in a result
- * set will be processed. The hint applies only to result sets created using
- * this Statement object. The default value is ResultSet.FETCH_FORWARD.
- *
- * @param direction
- * the initial direction for processing rows
- *
- * @exception SQLException
- * if a database-access error occurs or direction is not one
- * of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or
- * ResultSet.FETCH_UNKNOWN
- */
- public void setFetchDirection(int direction) throws SQLException {
- switch (direction) {
- case java.sql.ResultSet.FETCH_FORWARD:
- case java.sql.ResultSet.FETCH_REVERSE:
- case java.sql.ResultSet.FETCH_UNKNOWN:
- break;
-
- default:
- throw SQLError.createSQLException(
- Messages.getString("Statement.5"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
- }
-
- /**
- * JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should
- * be fetched from the database when more rows are needed. The number of
- * rows specified only affects result sets created using this statement. If
- * the value specified is zero, then the hint is ignored. The default value
- * is zero.
- *
- * @param rows
- * the number of rows to fetch
- *
- * @exception SQLException
- * if a database-access error occurs, or the condition 0
- * <= rows <= this.getMaxRows() is not satisfied.
- */
- public void setFetchSize(int rows) throws SQLException {
- if (((rows < 0) && (rows != Integer.MIN_VALUE))
- || ((this.maxRows != 0) && (this.maxRows != -1) && (rows > this
- .getMaxRows()))) {
- throw SQLError.createSQLException(
- Messages.getString("Statement.7"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- this.fetchSize = rows;
- }
-
- protected void setHoldResultsOpenOverClose(boolean holdResultsOpenOverClose) {
- this.holdResultsOpenOverClose = holdResultsOpenOverClose;
- }
-
- /**
- * Sets the maxFieldSize
- *
- * @param max
- * the new max column size limit; zero means unlimited
- *
- * @exception SQLException
- * if size exceeds buffer size
- */
- public void setMaxFieldSize(int max) throws SQLException {
- if (max < 0) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.11"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- int maxBuf = (this.connection != null) ? this.connection
- .getMaxAllowedPacket() : MysqlIO.getMaxBuf();
-
- if (max > maxBuf) {
- throw SQLError.createSQLException(Messages.getString(
- "Statement.13", //$NON-NLS-1$
- new Object[] { Constants.longValueOf(maxBuf) }), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- this.maxFieldSize = max;
- }
-
- /**
- * Set the maximum number of rows
- *
- * @param max
- * the new max rows limit; zero means unlimited
- *
- * @exception SQLException
- * if a database access error occurs
- *
- * @see getMaxRows
- */
- public void setMaxRows(int max) throws SQLException {
- if ((max > MysqlDefs.MAX_ROWS) || (max < 0)) {
- throw SQLError
- .createSQLException(
- Messages.getString("Statement.15") + max //$NON-NLS-1$
- + " > " //$NON-NLS-1$ //$NON-NLS-2$
- + MysqlDefs.MAX_ROWS + ".", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (max == 0) {
- max = -1;
- }
-
- this.maxRows = max;
- this.maxRowsChanged = true;
-
- if (this.maxRows == -1) {
- this.connection.unsetMaxRows(this);
- this.maxRowsChanged = false;
- } else {
- // Most people don't use setMaxRows()
- // so don't penalize them
- // with the extra query it takes
- // to do it efficiently unless we need
- // to.
- this.connection.maxRowsChanged(this);
- }
- }
-
- /**
- * Sets the queryTimeout limit
- *
- * @param seconds -
- * the new query timeout limit in seconds
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public void setQueryTimeout(int seconds) throws SQLException {
- if (seconds < 0) {
- throw SQLError.createSQLException(Messages
- .getString("Statement.21"), //$NON-NLS-1$
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- this.timeoutInMillis = seconds * 1000;
- }
-
- /**
- * Sets the concurrency for result sets generated by this statement
- *
- * @param concurrencyFlag
- * DOCUMENT ME!
- */
- void setResultSetConcurrency(int concurrencyFlag) {
- this.resultSetConcurrency = concurrencyFlag;
- }
-
- /**
- * Sets the result set type for result sets generated by this statement
- *
- * @param typeFlag
- * DOCUMENT ME!
- */
- void setResultSetType(int typeFlag) {
- this.resultSetType = typeFlag;
- }
-
- protected void getBatchedGeneratedKeys(java.sql.Statement batchedStatement) throws SQLException {
- if (this.retrieveGeneratedKeys) {
- java.sql.ResultSet rs = null;
-
- try {
- rs = batchedStatement.getGeneratedKeys();
-
- while (rs.next()) {
- this.batchedGeneratedKeys
- .add(new ByteArrayRow(new byte[][] { rs.getBytes(1) }, getExceptionInterceptor()));
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
- }
- }
-
- protected void getBatchedGeneratedKeys(int maxKeys) throws SQLException {
- if (this.retrieveGeneratedKeys) {
- java.sql.ResultSet rs = null;
-
- try {
- if (maxKeys == 0)
- rs = getGeneratedKeysInternal();
- else
- rs = getGeneratedKeysInternal(maxKeys);
-
- while (rs.next()) {
- this.batchedGeneratedKeys
- .add(new ByteArrayRow(new byte[][] { rs.getBytes(1) }, getExceptionInterceptor()));
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- }
- }
- }
-
- /**
- * @return
- */
- private boolean useServerFetch() throws SQLException {
-
- return this.connection.isCursorFetchEnabled() && this.fetchSize > 0
- && this.resultSetConcurrency == ResultSet.CONCUR_READ_ONLY
- && this.resultSetType == ResultSet.TYPE_FORWARD_ONLY;
- }
-
- public synchronized boolean isClosed() throws SQLException {
- return this.isClosed;
- }
-
- private boolean isPoolable = true;
-
- public boolean isPoolable() throws SQLException {
- return this.isPoolable;
- }
-
- public void setPoolable(boolean poolable) throws SQLException {
- this.isPoolable = poolable;
- }
-
- /**
- * Returns true if this either implements the interface argument or is directly or indirectly a wrapper
- * for an object that does. Returns false otherwise. If this implements the interface then return true,
- * else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
- * object. If this does not implement the interface and is not a wrapper, return false.
- * This method should be implemented as a low-cost operation compared to unwrap so that
- * callers can use this method to avoid expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument should succeed.
- *
- * @param interfaces a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly wraps an object that does.
- * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
- * for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class iface) throws SQLException {
- checkClosed();
-
- // This works for classes that aren't actually wrapping
- // anything
- return iface.isInstance(this);
- }
-
- /**
- * Returns an object that implements the given interface to allow access to non-standard methods,
- * or standard methods not exposed by the proxy.
- * The result may be either the object found to implement the interface or a proxy for that object.
- * If the receiver implements the interface then that is the object. If the receiver is a wrapper
- * and the wrapped object implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped object. If the receiver is not a
- * wrapper and does not implement the interface, then an SQLException is thrown.
- *
- * @param iface A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the actual implementing object.
- * @throws java.sql.SQLException If no object found that implements the interface
- * @since 1.6
- */
- public Object unwrap(Class iface) throws java.sql.SQLException {
- try {
- // This works for classes that aren't actually wrapping
- // anything
- return Util.cast(iface, this);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
- }
- }
-
- protected int findStartOfStatement(String sql) {
- int statementStartPos = 0;
-
- if (StringUtils.startsWithIgnoreCaseAndWs(sql, "/*")) {
- statementStartPos = sql.indexOf("*/");
-
- if (statementStartPos == -1) {
- statementStartPos = 0;
- } else {
- statementStartPos += 2;
- }
- } else if (StringUtils.startsWithIgnoreCaseAndWs(sql, "--")
- || StringUtils.startsWithIgnoreCaseAndWs(sql, "#")) {
- statementStartPos = sql.indexOf('\n');
-
- if (statementStartPos == -1) {
- statementStartPos = sql.indexOf('\r');
-
- if (statementStartPos == -1) {
- statementStartPos = 0;
- }
- }
- }
-
- return statementStartPos;
- }
-
- private InputStream localInfileInputStream;
-
- public synchronized InputStream getLocalInfileInputStream() {
- return this.localInfileInputStream;
- }
-
- public synchronized void setLocalInfileInputStream(InputStream stream) {
- this.localInfileInputStream = stream;
- }
-
- public synchronized void setPingTarget(PingTarget pingTarget) {
- this.pingTarget = pingTarget;
- }
-
- public ExceptionInterceptor getExceptionInterceptor() {
- return this.exceptionInterceptor;
- }
-
- protected boolean containsOnDuplicateKeyInString(String sql) {
- return getOnDuplicateKeyLocation(sql) != -1;
- }
-
- protected int getOnDuplicateKeyLocation(String sql) {
- return StringUtils.indexOfIgnoreCaseRespectMarker(0,
- sql, " ON DUPLICATE KEY UPDATE ", "\"'`", "\"'`", !this.connection.isNoBackslashEscapesSet());
- }
-}
diff --git a/src/com/mysql/jdbc/StatementInterceptor.java b/src/com/mysql/jdbc/StatementInterceptor.java
deleted file mode 100644
index 42af4794a..000000000
--- a/src/com/mysql/jdbc/StatementInterceptor.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc;
-
-import java.sql.SQLException;
-import java.util.Properties;
-
-/**
- * Implement this interface to be placed "in between" query execution, so that
- * you can influence it. (currently experimental).
- *
- * StatementInterceptors are "chainable" when configured by the user, the
- * results returned by the "current" interceptor will be passed on to the next
- * on in the chain, from left-to-right order, as specified by the user in the
- * JDBC configuration property "statementInterceptors".
- *
- * @version $Id: $
- */
-
-public interface StatementInterceptor extends Extension {
-
- /**
- * Called once per connection that wants to use the interceptor
- *
- * The properties are the same ones passed in in the URL or arguments to
- * Driver.connect() or DriverManager.getConnection().
- *
- * @param conn the connection for which this interceptor is being created
- * @param props configuration values as passed to the connection. Note that
- * in order to support javax.sql.DataSources, configuration properties specific
- * to an interceptor must be passed via setURL() on the
- * DataSource. StatementInterceptor properties are not exposed via
- * accessor/mutator methods on DataSources.
- *
- * @throws SQLException should be thrown if the the StatementInterceptor
- * can not initialize itself.
- */
-
- public abstract void init(Connection conn, Properties props) throws SQLException;
-
- /**
- * Called before the given statement is going to be sent to the
- * server for processing.
- *
- * Interceptors are free to return a result set (which must implement the
- * interface com.mysql.jdbc.ResultSetInternalMethods), and if so,
- * the server will not execute the query, and the given result set will be
- * returned to the application instead.
- *
- * This method will be called while the connection-level mutex is held, so
- * it will only be called from one thread at a time.
- *
- * @param sql the SQL representation of the statement
- * @param interceptedStatement the actual statement instance being intercepted
- * @param connection the connection the statement is using (passed in to make
- * thread-safe implementations straightforward)
- *
- * @return a result set that should be returned to the application instead
- * of results that are created from actual execution of the intercepted
- * statement.
- *
- * @throws SQLException if an error occurs during execution
- *
- * @see com.mysql.jdbc.ResultSetInternalMethods
- */
-
- public abstract ResultSetInternalMethods preProcess(String sql,
- Statement interceptedStatement, Connection connection)
- throws SQLException;
-
- /**
- * Called after the given statement has been sent to the server
- * for processing.
- *
- * Interceptors are free to inspect the "original" result set, and if a
- * different result set is returned by the interceptor, it is used in place
- * of the "original" result set. (the result set returned by the interceptor
- * must implement the interface
- * com.mysql.jdbc.ResultSetInternalMethods).
- *
- * This method will be called while the connection-level mutex is held, so
- * it will only be called from one thread at a time.
- *
- * @param sql the SQL representation of the statement
- * @param interceptedStatement the actual statement instance being intercepted
- * @param connection the connection the statement is using (passed in to make
- * thread-safe implementations straightforward)
- *
- * @return a result set that should be returned to the application instead
- * of results that are created from actual execution of the intercepted
- * statement.
- *
- * @throws SQLException if an error occurs during execution
- *
- * @see com.mysql.jdbc.ResultSetInternalMethods
- */
- public abstract ResultSetInternalMethods postProcess(String sql,
- Statement interceptedStatement,
- ResultSetInternalMethods originalResultSet,
- Connection connection) throws SQLException;
-
- /**
- * Should the driver execute this interceptor only for the
- * "original" top-level query, and not put it in the execution
- * path for queries that may be executed from other interceptors?
- *
- * If an interceptor issues queries using the connection it was created for,
- * and does not return true for this method, it must ensure
- * that it does not cause infinite recursion.
- *
- * @return true if the driver should ensure that this interceptor is only
- * executed for the top-level "original" query.
- */
- public abstract boolean executeTopLevelOnly();
-
- /**
- * Called by the driver when this extension should release any resources
- * it is holding and cleanup internally before the connection is
- * closed.
- */
- public abstract void destroy();
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/StreamingNotifiable.java b/src/com/mysql/jdbc/StreamingNotifiable.java
deleted file mode 100644
index 5b8e3d9b2..000000000
--- a/src/com/mysql/jdbc/StreamingNotifiable.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc;
-
-public interface StreamingNotifiable {
-
- public abstract void setWasStreamingResults();
-
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/StringUtils.java b/src/com/mysql/jdbc/StringUtils.java
deleted file mode 100644
index 0cc534012..000000000
--- a/src/com/mysql/jdbc/StringUtils.java
+++ /dev/null
@@ -1,1696 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * Various utility methods for converting to/from byte arrays in the platform
- * encoding
- *
- * @author Mark Matthews
- */
-public class StringUtils {
-
- private static final int BYTE_RANGE = (1 + Byte.MAX_VALUE) - Byte.MIN_VALUE;
-
- private static byte[] allBytes = new byte[BYTE_RANGE];
-
- private static char[] byteToChars = new char[BYTE_RANGE];
-
- private static Method toPlainStringMethod;
-
- static final int WILD_COMPARE_MATCH_NO_WILD = 0;
-
- static final int WILD_COMPARE_MATCH_WITH_WILD = 1;
-
- static final int WILD_COMPARE_NO_MATCH = -1;
-
- static {
- for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
- allBytes[i - Byte.MIN_VALUE] = (byte) i;
- }
-
- String allBytesString = new String(allBytes, 0, Byte.MAX_VALUE
- - Byte.MIN_VALUE);
-
- int allBytesStringLen = allBytesString.length();
-
- for (int i = 0; (i < (Byte.MAX_VALUE - Byte.MIN_VALUE))
- && (i < allBytesStringLen); i++) {
- byteToChars[i] = allBytesString.charAt(i);
- }
-
- try {
- toPlainStringMethod = BigDecimal.class.getMethod("toPlainString",
- new Class[0]);
- } catch (NoSuchMethodException nsme) {
- // that's okay, we fallback to .toString()
- }
- }
-
- /**
- * Takes care of the fact that Sun changed the output of
- * BigDecimal.toString() between JDK-1.4 and JDK 5
- *
- * @param decimal
- * the big decimal to stringify
- *
- * @return a string representation of 'decimal'
- */
- public static String consistentToString(BigDecimal decimal) {
- if (decimal == null) {
- return null;
- }
-
- if (toPlainStringMethod != null) {
- try {
- return (String) toPlainStringMethod.invoke(decimal, null);
- } catch (InvocationTargetException invokeEx) {
- // that's okay, we fall-through to decimal.toString()
- } catch (IllegalAccessException accessEx) {
- // that's okay, we fall-through to decimal.toString()
- }
- }
-
- return decimal.toString();
- }
-
- /**
- * Dumps the given bytes to STDOUT as a hex dump (up to length bytes).
- *
- * @param byteBuffer
- * the data to print as hex
- * @param length
- * the number of bytes to print
- *
- * @return ...
- */
- public static final String dumpAsHex(byte[] byteBuffer, int length) {
- StringBuffer outputBuf = new StringBuffer(length * 4);
-
- int p = 0;
- int rows = length / 8;
-
- for (int i = 0; (i < rows) && (p < length); i++) {
- int ptemp = p;
-
- for (int j = 0; j < 8; j++) {
- String hexVal = Integer.toHexString(byteBuffer[ptemp] & 0xff);
-
- if (hexVal.length() == 1) {
- hexVal = "0" + hexVal; //$NON-NLS-1$
- }
-
- outputBuf.append(hexVal + " "); //$NON-NLS-1$
- ptemp++;
- }
-
- outputBuf.append(" "); //$NON-NLS-1$
-
- for (int j = 0; j < 8; j++) {
- int b = 0xff & byteBuffer[p];
-
- if (b > 32 && b < 127) {
- outputBuf.append((char) b + " "); //$NON-NLS-1$
- } else {
- outputBuf.append(". "); //$NON-NLS-1$
- }
-
- p++;
- }
-
- outputBuf.append("\n"); //$NON-NLS-1$
- }
-
- int n = 0;
-
- for (int i = p; i < length; i++) {
- String hexVal = Integer.toHexString(byteBuffer[i] & 0xff);
-
- if (hexVal.length() == 1) {
- hexVal = "0" + hexVal; //$NON-NLS-1$
- }
-
- outputBuf.append(hexVal + " "); //$NON-NLS-1$
- n++;
- }
-
- for (int i = n; i < 8; i++) {
- outputBuf.append(" "); //$NON-NLS-1$
- }
-
- outputBuf.append(" "); //$NON-NLS-1$
-
- for (int i = p; i < length; i++) {
- int b = 0xff & byteBuffer[i];
-
- if (b > 32 && b < 127) {
- outputBuf.append((char) b + " "); //$NON-NLS-1$
- } else {
- outputBuf.append(". "); //$NON-NLS-1$
- }
- }
-
- outputBuf.append("\n"); //$NON-NLS-1$
-
- return outputBuf.toString();
- }
-
- private static boolean endsWith(byte[] dataFrom, String suffix) {
- for (int i = 1; i <= suffix.length(); i++) {
- int dfOffset = dataFrom.length - i;
- int suffixOffset = suffix.length() - i;
- if (dataFrom[dfOffset] != suffix.charAt(suffixOffset)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Unfortunately, SJIS has 0x5c as a high byte in some of its double-byte
- * characters, so we need to escape it.
- *
- * @param origBytes
- * the original bytes in SJIS format
- * @param origString
- * the string that had .getBytes() called on it
- * @param offset
- * where to start converting from
- * @param length
- * how many characters to convert.
- *
- * @return byte[] with 0x5c escaped
- */
- public static byte[] escapeEasternUnicodeByteStream(byte[] origBytes,
- String origString, int offset, int length) {
- if ((origBytes == null) || (origBytes.length == 0)) {
- return origBytes;
- }
-
- int bytesLen = origBytes.length;
- int bufIndex = 0;
- int strIndex = 0;
-
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(bytesLen);
-
- while (true) {
- if (origString.charAt(strIndex) == '\\') {
- // write it out as-is
- bytesOut.write(origBytes[bufIndex++]);
-
- // bytesOut.write(origBytes[bufIndex++]);
- } else {
- // Grab the first byte
- int loByte = origBytes[bufIndex];
-
- if (loByte < 0) {
- loByte += 256; // adjust for signedness/wrap-around
- }
-
- // We always write the first byte
- bytesOut.write(loByte);
-
- //
- // The codepage characters in question exist between
- // 0x81-0x9F and 0xE0-0xFC...
- //
- // See:
- //
- // http://www.microsoft.com/GLOBALDEV/Reference/dbcs/932.htm
- //
- // Problematic characters in GBK
- //
- // U+905C : CJK UNIFIED IDEOGRAPH
- //
- // Problematic characters in Big5
- //
- // B9F0 = U+5C62 : CJK UNIFIED IDEOGRAPH
- //
- if (loByte >= 0x80) {
- if (bufIndex < (bytesLen - 1)) {
- int hiByte = origBytes[bufIndex + 1];
-
- if (hiByte < 0) {
- hiByte += 256; // adjust for signedness/wrap-around
- }
-
- // write the high byte here, and increment the index
- // for the high byte
- bytesOut.write(hiByte);
- bufIndex++;
-
- // escape 0x5c if necessary
- if (hiByte == 0x5C) {
- bytesOut.write(hiByte);
- }
- }
- } else if (loByte == 0x5c) {
- if (bufIndex < (bytesLen - 1)) {
- int hiByte = origBytes[bufIndex + 1];
-
- if (hiByte < 0) {
- hiByte += 256; // adjust for signedness/wrap-around
- }
-
- if (hiByte == 0x62) {
- // we need to escape the 0x5c
- bytesOut.write(0x5c);
- bytesOut.write(0x62);
- bufIndex++;
- }
- }
- }
-
- bufIndex++;
- }
-
- if (bufIndex >= bytesLen) {
- // we're done
- break;
- }
-
- strIndex++;
- }
-
- return bytesOut.toByteArray();
- }
-
- /**
- * Returns the first non whitespace char, converted to upper case
- *
- * @param searchIn
- * the string to search in
- *
- * @return the first non-whitespace character, upper cased.
- */
- public static char firstNonWsCharUc(String searchIn) {
- return firstNonWsCharUc(searchIn, 0);
- }
-
- public static char firstNonWsCharUc(String searchIn, int startAt) {
- if (searchIn == null) {
- return 0;
- }
-
- int length = searchIn.length();
-
- for (int i = startAt; i < length; i++) {
- char c = searchIn.charAt(i);
-
- if (!Character.isWhitespace(c)) {
- return Character.toUpperCase(c);
- }
- }
-
- return 0;
- }
-
- public static char firstAlphaCharUc(String searchIn, int startAt) {
- if (searchIn == null) {
- return 0;
- }
-
- int length = searchIn.length();
-
- for (int i = startAt; i < length; i++) {
- char c = searchIn.charAt(i);
-
- if (Character.isLetter(c)) {
- return Character.toUpperCase(c);
- }
- }
-
- return 0;
- }
-
- /**
- * Adds '+' to decimal numbers that are positive (MySQL doesn't understand
- * them otherwise
- *
- * @param dString
- * The value as a string
- *
- * @return String the string with a '+' added (if needed)
- */
- public static final String fixDecimalExponent(String dString) {
- int ePos = dString.indexOf("E"); //$NON-NLS-1$
-
- if (ePos == -1) {
- ePos = dString.indexOf("e"); //$NON-NLS-1$
- }
-
- if (ePos != -1) {
- if (dString.length() > (ePos + 1)) {
- char maybeMinusChar = dString.charAt(ePos + 1);
-
- if (maybeMinusChar != '-' && maybeMinusChar != '+') {
- StringBuffer buf = new StringBuffer(dString.length() + 1);
- buf.append(dString.substring(0, ePos + 1));
- buf.append('+');
- buf.append(dString.substring(ePos + 1, dString.length()));
- dString = buf.toString();
- }
- }
- }
-
- return dString;
- }
-
- public static final byte[] getBytes(char[] c,
- SingleByteCharsetConverter converter, String encoding,
- String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor)
- throws SQLException {
- try {
- byte[] b = null;
-
- if (converter != null) {
- b = converter.toBytes(c);
- } else if (encoding == null) {
- b = new String(c).getBytes();
- } else {
- String s = new String(c);
-
- b = s.getBytes(encoding);
-
- if (!parserKnowsUnicode && (encoding.equalsIgnoreCase("SJIS") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("BIG5") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("GBK"))) { //$NON-NLS-1$
-
- if (!encoding.equalsIgnoreCase(serverEncoding)) {
- b = escapeEasternUnicodeByteStream(b, s, 0, s.length());
- }
- }
- }
-
- return b;
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException(Messages.getString("StringUtils.5") //$NON-NLS-1$
- + encoding + Messages.getString("StringUtils.6"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); //$NON-NLS-1$
- }
- }
-
- public static final byte[] getBytes(char[] c,
- SingleByteCharsetConverter converter, String encoding,
- String serverEncoding, int offset, int length,
- boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) throws SQLException {
- try {
- byte[] b = null;
-
- if (converter != null) {
- b = converter.toBytes(c, offset, length);
- } else if (encoding == null) {
- byte[] temp = new String(c, offset, length).getBytes();
-
- length = temp.length;
-
- b = new byte[length];
- System.arraycopy(temp, 0, b, 0, length);
- } else {
- String s = new String(c, offset, length);
-
- byte[] temp = s.getBytes(encoding);
-
- length = temp.length;
-
- b = new byte[length];
- System.arraycopy(temp, 0, b, 0, length);
-
- if (!parserKnowsUnicode && (encoding.equalsIgnoreCase("SJIS") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("BIG5") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("GBK"))) { //$NON-NLS-1$
-
- if (!encoding.equalsIgnoreCase(serverEncoding)) {
- b = escapeEasternUnicodeByteStream(b, s, offset, length);
- }
- }
- }
-
- return b;
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException(Messages.getString("StringUtils.10") //$NON-NLS-1$
- + encoding + Messages.getString("StringUtils.11"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); //$NON-NLS-1$
- }
- }
-
- public static final byte[] getBytes(char[] c, String encoding,
- String serverEncoding, boolean parserKnowsUnicode,
- ConnectionImpl conn, ExceptionInterceptor exceptionInterceptor)
- throws SQLException {
- try {
-
- SingleByteCharsetConverter converter = null;
-
- if (conn != null) {
- converter = conn.getCharsetConverter(encoding);
- } else {
- converter = SingleByteCharsetConverter.getInstance(encoding, null);
- }
-
- return getBytes(c, converter, encoding, serverEncoding,
- parserKnowsUnicode, exceptionInterceptor);
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException(Messages.getString("StringUtils.0") //$NON-NLS-1$
- + encoding + Messages.getString("StringUtils.1"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the byte[] representation of the given string (re)using the given
- * charset converter, and the given encoding.
- *
- * @param s
- * the string to convert
- * @param converter
- * the converter to reuse
- * @param encoding
- * the character encoding to use
- * @param serverEncoding
- * DOCUMENT ME!
- * @param parserKnowsUnicode
- * DOCUMENT ME!
- *
- * @return byte[] representation of the string
- *
- * @throws SQLException
- * if an encoding unsupported by the JVM is supplied.
- */
- public static final byte[] getBytes(String s,
- SingleByteCharsetConverter converter, String encoding,
- String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor)
- throws SQLException {
- try {
- byte[] b = null;
-
- if (converter != null) {
- b = converter.toBytes(s);
- } else if (encoding == null) {
- b = s.getBytes();
- } else {
- b = s.getBytes(encoding);
-
- if (!parserKnowsUnicode && (encoding.equalsIgnoreCase("SJIS") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("BIG5") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("GBK"))) { //$NON-NLS-1$
-
- if (!encoding.equalsIgnoreCase(serverEncoding)) {
- b = escapeEasternUnicodeByteStream(b, s, 0, s.length());
- }
- }
- }
-
- return b;
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException(Messages.getString("StringUtils.5") //$NON-NLS-1$
- + encoding + Messages.getString("StringUtils.6"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); //$NON-NLS-1$
- }
- }
-
- public static final byte[] getBytesWrapped(String s, char beginWrap, char endWrap,
- SingleByteCharsetConverter converter, String encoding,
- String serverEncoding, boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor)
- throws SQLException {
- try {
- byte[] b = null;
-
- if (converter != null) {
- b = converter.toBytesWrapped(s, beginWrap, endWrap);
- } else if (encoding == null) {
- StringBuffer buf = new StringBuffer(s.length() + 2);
- buf.append(beginWrap);
- buf.append(s);
- buf.append(endWrap);
-
- b = buf.toString().getBytes();
- } else {
- StringBuffer buf = new StringBuffer(s.length() + 2);
- buf.append(beginWrap);
- buf.append(s);
- buf.append(endWrap);
-
- b = buf.toString().getBytes(encoding);
-
- if (!parserKnowsUnicode && (encoding.equalsIgnoreCase("SJIS") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("BIG5") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("GBK"))) { //$NON-NLS-1$
-
- if (!encoding.equalsIgnoreCase(serverEncoding)) {
- b = escapeEasternUnicodeByteStream(b, s, 0, s.length());
- }
- }
- }
-
- return b;
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException(Messages.getString("StringUtils.5") //$NON-NLS-1$
- + encoding + Messages.getString("StringUtils.6"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); //$NON-NLS-1$
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param s
- * DOCUMENT ME!
- * @param converter
- * DOCUMENT ME!
- * @param encoding
- * DOCUMENT ME!
- * @param serverEncoding
- * DOCUMENT ME!
- * @param offset
- * DOCUMENT ME!
- * @param length
- * DOCUMENT ME!
- * @param parserKnowsUnicode
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public static final byte[] getBytes(String s,
- SingleByteCharsetConverter converter, String encoding,
- String serverEncoding, int offset, int length,
- boolean parserKnowsUnicode, ExceptionInterceptor exceptionInterceptor) throws SQLException {
- try {
- byte[] b = null;
-
- if (converter != null) {
- b = converter.toBytes(s, offset, length);
- } else if (encoding == null) {
- byte[] temp = s.substring(offset, offset + length).getBytes();
-
- length = temp.length;
-
- b = new byte[length];
- System.arraycopy(temp, 0, b, 0, length);
- } else {
-
- byte[] temp = s.substring(offset, offset + length)
- .getBytes(encoding);
-
- length = temp.length;
-
- b = new byte[length];
- System.arraycopy(temp, 0, b, 0, length);
-
- if (!parserKnowsUnicode && (encoding.equalsIgnoreCase("SJIS") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("BIG5") //$NON-NLS-1$
- || encoding.equalsIgnoreCase("GBK"))) { //$NON-NLS-1$
-
- if (!encoding.equalsIgnoreCase(serverEncoding)) {
- b = escapeEasternUnicodeByteStream(b, s, offset, length);
- }
- }
- }
-
- return b;
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException(Messages.getString("StringUtils.10") //$NON-NLS-1$
- + encoding + Messages.getString("StringUtils.11"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); //$NON-NLS-1$
- }
- }
-
- /**
- * Returns the byte[] representation of the given string using given
- * encoding.
- *
- * @param s
- * the string to convert
- * @param encoding
- * the character encoding to use
- * @param parserKnowsUnicode
- * DOCUMENT ME!
- *
- * @return byte[] representation of the string
- *
- * @throws SQLException
- * if an encoding unsupported by the JVM is supplied.
- */
- public static final byte[] getBytes(String s, String encoding,
- String serverEncoding, boolean parserKnowsUnicode,
- ConnectionImpl conn, ExceptionInterceptor exceptionInterceptor)
- throws SQLException {
- try {
- SingleByteCharsetConverter converter = null;
-
- if (conn != null) {
- converter = conn.getCharsetConverter(encoding);
- } else {
- converter = SingleByteCharsetConverter.getInstance(encoding, null);
- }
-
- return getBytes(s, converter, encoding, serverEncoding,
- parserKnowsUnicode, exceptionInterceptor);
- } catch (UnsupportedEncodingException uee) {
- throw SQLError.createSQLException(Messages.getString("StringUtils.0") //$NON-NLS-1$
- + encoding + Messages.getString("StringUtils.1"),
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor); //$NON-NLS-1$
- }
- }
-
- public static int getInt(byte[] buf, int offset, int endPos) throws NumberFormatException {
- int base = 10;
-
- int s = offset;
-
- /* Skip white space. */
- while (Character.isWhitespace((char) buf[s]) && (s < endPos)) {
- ++s;
- }
-
- if (s == endPos) {
- throw new NumberFormatException(new String(buf));
- }
-
- /* Check for a sign. */
- boolean negative = false;
-
- if ((char) buf[s] == '-') {
- negative = true;
- ++s;
- } else if ((char) buf[s] == '+') {
- ++s;
- }
-
- /* Save the pointer so we can check later if anything happened. */
- int save = s;
-
- int cutoff = Integer.MAX_VALUE / base;
- int cutlim = (Integer.MAX_VALUE % base);
-
- if (negative) {
- cutlim++;
- }
-
- boolean overflow = false;
-
- int i = 0;
-
- for (; s < endPos; s++) {
- char c = (char) buf[s];
-
- if (Character.isDigit(c)) {
- c -= '0';
- } else if (Character.isLetter(c)) {
- c = (char) (Character.toUpperCase(c) - 'A' + 10);
- } else {
- break;
- }
-
- if (c >= base) {
- break;
- }
-
- /* Check for overflow. */
- if ((i > cutoff) || ((i == cutoff) && (c > cutlim))) {
- overflow = true;
- } else {
- i *= base;
- i += c;
- }
- }
-
- if (s == save) {
- throw new NumberFormatException(new String(buf));
- }
-
- if (overflow) {
- throw new NumberFormatException(new String(buf));
- }
-
- /* Return the result of the appropriate sign. */
- return (negative ? (-i) : i);
- }
-
- public static int getInt(byte[] buf) throws NumberFormatException {
- return getInt(buf, 0, buf.length);
- }
-
- public static long getLong(byte[] buf) throws NumberFormatException {
- return getLong(buf, 0, buf.length);
- }
-
- public static long getLong(byte[] buf, int offset, int endpos) throws NumberFormatException {
- int base = 10;
-
- int s = offset;
-
- /* Skip white space. */
- while (Character.isWhitespace((char) buf[s]) && (s < endpos)) {
- ++s;
- }
-
- if (s == endpos) {
- throw new NumberFormatException(new String(buf));
- }
-
- /* Check for a sign. */
- boolean negative = false;
-
- if ((char) buf[s] == '-') {
- negative = true;
- ++s;
- } else if ((char) buf[s] == '+') {
- ++s;
- }
-
- /* Save the pointer so we can check later if anything happened. */
- int save = s;
-
- long cutoff = Long.MAX_VALUE / base;
- long cutlim = (int) (Long.MAX_VALUE % base);
-
- if (negative) {
- cutlim++;
- }
-
- boolean overflow = false;
- long i = 0;
-
- for (; s < endpos; s++) {
- char c = (char) buf[s];
-
- if (Character.isDigit(c)) {
- c -= '0';
- } else if (Character.isLetter(c)) {
- c = (char) (Character.toUpperCase(c) - 'A' + 10);
- } else {
- break;
- }
-
- if (c >= base) {
- break;
- }
-
- /* Check for overflow. */
- if ((i > cutoff) || ((i == cutoff) && (c > cutlim))) {
- overflow = true;
- } else {
- i *= base;
- i += c;
- }
- }
-
- if (s == save) {
- throw new NumberFormatException(new String(buf));
- }
-
- if (overflow) {
- throw new NumberFormatException(new String(buf));
- }
-
- /* Return the result of the appropriate sign. */
- return (negative ? (-i) : i);
- }
-
- public static short getShort(byte[] buf) throws NumberFormatException {
- short base = 10;
-
- int s = 0;
-
- /* Skip white space. */
- while (Character.isWhitespace((char) buf[s]) && (s < buf.length)) {
- ++s;
- }
-
- if (s == buf.length) {
- throw new NumberFormatException(new String(buf));
- }
-
- /* Check for a sign. */
- boolean negative = false;
-
- if ((char) buf[s] == '-') {
- negative = true;
- ++s;
- } else if ((char) buf[s] == '+') {
- ++s;
- }
-
- /* Save the pointer so we can check later if anything happened. */
- int save = s;
-
- short cutoff = (short) (Short.MAX_VALUE / base);
- short cutlim = (short) (Short.MAX_VALUE % base);
-
- if (negative) {
- cutlim++;
- }
-
- boolean overflow = false;
- short i = 0;
-
- for (; s < buf.length; s++) {
- char c = (char) buf[s];
-
- if (Character.isDigit(c)) {
- c -= '0';
- } else if (Character.isLetter(c)) {
- c = (char) (Character.toUpperCase(c) - 'A' + 10);
- } else {
- break;
- }
-
- if (c >= base) {
- break;
- }
-
- /* Check for overflow. */
- if ((i > cutoff) || ((i == cutoff) && (c > cutlim))) {
- overflow = true;
- } else {
- i *= base;
- i += c;
- }
- }
-
- if (s == save) {
- throw new NumberFormatException(new String(buf));
- }
-
- if (overflow) {
- throw new NumberFormatException(new String(buf));
- }
-
- /* Return the result of the appropriate sign. */
- return (negative ? (short) -i : (short) i);
- }
-
- public final static int indexOfIgnoreCase(int startingPosition,
- String searchIn, String searchFor) {
- if ((searchIn == null) || (searchFor == null)
- || startingPosition > searchIn.length()) {
- return -1;
- }
-
- int patternLength = searchFor.length();
- int stringLength = searchIn.length();
- int stopSearchingAt = stringLength - patternLength;
-
- if (patternLength == 0) {
- return -1;
- }
-
- // Brute force string pattern matching
- // Some locales don't follow upper-case rule, so need to check both
- char firstCharOfPatternUc = Character.toUpperCase(searchFor.charAt(0));
- char firstCharOfPatternLc = Character.toLowerCase(searchFor.charAt(0));
-
- // note, this also catches the case where patternLength > stringLength
- for (int i = startingPosition; i <= stopSearchingAt; i++) {
- if (isNotEqualIgnoreCharCase(searchIn, firstCharOfPatternUc,
- firstCharOfPatternLc, i)) {
- // find the first occurrence of the first character of searchFor in searchIn
- while (++i <= stopSearchingAt && (isNotEqualIgnoreCharCase(searchIn, firstCharOfPatternUc,
- firstCharOfPatternLc, i)));
- }
-
- if (i <= stopSearchingAt /* searchFor might be one character long! */) {
- // walk searchIn and searchFor in lock-step starting just past the first match,bail out if not
- // a match, or we've hit the end of searchFor...
- int j = i + 1;
- int end = j + patternLength - 1;
- for (int k = 1; j < end && (Character.toLowerCase(searchIn.charAt(j)) ==
- Character.toLowerCase(searchFor.charAt(k)) || Character.toUpperCase(searchIn.charAt(j)) ==
- Character.toUpperCase(searchFor.charAt(k))); j++, k++);
-
- if (j == end) {
- return i;
- }
- }
- }
-
- return -1;
- }
-
- private final static boolean isNotEqualIgnoreCharCase(String searchIn,
- char firstCharOfPatternUc, char firstCharOfPatternLc, int i) {
- return Character.toLowerCase(searchIn.charAt(i)) != firstCharOfPatternLc && Character.toUpperCase(searchIn.charAt(i)) != firstCharOfPatternUc;
- }
-
-
- /**
- * DOCUMENT ME!
- *
- * @param searchIn
- * DOCUMENT ME!
- * @param searchFor
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public final static int indexOfIgnoreCase(String searchIn, String searchFor) {
- return indexOfIgnoreCase(0, searchIn, searchFor);
- }
-
- public static int indexOfIgnoreCaseRespectMarker(int startAt, String src,
- String target, String marker, String markerCloses,
- boolean allowBackslashEscapes) {
- char contextMarker = Character.MIN_VALUE;
- boolean escaped = false;
- int markerTypeFound = 0;
- int srcLength = src.length();
- int ind = 0;
-
- for (int i = startAt; i < srcLength; i++) {
- char c = src.charAt(i);
-
- if (allowBackslashEscapes && c == '\\') {
- escaped = !escaped;
- } else if (c == markerCloses.charAt(markerTypeFound) && !escaped) {
- contextMarker = Character.MIN_VALUE;
- } else if ((ind = marker.indexOf(c)) != -1 && !escaped
- && contextMarker == Character.MIN_VALUE) {
- markerTypeFound = ind;
- contextMarker = c;
- } else if ((Character.toUpperCase(c) == Character.toUpperCase(target.charAt(0)) ||
- Character.toLowerCase(c) == Character.toLowerCase(target.charAt(0))) && !escaped
- && contextMarker == Character.MIN_VALUE) {
- if (startsWithIgnoreCase(src, i, target))
- return i;
- }
- }
-
- return -1;
-
- }
-
- public static int indexOfIgnoreCaseRespectQuotes(int startAt, String src,
- String target, char quoteChar, boolean allowBackslashEscapes) {
- char contextMarker = Character.MIN_VALUE;
- boolean escaped = false;
-
- int srcLength = src.length();
-
- for (int i = startAt; i < srcLength; i++) {
- char c = src.charAt(i);
-
- if (allowBackslashEscapes && c == '\\') {
- escaped = !escaped;
- } else if (c == contextMarker && !escaped) {
- contextMarker = Character.MIN_VALUE;
- } else if (c == quoteChar && !escaped
- && contextMarker == Character.MIN_VALUE) {
- contextMarker = c;
- // This test looks complex, but remember that in certain locales, upper case
- // of two different codepoints coverts to same codepoint, and vice-versa.
- } else if ((Character.toUpperCase(c) == Character.toUpperCase(target.charAt(0)) ||
- Character.toLowerCase(c) == Character.toLowerCase(target.charAt(0))) && !escaped
- && contextMarker == Character.MIN_VALUE) {
- if (startsWithIgnoreCase(src, i, target))
- return i;
- }
- }
-
- return -1;
-
- }
-
- /**
- * Splits stringToSplit into a list, using the given delimitter
- *
- * @param stringToSplit
- * the string to split
- * @param delimitter
- * the string to split on
- * @param trim
- * should the split strings be whitespace trimmed?
- *
- * @return the list of strings, split by delimitter
- *
- * @throws IllegalArgumentException
- * DOCUMENT ME!
- */
- public static final List split(String stringToSplit, String delimitter,
- boolean trim) {
- if (stringToSplit == null) {
- return new ArrayList();
- }
-
- if (delimitter == null) {
- throw new IllegalArgumentException();
- }
-
- StringTokenizer tokenizer = new StringTokenizer(stringToSplit,
- delimitter, false);
-
- List splitTokens = new ArrayList(tokenizer.countTokens());
-
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
-
- if (trim) {
- token = token.trim();
- }
-
- splitTokens.add(token);
- }
-
- return splitTokens;
- }
-
- /**
- * Splits stringToSplit into a list, using the given delimitter
- *
- * @param stringToSplit
- * the string to split
- * @param delimitter
- * the string to split on
- * @param trim
- * should the split strings be whitespace trimmed?
- *
- * @return the list of strings, split by delimiter
- *
- * @throws IllegalArgumentException
- * DOCUMENT ME!
- */
- public static final List split(String stringToSplit, String delimiter,
- String markers, String markerCloses, boolean trim) {
- if (stringToSplit == null) {
- return new ArrayList();
- }
-
- if (delimiter == null) {
- throw new IllegalArgumentException();
- }
-
- int delimPos = 0;
- int currentPos = 0;
-
- List splitTokens = new ArrayList();
-
- while ((delimPos = indexOfIgnoreCaseRespectMarker(currentPos,
- stringToSplit, delimiter, markers, markerCloses, false)) != -1) {
- String token = stringToSplit.substring(currentPos, delimPos);
-
- if (trim) {
- token = token.trim();
- }
-
- splitTokens.add(token);
- currentPos = delimPos + 1;
- }
-
- if (currentPos < stringToSplit.length()) {
- String token = stringToSplit.substring(currentPos);
-
- if (trim) {
- token = token.trim();
- }
-
- splitTokens.add(token);
- }
-
- return splitTokens;
- }
-
- private static boolean startsWith(byte[] dataFrom, String chars) {
- for (int i = 0; i < chars.length(); i++) {
- if (dataFrom[i] != chars.charAt(i)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Determines whether or not the string 'searchIn' contains the string
- * 'searchFor', dis-regarding case starting at 'startAt' Shorthand for a
- * String.regionMatch(...)
- *
- * @param searchIn
- * the string to search in
- * @param startAt
- * the position to start at
- * @param searchFor
- * the string to search for
- *
- * @return whether searchIn starts with searchFor, ignoring case
- */
- public static boolean startsWithIgnoreCase(String searchIn, int startAt,
- String searchFor) {
- return searchIn.regionMatches(true, startAt, searchFor, 0, searchFor
- .length());
- }
-
- /**
- * Determines whether or not the string 'searchIn' contains the string
- * 'searchFor', dis-regarding case. Shorthand for a String.regionMatch(...)
- *
- * @param searchIn
- * the string to search in
- * @param searchFor
- * the string to search for
- *
- * @return whether searchIn starts with searchFor, ignoring case
- */
- public static boolean startsWithIgnoreCase(String searchIn, String searchFor) {
- return startsWithIgnoreCase(searchIn, 0, searchFor);
- }
-
- /**
- * Determines whether or not the sting 'searchIn' contains the string
- * 'searchFor', disregarding case,leading whitespace and non-alphanumeric
- * characters.
- *
- * @param searchIn
- * the string to search in
- * @param searchFor
- * the string to search for
- *
- * @return true if the string starts with 'searchFor' ignoring whitespace
- */
- public static boolean startsWithIgnoreCaseAndNonAlphaNumeric(
- String searchIn, String searchFor) {
- if (searchIn == null) {
- return searchFor == null;
- }
-
- int beginPos = 0;
-
- int inLength = searchIn.length();
-
- for (beginPos = 0; beginPos < inLength; beginPos++) {
- char c = searchIn.charAt(beginPos);
-
- if (Character.isLetterOrDigit(c)) {
- break;
- }
- }
-
- return startsWithIgnoreCase(searchIn, beginPos, searchFor);
- }
-
- /**
- * Determines whether or not the sting 'searchIn' contains the string
- * 'searchFor', disregarding case and leading whitespace
- *
- * @param searchIn
- * the string to search in
- * @param searchFor
- * the string to search for
- *
- * @return true if the string starts with 'searchFor' ignoring whitespace
- */
- public static boolean startsWithIgnoreCaseAndWs(String searchIn,
- String searchFor) {
- return startsWithIgnoreCaseAndWs(searchIn, searchFor, 0);
- }
-
- /**
- * Determines whether or not the sting 'searchIn' contains the string
- * 'searchFor', disregarding case and leading whitespace
- *
- * @param searchIn
- * the string to search in
- * @param searchFor
- * the string to search for
- * @param beginPos
- * where to start searching
- *
- * @return true if the string starts with 'searchFor' ignoring whitespace
- */
-
- public static boolean startsWithIgnoreCaseAndWs(String searchIn,
- String searchFor, int beginPos) {
- if (searchIn == null) {
- return searchFor == null;
- }
-
- int inLength = searchIn.length();
-
- for (; beginPos < inLength; beginPos++) {
- if (!Character.isWhitespace(searchIn.charAt(beginPos))) {
- break;
- }
- }
-
- return startsWithIgnoreCase(searchIn, beginPos, searchFor);
- }
-
- /**
- * @param bytesToStrip
- * @param prefix
- * @param suffix
- * @return
- */
- public static byte[] stripEnclosure(byte[] source, String prefix,
- String suffix) {
- if (source.length >= prefix.length() + suffix.length()
- && startsWith(source, prefix) && endsWith(source, suffix)) {
-
- int totalToStrip = prefix.length() + suffix.length();
- int enclosedLength = source.length - totalToStrip;
- byte[] enclosed = new byte[enclosedLength];
-
- int startPos = prefix.length();
- int numToCopy = enclosed.length;
- System.arraycopy(source, startPos, enclosed, 0, numToCopy);
-
- return enclosed;
- }
- return source;
- }
-
- /**
- * Returns the bytes as an ASCII String.
- *
- * @param buffer
- * the bytes representing the string
- *
- * @return The ASCII String.
- */
- public static final String toAsciiString(byte[] buffer) {
- return toAsciiString(buffer, 0, buffer.length);
- }
-
- /**
- * Returns the bytes as an ASCII String.
- *
- * @param buffer
- * the bytes to convert
- * @param startPos
- * the position to start converting
- * @param length
- * the length of the string to convert
- *
- * @return the ASCII string
- */
- public static final String toAsciiString(byte[] buffer, int startPos,
- int length) {
- char[] charArray = new char[length];
- int readpoint = startPos;
-
- for (int i = 0; i < length; i++) {
- charArray[i] = (char) buffer[readpoint];
- readpoint++;
- }
-
- return new String(charArray);
- }
-
- /**
- * Compares searchIn against searchForWildcard with wildcards (heavily
- * borrowed from strings/ctype-simple.c in the server sources)
- *
- * @param searchIn
- * the string to search in
- * @param searchForWildcard
- * the string to search for, using the 'standard' SQL wildcard
- * chars of '%' and '_'
- *
- * @return WILD_COMPARE_MATCH_NO_WILD if matched, WILD_COMPARE_NO_MATCH if
- * not matched with wildcard, WILD_COMPARE_MATCH_WITH_WILD if
- * matched with wildcard
- */
- public static int wildCompare(String searchIn, String searchForWildcard) {
- if ((searchIn == null) || (searchForWildcard == null)) {
- return WILD_COMPARE_NO_MATCH;
- }
-
- if (searchForWildcard.equals("%")) { //$NON-NLS-1$
-
- return WILD_COMPARE_MATCH_WITH_WILD;
- }
-
- int result = WILD_COMPARE_NO_MATCH; /* Not found, using wildcards */
-
- char wildcardMany = '%';
- char wildcardOne = '_';
- char wildcardEscape = '\\';
-
- int searchForPos = 0;
- int searchForEnd = searchForWildcard.length();
-
- int searchInPos = 0;
- int searchInEnd = searchIn.length();
-
- while (searchForPos != searchForEnd) {
- char wildstrChar = searchForWildcard.charAt(searchForPos);
-
- while ((searchForWildcard.charAt(searchForPos) != wildcardMany)
- && (wildstrChar != wildcardOne)) {
- if ((searchForWildcard.charAt(searchForPos) == wildcardEscape)
- && ((searchForPos + 1) != searchForEnd)) {
- searchForPos++;
- }
-
- if ((searchInPos == searchInEnd)
- || (Character.toUpperCase(searchForWildcard
- .charAt(searchForPos++)) != Character
- .toUpperCase(searchIn.charAt(searchInPos++)))) {
- return WILD_COMPARE_MATCH_WITH_WILD; /* No match */
- }
-
- if (searchForPos == searchForEnd) {
- return ((searchInPos != searchInEnd) ? WILD_COMPARE_MATCH_WITH_WILD
- : WILD_COMPARE_MATCH_NO_WILD); /*
- * Match if both are
- * at end
- */
- }
-
- result = WILD_COMPARE_MATCH_WITH_WILD; /* Found an anchor char */
- }
-
- if (searchForWildcard.charAt(searchForPos) == wildcardOne) {
- do {
- if (searchInPos == searchInEnd) { /*
- * Skip one char if
- * possible
- */
-
- return (result);
- }
-
- searchInPos++;
- } while ((++searchForPos < searchForEnd)
- && (searchForWildcard.charAt(searchForPos) == wildcardOne));
-
- if (searchForPos == searchForEnd) {
- break;
- }
- }
-
- if (searchForWildcard.charAt(searchForPos) == wildcardMany) { /*
- * Found
- * w_many
- */
-
- char cmp;
-
- searchForPos++;
-
- /* Remove any '%' and '_' from the wild search string */
- for (; searchForPos != searchForEnd; searchForPos++) {
- if (searchForWildcard.charAt(searchForPos) == wildcardMany) {
- continue;
- }
-
- if (searchForWildcard.charAt(searchForPos) == wildcardOne) {
- if (searchInPos == searchInEnd) {
- return (WILD_COMPARE_NO_MATCH);
- }
-
- searchInPos++;
-
- continue;
- }
-
- break; /* Not a wild character */
- }
-
- if (searchForPos == searchForEnd) {
- return WILD_COMPARE_MATCH_NO_WILD; /* Ok if w_many is last */
- }
-
- if (searchInPos == searchInEnd) {
- return WILD_COMPARE_NO_MATCH;
- }
-
- if (((cmp = searchForWildcard.charAt(searchForPos)) == wildcardEscape)
- && ((searchForPos + 1) != searchForEnd)) {
- cmp = searchForWildcard.charAt(++searchForPos);
- }
-
- searchForPos++;
-
- do {
- while ((searchInPos != searchInEnd)
- && (Character.toUpperCase(searchIn
- .charAt(searchInPos)) != Character
- .toUpperCase(cmp)))
- searchInPos++;
-
- if (searchInPos++ == searchInEnd) {
- return WILD_COMPARE_NO_MATCH;
- }
-
- {
- int tmp = wildCompare(searchIn, searchForWildcard);
-
- if (tmp <= 0) {
- return (tmp);
- }
- }
- } while ((searchInPos != searchInEnd)
- && (searchForWildcard.charAt(0) != wildcardMany));
-
- return WILD_COMPARE_NO_MATCH;
- }
- }
-
- return ((searchInPos != searchInEnd) ? WILD_COMPARE_MATCH_WITH_WILD
- : WILD_COMPARE_MATCH_NO_WILD);
- }
-
- static byte[] s2b(String s, ConnectionImpl conn) throws SQLException {
- if (s == null) {
- return null;
- }
-
- if ((conn != null) && conn.getUseUnicode()) {
- try {
- String encoding = conn.getEncoding();
-
- if (encoding == null) {
- return s.getBytes();
- }
-
- SingleByteCharsetConverter converter = conn
- .getCharsetConverter(encoding);
-
- if (converter != null) {
- return converter.toBytes(s);
- }
-
- return s.getBytes(encoding);
- } catch (java.io.UnsupportedEncodingException E) {
- return s.getBytes();
- }
- }
-
- return s.getBytes();
- }
-
- public static int lastIndexOf(byte[] s, char c) {
- if (s == null) {
- return -1;
- }
-
- for (int i = s.length - 1; i >= 0; i--) {
- if (s[i] == c) {
- return i;
- }
- }
-
- return -1;
- }
-
- public static int indexOf(byte[] s, char c) {
- if (s == null) {
- return -1;
- }
-
- int length = s.length;
-
- for (int i = 0; i < length; i++) {
- if (s[i] == c) {
- return i;
- }
- }
-
- return -1;
- }
-
- public static boolean isNullOrEmpty(String toTest) {
- return (toTest == null || toTest.length() == 0);
- }
-
- /**
- * Returns the given string, with comments removed
- *
- * @param src
- * the source string
- * @param stringOpens
- * characters which delimit the "open" of a string
- * @param stringCloses
- * characters which delimit the "close" of a string, in
- * counterpart order to stringOpens
- * @param slashStarComments
- * strip slash-star type "C" style comments
- * @param slashSlashComments
- * strip slash-slash C++ style comments to end-of-line
- * @param hashComments
- * strip #-style comments to end-of-line
- * @param dashDashComments
- * strip "--" style comments to end-of-line
- * @return the input string with all comment-delimited data removed
- */
- public static String stripComments(String src, String stringOpens,
- String stringCloses, boolean slashStarComments,
- boolean slashSlashComments, boolean hashComments,
- boolean dashDashComments) {
- if (src == null) {
- return null;
- }
-
- StringBuffer buf = new StringBuffer(src.length());
-
- // It's just more natural to deal with this as a stream
- // when parsing..This code is currently only called when
- // parsing the kind of metadata that developers are strongly
- // recommended to cache anyways, so we're not worried
- // about the _1_ extra object allocation if it cleans
- // up the code
-
- StringReader sourceReader = new StringReader(src);
-
- int contextMarker = Character.MIN_VALUE;
- boolean escaped = false;
- int markerTypeFound = -1;
-
- int ind = 0;
-
- int currentChar = 0;
-
- try {
- while ((currentChar = sourceReader.read()) != -1) {
-
- if (false && currentChar == '\\') {
- escaped = !escaped;
- } else if (markerTypeFound != -1 && currentChar == stringCloses.charAt(markerTypeFound)
- && !escaped) {
- contextMarker = Character.MIN_VALUE;
- markerTypeFound = -1;
- } else if ((ind = stringOpens.indexOf(currentChar)) != -1
- && !escaped && contextMarker == Character.MIN_VALUE) {
- markerTypeFound = ind;
- contextMarker = currentChar;
- }
-
- if (contextMarker == Character.MIN_VALUE && currentChar == '/'
- && (slashSlashComments || slashStarComments)) {
- currentChar = sourceReader.read();
- if (currentChar == '*' && slashStarComments) {
- int prevChar = 0;
- while ((currentChar = sourceReader.read()) != '/'
- || prevChar != '*') {
- if (currentChar == '\r') {
-
- currentChar = sourceReader.read();
- if (currentChar == '\n') {
- currentChar = sourceReader.read();
- }
- } else {
- if (currentChar == '\n') {
-
- currentChar = sourceReader.read();
- }
- }
- if (currentChar < 0)
- break;
- prevChar = currentChar;
- }
- continue;
- } else if (currentChar == '/' && slashSlashComments) {
- while ((currentChar = sourceReader.read()) != '\n'
- && currentChar != '\r' && currentChar >= 0)
- ;
- }
- } else if (contextMarker == Character.MIN_VALUE
- && currentChar == '#' && hashComments) {
- // Slurp up everything until the newline
- while ((currentChar = sourceReader.read()) != '\n'
- && currentChar != '\r' && currentChar >= 0)
- ;
- } else if (contextMarker == Character.MIN_VALUE
- && currentChar == '-' && dashDashComments) {
- currentChar = sourceReader.read();
-
- if (currentChar == -1 || currentChar != '-') {
- buf.append('-');
-
- if (currentChar != -1) {
- buf.append(currentChar);
- }
-
- continue;
- }
-
- // Slurp up everything until the newline
-
- while ((currentChar = sourceReader.read()) != '\n'
- && currentChar != '\r' && currentChar >= 0)
- ;
- }
-
- if (currentChar != -1) {
- buf.append((char) currentChar);
- }
- }
- } catch (IOException ioEx) {
- // we'll never see this from a StringReader
- }
-
- return buf.toString();
- }
-
- public static final boolean isEmptyOrWhitespaceOnly(String str) {
- if (str == null || str.length() == 0) {
- return true;
- }
-
- int length = str.length();
-
- for (int i = 0; i < length; i++) {
- if (!Character.isWhitespace(str.charAt(i))) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/com/mysql/jdbc/TimeUtil.java b/src/com/mysql/jdbc/TimeUtil.java
deleted file mode 100644
index a991dcc62..000000000
--- a/src/com/mysql/jdbc/TimeUtil.java
+++ /dev/null
@@ -1,1284 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.sql.Date;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TimeZone;
-
-/**
- * Timezone conversion routines
- *
- * @author Mark Matthews
- */
-public class TimeUtil {
- static final Map ABBREVIATED_TIMEZONES;
-
- static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT");
-
- static final Map TIMEZONE_MAPPINGS;
-
- static {
- HashMap tempMap = new HashMap();
-
- //
- // Windows Mappings
- //
- tempMap.put("Romance", "Europe/Paris");
- tempMap.put("Romance Standard Time", "Europe/Paris");
- tempMap.put("Warsaw", "Europe/Warsaw");
- tempMap.put("Central Europe", "Europe/Prague");
- tempMap.put("Central Europe Standard Time", "Europe/Prague");
- tempMap.put("Prague Bratislava", "Europe/Prague");
- tempMap.put("W. Central Africa Standard Time", "Africa/Luanda");
- tempMap.put("FLE", "Europe/Helsinki");
- tempMap.put("FLE Standard Time", "Europe/Helsinki");
- tempMap.put("GFT", "Europe/Athens");
- tempMap.put("GFT Standard Time", "Europe/Athens");
- tempMap.put("GTB", "Europe/Athens");
- tempMap.put("GTB Standard Time", "Europe/Athens");
- tempMap.put("Israel", "Asia/Jerusalem");
- tempMap.put("Israel Standard Time", "Asia/Jerusalem");
- tempMap.put("Arab", "Asia/Riyadh");
- tempMap.put("Arab Standard Time", "Asia/Riyadh");
- tempMap.put("Arabic Standard Time", "Asia/Baghdad");
- tempMap.put("E. Africa", "Africa/Nairobi");
- tempMap.put("E. Africa Standard Time", "Africa/Nairobi");
- tempMap.put("Saudi Arabia", "Asia/Riyadh");
- tempMap.put("Saudi Arabia Standard Time", "Asia/Riyadh");
- tempMap.put("Iran", "Asia/Tehran");
- tempMap.put("Iran Standard Time", "Asia/Tehran");
- tempMap.put("Afghanistan", "Asia/Kabul");
- tempMap.put("Afghanistan Standard Time", "Asia/Kabul");
- tempMap.put("India", "Asia/Calcutta");
- tempMap.put("India Standard Time", "Asia/Calcutta");
- tempMap.put("Myanmar Standard Time", "Asia/Rangoon");
- tempMap.put("Nepal Standard Time", "Asia/Katmandu");
- tempMap.put("Sri Lanka", "Asia/Colombo");
- tempMap.put("Sri Lanka Standard Time", "Asia/Colombo");
- tempMap.put("Beijing", "Asia/Shanghai");
- tempMap.put("China", "Asia/Shanghai");
- tempMap.put("China Standard Time", "Asia/Shanghai");
- tempMap.put("AUS Central", "Australia/Darwin");
- tempMap.put("AUS Central Standard Time", "Australia/Darwin");
- tempMap.put("Cen. Australia", "Australia/Adelaide");
- tempMap.put("Cen. Australia Standard Time", "Australia/Adelaide");
- tempMap.put("Vladivostok", "Asia/Vladivostok");
- tempMap.put("Vladivostok Standard Time", "Asia/Vladivostok");
- tempMap.put("West Pacific", "Pacific/Guam");
- tempMap.put("West Pacific Standard Time", "Pacific/Guam");
- tempMap.put("E. South America", "America/Sao_Paulo");
- tempMap.put("E. South America Standard Time", "America/Sao_Paulo");
- tempMap.put("Greenland Standard Time", "America/Godthab");
- tempMap.put("Newfoundland", "America/St_Johns");
- tempMap.put("Newfoundland Standard Time", "America/St_Johns");
- tempMap.put("Pacific SA", "America/Caracas");
- tempMap.put("Pacific SA Standard Time", "America/Caracas");
- tempMap.put("SA Western", "America/Caracas");
- tempMap.put("SA Western Standard Time", "America/Caracas");
- tempMap.put("SA Pacific", "America/Bogota");
- tempMap.put("SA Pacific Standard Time", "America/Bogota");
- tempMap.put("US Eastern", "America/Indianapolis");
- tempMap.put("US Eastern Standard Time", "America/Indianapolis");
- tempMap.put("Central America Standard Time", "America/Regina");
- tempMap.put("Mexico", "America/Mexico_City");
- tempMap.put("Mexico Standard Time", "America/Mexico_City");
- tempMap.put("Canada Central", "America/Regina");
- tempMap.put("Canada Central Standard Time", "America/Regina");
- tempMap.put("US Mountain", "America/Phoenix");
- tempMap.put("US Mountain Standard Time", "America/Phoenix");
- tempMap.put("GMT", "GMT");
- tempMap.put("Ekaterinburg", "Asia/Yekaterinburg");
- tempMap.put("Ekaterinburg Standard Time", "Asia/Yekaterinburg");
- tempMap.put("West Asia", "Asia/Karachi");
- tempMap.put("West Asia Standard Time", "Asia/Karachi");
- tempMap.put("Central Asia", "Asia/Dhaka");
- tempMap.put("Central Asia Standard Time", "Asia/Dhaka");
- tempMap.put("N. Central Asia Standard Time", "Asia/Novosibirsk");
- tempMap.put("Bangkok", "Asia/Bangkok");
- tempMap.put("Bangkok Standard Time", "Asia/Bangkok");
- tempMap.put("North Asia Standard Time", "Asia/Krasnoyarsk");
- tempMap.put("SE Asia", "Asia/Bangkok");
- tempMap.put("SE Asia Standard Time", "Asia/Bangkok");
- tempMap.put("North Asia East Standard Time", "Asia/Ulaanbaatar");
- tempMap.put("Singapore", "Asia/Singapore");
- tempMap.put("Singapore Standard Time", "Asia/Singapore");
- tempMap.put("Taipei", "Asia/Taipei");
- tempMap.put("Taipei Standard Time", "Asia/Taipei");
- tempMap.put("W. Australia", "Australia/Perth");
- tempMap.put("W. Australia Standard Time", "Australia/Perth");
- tempMap.put("Korea", "Asia/Seoul");
- tempMap.put("Korea Standard Time", "Asia/Seoul");
- tempMap.put("Tokyo", "Asia/Tokyo");
- tempMap.put("Tokyo Standard Time", "Asia/Tokyo");
- tempMap.put("Yakutsk", "Asia/Yakutsk");
- tempMap.put("Yakutsk Standard Time", "Asia/Yakutsk");
- tempMap.put("Central European", "Europe/Belgrade");
- tempMap.put("Central European Standard Time", "Europe/Belgrade");
- tempMap.put("W. Europe", "Europe/Berlin");
- tempMap.put("W. Europe Standard Time", "Europe/Berlin");
- tempMap.put("Tasmania", "Australia/Hobart");
- tempMap.put("Tasmania Standard Time", "Australia/Hobart");
- tempMap.put("AUS Eastern", "Australia/Sydney");
- tempMap.put("AUS Eastern Standard Time", "Australia/Sydney");
- tempMap.put("E. Australia", "Australia/Brisbane");
- tempMap.put("E. Australia Standard Time", "Australia/Brisbane");
- tempMap.put("Sydney Standard Time", "Australia/Sydney");
- tempMap.put("Central Pacific", "Pacific/Guadalcanal");
- tempMap.put("Central Pacific Standard Time", "Pacific/Guadalcanal");
- tempMap.put("Dateline", "Pacific/Majuro");
- tempMap.put("Dateline Standard Time", "Pacific/Majuro");
- tempMap.put("Fiji", "Pacific/Fiji");
- tempMap.put("Fiji Standard Time", "Pacific/Fiji");
- tempMap.put("Samoa", "Pacific/Apia");
- tempMap.put("Samoa Standard Time", "Pacific/Apia");
- tempMap.put("Hawaiian", "Pacific/Honolulu");
- tempMap.put("Hawaiian Standard Time", "Pacific/Honolulu");
- tempMap.put("Alaskan", "America/Anchorage");
- tempMap.put("Alaskan Standard Time", "America/Anchorage");
- tempMap.put("Pacific", "America/Los_Angeles");
- tempMap.put("Pacific Standard Time", "America/Los_Angeles");
- tempMap.put("Mexico Standard Time 2", "America/Chihuahua");
- tempMap.put("Mountain", "America/Denver");
- tempMap.put("Mountain Standard Time", "America/Denver");
- tempMap.put("Central", "America/Chicago");
- tempMap.put("Central Standard Time", "America/Chicago");
- tempMap.put("Eastern", "America/New_York");
- tempMap.put("Eastern Standard Time", "America/New_York");
- tempMap.put("E. Europe", "Europe/Bucharest");
- tempMap.put("E. Europe Standard Time", "Europe/Bucharest");
- tempMap.put("Egypt", "Africa/Cairo");
- tempMap.put("Egypt Standard Time", "Africa/Cairo");
- tempMap.put("South Africa", "Africa/Harare");
- tempMap.put("South Africa Standard Time", "Africa/Harare");
- tempMap.put("Atlantic", "America/Halifax");
- tempMap.put("Atlantic Standard Time", "America/Halifax");
- tempMap.put("SA Eastern", "America/Buenos_Aires");
- tempMap.put("SA Eastern Standard Time", "America/Buenos_Aires");
- tempMap.put("Mid-Atlantic", "Atlantic/South_Georgia");
- tempMap.put("Mid-Atlantic Standard Time", "Atlantic/South_Georgia");
- tempMap.put("Azores", "Atlantic/Azores");
- tempMap.put("Azores Standard Time", "Atlantic/Azores");
- tempMap.put("Cape Verde Standard Time", "Atlantic/Cape_Verde");
- tempMap.put("Russian", "Europe/Moscow");
- tempMap.put("Russian Standard Time", "Europe/Moscow");
- tempMap.put("New Zealand", "Pacific/Auckland");
- tempMap.put("New Zealand Standard Time", "Pacific/Auckland");
- tempMap.put("Tonga Standard Time", "Pacific/Tongatapu");
- tempMap.put("Arabian", "Asia/Muscat");
- tempMap.put("Arabian Standard Time", "Asia/Muscat");
- tempMap.put("Caucasus", "Asia/Tbilisi");
- tempMap.put("Caucasus Standard Time", "Asia/Tbilisi");
- tempMap.put("GMT Standard Time", "GMT");
- tempMap.put("Greenwich", "GMT");
- tempMap.put("Greenwich Standard Time", "GMT");
- tempMap.put("UTC", "GMT");
-
- // MySQL understands the Continent/City/region as well
- Iterator entries = tempMap.entrySet().iterator();
- Map entryMap = new HashMap(tempMap.size()); // to avoid ConcurrentModificationException
-
- while (entries.hasNext()) {
- String name = ((Map.Entry)entries.next()).getValue().toString();
- entryMap.put(name, name);
- }
-
- tempMap.putAll(entryMap);
-
- TIMEZONE_MAPPINGS = Collections.unmodifiableMap(tempMap);
-
- //
- // Handle abbreviated mappings
- //
- tempMap = new HashMap();
-
- tempMap.put("ACST", new String[] { "America/Porto_Acre" });
- tempMap.put("ACT", new String[] { "America/Porto_Acre" });
- tempMap.put("ADDT", new String[] { "America/Pangnirtung" });
- tempMap.put("ADMT", new String[] { "Africa/Asmera",
- "Africa/Addis_Ababa" });
- tempMap.put("ADT", new String[] { "Atlantic/Bermuda", "Asia/Baghdad",
- "America/Thule", "America/Goose_Bay", "America/Halifax",
- "America/Glace_Bay", "America/Pangnirtung", "America/Barbados",
- "America/Martinique" });
- tempMap.put("AFT", new String[] { "Asia/Kabul" });
- tempMap.put("AHDT", new String[] { "America/Anchorage" });
- tempMap.put("AHST", new String[] { "America/Anchorage" });
- tempMap.put("AHWT", new String[] { "America/Anchorage" });
- tempMap.put("AKDT", new String[] { "America/Juneau", "America/Yakutat",
- "America/Anchorage", "America/Nome" });
- tempMap.put("AKST", new String[] { "Asia/Aqtobe", "America/Juneau",
- "America/Yakutat", "America/Anchorage", "America/Nome" });
- tempMap.put("AKT", new String[] { "Asia/Aqtobe" });
- tempMap.put("AKTST", new String[] { "Asia/Aqtobe" });
- tempMap.put("AKWT", new String[] { "America/Juneau", "America/Yakutat",
- "America/Anchorage", "America/Nome" });
- tempMap.put("ALMST", new String[] { "Asia/Almaty" });
- tempMap.put("ALMT", new String[] { "Asia/Almaty" });
- tempMap.put("AMST", new String[] { "Asia/Yerevan", "America/Cuiaba",
- "America/Porto_Velho", "America/Boa_Vista", "America/Manaus" });
- tempMap.put("AMT", new String[] { "Europe/Athens", "Europe/Amsterdam",
- "Asia/Yerevan", "Africa/Asmera", "America/Cuiaba",
- "America/Porto_Velho", "America/Boa_Vista", "America/Manaus",
- "America/Asuncion" });
- tempMap.put("ANAMT", new String[] { "Asia/Anadyr" });
- tempMap.put("ANAST", new String[] { "Asia/Anadyr" });
- tempMap.put("ANAT", new String[] { "Asia/Anadyr" });
- tempMap.put("ANT", new String[] { "America/Aruba", "America/Curacao" });
- tempMap.put("AQTST", new String[] { "Asia/Aqtobe", "Asia/Aqtau" });
- tempMap.put("AQTT", new String[] { "Asia/Aqtobe", "Asia/Aqtau" });
- tempMap.put("ARST", new String[] { "Antarctica/Palmer",
- "America/Buenos_Aires", "America/Rosario", "America/Cordoba",
- "America/Jujuy", "America/Catamarca", "America/Mendoza" });
- tempMap.put("ART", new String[] { "Antarctica/Palmer",
- "America/Buenos_Aires", "America/Rosario", "America/Cordoba",
- "America/Jujuy", "America/Catamarca", "America/Mendoza" });
- tempMap.put("ASHST", new String[] { "Asia/Ashkhabad" });
- tempMap.put("ASHT", new String[] { "Asia/Ashkhabad" });
- tempMap.put("AST", new String[] { "Atlantic/Bermuda", "Asia/Bahrain",
- "Asia/Baghdad", "Asia/Kuwait", "Asia/Qatar", "Asia/Riyadh",
- "Asia/Aden", "America/Thule", "America/Goose_Bay",
- "America/Halifax", "America/Glace_Bay", "America/Pangnirtung",
- "America/Anguilla", "America/Antigua", "America/Barbados",
- "America/Dominica", "America/Santo_Domingo", "America/Grenada",
- "America/Guadeloupe", "America/Martinique",
- "America/Montserrat", "America/Puerto_Rico",
- "America/St_Kitts", "America/St_Lucia", "America/Miquelon",
- "America/St_Vincent", "America/Tortola", "America/St_Thomas",
- "America/Aruba", "America/Curacao", "America/Port_of_Spain" });
- tempMap.put("AWT", new String[] { "America/Puerto_Rico" });
- tempMap.put("AZOST", new String[] { "Atlantic/Azores" });
- tempMap.put("AZOT", new String[] { "Atlantic/Azores" });
- tempMap.put("AZST", new String[] { "Asia/Baku" });
- tempMap.put("AZT", new String[] { "Asia/Baku" });
- tempMap.put("BAKST", new String[] { "Asia/Baku" });
- tempMap.put("BAKT", new String[] { "Asia/Baku" });
- tempMap.put("BDT", new String[] { "Asia/Dacca", "America/Nome",
- "America/Adak" });
- tempMap.put("BEAT", new String[] { "Africa/Nairobi",
- "Africa/Mogadishu", "Africa/Kampala" });
- tempMap.put("BEAUT", new String[] { "Africa/Nairobi",
- "Africa/Dar_es_Salaam", "Africa/Kampala" });
- tempMap.put("BMT", new String[] { "Europe/Brussels", "Europe/Chisinau",
- "Europe/Tiraspol", "Europe/Bucharest", "Europe/Zurich",
- "Asia/Baghdad", "Asia/Bangkok", "Africa/Banjul",
- "America/Barbados", "America/Bogota" });
- tempMap.put("BNT", new String[] { "Asia/Brunei" });
- tempMap.put("BORT",
- new String[] { "Asia/Ujung_Pandang", "Asia/Kuching" });
- tempMap.put("BOST", new String[] { "America/La_Paz" });
- tempMap.put("BOT", new String[] { "America/La_Paz" });
- tempMap.put("BRST", new String[] { "America/Belem",
- "America/Fortaleza", "America/Araguaina", "America/Maceio",
- "America/Sao_Paulo" });
- tempMap.put("BRT", new String[] { "America/Belem", "America/Fortaleza",
- "America/Araguaina", "America/Maceio", "America/Sao_Paulo" });
- tempMap.put("BST", new String[] { "Europe/London", "Europe/Belfast",
- "Europe/Dublin", "Europe/Gibraltar", "Pacific/Pago_Pago",
- "Pacific/Midway", "America/Nome", "America/Adak" });
- tempMap.put("BTT", new String[] { "Asia/Thimbu" });
- tempMap.put("BURT", new String[] { "Asia/Dacca", "Asia/Rangoon",
- "Asia/Calcutta" });
- tempMap.put("BWT", new String[] { "America/Nome", "America/Adak" });
- tempMap.put("CANT", new String[] { "Atlantic/Canary" });
- tempMap.put("CAST",
- new String[] { "Africa/Gaborone", "Africa/Khartoum" });
- tempMap.put("CAT", new String[] { "Africa/Gaborone",
- "Africa/Bujumbura", "Africa/Lubumbashi", "Africa/Blantyre",
- "Africa/Maputo", "Africa/Windhoek", "Africa/Kigali",
- "Africa/Khartoum", "Africa/Lusaka", "Africa/Harare",
- "America/Anchorage" });
- tempMap.put("CCT", new String[] { "Indian/Cocos" });
- tempMap.put("CDDT", new String[] { "America/Rankin_Inlet" });
- tempMap.put("CDT", new String[] { "Asia/Harbin", "Asia/Shanghai",
- "Asia/Chungking", "Asia/Urumqi", "Asia/Kashgar", "Asia/Taipei",
- "Asia/Macao", "America/Chicago", "America/Indianapolis",
- "America/Indiana/Marengo", "America/Indiana/Knox",
- "America/Indiana/Vevay", "America/Louisville",
- "America/Menominee", "America/Rainy_River", "America/Winnipeg",
- "America/Pangnirtung", "America/Iqaluit",
- "America/Rankin_Inlet", "America/Cambridge_Bay",
- "America/Cancun", "America/Mexico_City", "America/Chihuahua",
- "America/Belize", "America/Costa_Rica", "America/Havana",
- "America/El_Salvador", "America/Guatemala",
- "America/Tegucigalpa", "America/Managua" });
- tempMap.put("CEST", new String[] { "Europe/Tirane", "Europe/Andorra",
- "Europe/Vienna", "Europe/Minsk", "Europe/Brussels",
- "Europe/Sofia", "Europe/Prague", "Europe/Copenhagen",
- "Europe/Tallinn", "Europe/Berlin", "Europe/Gibraltar",
- "Europe/Athens", "Europe/Budapest", "Europe/Rome",
- "Europe/Riga", "Europe/Vaduz", "Europe/Vilnius",
- "Europe/Luxembourg", "Europe/Malta", "Europe/Chisinau",
- "Europe/Tiraspol", "Europe/Monaco", "Europe/Amsterdam",
- "Europe/Oslo", "Europe/Warsaw", "Europe/Lisbon",
- "Europe/Kaliningrad", "Europe/Madrid", "Europe/Stockholm",
- "Europe/Zurich", "Europe/Kiev", "Europe/Uzhgorod",
- "Europe/Zaporozhye", "Europe/Simferopol", "Europe/Belgrade",
- "Africa/Algiers", "Africa/Tripoli", "Africa/Tunis",
- "Africa/Ceuta" });
- tempMap.put("CET", new String[] { "Europe/Tirane", "Europe/Andorra",
- "Europe/Vienna", "Europe/Minsk", "Europe/Brussels",
- "Europe/Sofia", "Europe/Prague", "Europe/Copenhagen",
- "Europe/Tallinn", "Europe/Berlin", "Europe/Gibraltar",
- "Europe/Athens", "Europe/Budapest", "Europe/Rome",
- "Europe/Riga", "Europe/Vaduz", "Europe/Vilnius",
- "Europe/Luxembourg", "Europe/Malta", "Europe/Chisinau",
- "Europe/Tiraspol", "Europe/Monaco", "Europe/Amsterdam",
- "Europe/Oslo", "Europe/Warsaw", "Europe/Lisbon",
- "Europe/Kaliningrad", "Europe/Madrid", "Europe/Stockholm",
- "Europe/Zurich", "Europe/Kiev", "Europe/Uzhgorod",
- "Europe/Zaporozhye", "Europe/Simferopol", "Europe/Belgrade",
- "Africa/Algiers", "Africa/Tripoli", "Africa/Casablanca",
- "Africa/Tunis", "Africa/Ceuta" });
- tempMap.put("CGST", new String[] { "America/Scoresbysund" });
- tempMap.put("CGT", new String[] { "America/Scoresbysund" });
- tempMap.put("CHDT", new String[] { "America/Belize" });
- tempMap.put("CHUT", new String[] { "Asia/Chungking" });
- tempMap.put("CJT", new String[] { "Asia/Tokyo" });
- tempMap.put("CKHST", new String[] { "Pacific/Rarotonga" });
- tempMap.put("CKT", new String[] { "Pacific/Rarotonga" });
- tempMap.put("CLST", new String[] { "Antarctica/Palmer",
- "America/Santiago" });
- tempMap.put("CLT", new String[] { "Antarctica/Palmer",
- "America/Santiago" });
- tempMap.put("CMT", new String[] { "Europe/Copenhagen",
- "Europe/Chisinau", "Europe/Tiraspol", "America/St_Lucia",
- "America/Buenos_Aires", "America/Rosario", "America/Cordoba",
- "America/Jujuy", "America/Catamarca", "America/Mendoza",
- "America/Caracas" });
- tempMap.put("COST", new String[] { "America/Bogota" });
- tempMap.put("COT", new String[] { "America/Bogota" });
- tempMap
- .put("CST", new String[] { "Asia/Harbin", "Asia/Shanghai",
- "Asia/Chungking", "Asia/Urumqi", "Asia/Kashgar",
- "Asia/Taipei", "Asia/Macao", "Asia/Jayapura",
- "Australia/Darwin", "Australia/Adelaide",
- "Australia/Broken_Hill", "America/Chicago",
- "America/Indianapolis", "America/Indiana/Marengo",
- "America/Indiana/Knox", "America/Indiana/Vevay",
- "America/Louisville", "America/Detroit",
- "America/Menominee", "America/Rainy_River",
- "America/Winnipeg", "America/Regina",
- "America/Swift_Current", "America/Pangnirtung",
- "America/Iqaluit", "America/Rankin_Inlet",
- "America/Cambridge_Bay", "America/Cancun",
- "America/Mexico_City", "America/Chihuahua",
- "America/Hermosillo", "America/Mazatlan",
- "America/Belize", "America/Costa_Rica",
- "America/Havana", "America/El_Salvador",
- "America/Guatemala", "America/Tegucigalpa",
- "America/Managua" });
- tempMap.put("CUT", new String[] { "Europe/Zaporozhye" });
- tempMap.put("CVST", new String[] { "Atlantic/Cape_Verde" });
- tempMap.put("CVT", new String[] { "Atlantic/Cape_Verde" });
- tempMap.put("CWT", new String[] { "America/Chicago",
- "America/Indianapolis", "America/Indiana/Marengo",
- "America/Indiana/Knox", "America/Indiana/Vevay",
- "America/Louisville", "America/Menominee" });
- tempMap.put("CXT", new String[] { "Indian/Christmas" });
- tempMap.put("DACT", new String[] { "Asia/Dacca" });
- tempMap.put("DAVT", new String[] { "Antarctica/Davis" });
- tempMap.put("DDUT", new String[] { "Antarctica/DumontDUrville" });
- tempMap.put("DFT", new String[] { "Europe/Oslo", "Europe/Paris" });
- tempMap.put("DMT", new String[] { "Europe/Belfast", "Europe/Dublin" });
- tempMap.put("DUSST", new String[] { "Asia/Dushanbe" });
- tempMap.put("DUST", new String[] { "Asia/Dushanbe" });
- tempMap.put("EASST", new String[] { "Pacific/Easter" });
- tempMap.put("EAST", new String[] { "Indian/Antananarivo",
- "Pacific/Easter" });
- tempMap.put("EAT", new String[] { "Indian/Comoro",
- "Indian/Antananarivo", "Indian/Mayotte", "Africa/Djibouti",
- "Africa/Asmera", "Africa/Addis_Ababa", "Africa/Nairobi",
- "Africa/Mogadishu", "Africa/Khartoum", "Africa/Dar_es_Salaam",
- "Africa/Kampala" });
- tempMap.put("ECT", new String[] { "Pacific/Galapagos",
- "America/Guayaquil" });
- tempMap.put("EDDT", new String[] { "America/Iqaluit" });
- tempMap.put("EDT", new String[] { "America/New_York",
- "America/Indianapolis", "America/Indiana/Marengo",
- "America/Indiana/Vevay", "America/Louisville",
- "America/Detroit", "America/Montreal", "America/Thunder_Bay",
- "America/Nipigon", "America/Pangnirtung", "America/Iqaluit",
- "America/Cancun", "America/Nassau", "America/Santo_Domingo",
- "America/Port-au-Prince", "America/Jamaica",
- "America/Grand_Turk" });
- tempMap.put("EEMT", new String[] { "Europe/Minsk", "Europe/Chisinau",
- "Europe/Tiraspol", "Europe/Kaliningrad", "Europe/Moscow" });
- tempMap.put("EEST", new String[] { "Europe/Minsk", "Europe/Sofia",
- "Europe/Tallinn", "Europe/Helsinki", "Europe/Athens",
- "Europe/Riga", "Europe/Vilnius", "Europe/Chisinau",
- "Europe/Tiraspol", "Europe/Warsaw", "Europe/Bucharest",
- "Europe/Kaliningrad", "Europe/Moscow", "Europe/Istanbul",
- "Europe/Kiev", "Europe/Uzhgorod", "Europe/Zaporozhye",
- "Asia/Nicosia", "Asia/Amman", "Asia/Beirut", "Asia/Gaza",
- "Asia/Damascus", "Africa/Cairo" });
- tempMap.put("EET", new String[] { "Europe/Minsk", "Europe/Sofia",
- "Europe/Tallinn", "Europe/Helsinki", "Europe/Athens",
- "Europe/Riga", "Europe/Vilnius", "Europe/Chisinau",
- "Europe/Tiraspol", "Europe/Warsaw", "Europe/Bucharest",
- "Europe/Kaliningrad", "Europe/Moscow", "Europe/Istanbul",
- "Europe/Kiev", "Europe/Uzhgorod", "Europe/Zaporozhye",
- "Europe/Simferopol", "Asia/Nicosia", "Asia/Amman",
- "Asia/Beirut", "Asia/Gaza", "Asia/Damascus", "Africa/Cairo",
- "Africa/Tripoli" });
- tempMap.put("EGST", new String[] { "America/Scoresbysund" });
- tempMap.put("EGT", new String[] { "Atlantic/Jan_Mayen",
- "America/Scoresbysund" });
- tempMap.put("EHDT", new String[] { "America/Santo_Domingo" });
- tempMap.put("EST", new String[] { "Australia/Brisbane",
- "Australia/Lindeman", "Australia/Hobart",
- "Australia/Melbourne", "Australia/Sydney",
- "Australia/Broken_Hill", "Australia/Lord_Howe",
- "America/New_York", "America/Chicago", "America/Indianapolis",
- "America/Indiana/Marengo", "America/Indiana/Knox",
- "America/Indiana/Vevay", "America/Louisville",
- "America/Detroit", "America/Menominee", "America/Montreal",
- "America/Thunder_Bay", "America/Nipigon",
- "America/Pangnirtung", "America/Iqaluit", "America/Cancun",
- "America/Antigua", "America/Nassau", "America/Cayman",
- "America/Santo_Domingo", "America/Port-au-Prince",
- "America/Jamaica", "America/Managua", "America/Panama",
- "America/Grand_Turk" });
- tempMap.put("EWT", new String[] { "America/New_York",
- "America/Indianapolis", "America/Indiana/Marengo",
- "America/Indiana/Vevay", "America/Louisville",
- "America/Detroit", "America/Jamaica" });
- tempMap.put("FFMT", new String[] { "America/Martinique" });
- tempMap.put("FJST", new String[] { "Pacific/Fiji" });
- tempMap.put("FJT", new String[] { "Pacific/Fiji" });
- tempMap.put("FKST", new String[] { "Atlantic/Stanley" });
- tempMap.put("FKT", new String[] { "Atlantic/Stanley" });
- tempMap.put("FMT",
- new String[] { "Atlantic/Madeira", "Africa/Freetown" });
- tempMap.put("FNST", new String[] { "America/Noronha" });
- tempMap.put("FNT", new String[] { "America/Noronha" });
- tempMap.put("FRUST", new String[] { "Asia/Bishkek" });
- tempMap.put("FRUT", new String[] { "Asia/Bishkek" });
- tempMap.put("GALT", new String[] { "Pacific/Galapagos" });
- tempMap.put("GAMT", new String[] { "Pacific/Gambier" });
- tempMap.put("GBGT", new String[] { "America/Guyana" });
- tempMap.put("GEST", new String[] { "Asia/Tbilisi" });
- tempMap.put("GET", new String[] { "Asia/Tbilisi" });
- tempMap.put("GFT", new String[] { "America/Cayenne" });
- tempMap.put("GHST", new String[] { "Africa/Accra" });
- tempMap.put("GILT", new String[] { "Pacific/Tarawa" });
- tempMap.put("GMT", new String[] { "Atlantic/St_Helena",
- "Atlantic/Reykjavik", "Europe/London", "Europe/Belfast",
- "Europe/Dublin", "Europe/Gibraltar", "Africa/Porto-Novo",
- "Africa/Ouagadougou", "Africa/Abidjan", "Africa/Malabo",
- "Africa/Banjul", "Africa/Accra", "Africa/Conakry",
- "Africa/Bissau", "Africa/Monrovia", "Africa/Bamako",
- "Africa/Timbuktu", "Africa/Nouakchott", "Africa/Niamey",
- "Africa/Sao_Tome", "Africa/Dakar", "Africa/Freetown",
- "Africa/Lome" });
- tempMap.put("GST", new String[] { "Atlantic/South_Georgia",
- "Asia/Bahrain", "Asia/Muscat", "Asia/Qatar", "Asia/Dubai",
- "Pacific/Guam" });
- tempMap.put("GYT", new String[] { "America/Guyana" });
- tempMap.put("HADT", new String[] { "America/Adak" });
- tempMap.put("HART", new String[] { "Asia/Harbin" });
- tempMap.put("HAST", new String[] { "America/Adak" });
- tempMap.put("HAWT", new String[] { "America/Adak" });
- tempMap.put("HDT", new String[] { "Pacific/Honolulu" });
- tempMap.put("HKST", new String[] { "Asia/Hong_Kong" });
- tempMap.put("HKT", new String[] { "Asia/Hong_Kong" });
- tempMap.put("HMT", new String[] { "Atlantic/Azores", "Europe/Helsinki",
- "Asia/Dacca", "Asia/Calcutta", "America/Havana" });
- tempMap.put("HOVST", new String[] { "Asia/Hovd" });
- tempMap.put("HOVT", new String[] { "Asia/Hovd" });
- tempMap.put("HST", new String[] { "Pacific/Johnston",
- "Pacific/Honolulu" });
- tempMap.put("HWT", new String[] { "Pacific/Honolulu" });
- tempMap.put("ICT", new String[] { "Asia/Phnom_Penh", "Asia/Vientiane",
- "Asia/Bangkok", "Asia/Saigon" });
- tempMap.put("IDDT", new String[] { "Asia/Jerusalem", "Asia/Gaza" });
- tempMap.put("IDT", new String[] { "Asia/Jerusalem", "Asia/Gaza" });
- tempMap.put("IHST", new String[] { "Asia/Colombo" });
- tempMap.put("IMT", new String[] { "Europe/Sofia", "Europe/Istanbul",
- "Asia/Irkutsk" });
- tempMap.put("IOT", new String[] { "Indian/Chagos" });
- tempMap.put("IRKMT", new String[] { "Asia/Irkutsk" });
- tempMap.put("IRKST", new String[] { "Asia/Irkutsk" });
- tempMap.put("IRKT", new String[] { "Asia/Irkutsk" });
- tempMap.put("IRST", new String[] { "Asia/Tehran" });
- tempMap.put("IRT", new String[] { "Asia/Tehran" });
- tempMap.put("ISST", new String[] { "Atlantic/Reykjavik" });
- tempMap.put("IST", new String[] { "Atlantic/Reykjavik",
- "Europe/Belfast", "Europe/Dublin", "Asia/Dacca", "Asia/Thimbu",
- "Asia/Calcutta", "Asia/Jerusalem", "Asia/Katmandu",
- "Asia/Karachi", "Asia/Gaza", "Asia/Colombo" });
- tempMap.put("JAYT", new String[] { "Asia/Jayapura" });
- tempMap.put("JMT", new String[] { "Atlantic/St_Helena",
- "Asia/Jerusalem" });
- tempMap.put("JST", new String[] { "Asia/Rangoon", "Asia/Dili",
- "Asia/Ujung_Pandang", "Asia/Tokyo", "Asia/Kuala_Lumpur",
- "Asia/Kuching", "Asia/Manila", "Asia/Singapore",
- "Pacific/Nauru" });
- tempMap.put("KART", new String[] { "Asia/Karachi" });
- tempMap.put("KAST", new String[] { "Asia/Kashgar" });
- tempMap.put("KDT", new String[] { "Asia/Seoul" });
- tempMap.put("KGST", new String[] { "Asia/Bishkek" });
- tempMap.put("KGT", new String[] { "Asia/Bishkek" });
- tempMap.put("KMT", new String[] { "Europe/Vilnius", "Europe/Kiev",
- "America/Cayman", "America/Jamaica", "America/St_Vincent",
- "America/Grand_Turk" });
- tempMap.put("KOST", new String[] { "Pacific/Kosrae" });
- tempMap.put("KRAMT", new String[] { "Asia/Krasnoyarsk" });
- tempMap.put("KRAST", new String[] { "Asia/Krasnoyarsk" });
- tempMap.put("KRAT", new String[] { "Asia/Krasnoyarsk" });
- tempMap.put("KST", new String[] { "Asia/Seoul", "Asia/Pyongyang" });
- tempMap.put("KUYMT", new String[] { "Europe/Samara" });
- tempMap.put("KUYST", new String[] { "Europe/Samara" });
- tempMap.put("KUYT", new String[] { "Europe/Samara" });
- tempMap.put("KWAT", new String[] { "Pacific/Kwajalein" });
- tempMap.put("LHST", new String[] { "Australia/Lord_Howe" });
- tempMap.put("LINT", new String[] { "Pacific/Kiritimati" });
- tempMap.put("LKT", new String[] { "Asia/Colombo" });
- tempMap.put("LPMT", new String[] { "America/La_Paz" });
- tempMap.put("LRT", new String[] { "Africa/Monrovia" });
- tempMap.put("LST", new String[] { "Europe/Riga" });
- tempMap.put("M", new String[] { "Europe/Moscow" });
- tempMap.put("MADST", new String[] { "Atlantic/Madeira" });
- tempMap.put("MAGMT", new String[] { "Asia/Magadan" });
- tempMap.put("MAGST", new String[] { "Asia/Magadan" });
- tempMap.put("MAGT", new String[] { "Asia/Magadan" });
- tempMap.put("MALT", new String[] { "Asia/Kuala_Lumpur",
- "Asia/Singapore" });
- tempMap.put("MART", new String[] { "Pacific/Marquesas" });
- tempMap.put("MAWT", new String[] { "Antarctica/Mawson" });
- tempMap.put("MDDT", new String[] { "America/Cambridge_Bay",
- "America/Yellowknife", "America/Inuvik" });
- tempMap.put("MDST", new String[] { "Europe/Moscow" });
- tempMap.put("MDT", new String[] { "America/Denver", "America/Phoenix",
- "America/Boise", "America/Regina", "America/Swift_Current",
- "America/Edmonton", "America/Cambridge_Bay",
- "America/Yellowknife", "America/Inuvik", "America/Chihuahua",
- "America/Hermosillo", "America/Mazatlan" });
- tempMap.put("MET", new String[] { "Europe/Tirane", "Europe/Andorra",
- "Europe/Vienna", "Europe/Minsk", "Europe/Brussels",
- "Europe/Sofia", "Europe/Prague", "Europe/Copenhagen",
- "Europe/Tallinn", "Europe/Berlin", "Europe/Gibraltar",
- "Europe/Athens", "Europe/Budapest", "Europe/Rome",
- "Europe/Riga", "Europe/Vaduz", "Europe/Vilnius",
- "Europe/Luxembourg", "Europe/Malta", "Europe/Chisinau",
- "Europe/Tiraspol", "Europe/Monaco", "Europe/Amsterdam",
- "Europe/Oslo", "Europe/Warsaw", "Europe/Lisbon",
- "Europe/Kaliningrad", "Europe/Madrid", "Europe/Stockholm",
- "Europe/Zurich", "Europe/Kiev", "Europe/Uzhgorod",
- "Europe/Zaporozhye", "Europe/Simferopol", "Europe/Belgrade",
- "Africa/Algiers", "Africa/Tripoli", "Africa/Casablanca",
- "Africa/Tunis", "Africa/Ceuta" });
- tempMap.put("MHT",
- new String[] { "Pacific/Majuro", "Pacific/Kwajalein" });
- tempMap.put("MMT", new String[] { "Indian/Maldives", "Europe/Minsk",
- "Europe/Moscow", "Asia/Rangoon", "Asia/Ujung_Pandang",
- "Asia/Colombo", "Pacific/Easter", "Africa/Monrovia",
- "America/Managua", "America/Montevideo" });
- tempMap.put("MOST", new String[] { "Asia/Macao" });
- tempMap.put("MOT", new String[] { "Asia/Macao" });
- tempMap.put("MPT", new String[] { "Pacific/Saipan" });
- tempMap.put("MSK", new String[] { "Europe/Minsk", "Europe/Tallinn",
- "Europe/Riga", "Europe/Vilnius", "Europe/Chisinau",
- "Europe/Kiev", "Europe/Uzhgorod", "Europe/Zaporozhye",
- "Europe/Simferopol" });
- tempMap.put("MST", new String[] { "Europe/Moscow", "America/Denver",
- "America/Phoenix", "America/Boise", "America/Regina",
- "America/Swift_Current", "America/Edmonton",
- "America/Dawson_Creek", "America/Cambridge_Bay",
- "America/Yellowknife", "America/Inuvik", "America/Mexico_City",
- "America/Chihuahua", "America/Hermosillo", "America/Mazatlan",
- "America/Tijuana" });
- tempMap.put("MUT", new String[] { "Indian/Mauritius" });
- tempMap.put("MVT", new String[] { "Indian/Maldives" });
- tempMap.put("MWT", new String[] { "America/Denver", "America/Phoenix",
- "America/Boise" });
- tempMap
- .put("MYT",
- new String[] { "Asia/Kuala_Lumpur", "Asia/Kuching" });
- tempMap.put("NCST", new String[] { "Pacific/Noumea" });
- tempMap.put("NCT", new String[] { "Pacific/Noumea" });
- tempMap.put("NDT", new String[] { "America/Nome", "America/Adak",
- "America/St_Johns", "America/Goose_Bay" });
- tempMap.put("NEGT", new String[] { "America/Paramaribo" });
- tempMap.put("NFT", new String[] { "Europe/Paris", "Europe/Oslo",
- "Pacific/Norfolk" });
- tempMap.put("NMT", new String[] { "Pacific/Norfolk" });
- tempMap.put("NOVMT", new String[] { "Asia/Novosibirsk" });
- tempMap.put("NOVST", new String[] { "Asia/Novosibirsk" });
- tempMap.put("NOVT", new String[] { "Asia/Novosibirsk" });
- tempMap.put("NPT", new String[] { "Asia/Katmandu" });
- tempMap.put("NRT", new String[] { "Pacific/Nauru" });
- tempMap.put("NST", new String[] { "Europe/Amsterdam",
- "Pacific/Pago_Pago", "Pacific/Midway", "America/Nome",
- "America/Adak", "America/St_Johns", "America/Goose_Bay" });
- tempMap.put("NUT", new String[] { "Pacific/Niue" });
- tempMap.put("NWT", new String[] { "America/Nome", "America/Adak" });
- tempMap.put("NZDT", new String[] { "Antarctica/McMurdo" });
- tempMap.put("NZHDT", new String[] { "Pacific/Auckland" });
- tempMap.put("NZST", new String[] { "Antarctica/McMurdo",
- "Pacific/Auckland" });
- tempMap.put("OMSMT", new String[] { "Asia/Omsk" });
- tempMap.put("OMSST", new String[] { "Asia/Omsk" });
- tempMap.put("OMST", new String[] { "Asia/Omsk" });
- tempMap.put("PDDT", new String[] { "America/Inuvik",
- "America/Whitehorse", "America/Dawson" });
- tempMap.put("PDT", new String[] { "America/Los_Angeles",
- "America/Juneau", "America/Boise", "America/Vancouver",
- "America/Dawson_Creek", "America/Inuvik", "America/Whitehorse",
- "America/Dawson", "America/Tijuana" });
- tempMap.put("PEST", new String[] { "America/Lima" });
- tempMap.put("PET", new String[] { "America/Lima" });
- tempMap.put("PETMT", new String[] { "Asia/Kamchatka" });
- tempMap.put("PETST", new String[] { "Asia/Kamchatka" });
- tempMap.put("PETT", new String[] { "Asia/Kamchatka" });
- tempMap.put("PGT", new String[] { "Pacific/Port_Moresby" });
- tempMap.put("PHOT", new String[] { "Pacific/Enderbury" });
- tempMap.put("PHST", new String[] { "Asia/Manila" });
- tempMap.put("PHT", new String[] { "Asia/Manila" });
- tempMap.put("PKT", new String[] { "Asia/Karachi" });
- tempMap.put("PMDT", new String[] { "America/Miquelon" });
- tempMap.put("PMMT", new String[] { "Pacific/Port_Moresby" });
- tempMap.put("PMST", new String[] { "America/Miquelon" });
- tempMap.put("PMT", new String[] { "Antarctica/DumontDUrville",
- "Europe/Prague", "Europe/Paris", "Europe/Monaco",
- "Africa/Algiers", "Africa/Tunis", "America/Panama",
- "America/Paramaribo" });
- tempMap.put("PNT", new String[] { "Pacific/Pitcairn" });
- tempMap.put("PONT", new String[] { "Pacific/Ponape" });
- tempMap.put("PPMT", new String[] { "America/Port-au-Prince" });
- tempMap.put("PST", new String[] { "Pacific/Pitcairn",
- "America/Los_Angeles", "America/Juneau", "America/Boise",
- "America/Vancouver", "America/Dawson_Creek", "America/Inuvik",
- "America/Whitehorse", "America/Dawson", "America/Hermosillo",
- "America/Mazatlan", "America/Tijuana" });
- tempMap.put("PWT", new String[] { "Pacific/Palau",
- "America/Los_Angeles", "America/Juneau", "America/Boise",
- "America/Tijuana" });
- tempMap.put("PYST", new String[] { "America/Asuncion" });
- tempMap.put("PYT", new String[] { "America/Asuncion" });
- tempMap.put("QMT", new String[] { "America/Guayaquil" });
- tempMap.put("RET", new String[] { "Indian/Reunion" });
- tempMap.put("RMT", new String[] { "Atlantic/Reykjavik", "Europe/Rome",
- "Europe/Riga", "Asia/Rangoon" });
- tempMap.put("S", new String[] { "Europe/Moscow" });
- tempMap.put("SAMMT", new String[] { "Europe/Samara" });
- tempMap
- .put("SAMST",
- new String[] { "Europe/Samara", "Asia/Samarkand" });
- tempMap.put("SAMT", new String[] { "Europe/Samara", "Asia/Samarkand",
- "Pacific/Pago_Pago", "Pacific/Apia" });
- tempMap.put("SAST", new String[] { "Africa/Maseru", "Africa/Windhoek",
- "Africa/Johannesburg", "Africa/Mbabane" });
- tempMap.put("SBT", new String[] { "Pacific/Guadalcanal" });
- tempMap.put("SCT", new String[] { "Indian/Mahe" });
- tempMap.put("SDMT", new String[] { "America/Santo_Domingo" });
- tempMap.put("SGT", new String[] { "Asia/Singapore" });
- tempMap.put("SHEST", new String[] { "Asia/Aqtau" });
- tempMap.put("SHET", new String[] { "Asia/Aqtau" });
- tempMap.put("SJMT", new String[] { "America/Costa_Rica" });
- tempMap.put("SLST", new String[] { "Africa/Freetown" });
- tempMap.put("SMT", new String[] { "Atlantic/Stanley",
- "Europe/Stockholm", "Europe/Simferopol", "Asia/Phnom_Penh",
- "Asia/Vientiane", "Asia/Kuala_Lumpur", "Asia/Singapore",
- "Asia/Saigon", "America/Santiago" });
- tempMap.put("SRT", new String[] { "America/Paramaribo" });
- tempMap.put("SST",
- new String[] { "Pacific/Pago_Pago", "Pacific/Midway" });
- tempMap.put("SVEMT", new String[] { "Asia/Yekaterinburg" });
- tempMap.put("SVEST", new String[] { "Asia/Yekaterinburg" });
- tempMap.put("SVET", new String[] { "Asia/Yekaterinburg" });
- tempMap.put("SWAT", new String[] { "Africa/Windhoek" });
- tempMap.put("SYOT", new String[] { "Antarctica/Syowa" });
- tempMap.put("TAHT", new String[] { "Pacific/Tahiti" });
- tempMap
- .put("TASST",
- new String[] { "Asia/Samarkand", "Asia/Tashkent" });
- tempMap.put("TAST", new String[] { "Asia/Samarkand", "Asia/Tashkent" });
- tempMap.put("TBIST", new String[] { "Asia/Tbilisi" });
- tempMap.put("TBIT", new String[] { "Asia/Tbilisi" });
- tempMap.put("TBMT", new String[] { "Asia/Tbilisi" });
- tempMap.put("TFT", new String[] { "Indian/Kerguelen" });
- tempMap.put("TJT", new String[] { "Asia/Dushanbe" });
- tempMap.put("TKT", new String[] { "Pacific/Fakaofo" });
- tempMap.put("TMST", new String[] { "Asia/Ashkhabad" });
- tempMap.put("TMT", new String[] { "Europe/Tallinn", "Asia/Tehran",
- "Asia/Ashkhabad" });
- tempMap.put("TOST", new String[] { "Pacific/Tongatapu" });
- tempMap.put("TOT", new String[] { "Pacific/Tongatapu" });
- tempMap.put("TPT", new String[] { "Asia/Dili" });
- tempMap.put("TRST", new String[] { "Europe/Istanbul" });
- tempMap.put("TRT", new String[] { "Europe/Istanbul" });
- tempMap.put("TRUT", new String[] { "Pacific/Truk" });
- tempMap.put("TVT", new String[] { "Pacific/Funafuti" });
- tempMap.put("ULAST", new String[] { "Asia/Ulaanbaatar" });
- tempMap.put("ULAT", new String[] { "Asia/Ulaanbaatar" });
- tempMap.put("URUT", new String[] { "Asia/Urumqi" });
- tempMap.put("UYHST", new String[] { "America/Montevideo" });
- tempMap.put("UYT", new String[] { "America/Montevideo" });
- tempMap.put("UZST", new String[] { "Asia/Samarkand", "Asia/Tashkent" });
- tempMap.put("UZT", new String[] { "Asia/Samarkand", "Asia/Tashkent" });
- tempMap.put("VET", new String[] { "America/Caracas" });
- tempMap.put("VLAMT", new String[] { "Asia/Vladivostok" });
- tempMap.put("VLAST", new String[] { "Asia/Vladivostok" });
- tempMap.put("VLAT", new String[] { "Asia/Vladivostok" });
- tempMap.put("VUST", new String[] { "Pacific/Efate" });
- tempMap.put("VUT", new String[] { "Pacific/Efate" });
- tempMap.put("WAKT", new String[] { "Pacific/Wake" });
- tempMap.put("WARST",
- new String[] { "America/Jujuy", "America/Mendoza" });
- tempMap
- .put("WART",
- new String[] { "America/Jujuy", "America/Mendoza" });
- tempMap.put("WAST",
- new String[] { "Africa/Ndjamena", "Africa/Windhoek" });
- tempMap.put("WAT", new String[] { "Africa/Luanda", "Africa/Porto-Novo",
- "Africa/Douala", "Africa/Bangui", "Africa/Ndjamena",
- "Africa/Kinshasa", "Africa/Brazzaville", "Africa/Malabo",
- "Africa/Libreville", "Africa/Banjul", "Africa/Conakry",
- "Africa/Bissau", "Africa/Bamako", "Africa/Nouakchott",
- "Africa/El_Aaiun", "Africa/Windhoek", "Africa/Niamey",
- "Africa/Lagos", "Africa/Dakar", "Africa/Freetown" });
- tempMap.put("WEST", new String[] { "Atlantic/Faeroe",
- "Atlantic/Azores", "Atlantic/Madeira", "Atlantic/Canary",
- "Europe/Brussels", "Europe/Luxembourg", "Europe/Monaco",
- "Europe/Lisbon", "Europe/Madrid", "Africa/Algiers",
- "Africa/Casablanca", "Africa/Ceuta" });
- tempMap.put("WET", new String[] { "Atlantic/Faeroe", "Atlantic/Azores",
- "Atlantic/Madeira", "Atlantic/Canary", "Europe/Andorra",
- "Europe/Brussels", "Europe/Luxembourg", "Europe/Monaco",
- "Europe/Lisbon", "Europe/Madrid", "Africa/Algiers",
- "Africa/Casablanca", "Africa/El_Aaiun", "Africa/Ceuta" });
- tempMap.put("WFT", new String[] { "Pacific/Wallis" });
- tempMap.put("WGST", new String[] { "America/Godthab" });
- tempMap.put("WGT", new String[] { "America/Godthab" });
- tempMap.put("WMT", new String[] { "Europe/Vilnius", "Europe/Warsaw" });
- tempMap.put("WST", new String[] { "Antarctica/Casey", "Pacific/Apia",
- "Australia/Perth" });
- tempMap.put("YAKMT", new String[] { "Asia/Yakutsk" });
- tempMap.put("YAKST", new String[] { "Asia/Yakutsk" });
- tempMap.put("YAKT", new String[] { "Asia/Yakutsk" });
- tempMap.put("YAPT", new String[] { "Pacific/Yap" });
- tempMap.put("YDDT", new String[] { "America/Whitehorse",
- "America/Dawson" });
- tempMap.put("YDT", new String[] { "America/Yakutat",
- "America/Whitehorse", "America/Dawson" });
- tempMap.put("YEKMT", new String[] { "Asia/Yekaterinburg" });
- tempMap.put("YEKST", new String[] { "Asia/Yekaterinburg" });
- tempMap.put("YEKT", new String[] { "Asia/Yekaterinburg" });
- tempMap.put("YERST", new String[] { "Asia/Yerevan" });
- tempMap.put("YERT", new String[] { "Asia/Yerevan" });
- tempMap.put("YST", new String[] { "America/Yakutat",
- "America/Whitehorse", "America/Dawson" });
- tempMap.put("YWT", new String[] { "America/Yakutat" });
-
- ABBREVIATED_TIMEZONES = Collections.unmodifiableMap(tempMap);
- }
-
- /**
- * Change the given times from one timezone to another
- *
- * @param conn
- * the current connection to the MySQL server
- * @param t
- * the times to change
- * @param fromTz
- * the timezone to change from
- * @param toTz
- * the timezone to change to
- *
- * @return the times changed to the timezone 'toTz'
- */
- public static Time changeTimezone(ConnectionImpl conn,
- Calendar sessionCalendar,
- Calendar targetCalendar,
- Time t,
- TimeZone fromTz,
- TimeZone toTz,
- boolean rollForward) {
- if ((conn != null)) {
- if (conn.getUseTimezone() &&
- !conn.getNoTimezoneConversionForTimeType()) {
- // Convert the timestamp from GMT to the server's timezone
- Calendar fromCal = Calendar.getInstance(fromTz);
- fromCal.setTime(t);
-
- int fromOffset = fromCal.get(Calendar.ZONE_OFFSET)
- + fromCal.get(Calendar.DST_OFFSET);
- Calendar toCal = Calendar.getInstance(toTz);
- toCal.setTime(t);
-
- int toOffset = toCal.get(Calendar.ZONE_OFFSET)
- + toCal.get(Calendar.DST_OFFSET);
- int offsetDiff = fromOffset - toOffset;
- long toTime = toCal.getTime().getTime();
-
- if (rollForward || (conn.isServerTzUTC() && !conn.isClientTzUTC())) {
- toTime += offsetDiff;
- } else {
- toTime -= offsetDiff;
- }
-
- Time changedTime = new Time(toTime);
-
- return changedTime;
- } else if (conn.getUseJDBCCompliantTimezoneShift()) {
- if (targetCalendar != null) {
-
- Time adjustedTime = new Time(
- jdbcCompliantZoneShift(sessionCalendar,
- targetCalendar, t));
-
- return adjustedTime;
- }
- }
- }
-
- return t;
- }
-
- /**
- * Change the given timestamp from one timezone to another
- *
- * @param conn
- * the current connection to the MySQL server
- * @param tstamp
- * the timestamp to change
- * @param fromTz
- * the timezone to change from
- * @param toTz
- * the timezone to change to
- *
- * @return the timestamp changed to the timezone 'toTz'
- */
- public static Timestamp changeTimezone(ConnectionImpl conn,
- Calendar sessionCalendar,
- Calendar targetCalendar,
- Timestamp tstamp,
- TimeZone fromTz,
- TimeZone toTz,
- boolean rollForward) {
- if ((conn != null)) {
- if (conn.getUseTimezone()) {
- // Convert the timestamp from GMT to the server's timezone
- Calendar fromCal = Calendar.getInstance(fromTz);
- fromCal.setTime(tstamp);
-
- int fromOffset = fromCal.get(Calendar.ZONE_OFFSET)
- + fromCal.get(Calendar.DST_OFFSET);
- Calendar toCal = Calendar.getInstance(toTz);
- toCal.setTime(tstamp);
-
- int toOffset = toCal.get(Calendar.ZONE_OFFSET)
- + toCal.get(Calendar.DST_OFFSET);
- int offsetDiff = fromOffset - toOffset;
- long toTime = toCal.getTime().getTime();
-
- if (rollForward || (conn.isServerTzUTC() && !conn.isClientTzUTC())) {
- toTime += offsetDiff;
- } else {
- toTime -= offsetDiff;
- }
-
- Timestamp changedTimestamp = new Timestamp(toTime);
-
- return changedTimestamp;
- } else if (conn.getUseJDBCCompliantTimezoneShift()) {
- if (targetCalendar != null) {
-
- Timestamp adjustedTimestamp = new Timestamp(
- jdbcCompliantZoneShift(sessionCalendar,
- targetCalendar, tstamp));
-
- adjustedTimestamp.setNanos(tstamp.getNanos());
-
- return adjustedTimestamp;
- }
- }
- }
-
- return tstamp;
- }
-
- private static long jdbcCompliantZoneShift(Calendar sessionCalendar,
- Calendar targetCalendar,
- java.util.Date dt) {
- if (sessionCalendar == null) {
- sessionCalendar = new GregorianCalendar();
- }
-
- // JDBC spec is not clear whether or not this
- // calendar should be immutable, so let's treat
- // it like it is, for safety
-
- java.util.Date origCalDate = targetCalendar.getTime();
- java.util.Date origSessionDate = sessionCalendar.getTime();
-
- try {
- sessionCalendar.setTime(dt);
-
- targetCalendar.set(Calendar.YEAR, sessionCalendar.get(Calendar.YEAR));
- targetCalendar.set(Calendar.MONTH, sessionCalendar.get(Calendar.MONTH));
- targetCalendar.set(Calendar.DAY_OF_MONTH, sessionCalendar.get(Calendar.DAY_OF_MONTH));
-
- targetCalendar.set(Calendar.HOUR_OF_DAY, sessionCalendar.get(Calendar.HOUR_OF_DAY));
- targetCalendar.set(Calendar.MINUTE, sessionCalendar.get(Calendar.MINUTE));
- targetCalendar.set(Calendar.SECOND, sessionCalendar.get(Calendar.SECOND));
- targetCalendar.set(Calendar.MILLISECOND, sessionCalendar.get(Calendar.MILLISECOND));
-
- return targetCalendar.getTime().getTime();
-
- } finally {
- sessionCalendar.setTime(origSessionDate);
- targetCalendar.setTime(origCalDate);
- }
- }
-
- //
- // WARN! You must externally synchronize these calendar instances
- // See ResultSet.fastDateCreate() for an example
- //
- final static Date fastDateCreate(boolean useGmtConversion,
- Calendar gmtCalIfNeeded,
- Calendar cal, int year, int month, int day) {
-
- Calendar dateCal = cal;
-
- if (useGmtConversion) {
-
- if (gmtCalIfNeeded == null) {
- gmtCalIfNeeded = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- }
- gmtCalIfNeeded.clear();
-
- dateCal = gmtCalIfNeeded;
- }
-
- dateCal.clear();
- dateCal.set(Calendar.MILLISECOND, 0);
-
- // why-oh-why is this different than java.util.date,
- // in the year part, but it still keeps the silly '0'
- // for the start month????
- dateCal.set(year, month - 1, day, 0, 0, 0);
-
- long dateAsMillis = 0;
-
- try {
- dateAsMillis = dateCal.getTimeInMillis();
- } catch (IllegalAccessError iae) {
- // Must be on JDK-1.3.1 or older....
- dateAsMillis = dateCal.getTime().getTime();
- }
-
- return new Date(dateAsMillis);
- }
-
- final static Date fastDateCreate(int year, int month, int day, Calendar targetCalendar) {
-
-
- Calendar dateCal = (targetCalendar == null) ? new GregorianCalendar() : targetCalendar;
-
- dateCal.clear();
-
-
- // why-oh-why is this different than java.util.date,
- // in the year part, but it still keeps the silly '0'
- // for the start month????
- dateCal.set(year, month - 1, day, 0, 0, 0);
- dateCal.set(Calendar.MILLISECOND, 0);
-
- long dateAsMillis = 0;
-
- try {
- dateAsMillis = dateCal.getTimeInMillis();
- } catch (IllegalAccessError iae) {
- // Must be on JDK-1.3.1 or older....
- dateAsMillis = dateCal.getTime().getTime();
- }
-
- return new Date(dateAsMillis);
- }
-
- final static Time fastTimeCreate(Calendar cal, int hour, int minute,
- int second, ExceptionInterceptor exceptionInterceptor) throws SQLException {
- if (hour < 0 || hour > 24) {
- throw SQLError.createSQLException("Illegal hour value '" + hour + "' for java.sql.Time type in value '"
- + timeFormattedString(hour, minute, second) + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- if (minute < 0 || minute > 59) {
- throw SQLError.createSQLException("Illegal minute value '" + minute + "'" + "' for java.sql.Time type in value '"
- + timeFormattedString(hour, minute, second) + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- if (second < 0 || second > 59) {
- throw SQLError.createSQLException("Illegal minute value '" + second + "'" + "' for java.sql.Time type in value '"
- + timeFormattedString(hour, minute, second) + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- cal.clear();
-
- // Set 'date' to epoch of Jan 1, 1970
- cal.set(1970, 0, 1, hour, minute, second);
-
- long timeAsMillis = 0;
-
- try {
- timeAsMillis = cal.getTimeInMillis();
- } catch (IllegalAccessError iae) {
- // Must be on JDK-1.3.1 or older....
- timeAsMillis = cal.getTime().getTime();
- }
-
- return new Time(timeAsMillis);
- }
-
- final static Time fastTimeCreate(int hour, int minute,
- int second, Calendar targetCalendar, ExceptionInterceptor exceptionInterceptor) throws SQLException {
- if (hour < 0 || hour > 23) {
- throw SQLError.createSQLException("Illegal hour value '" + hour + "' for java.sql.Time type in value '"
- + timeFormattedString(hour, minute, second) + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- if (minute < 0 || minute > 59) {
- throw SQLError.createSQLException("Illegal minute value '" + minute + "'" + "' for java.sql.Time type in value '"
- + timeFormattedString(hour, minute, second) + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- if (second < 0 || second > 59) {
- throw SQLError.createSQLException("Illegal minute value '" + second + "'" + "' for java.sql.Time type in value '"
- + timeFormattedString(hour, minute, second) + ".",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- Calendar cal = (targetCalendar == null) ? new GregorianCalendar() : targetCalendar;
- cal.clear();
-
- // Set 'date' to epoch of Jan 1, 1970
- cal.set(1970, 0, 1, hour, minute, second);
-
- long timeAsMillis = 0;
-
- try {
- timeAsMillis = cal.getTimeInMillis();
- } catch (IllegalAccessError iae) {
- // Must be on JDK-1.3.1 or older....
- timeAsMillis = cal.getTime().getTime();
- }
-
- return new Time(timeAsMillis);
- }
-
- final static Timestamp fastTimestampCreate(boolean useGmtConversion,
- Calendar gmtCalIfNeeded,
- Calendar cal, int year,
- int month, int day, int hour, int minute, int seconds,
- int secondsPart) {
- cal.clear();
-
- // why-oh-why is this different than java.util.date,
- // in the year part, but it still keeps the silly '0'
- // for the start month????
- cal.set(year, month - 1, day, hour, minute, seconds);
-
- int offsetDiff = 0;
-
- if (useGmtConversion) {
- int fromOffset = cal.get(Calendar.ZONE_OFFSET)
- + cal.get(Calendar.DST_OFFSET);
-
- if (gmtCalIfNeeded == null) {
- gmtCalIfNeeded = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- }
- gmtCalIfNeeded.clear();
-
- gmtCalIfNeeded.setTimeInMillis(cal.getTimeInMillis());
-
- int toOffset = gmtCalIfNeeded.get(Calendar.ZONE_OFFSET)
- + gmtCalIfNeeded.get(Calendar.DST_OFFSET);
- offsetDiff = fromOffset - toOffset;
- }
-
- if (secondsPart != 0) {
- cal.set(Calendar.MILLISECOND, secondsPart / 1000000);
- }
-
- long tsAsMillis = 0;
-
-
- try {
- tsAsMillis = cal.getTimeInMillis();
- } catch (IllegalAccessError iae) {
- // Must be on JDK-1.3.1 or older....
- tsAsMillis = cal.getTime().getTime();
- }
-
- Timestamp ts = new Timestamp(tsAsMillis + offsetDiff);
-
- ts.setNanos(secondsPart);
-
- return ts;
- }
-
- final static Timestamp fastTimestampCreate(TimeZone tz, int year,
- int month, int day, int hour, int minute, int seconds,
- int secondsPart) {
- Calendar cal = (tz == null) ? new GregorianCalendar() : new GregorianCalendar(tz);
- cal.clear();
-
- // why-oh-why is this different than java.util.date,
- // in the year part, but it still keeps the silly '0'
- // for the start month????
- cal.set(year, month - 1, day, hour, minute, seconds);
-
- long tsAsMillis = 0;
-
- try {
- tsAsMillis = cal.getTimeInMillis();
- } catch (IllegalAccessError iae) {
- // Must be on JDK-1.3.1 or older....
- tsAsMillis = cal.getTime().getTime();
- }
-
- Timestamp ts = new Timestamp(tsAsMillis);
- ts.setNanos(secondsPart);
-
- return ts;
- }
-
- /**
- * Returns the 'official' Java timezone name for the given timezone
- *
- * @param timezoneStr
- * the 'common' timezone name
- *
- * @return the Java timezone name for the given timezone
- * @throws SQLException
- *
- * @throws IllegalArgumentException
- * DOCUMENT ME!
- */
- public static String getCanoncialTimezone(String timezoneStr, ExceptionInterceptor exceptionInterceptor) throws SQLException {
- if (timezoneStr == null) {
- return null;
- }
-
- timezoneStr = timezoneStr.trim();
-
- // handle '+/-hh:mm' form ...
-
- if (timezoneStr.length() > 2) {
- if ((timezoneStr.charAt(0) == '+' || timezoneStr.charAt(0) == '-') &&
- Character.isDigit(timezoneStr.charAt(1))) {
- return "GMT" + timezoneStr;
- }
- }
- // Fix windows Daylight/Standard shift JDK doesn't map these (doh)
-
- int daylightIndex = StringUtils.indexOfIgnoreCase(timezoneStr,
- "DAYLIGHT");
-
- if (daylightIndex != -1) {
- StringBuffer timezoneBuf = new StringBuffer();
- timezoneBuf.append(timezoneStr.substring(0, daylightIndex));
- timezoneBuf.append("Standard");
- timezoneBuf.append(timezoneStr.substring(daylightIndex
- + "DAYLIGHT".length(), timezoneStr.length()));
- timezoneStr = timezoneBuf.toString();
- }
-
- String canonicalTz = (String) TIMEZONE_MAPPINGS.get(timezoneStr);
-
- // if we didn't find it, try abbreviated timezones
- if (canonicalTz == null) {
- String[] abbreviatedTimezone = (String[]) ABBREVIATED_TIMEZONES
- .get(timezoneStr);
-
- if (abbreviatedTimezone != null) {
- // If there's only one mapping use that
- if (abbreviatedTimezone.length == 1) {
- canonicalTz = abbreviatedTimezone[0];
- } else {
- StringBuffer possibleTimezones = new StringBuffer(128);
-
- possibleTimezones.append(abbreviatedTimezone[0]);
-
- for (int i = 1; i < abbreviatedTimezone.length; i++) {
- possibleTimezones.append(", ");
- possibleTimezones.append(abbreviatedTimezone[i]);
- }
-
- throw SQLError.createSQLException(Messages.getString("TimeUtil.TooGenericTimezoneId",
- new Object[] {timezoneStr, possibleTimezones}), SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, exceptionInterceptor);
- }
- }
- }
-
- return canonicalTz;
- }
-
- // we could use SimpleDateFormat, but it won't work when the time values
- // are out-of-bounds, and we're using this for error messages for exactly
- // that case
- //
-
- private static String timeFormattedString(int hours, int minutes, int seconds) {
- StringBuffer buf = new StringBuffer(8);
- if (hours < 10) {
- buf.append("0");
- }
-
- buf.append(hours);
- buf.append(":");
-
- if (minutes < 10) {
- buf.append("0");
- }
-
- buf.append(minutes);
- buf.append(":");
-
- if (seconds < 10) {
- buf.append("0");
- }
-
- buf.append(seconds);
-
- return buf.toString();
- }
-}
diff --git a/src/com/mysql/jdbc/UpdatableResultSet.java b/src/com/mysql/jdbc/UpdatableResultSet.java
deleted file mode 100644
index 3aa825425..000000000
--- a/src/com/mysql/jdbc/UpdatableResultSet.java
+++ /dev/null
@@ -1,2581 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.math.BigDecimal;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import com.mysql.jdbc.profiler.ProfilerEvent;
-import com.mysql.jdbc.profiler.ProfilerEventHandlerFactory;
-
-/**
- * A result set that is updatable.
- *
- * @author Mark Matthews
- */
-public class UpdatableResultSet extends ResultSetImpl {
- /** Marker for 'stream' data when doing INSERT rows */
- protected final static byte[] STREAM_DATA_MARKER = "** STREAM DATA **" //$NON-NLS-1$
- .getBytes();
-
- protected SingleByteCharsetConverter charConverter;
-
- private String charEncoding;
-
- /** What is the default value for the column? */
- private byte[][] defaultColumnValue;
-
- /** PreparedStatement used to delete data */
- private com.mysql.jdbc.PreparedStatement deleter = null;
-
- private String deleteSQL = null;
-
- private boolean initializedCharConverter = false;
-
- /** PreparedStatement used to insert data */
- protected com.mysql.jdbc.PreparedStatement inserter = null;
-
- private String insertSQL = null;
-
- /** Is this result set updateable? */
- private boolean isUpdatable = false;
-
- /** Reason the result set is not updatable */
- private String notUpdatableReason = null;
-
- /** List of primary keys */
- private List primaryKeyIndicies = null;
-
- private String qualifiedAndQuotedTableName;
-
- private String quotedIdChar = null;
-
- /** PreparedStatement used to refresh data */
- private com.mysql.jdbc.PreparedStatement refresher;
-
- private String refreshSQL = null;
-
- /** The binary data for the 'current' row */
- private ResultSetRow savedCurrentRow;
-
- /** PreparedStatement used to delete data */
- protected com.mysql.jdbc.PreparedStatement updater = null;
-
- /** SQL for in-place modifcation */
- private String updateSQL = null;
-
- private boolean populateInserterWithDefaultValues = false;
-
- private Map databasesUsedToTablesUsed = null;
-
- /**
- * Creates a new ResultSet object.
- *
- * @param catalog
- * the database in use when we were created
- * @param fields
- * an array of Field objects (basically, the ResultSet MetaData)
- * @param tuples
- * actual row data
- * @param conn
- * the Connection that created us.
- * @param creatorStmt
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- protected UpdatableResultSet(String catalog, Field[] fields, RowData tuples,
- ConnectionImpl conn, StatementImpl creatorStmt) throws SQLException {
- super(catalog, fields, tuples, conn, creatorStmt);
- checkUpdatability();
- this.populateInserterWithDefaultValues =
- this.connection.getPopulateInsertRowWithDefaultValues();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Move to an absolute row number in the result set.
- *
- *
- *
- * If row is positive, moves to an absolute row with respect to the
- * beginning of the result set. The first row is row 1, the second is row 2,
- * etc.
- *
- *
- *
- * If row is negative, moves to an absolute row position with respect to the
- * end of result set. For example, calling absolute(-1) positions the cursor
- * on the last row, absolute(-2) indicates the next-to-last row, etc.
- *
- *
- *
- * An attempt to position the cursor beyond the first/last row in the result
- * set, leaves the cursor before/after the first/last row, respectively.
- *
- *
- *
- * Note: Calling absolute(1) is the same as calling first(). Calling
- * absolute(-1) is the same as calling last().
- *
- *
- * @param row
- * DOCUMENT ME!
- *
- * @return true if on the result set, false if off.
- *
- * @exception SQLException
- * if a database-access error occurs, or row is 0, or result
- * set type is TYPE_FORWARD_ONLY.
- */
- public synchronized boolean absolute(int row) throws SQLException {
- return super.absolute(row);
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the end of the result set, just after the last row. Has no
- * effect if the result set contains no rows.
- *
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY.
- */
- public synchronized void afterLast() throws SQLException {
- super.afterLast();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the front of the result set, just before the first row. Has no
- * effect if the result set contains no rows.
- *
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY
- */
- public synchronized void beforeFirst() throws SQLException {
- super.beforeFirst();
- }
-
- /**
- * JDBC 2.0 The cancelRowUpdates() method may be called after calling an
- * updateXXX() method(s) and before calling updateRow() to rollback the
- * updates made to a row. If no updates have been made or updateRow() has
- * already been called, then this method has no effect.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row.
- */
- public synchronized void cancelRowUpdates() throws SQLException {
- checkClosed();
-
- if (this.doingUpdates) {
- this.doingUpdates = false;
- this.updater.clearParameters();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.ResultSet#checkRowPos()
- */
- protected void checkRowPos() throws SQLException {
- checkClosed();
-
- if (!this.onInsertRow) {
- super.checkRowPos();
- }
- }
-
- /**
- * Is this ResultSet updateable?
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- protected void checkUpdatability() throws SQLException {
- try {
- if (this.fields == null) {
- // we've been created to be populated with cached
- // metadata, and we don't have the metadata yet,
- // we'll be called again by
- // Connection.initializeResultsMetadataFromCache()
- // when the metadata has been made available
-
- return;
- }
-
- String singleTableName = null;
- String catalogName = null;
-
- int primaryKeyCount = 0;
-
- // We can only do this if we know that there is a currently
- // selected database, or if we're talking to a > 4.1 version
- // of MySQL server (as it returns database names in field
- // info)
- //
- if ((this.catalog == null) || (this.catalog.length() == 0)) {
- this.catalog = this.fields[0].getDatabaseName();
-
- if ((this.catalog == null) || (this.catalog.length() == 0)) {
- throw SQLError.createSQLException(Messages
- .getString("UpdatableResultSet.43") //$NON-NLS-1$
- , SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- if (this.fields.length > 0) {
- singleTableName = this.fields[0].getOriginalTableName();
- catalogName = this.fields[0].getDatabaseName();
-
- if (singleTableName == null) {
- singleTableName = this.fields[0].getTableName();
- catalogName = this.catalog;
- }
-
- if (singleTableName != null && singleTableName.length() == 0) {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.3");
-
- return;
- }
-
- if (this.fields[0].isPrimaryKey()) {
- primaryKeyCount++;
- }
-
- //
- // References only one table?
- //
- for (int i = 1; i < this.fields.length; i++) {
- String otherTableName = this.fields[i].getOriginalTableName();
- String otherCatalogName = this.fields[i].getDatabaseName();
-
- if (otherTableName == null) {
- otherTableName = this.fields[i].getTableName();
- otherCatalogName = this.catalog;
- }
-
- if (otherTableName != null && otherTableName.length() == 0) {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.3");
-
- return;
- }
-
- if ((singleTableName == null)
- || !otherTableName.equals(singleTableName)) {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.0");
-
- return;
- }
-
- // Can't reference more than one database
- if ((catalogName == null)
- || !otherCatalogName.equals(catalogName)) {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.1");
-
- return;
- }
-
- if (this.fields[i].isPrimaryKey()) {
- primaryKeyCount++;
- }
- }
-
- if ((singleTableName == null) || (singleTableName.length() == 0)) {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.2");
-
- return;
- }
- } else {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.3");
-
- return;
- }
-
- if (this.connection.getStrictUpdates()) {
- java.sql.DatabaseMetaData dbmd = this.connection.getMetaData();
-
- java.sql.ResultSet rs = null;
- HashMap primaryKeyNames = new HashMap();
-
- try {
- rs = dbmd.getPrimaryKeys(catalogName, null, singleTableName);
-
- while (rs.next()) {
- String keyName = rs.getString(4);
- keyName = keyName.toUpperCase();
- primaryKeyNames.put(keyName, keyName);
- }
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (Exception ex) {
- AssertionFailedException.shouldNotHappen(ex);
- }
-
- rs = null;
- }
- }
-
- int existingPrimaryKeysCount = primaryKeyNames.size();
-
- if (existingPrimaryKeysCount == 0) {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.5");
-
- return; // we can't update tables w/o keys
- }
-
- //
- // Contains all primary keys?
- //
- for (int i = 0; i < this.fields.length; i++) {
- if (this.fields[i].isPrimaryKey()) {
- String columnNameUC = this.fields[i].getName()
- .toUpperCase();
-
- if (primaryKeyNames.remove(columnNameUC) == null) {
- // try original name
- String originalName = this.fields[i].getOriginalName();
-
- if (originalName != null) {
- if (primaryKeyNames.remove(originalName
- .toUpperCase()) == null) {
- // we don't know about this key, so give up :(
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.6",
- new Object[] {originalName});
-
- return;
- }
- }
- }
- }
- }
-
- this.isUpdatable = primaryKeyNames.isEmpty();
-
- if (!this.isUpdatable) {
- if (existingPrimaryKeysCount > 1) {
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.7");
- } else {
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.4");
- }
-
- return;
- }
- }
-
- //
- // Must have at least one primary key
- //
- if (primaryKeyCount == 0) {
- this.isUpdatable = false;
- this.notUpdatableReason = Messages.getString("NotUpdatableReason.4");
-
- return;
- }
-
- this.isUpdatable = true;
- this.notUpdatableReason = null;
-
- return;
- } catch (SQLException sqlEx) {
- this.isUpdatable = false;
- this.notUpdatableReason = sqlEx.getMessage();
- }
- }
-
- /**
- * JDBC 2.0 Delete the current row from the result set and the underlying
- * database. Cannot be called when on the insert row.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row.
- * @throws SQLException
- * if the ResultSet is not updatable or some other error occurs
- */
- public synchronized void deleteRow() throws SQLException {
- checkClosed();
-
- if (!this.isUpdatable) {
- throw new NotUpdatable(this.notUpdatableReason);
- }
-
- if (this.onInsertRow) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.1"), getExceptionInterceptor()); //$NON-NLS-1$
- } else if (this.rowData.size() == 0) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.2"), getExceptionInterceptor()); //$NON-NLS-1$
- } else if (isBeforeFirst()) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.3"), getExceptionInterceptor()); //$NON-NLS-1$
- } else if (isAfterLast()) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.4"), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- if (this.deleter == null) {
- if (this.deleteSQL == null) {
- generateStatements();
- }
-
- this.deleter = (PreparedStatement) this.connection
- .clientPrepareStatement(this.deleteSQL);
- }
-
- this.deleter.clearParameters();
-
- String characterEncoding = null;
-
- if (this.connection.getUseUnicode()) {
- characterEncoding = this.connection.getEncoding();
- }
-
- int numKeys = this.primaryKeyIndicies.size();
-
- if (numKeys == 1) {
- int index = ((Integer) this.primaryKeyIndicies.get(0))
- .intValue();
- byte[] currentVal = this.thisRow.getColumnValue(index);
- this.deleter.setBytes(1, currentVal);
- } else {
- for (int i = 0; i < numKeys; i++) {
- int index = ((Integer) this.primaryKeyIndicies.get(i))
- .intValue();
- byte[] currentVal = this.thisRow.getColumnValue(index);
-
- this.deleter.setBytes(i + 1, currentVal);
- }
- }
-
- this.deleter.executeUpdate();
- this.rowData.removeRow(this.rowData.getCurrentRowNumber());
-
- // position on previous row - Bug#27431
- previous();
-
- }
-
- private synchronized void extractDefaultValues() throws SQLException {
- java.sql.DatabaseMetaData dbmd = this.connection.getMetaData();
- this.defaultColumnValue = new byte[this.fields.length][];
-
- java.sql.ResultSet columnsResultSet = null;
- Iterator referencedDbs = this.databasesUsedToTablesUsed.entrySet().iterator();
-
- while (referencedDbs.hasNext()) {
- Map.Entry dbEntry = (Map.Entry)referencedDbs.next();
- String databaseName = dbEntry.getKey().toString();
-
- Iterator referencedTables = ((Map)dbEntry.getValue()).entrySet().iterator();
-
- while (referencedTables.hasNext()) {
- Map.Entry tableEntry = (Map.Entry)referencedTables.next();
- String tableName = tableEntry.getKey().toString();
- Map columnNamesToIndices = (Map)tableEntry.getValue();
-
- try {
- columnsResultSet = dbmd.getColumns(this.catalog, null,
- tableName, "%"); //$NON-NLS-1$
-
- while (columnsResultSet.next()) {
- String columnName = columnsResultSet.getString("COLUMN_NAME"); //$NON-NLS-1$
- byte[] defaultValue = columnsResultSet.getBytes("COLUMN_DEF"); //$NON-NLS-1$
-
- if (columnNamesToIndices.containsKey(columnName)) {
- int localColumnIndex = ((Integer)columnNamesToIndices.get(columnName)).intValue();
-
- this.defaultColumnValue[localColumnIndex] = defaultValue;
- } // else assert?
- }
- } finally {
- if (columnsResultSet != null) {
- columnsResultSet.close();
-
- columnsResultSet = null;
- }
- }
- }
- }
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the first row in the result set.
- *
- *
- * @return true if on a valid row, false if no rows in the result set.
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY.
- */
- public synchronized boolean first() throws SQLException {
- return super.first();
- }
-
- /**
- * Figure out whether or not this ResultSet is updateable, and if so,
- * generate the PreparedStatements to support updates.
- *
- * @throws SQLException
- * DOCUMENT ME!
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- protected synchronized void generateStatements() throws SQLException {
- if (!this.isUpdatable) {
- this.doingUpdates = false;
- this.onInsertRow = false;
-
- throw new NotUpdatable(this.notUpdatableReason);
- }
-
- String quotedId = getQuotedIdChar();
-
- Map tableNamesSoFar = null;
-
- if (this.connection.lowerCaseTableNames()) {
- tableNamesSoFar = new TreeMap(String.CASE_INSENSITIVE_ORDER);
- this.databasesUsedToTablesUsed = new TreeMap(String.CASE_INSENSITIVE_ORDER);
- } else {
- tableNamesSoFar = new TreeMap();
- this.databasesUsedToTablesUsed = new TreeMap();
- }
-
- this.primaryKeyIndicies = new ArrayList();
-
- StringBuffer fieldValues = new StringBuffer();
- StringBuffer keyValues = new StringBuffer();
- StringBuffer columnNames = new StringBuffer();
- StringBuffer insertPlaceHolders = new StringBuffer();
- StringBuffer allTablesBuf = new StringBuffer();
- Map columnIndicesToTable = new HashMap();
-
- boolean firstTime = true;
- boolean keysFirstTime = true;
-
- String equalsStr = this.connection.versionMeetsMinimum(3, 23, 0) ? "<=>"
- : "=";
-
- for (int i = 0; i < this.fields.length; i++) {
- StringBuffer tableNameBuffer = new StringBuffer();
- Map updColumnNameToIndex = null;
-
- // FIXME: What about no table?
- if (this.fields[i].getOriginalTableName() != null) {
-
- String databaseName = this.fields[i].getDatabaseName();
-
- if ((databaseName != null) && (databaseName.length() > 0)) {
- tableNameBuffer.append(quotedId);
- tableNameBuffer.append(databaseName);
- tableNameBuffer.append(quotedId);
- tableNameBuffer.append('.');
- }
-
- String tableOnlyName = this.fields[i].getOriginalTableName();
-
- tableNameBuffer.append(quotedId);
- tableNameBuffer.append(tableOnlyName);
- tableNameBuffer.append(quotedId);
-
- String fqTableName = tableNameBuffer.toString();
-
- if (!tableNamesSoFar.containsKey(fqTableName)) {
- if (!tableNamesSoFar.isEmpty()) {
- allTablesBuf.append(',');
- }
-
- allTablesBuf.append(fqTableName);
- tableNamesSoFar.put(fqTableName, fqTableName);
- }
-
- columnIndicesToTable.put(new Integer(i), fqTableName);
-
- updColumnNameToIndex = getColumnsToIndexMapForTableAndDB(databaseName, tableOnlyName);
- } else {
- String tableOnlyName = this.fields[i].getTableName();
-
- if (tableOnlyName != null) {
- tableNameBuffer.append(quotedId);
- tableNameBuffer.append(tableOnlyName);
- tableNameBuffer.append(quotedId);
-
- String fqTableName = tableNameBuffer.toString();
-
- if (!tableNamesSoFar.containsKey(fqTableName)) {
- if (!tableNamesSoFar.isEmpty()) {
- allTablesBuf.append(',');
- }
-
- allTablesBuf.append(fqTableName);
- tableNamesSoFar.put(fqTableName, fqTableName);
- }
-
- columnIndicesToTable.put(new Integer(i), fqTableName);
-
- updColumnNameToIndex = getColumnsToIndexMapForTableAndDB(this.catalog, tableOnlyName);
- }
- }
-
- String originalColumnName = this.fields[i].getOriginalName();
- String columnName = null;
-
- if (this.connection.getIO().hasLongColumnInfo()
- && (originalColumnName != null)
- && (originalColumnName.length() > 0)) {
- columnName = originalColumnName;
- } else {
- columnName = this.fields[i].getName();
- }
-
- if (updColumnNameToIndex != null && columnName != null) {
- updColumnNameToIndex.put(columnName, new Integer(i));
- }
-
- String originalTableName = this.fields[i].getOriginalTableName();
- String tableName = null;
-
- if (this.connection.getIO().hasLongColumnInfo()
- && (originalTableName != null)
- && (originalTableName.length() > 0)) {
- tableName = originalTableName;
- } else {
- tableName = this.fields[i].getTableName();
- }
-
- StringBuffer fqcnBuf = new StringBuffer();
- String databaseName = this.fields[i].getDatabaseName();
-
- if (databaseName != null && databaseName.length() > 0) {
- fqcnBuf.append(quotedId);
- fqcnBuf.append(databaseName);
- fqcnBuf.append(quotedId);
- fqcnBuf.append('.');
- }
-
- fqcnBuf.append(quotedId);
- fqcnBuf.append(tableName);
- fqcnBuf.append(quotedId);
- fqcnBuf.append('.');
- fqcnBuf.append(quotedId);
- fqcnBuf.append(columnName);
- fqcnBuf.append(quotedId);
-
- String qualifiedColumnName = fqcnBuf.toString();
-
- if (this.fields[i].isPrimaryKey()) {
- this.primaryKeyIndicies.add(Constants.integerValueOf(i));
-
- if (!keysFirstTime) {
- keyValues.append(" AND "); //$NON-NLS-1$
- } else {
- keysFirstTime = false;
- }
-
- keyValues.append(qualifiedColumnName);
- keyValues.append(equalsStr);
- keyValues.append("?"); //$NON-NLS-1$
- }
-
- if (firstTime) {
- firstTime = false;
- fieldValues.append("SET "); //$NON-NLS-1$
- } else {
- fieldValues.append(","); //$NON-NLS-1$
- columnNames.append(","); //$NON-NLS-1$
- insertPlaceHolders.append(","); //$NON-NLS-1$
- }
-
- insertPlaceHolders.append("?"); //$NON-NLS-1$
-
- columnNames.append(qualifiedColumnName);
-
- fieldValues.append(qualifiedColumnName);
- fieldValues.append("=?"); //$NON-NLS-1$
- }
-
- this.qualifiedAndQuotedTableName = allTablesBuf.toString();
-
- this.updateSQL = "UPDATE " + this.qualifiedAndQuotedTableName + " " //$NON-NLS-1$ //$NON-NLS-2$
- + fieldValues.toString() //$NON-NLS-1$ //$NON-NLS-2$
- + " WHERE " + keyValues.toString(); //$NON-NLS-1$
- this.insertSQL = "INSERT INTO " + this.qualifiedAndQuotedTableName //$NON-NLS-1$
- + " (" + columnNames.toString() //$NON-NLS-1$ //$NON-NLS-2$
- + ") VALUES (" + insertPlaceHolders.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- this.refreshSQL = "SELECT " + columnNames.toString() + " FROM " //$NON-NLS-1$ //$NON-NLS-2$
- + this.qualifiedAndQuotedTableName //$NON-NLS-1$ //$NON-NLS-2$
- + " WHERE " + keyValues.toString(); //$NON-NLS-1$
- this.deleteSQL = "DELETE FROM " + this.qualifiedAndQuotedTableName //$NON-NLS-1$
- + " WHERE " //$NON-NLS-1$ //$NON-NLS-2$
- + keyValues.toString();
- }
-
- private Map getColumnsToIndexMapForTableAndDB(String databaseName, String tableName) {
- Map nameToIndex;
- Map tablesUsedToColumnsMap = (Map)this.databasesUsedToTablesUsed.get(databaseName);
-
- if (tablesUsedToColumnsMap == null) {
- if (this.connection.lowerCaseTableNames()) {
- tablesUsedToColumnsMap = new TreeMap(String.CASE_INSENSITIVE_ORDER);
- } else {
- tablesUsedToColumnsMap = new TreeMap();
- }
-
- this.databasesUsedToTablesUsed.put(databaseName, tablesUsedToColumnsMap);
- }
-
- nameToIndex = (Map)tablesUsedToColumnsMap.get(tableName);
-
- if (nameToIndex == null) {
- nameToIndex = new HashMap();
- tablesUsedToColumnsMap.put(tableName, nameToIndex);
- }
-
- return nameToIndex;
- }
-
- private synchronized SingleByteCharsetConverter getCharConverter()
- throws SQLException {
- if (!this.initializedCharConverter) {
- this.initializedCharConverter = true;
-
- if (this.connection.getUseUnicode()) {
- this.charEncoding = connection.getEncoding();
- this.charConverter = this.connection
- .getCharsetConverter(this.charEncoding);
- }
- }
-
- return this.charConverter;
- }
-
- /**
- * JDBC 2.0 Return the concurrency of this result set. The concurrency used
- * is determined by the statement that created the result set.
- *
- * @return the concurrency type, CONCUR_READ_ONLY, etc.
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public int getConcurrency() throws SQLException {
- return (this.isUpdatable ? CONCUR_UPDATABLE : CONCUR_READ_ONLY);
- }
-
- private synchronized String getQuotedIdChar() throws SQLException {
- if (this.quotedIdChar == null) {
- boolean useQuotedIdentifiers = this.connection
- .supportsQuotedIdentifiers();
-
- if (useQuotedIdentifiers) {
- java.sql.DatabaseMetaData dbmd = this.connection.getMetaData();
- this.quotedIdChar = dbmd.getIdentifierQuoteString();
- } else {
- this.quotedIdChar = ""; //$NON-NLS-1$
- }
- }
-
- return this.quotedIdChar;
- }
-
- /**
- * JDBC 2.0 Insert the contents of the insert row into the result set and
- * the database. Must be on the insert row when this method is called.
- *
- * @exception SQLException
- * if a database-access error occurs, if called when not on
- * the insert row, or if all non-nullable columns in the
- * insert row have not been given a value
- */
- public synchronized void insertRow() throws SQLException {
- checkClosed();
-
- if (!this.onInsertRow) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.7"), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- this.inserter.executeUpdate();
-
- long autoIncrementId = this.inserter.getLastInsertID();
- int numFields = this.fields.length;
- byte[][] newRow = new byte[numFields][];
-
- for (int i = 0; i < numFields; i++) {
- if (this.inserter.isNull(i)) {
- newRow[i] = null;
- } else {
- newRow[i] = this.inserter.getBytesRepresentation(i);
- }
-
- //
- // WARN: This non-variant only holds if MySQL never allows more
- // than one auto-increment key (which is the way it is _today_)
- //
- if (this.fields[i].isAutoIncrement() && autoIncrementId > 0) {
- newRow[i] = String.valueOf(autoIncrementId).getBytes();
- this.inserter.setBytesNoEscapeNoQuotes(i + 1, newRow[i]);
- }
- }
-
- ResultSetRow resultSetRow = new ByteArrayRow(newRow, getExceptionInterceptor());
-
- refreshRow(this.inserter, resultSetRow);
-
- this.rowData.addRow(resultSetRow);
- resetInserter();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is after the last row in the result set.
- *
- *
- * @return true if after the last row, false otherwise. Returns false when
- * the result set contains no rows.
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public synchronized boolean isAfterLast() throws SQLException {
- return super.isAfterLast();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is before the first row in the result set.
- *
- *
- * @return true if before the first row, false otherwise. Returns false when
- * the result set contains no rows.
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public synchronized boolean isBeforeFirst() throws SQLException {
- return super.isBeforeFirst();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is on the first row of the result set.
- *
- *
- * @return true if on the first row, false otherwise.
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public synchronized boolean isFirst() throws SQLException {
- return super.isFirst();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Determine if the cursor is on the last row of the result set. Note:
- * Calling isLast() may be expensive since the JDBC driver might need to
- * fetch ahead one row in order to determine whether the current row is the
- * last row in the result set.
- *
- *
- * @return true if on the last row, false otherwise.
- *
- * @exception SQLException
- * if a database-access error occurs.
- */
- public synchronized boolean isLast() throws SQLException {
- return super.isLast();
- }
-
- boolean isUpdatable() {
- return this.isUpdatable;
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the last row in the result set.
- *
- *
- * @return true if on a valid row, false if no rows in the result set.
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWARD_ONLY.
- */
- public synchronized boolean last() throws SQLException {
- return super.last();
- }
-
- /**
- * JDBC 2.0 Move the cursor to the remembered cursor position, usually the
- * current row. Has no effect unless the cursor is on the insert row.
- *
- * @exception SQLException
- * if a database-access error occurs, or the result set is
- * not updatable
- * @throws SQLException
- * if the ResultSet is not updatable or some other error occurs
- */
- public synchronized void moveToCurrentRow() throws SQLException {
- checkClosed();
-
- if (!this.isUpdatable) {
- throw new NotUpdatable(this.notUpdatableReason);
- }
-
- if (this.onInsertRow) {
- this.onInsertRow = false;
- this.thisRow = this.savedCurrentRow;
- }
- }
-
- /**
- * JDBC 2.0 Move to the insert row. The current cursor position is
- * remembered while the cursor is positioned on the insert row. The insert
- * row is a special row associated with an updatable result set. It is
- * essentially a buffer where a new row may be constructed by calling the
- * updateXXX() methods prior to inserting the row into the result set. Only
- * the updateXXX(), getXXX(), and insertRow() methods may be called when the
- * cursor is on the insert row. All of the columns in a result set must be
- * given a value each time this method is called before calling insertRow().
- * UpdateXXX()must be called before getXXX() on a column.
- *
- * @exception SQLException
- * if a database-access error occurs, or the result set is
- * not updatable
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public synchronized void moveToInsertRow() throws SQLException {
- checkClosed();
-
- if (!this.isUpdatable) {
- throw new NotUpdatable(this.notUpdatableReason);
- }
-
- if (this.inserter == null) {
- if (this.insertSQL == null) {
- generateStatements();
- }
-
- this.inserter = (PreparedStatement) this.connection
- .clientPrepareStatement(this.insertSQL);
- if (this.populateInserterWithDefaultValues) {
- extractDefaultValues();
- }
-
- resetInserter();
- } else {
- resetInserter();
- }
-
- int numFields = this.fields.length;
-
- this.onInsertRow = true;
- this.doingUpdates = false;
- this.savedCurrentRow = this.thisRow;
- byte[][] newRowData = new byte[numFields][];
- this.thisRow = new ByteArrayRow(newRowData, getExceptionInterceptor());
-
- for (int i = 0; i < numFields; i++) {
- if (!this.populateInserterWithDefaultValues) {
- this.inserter.setBytesNoEscapeNoQuotes(i + 1,
- "DEFAULT".getBytes());
- newRowData = null;
- } else {
- if (this.defaultColumnValue[i] != null) {
- Field f = this.fields[i];
-
- switch (f.getMysqlType()) {
- case MysqlDefs.FIELD_TYPE_DATE:
- case MysqlDefs.FIELD_TYPE_DATETIME:
- case MysqlDefs.FIELD_TYPE_NEWDATE:
- case MysqlDefs.FIELD_TYPE_TIME:
- case MysqlDefs.FIELD_TYPE_TIMESTAMP:
-
- if (this.defaultColumnValue[i].length > 7
- && this.defaultColumnValue[i][0] == (byte) 'C'
- && this.defaultColumnValue[i][1] == (byte) 'U'
- && this.defaultColumnValue[i][2] == (byte) 'R'
- && this.defaultColumnValue[i][3] == (byte) 'R'
- && this.defaultColumnValue[i][4] == (byte) 'E'
- && this.defaultColumnValue[i][5] == (byte) 'N'
- && this.defaultColumnValue[i][6] == (byte) 'T'
- && this.defaultColumnValue[i][7] == (byte) '_') {
- this.inserter.setBytesNoEscapeNoQuotes(i + 1,
- this.defaultColumnValue[i]);
-
- break;
- }
- default:
- this.inserter.setBytes(i + 1, this.defaultColumnValue[i],
- false, false);
- }
-
- // This value _could_ be changed from a getBytes(), so we
- // need a copy....
- byte[] defaultValueCopy = new byte[this.defaultColumnValue[i].length];
- System.arraycopy(defaultColumnValue[i], 0, defaultValueCopy, 0,
- defaultValueCopy.length);
- newRowData[i] = defaultValueCopy;
- } else {
- this.inserter.setNull(i + 1, java.sql.Types.NULL);
- newRowData[i] = null;
- }
- }
- }
- }
-
- // ---------------------------------------------------------------------
- // Updates
- // ---------------------------------------------------------------------
-
- /**
- * A ResultSet is initially positioned before its first row, the first call
- * to next makes the first row the current row; the second call makes the
- * second row the current row, etc.
- *
- *
- * If an input stream from the previous row is open, it is implicitly
- * closed. The ResultSet's warning chain is cleared when a new row is read
- *
- *
- * @return true if the new current is valid; false if there are no more rows
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public synchronized boolean next() throws SQLException {
- return super.next();
- }
-
- /**
- * The prev method is not part of JDBC, but because of the architecture of
- * this driver it is possible to move both forward and backward within the
- * result set.
- *
- *
- * If an input stream from the previous row is open, it is implicitly
- * closed. The ResultSet's warning chain is cleared when a new row is read
- *
- *
- * @return true if the new current is valid; false if there are no more rows
- *
- * @exception SQLException
- * if a database access error occurs
- */
- public synchronized boolean prev() throws SQLException {
- return super.prev();
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves to the previous row in the result set.
- *
- *
- *
- * Note: previous() is not the same as relative(-1) since it makes sense to
- * call previous() when there is no current row.
- *
- *
- * @return true if on a valid row, false if off the result set.
- *
- * @exception SQLException
- * if a database-access error occurs, or result set type is
- * TYPE_FORWAR_DONLY.
- */
- public synchronized boolean previous() throws SQLException {
- return super.previous();
- }
-
- /**
- * Closes this ResultSet, releasing all resources.
- *
- * @param calledExplicitly
- * was this called from close()?
- *
- * @throws SQLException
- * if an error occurs.
- */
- public void realClose(boolean calledExplicitly) throws SQLException {
- if (this.isClosed) {
- return;
- }
-
- SQLException sqlEx = null;
-
- if (this.useUsageAdvisor) {
- if ((this.deleter == null) && (this.inserter == null)
- && (this.refresher == null) && (this.updater == null)) {
- this.eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);
-
- String message = Messages.getString("UpdatableResultSet.34"); //$NON-NLS-1$
-
- this.eventSink.consumeEvent(new ProfilerEvent(
- ProfilerEvent.TYPE_WARN,
- "", //$NON-NLS-1$
- (this.owningStatement == null) ? "N/A" //$NON-NLS-1$
- : this.owningStatement.currentCatalog, //$NON-NLS-1$
- this.connectionId,
- (this.owningStatement == null) ? (-1)
- : this.owningStatement.getId(), this.resultId,
- System.currentTimeMillis(), 0, Constants.MILLIS_I18N,
- null, this.pointOfOrigin, message));
- }
- }
-
- try {
- if (this.deleter != null) {
- this.deleter.close();
- }
- } catch (SQLException ex) {
- sqlEx = ex;
- }
-
- try {
- if (this.inserter != null) {
- this.inserter.close();
- }
- } catch (SQLException ex) {
- sqlEx = ex;
- }
-
- try {
- if (this.refresher != null) {
- this.refresher.close();
- }
- } catch (SQLException ex) {
- sqlEx = ex;
- }
-
- try {
- if (this.updater != null) {
- this.updater.close();
- }
- } catch (SQLException ex) {
- sqlEx = ex;
- }
-
- super.realClose(calledExplicitly);
-
- if (sqlEx != null) {
- throw sqlEx;
- }
- }
-
- /**
- * JDBC 2.0 Refresh the value of the current row with its current value in
- * the database. Cannot be called when on the insert row. The refreshRow()
- * method provides a way for an application to explicitly tell the JDBC
- * driver to refetch a row(s) from the database. An application may want to
- * call refreshRow() when caching or prefetching is being done by the JDBC
- * driver to fetch the latest value of a row from the database. The JDBC
- * driver may actually refresh multiple rows at once if the fetch size is
- * greater than one. All values are refetched subject to the transaction
- * isolation level and cursor sensitivity. If refreshRow() is called after
- * calling updateXXX(), but before calling updateRow() then the updates made
- * to the row are lost. Calling refreshRow() frequently will likely slow
- * performance.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row.
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public synchronized void refreshRow() throws SQLException {
- checkClosed();
-
- if (!this.isUpdatable) {
- throw new NotUpdatable();
- }
-
- if (this.onInsertRow) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.8"), getExceptionInterceptor()); //$NON-NLS-1$
- } else if (this.rowData.size() == 0) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.9"), getExceptionInterceptor()); //$NON-NLS-1$
- } else if (isBeforeFirst()) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.10"), getExceptionInterceptor()); //$NON-NLS-1$
- } else if (isAfterLast()) {
- throw SQLError.createSQLException(Messages.getString("UpdatableResultSet.11"), getExceptionInterceptor()); //$NON-NLS-1$
- }
-
- refreshRow(this.updater, this.thisRow);
- }
-
- private synchronized void refreshRow(PreparedStatement updateInsertStmt,
- ResultSetRow rowToRefresh) throws SQLException {
- if (this.refresher == null) {
- if (this.refreshSQL == null) {
- generateStatements();
- }
-
- this.refresher = (PreparedStatement) this.connection
- .clientPrepareStatement(this.refreshSQL);
- }
-
- this.refresher.clearParameters();
-
- int numKeys = this.primaryKeyIndicies.size();
-
- if (numKeys == 1) {
- byte[] dataFrom = null;
- int index = ((Integer) this.primaryKeyIndicies.get(0)).intValue();
-
- if (!this.doingUpdates && !this.onInsertRow) {
- dataFrom = (byte[]) rowToRefresh.getColumnValue(index);
- } else {
- dataFrom = updateInsertStmt.getBytesRepresentation(index);
-
- // Primary keys not set?
- if (updateInsertStmt.isNull(index) || (dataFrom.length == 0)) {
- dataFrom = (byte[]) rowToRefresh.getColumnValue(index);
- } else {
- dataFrom = stripBinaryPrefix(dataFrom);
- }
- }
-
- this.refresher.setBytesNoEscape(1, dataFrom);
- } else {
- for (int i = 0; i < numKeys; i++) {
- byte[] dataFrom = null;
- int index = ((Integer) this.primaryKeyIndicies.get(i))
- .intValue();
-
- if (!this.doingUpdates && !this.onInsertRow) {
- dataFrom = (byte[]) rowToRefresh.getColumnValue(index);
- } else {
- dataFrom = updateInsertStmt.getBytesRepresentation(index);
-
- // Primary keys not set?
- if (updateInsertStmt.isNull(index) || (dataFrom.length == 0)) {
- dataFrom = (byte[]) rowToRefresh.getColumnValue(index);
- } else {
- dataFrom = stripBinaryPrefix(dataFrom);
- }
- }
-
- this.refresher.setBytesNoEscape(i + 1, dataFrom);
- }
- }
-
- java.sql.ResultSet rs = null;
-
- try {
- rs = this.refresher.executeQuery();
-
- int numCols = rs.getMetaData().getColumnCount();
-
- if (rs.next()) {
- for (int i = 0; i < numCols; i++) {
- byte[] val = rs.getBytes(i + 1);
-
- if ((val == null) || rs.wasNull()) {
- rowToRefresh.setColumnValue(i, null);
- } else {
- rowToRefresh.setColumnValue(i, rs.getBytes(i + 1));
- }
- }
- } else {
- throw SQLError.createSQLException(Messages
- .getString("UpdatableResultSet.12"), //$NON-NLS-1$
- SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor()); //$NON-NLS-1$
- }
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException ex) {
- ; // ignore
- }
- }
- }
- }
-
- /**
- * JDBC 2.0
- *
- *
- * Moves a relative number of rows, either positive or negative. Attempting
- * to move beyond the first/last row in the result set positions the cursor
- * before/after the the first/last row. Calling relative(0) is valid, but
- * does not change the cursor position.
- *
- *
- *
- * Note: Calling relative(1) is different than calling next() since is makes
- * sense to call next() when there is no current row, for example, when the
- * cursor is positioned before the first row or after the last row of the
- * result set.
- *
- *
- * @param rows
- * DOCUMENT ME!
- *
- * @return true if on a row, false otherwise.
- *
- * @exception SQLException
- * if a database-access error occurs, or there is no current
- * row, or result set type is TYPE_FORWARD_ONLY.
- */
- public synchronized boolean relative(int rows) throws SQLException {
- return super.relative(rows);
- }
-
- private void resetInserter() throws SQLException {
- this.inserter.clearParameters();
-
- for (int i = 0; i < this.fields.length; i++) {
- this.inserter.setNull(i + 1, 0);
- }
- }
-
- /**
- * JDBC 2.0 Determine if this row has been deleted. A deleted row may leave
- * a visible "hole" in a result set. This method can be used to detect holes
- * in a result set. The value returned depends on whether or not the result
- * set can detect deletions.
- *
- * @return true if deleted and deletes are detected
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- *
- * @see DatabaseMetaData#deletesAreDetected
- */
- public synchronized boolean rowDeleted() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Determine if the current row has been inserted. The value
- * returned depends on whether or not the result set can detect visible
- * inserts.
- *
- * @return true if inserted and inserts are detected
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- *
- * @see DatabaseMetaData#insertsAreDetected
- */
- public synchronized boolean rowInserted() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * JDBC 2.0 Determine if the current row has been updated. The value
- * returned depends on whether or not the result set can detect updates.
- *
- * @return true if the row has been visibly updated by the owner or another,
- * and updates are detected
- *
- * @exception SQLException
- * if a database-access error occurs
- * @throws NotImplemented
- * DOCUMENT ME!
- *
- * @see DatabaseMetaData#updatesAreDetected
- */
- public synchronized boolean rowUpdated() throws SQLException {
- throw SQLError.notImplemented();
- }
-
- /**
- * Sets the concurrency type of this result set
- *
- * @param concurrencyFlag
- * the type of concurrency that this ResultSet should support.
- */
- protected void setResultSetConcurrency(int concurrencyFlag) {
- super.setResultSetConcurrency(concurrencyFlag);
-
- //
- // FIXME: Issue warning when asked for updateable result set, but result
- // set is not
- // updatable
- //
- // if ((concurrencyFlag == CONCUR_UPDATABLE) && !isUpdatable()) {
- // java.sql.SQLWarning warning = new java.sql.SQLWarning(
- // NotUpdatable.NOT_UPDATEABLE_MESSAGE);
- // }
- }
-
- private byte[] stripBinaryPrefix(byte[] dataFrom) {
- return StringUtils.stripEnclosure(dataFrom, "_binary'", "'");
- }
-
- /**
- * Reset UPDATE prepared statement to value in current row. This_Row MUST
- * point to current, valid row.
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- protected synchronized void syncUpdate() throws SQLException {
- if (this.updater == null) {
- if (this.updateSQL == null) {
- generateStatements();
- }
-
- this.updater = (PreparedStatement) this.connection
- .clientPrepareStatement(this.updateSQL);
- }
-
- int numFields = this.fields.length;
- this.updater.clearParameters();
-
- for (int i = 0; i < numFields; i++) {
- if (this.thisRow.getColumnValue(i) != null) {
- this.updater.setBytes(i + 1, (byte[]) this.thisRow.getColumnValue(i),
- this.fields[i].isBinary(), false);
- } else {
- this.updater.setNull(i + 1, 0);
- }
- }
-
- int numKeys = this.primaryKeyIndicies.size();
-
- if (numKeys == 1) {
- int index = ((Integer) this.primaryKeyIndicies.get(0)).intValue();
- byte[] keyData = (byte[]) this.thisRow.getColumnValue(index);
- this.updater.setBytes(numFields + 1, keyData, false, false);
- } else {
- for (int i = 0; i < numKeys; i++) {
- byte[] currentVal = (byte[]) this.thisRow.getColumnValue(((Integer) this.primaryKeyIndicies
- .get(i)).intValue());
-
- if (currentVal != null) {
- this.updater.setBytes(numFields + i + 1, currentVal, false,
- false);
- } else {
- this.updater.setNull(numFields + i + 1, 0);
- }
- }
- }
- }
-
- /**
- * JDBC 2.0 Update a column with an ascii stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateAsciiStream(int columnIndex,
- java.io.InputStream x, int length) throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setAsciiStream(columnIndex, x, length);
- } else {
- this.inserter.setAsciiStream(columnIndex, x, length);
- this.thisRow.setColumnValue(columnIndex - 1, STREAM_DATA_MARKER);
- }
- }
-
- /**
- * JDBC 2.0 Update a column with an ascii stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- * @param length
- * of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateAsciiStream(String columnName,
- java.io.InputStream x, int length) throws SQLException {
- updateAsciiStream(findColumn(columnName), x, length);
- }
-
- /**
- * JDBC 2.0 Update a column with a BigDecimal value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBigDecimal(int columnIndex, BigDecimal x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setBigDecimal(columnIndex, x);
- } else {
- this.inserter.setBigDecimal(columnIndex, x);
-
- if (x == null) {
- this.thisRow.setColumnValue(columnIndex - 1, null);
- } else {
- this.thisRow.setColumnValue(columnIndex - 1, x.toString().getBytes());
- }
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a BigDecimal value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBigDecimal(String columnName, BigDecimal x)
- throws SQLException {
- updateBigDecimal(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a binary stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBinaryStream(int columnIndex,
- java.io.InputStream x, int length) throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setBinaryStream(columnIndex, x, length);
- } else {
- this.inserter.setBinaryStream(columnIndex, x, length);
-
- if (x == null) {
- this.thisRow.setColumnValue(columnIndex - 1, null);
- } else {
- this.thisRow.setColumnValue(columnIndex - 1, STREAM_DATA_MARKER);
- }
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a binary stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- * @param length
- * of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBinaryStream(String columnName,
- java.io.InputStream x, int length) throws SQLException {
- updateBinaryStream(findColumn(columnName), x, length);
- }
-
- /**
- * @see ResultSetInternalMethods#updateBlob(int, Blob)
- */
- public synchronized void updateBlob(int columnIndex, java.sql.Blob blob)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setBlob(columnIndex, blob);
- } else {
- this.inserter.setBlob(columnIndex, blob);
-
- if (blob == null) {
- this.thisRow.setColumnValue(columnIndex - 1, null);
- } else {
- this.thisRow.setColumnValue(columnIndex - 1, STREAM_DATA_MARKER);
- }
- }
- }
-
- /**
- * @see ResultSetInternalMethods#updateBlob(String, Blob)
- */
- public synchronized void updateBlob(String columnName, java.sql.Blob blob)
- throws SQLException {
- updateBlob(findColumn(columnName), blob);
- }
-
- /**
- * JDBC 2.0 Update a column with a boolean value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBoolean(int columnIndex, boolean x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setBoolean(columnIndex, x);
- } else {
- this.inserter.setBoolean(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a boolean value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBoolean(String columnName, boolean x)
- throws SQLException {
- updateBoolean(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a byte value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateByte(int columnIndex, byte x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setByte(columnIndex, x);
- } else {
- this.inserter.setByte(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a byte value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateByte(String columnName, byte x)
- throws SQLException {
- updateByte(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a byte array value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBytes(int columnIndex, byte[] x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setBytes(columnIndex, x);
- } else {
- this.inserter.setBytes(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, x);
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a byte array value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateBytes(String columnName, byte[] x)
- throws SQLException {
- updateBytes(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param length
- * the length of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateCharacterStream(int columnIndex,
- java.io.Reader x, int length) throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setCharacterStream(columnIndex, x, length);
- } else {
- this.inserter.setCharacterStream(columnIndex, x, length);
-
- if (x == null) {
- this.thisRow.setColumnValue(columnIndex - 1, null);
- } else {
- this.thisRow.setColumnValue(columnIndex - 1, STREAM_DATA_MARKER);
- }
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a character stream value. The updateXXX()
- * methods are used to update column values in the current row, or the
- * insert row. The updateXXX() methods do not update the underlying
- * database, instead the updateRow() or insertRow() methods are called to
- * update the database.
- *
- * @param columnName
- * the name of the column
- * @param reader
- * the new column value
- * @param length
- * of the stream
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateCharacterStream(String columnName,
- java.io.Reader reader, int length) throws SQLException {
- updateCharacterStream(findColumn(columnName), reader, length);
- }
-
- /**
- * @see ResultSetInternalMethods#updateClob(int, Clob)
- */
- public void updateClob(int columnIndex, java.sql.Clob clob)
- throws SQLException {
- if (clob == null) {
- updateNull(columnIndex);
- } else {
- updateCharacterStream(columnIndex, clob.getCharacterStream(),
- (int) clob.length());
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a Date value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateDate(int columnIndex, java.sql.Date x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setDate(columnIndex, x);
- } else {
- this.inserter.setDate(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a Date value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateDate(String columnName, java.sql.Date x)
- throws SQLException {
- updateDate(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a Double value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateDouble(int columnIndex, double x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setDouble(columnIndex, x);
- } else {
- this.inserter.setDouble(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a double value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateDouble(String columnName, double x)
- throws SQLException {
- updateDouble(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a float value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateFloat(int columnIndex, float x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setFloat(columnIndex, x);
- } else {
- this.inserter.setFloat(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a float value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateFloat(String columnName, float x)
- throws SQLException {
- updateFloat(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with an integer value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateInt(int columnIndex, int x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setInt(columnIndex, x);
- } else {
- this.inserter.setInt(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with an integer value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateInt(String columnName, int x)
- throws SQLException {
- updateInt(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a long value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateLong(int columnIndex, long x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setLong(columnIndex, x);
- } else {
- this.inserter.setLong(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a long value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateLong(String columnName, long x)
- throws SQLException {
- updateLong(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Give a nullable column a null value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateNull(int columnIndex) throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setNull(columnIndex, 0);
- } else {
- this.inserter.setNull(columnIndex, 0);
-
- this.thisRow.setColumnValue(columnIndex - 1, null);
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a null value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateNull(String columnName) throws SQLException {
- updateNull(findColumn(columnName));
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateObject(int columnIndex, Object x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setObject(columnIndex, x);
- } else {
- this.inserter.setObject(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- * @param scale
- * For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types
- * this is the number of digits after the decimal. For all other
- * types this value will be ignored.
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateObject(int columnIndex, Object x, int scale)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setObject(columnIndex, x);
- } else {
- this.inserter.setObject(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateObject(String columnName, Object x)
- throws SQLException {
- updateObject(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with an Object value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- * @param scale
- * For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types
- * this is the number of digits after the decimal. For all other
- * types this value will be ignored.
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateObject(String columnName, Object x, int scale)
- throws SQLException {
- updateObject(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update the underlying database with the new contents of the
- * current row. Cannot be called when on the insert row.
- *
- * @exception SQLException
- * if a database-access error occurs, or if called when on
- * the insert row
- * @throws NotUpdatable
- * DOCUMENT ME!
- */
- public synchronized void updateRow() throws SQLException {
- if (!this.isUpdatable) {
- throw new NotUpdatable(this.notUpdatableReason);
- }
-
- if (this.doingUpdates) {
- this.updater.executeUpdate();
- refreshRow();
- this.doingUpdates = false;
- }
-
- //
- // fixes calling updateRow() and then doing more
- // updates on same row...
- syncUpdate();
- }
-
- /**
- * JDBC 2.0 Update a column with a short value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateShort(int columnIndex, short x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setShort(columnIndex, x);
- } else {
- this.inserter.setShort(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a short value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateShort(String columnName, short x)
- throws SQLException {
- updateShort(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a String value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateString(int columnIndex, String x)
- throws SQLException {
- checkClosed();
-
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setString(columnIndex, x);
- } else {
- this.inserter.setString(columnIndex, x);
-
- if (x == null) {
- this.thisRow.setColumnValue(columnIndex - 1, null);
- } else {
- if (getCharConverter() != null) {
- this.thisRow.setColumnValue(columnIndex - 1, StringUtils.getBytes(x,
- this.charConverter, this.charEncoding,
- this.connection.getServerCharacterEncoding(),
- this.connection.parserKnowsUnicode(), getExceptionInterceptor()));
- } else {
- this.thisRow.setColumnValue(columnIndex - 1, x.getBytes());
- }
- }
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a String value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateString(String columnName, String x)
- throws SQLException {
- updateString(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a Time value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateTime(int columnIndex, java.sql.Time x)
- throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setTime(columnIndex, x);
- } else {
- this.inserter.setTime(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a Time value. The updateXXX() methods are
- * used to update column values in the current row, or the insert row. The
- * updateXXX() methods do not update the underlying database, instead the
- * updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateTime(String columnName, java.sql.Time x)
- throws SQLException {
- updateTime(findColumn(columnName), x);
- }
-
- /**
- * JDBC 2.0 Update a column with a Timestamp value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnIndex
- * the first column is 1, the second is 2, ...
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateTimestamp(int columnIndex,
- java.sql.Timestamp x) throws SQLException {
- if (!this.onInsertRow) {
- if (!this.doingUpdates) {
- this.doingUpdates = true;
- syncUpdate();
- }
-
- this.updater.setTimestamp(columnIndex, x);
- } else {
- this.inserter.setTimestamp(columnIndex, x);
-
- this.thisRow.setColumnValue(columnIndex - 1, this.inserter
- .getBytesRepresentation(columnIndex - 1));
- }
- }
-
- /**
- * JDBC 2.0 Update a column with a Timestamp value. The updateXXX() methods
- * are used to update column values in the current row, or the insert row.
- * The updateXXX() methods do not update the underlying database, instead
- * the updateRow() or insertRow() methods are called to update the database.
- *
- * @param columnName
- * the name of the column
- * @param x
- * the new column value
- *
- * @exception SQLException
- * if a database-access error occurs
- */
- public synchronized void updateTimestamp(String columnName,
- java.sql.Timestamp x) throws SQLException {
- updateTimestamp(findColumn(columnName), x);
- }
-}
diff --git a/src/com/mysql/jdbc/Util.java b/src/com/mysql/jdbc/Util.java
deleted file mode 100644
index 8973a46c4..000000000
--- a/src/com/mysql/jdbc/Util.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.ObjectInputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TimeZone;
-
-/**
- * Various utility methods for the driver.
- *
- * @author Mark Matthews
- */
-public class Util {
- protected static Method systemNanoTimeMethod;
-
- static {
- try {
- systemNanoTimeMethod = System.class.getMethod("nanoTime", null);
- } catch (SecurityException e) {
- systemNanoTimeMethod = null;
- } catch (NoSuchMethodException e) {
- systemNanoTimeMethod = null;
- }
- }
-
- public static boolean nanoTimeAvailable() {
- return systemNanoTimeMethod != null;
- }
-
- private static Method CAST_METHOD;
-
- // cache this ourselves, as the method call is statically-synchronized in
- // all but JDK6!
-
- private static final TimeZone DEFAULT_TIMEZONE = TimeZone.getDefault();
-
- static final TimeZone getDefaultTimeZone() {
- return (TimeZone) DEFAULT_TIMEZONE.clone();
- }
-
- class RandStructcture {
- long maxValue;
-
- double maxValueDbl;
-
- long seed1;
-
- long seed2;
- }
-
- private static Util enclosingInstance = new Util();
-
- private static boolean isJdbc4 = false;
-
- private static boolean isColdFusion = false;
-
- static {
- try {
- CAST_METHOD = Class.class.getMethod("cast",
- new Class[] { Object.class });
- } catch (Throwable t) {
- // ignore - not available in this VM
- }
-
- try {
- Class.forName("java.sql.NClob");
- isJdbc4 = true;
- } catch (Throwable t) {
- isJdbc4 = false;
- }
-
- //
- // Detect the ColdFusion MX environment
- //
- // Unfortunately, no easy-to-discern classes are available
- // to our classloader to check...
- //
-
- String loadedFrom = stackTraceToString(new Throwable());
-
- if (loadedFrom != null) {
- isColdFusion = loadedFrom.indexOf("coldfusion") != -1;
- } else {
- isColdFusion = false;
- }
- }
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- public static boolean isJdbc4() {
- return isJdbc4;
- }
-
- public static boolean isColdFusion() {
- return isColdFusion;
- }
-
- // Right from Monty's code
- static String newCrypt(String password, String seed) {
- byte b;
- double d;
-
- if ((password == null) || (password.length() == 0)) {
- return password;
- }
-
- long[] pw = newHash(seed);
- long[] msg = newHash(password);
- long max = 0x3fffffffL;
- long seed1 = (pw[0] ^ msg[0]) % max;
- long seed2 = (pw[1] ^ msg[1]) % max;
- char[] chars = new char[seed.length()];
-
- for (int i = 0; i < seed.length(); i++) {
- seed1 = ((seed1 * 3) + seed2) % max;
- seed2 = (seed1 + seed2 + 33) % max;
- d = (double) seed1 / (double) max;
- b = (byte) java.lang.Math.floor((d * 31) + 64);
- chars[i] = (char) b;
- }
-
- seed1 = ((seed1 * 3) + seed2) % max;
- seed2 = (seed1 + seed2 + 33) % max;
- d = (double) seed1 / (double) max;
- b = (byte) java.lang.Math.floor(d * 31);
-
- for (int i = 0; i < seed.length(); i++) {
- chars[i] ^= (char) b;
- }
-
- return new String(chars);
- }
-
- static long[] newHash(String password) {
- long nr = 1345345333L;
- long add = 7;
- long nr2 = 0x12345671L;
- long tmp;
-
- for (int i = 0; i < password.length(); ++i) {
- if ((password.charAt(i) == ' ') || (password.charAt(i) == '\t')) {
- continue; // skip spaces
- }
-
- tmp = (0xff & password.charAt(i));
- nr ^= ((((nr & 63) + add) * tmp) + (nr << 8));
- nr2 += ((nr2 << 8) ^ nr);
- add += tmp;
- }
-
- long[] result = new long[2];
- result[0] = nr & 0x7fffffffL;
- result[1] = nr2 & 0x7fffffffL;
-
- return result;
- }
-
- static String oldCrypt(String password, String seed) {
- long hp;
- long hm;
- long s1;
- long s2;
- long max = 0x01FFFFFF;
- double d;
- byte b;
-
- if ((password == null) || (password.length() == 0)) {
- return password;
- }
-
- hp = oldHash(seed);
- hm = oldHash(password);
-
- long nr = hp ^ hm;
- nr %= max;
- s1 = nr;
- s2 = nr / 2;
-
- char[] chars = new char[seed.length()];
-
- for (int i = 0; i < seed.length(); i++) {
- s1 = ((s1 * 3) + s2) % max;
- s2 = (s1 + s2 + 33) % max;
- d = (double) s1 / max;
- b = (byte) java.lang.Math.floor((d * 31) + 64);
- chars[i] = (char) b;
- }
-
- return new String(chars);
- }
-
- static long oldHash(String password) {
- long nr = 1345345333;
- long nr2 = 7;
- long tmp;
-
- for (int i = 0; i < password.length(); i++) {
- if ((password.charAt(i) == ' ') || (password.charAt(i) == '\t')) {
- continue;
- }
-
- tmp = password.charAt(i);
- nr ^= ((((nr & 63) + nr2) * tmp) + (nr << 8));
- nr2 += tmp;
- }
-
- return nr & ((1L << 31) - 1L);
- }
-
- private static RandStructcture randomInit(long seed1, long seed2) {
- RandStructcture randStruct = enclosingInstance.new RandStructcture();
-
- randStruct.maxValue = 0x3FFFFFFFL;
- randStruct.maxValueDbl = randStruct.maxValue;
- randStruct.seed1 = seed1 % randStruct.maxValue;
- randStruct.seed2 = seed2 % randStruct.maxValue;
-
- return randStruct;
- }
-
- /**
- * Given a ResultSet and an index into the columns of that ResultSet, read
- * binary data from the column which represents a serialized object, and
- * re-create the object.
- *
- * @param resultSet
- * the ResultSet to use.
- * @param index
- * an index into the ResultSet.
- * @return the object if it can be de-serialized
- * @throws Exception
- * if an error occurs
- */
- public static Object readObject(java.sql.ResultSet resultSet, int index)
- throws Exception {
- ObjectInputStream objIn = new ObjectInputStream(resultSet
- .getBinaryStream(index));
- Object obj = objIn.readObject();
- objIn.close();
-
- return obj;
- }
-
- private static double rnd(RandStructcture randStruct) {
- randStruct.seed1 = ((randStruct.seed1 * 3) + randStruct.seed2)
- % randStruct.maxValue;
- randStruct.seed2 = (randStruct.seed1 + randStruct.seed2 + 33)
- % randStruct.maxValue;
-
- return ((randStruct.seed1) / randStruct.maxValueDbl);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param message
- * DOCUMENT ME!
- * @param password
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public static String scramble(String message, String password) {
- long[] hashPass;
- long[] hashMessage;
- byte[] to = new byte[8];
- String val = ""; //$NON-NLS-1$
-
- message = message.substring(0, 8);
-
- if ((password != null) && (password.length() > 0)) {
- hashPass = newHash(password);
- hashMessage = newHash(message);
-
- RandStructcture randStruct = randomInit(hashPass[0]
- ^ hashMessage[0], hashPass[1] ^ hashMessage[1]);
-
- int msgPos = 0;
- int msgLength = message.length();
- int toPos = 0;
-
- while (msgPos++ < msgLength) {
- to[toPos++] = (byte) (Math.floor(rnd(randStruct) * 31) + 64);
- }
-
- /* Make it harder to break */
- byte extra = (byte) (Math.floor(rnd(randStruct) * 31));
-
- for (int i = 0; i < to.length; i++) {
- to[i] ^= extra;
- }
-
- val = new String(to);
- }
-
- return val;
- }
-
- // ~ Inner Classes
- // ----------------------------------------------------------
-
- /**
- * Converts a nested exception into a nicer message
- *
- * @param ex
- * the exception to expand into a message.
- *
- * @return a message containing the exception, the message (if any), and a
- * stacktrace.
- */
- public static String stackTraceToString(Throwable ex) {
- StringBuffer traceBuf = new StringBuffer();
- traceBuf.append(Messages.getString("Util.1")); //$NON-NLS-1$
-
- if (ex != null) {
- traceBuf.append(ex.getClass().getName());
-
- String message = ex.getMessage();
-
- if (message != null) {
- traceBuf.append(Messages.getString("Util.2")); //$NON-NLS-1$
- traceBuf.append(message);
- }
-
- StringWriter out = new StringWriter();
-
- PrintWriter printOut = new PrintWriter(out);
-
- ex.printStackTrace(printOut);
-
- traceBuf.append(Messages.getString("Util.3")); //$NON-NLS-1$
- traceBuf.append(out.toString());
- }
-
- traceBuf.append(Messages.getString("Util.4")); //$NON-NLS-1$
-
- return traceBuf.toString();
- }
-
- public static Object getInstance(String className, Class[] argTypes,
- Object[] args, ExceptionInterceptor exceptionInterceptor) throws SQLException {
-
- try {
- return handleNewInstance(Class.forName(className).getConstructor(
- argTypes), args, exceptionInterceptor);
- } catch (SecurityException e) {
- throw SQLError.createSQLException(
- "Can't instantiate required class",
- SQLError.SQL_STATE_GENERAL_ERROR, e, exceptionInterceptor);
- } catch (NoSuchMethodException e) {
- throw SQLError.createSQLException(
- "Can't instantiate required class",
- SQLError.SQL_STATE_GENERAL_ERROR, e, exceptionInterceptor);
- } catch (ClassNotFoundException e) {
- throw SQLError.createSQLException(
- "Can't instantiate required class",
- SQLError.SQL_STATE_GENERAL_ERROR, e, exceptionInterceptor);
- }
- }
-
- /**
- * Handles constructing new instance with the given constructor and wrapping
- * (or not, as required) the exceptions that could possibly be generated
- */
- public static final Object handleNewInstance(Constructor ctor, Object[] args, ExceptionInterceptor exceptionInterceptor)
- throws SQLException {
- try {
-
- return ctor.newInstance(args);
- } catch (IllegalArgumentException e) {
- throw SQLError.createSQLException(
- "Can't instantiate required class",
- SQLError.SQL_STATE_GENERAL_ERROR, e, exceptionInterceptor);
- } catch (InstantiationException e) {
- throw SQLError.createSQLException(
- "Can't instantiate required class",
- SQLError.SQL_STATE_GENERAL_ERROR, e, exceptionInterceptor);
- } catch (IllegalAccessException e) {
- throw SQLError.createSQLException(
- "Can't instantiate required class",
- SQLError.SQL_STATE_GENERAL_ERROR, e, exceptionInterceptor);
- } catch (InvocationTargetException e) {
- Throwable target = e.getTargetException();
-
- if (target instanceof SQLException) {
- throw (SQLException) target;
- }
-
- if (target instanceof ExceptionInInitializerError) {
- target = ((ExceptionInInitializerError) target).getException();
- }
-
- throw SQLError.createSQLException(target.toString(),
- SQLError.SQL_STATE_GENERAL_ERROR, exceptionInterceptor);
- }
- }
-
- /**
- * Does a network interface exist locally with the given hostname?
- *
- * @param hostname
- * the hostname (or IP address in string form) to check
- * @return true if it exists, false if no, or unable to determine due to VM
- * version support of java.net.NetworkInterface
- */
- public static boolean interfaceExists(String hostname) {
- try {
- Class networkInterfaceClass = Class
- .forName("java.net.NetworkInterface");
- return networkInterfaceClass.getMethod("getByName", null).invoke(
- networkInterfaceClass, new Object[] { hostname }) != null;
- } catch (Throwable t) {
- return false;
- }
- }
-
- /**
- * Reflexive access on JDK-1.5's Class.cast() method so we don't have to
- * move that out into separate classes built for JDBC-4.0.
- *
- * @param invokeOn
- * @param toCast
- * @return
- */
- public static Object cast(Object invokeOn, Object toCast) {
- if (CAST_METHOD != null) {
- try {
- return CAST_METHOD.invoke(invokeOn, new Object[] { toCast });
- } catch (Throwable t) {
- return null;
- }
- }
-
- return null;
- }
-
- public static long getCurrentTimeNanosOrMillis() {
- if (systemNanoTimeMethod != null) {
- try {
- return ((Long) systemNanoTimeMethod.invoke(null, null))
- .longValue();
- } catch (IllegalArgumentException e) {
- // ignore - fall through to currentTimeMillis()
- } catch (IllegalAccessException e) {
- // ignore - fall through to currentTimeMillis()
- } catch (InvocationTargetException e) {
- // ignore - fall through to currentTimeMillis()
- }
- }
-
- return System.currentTimeMillis();
- }
-
- public static void resultSetToMap(Map mappedValues, java.sql.ResultSet rs)
- throws SQLException {
- while (rs.next()) {
- mappedValues.put(rs.getObject(1), rs.getObject(2));
- }
- }
-
- public static Map calculateDifferences(Map map1, Map map2) {
- Map diffMap = new HashMap();
-
- Iterator map1Entries = map1.entrySet().iterator();
-
- while (map1Entries.hasNext()) {
- Map.Entry entry = (Map.Entry) map1Entries.next();
- Object key = entry.getKey();
-
- Number value1 = null;
- Number value2 = null;
-
- if (entry.getValue() instanceof Number) {
-
- value1 = (Number) entry.getValue();
- value2 = (Number) map2.get(key);
- } else {
- try {
- value1 = new Double(entry.getValue().toString());
- value2 = new Double(map2.get(key).toString());
- } catch (NumberFormatException nfe) {
- continue;
- }
- }
-
- if (value1.equals(value2)) {
- continue;
- }
-
- if (value1 instanceof Byte) {
- diffMap.put(key, new Byte(
- (byte) (((Byte) value2).byteValue() - ((Byte) value1)
- .byteValue())));
- } else if (value1 instanceof Short) {
- diffMap.put(key, new Short((short) (((Short) value2)
- .shortValue() - ((Short) value1).shortValue())));
- } else if (value1 instanceof Integer) {
- diffMap.put(key, new Integer(
- (((Integer) value2).intValue() - ((Integer) value1)
- .intValue())));
- } else if (value1 instanceof Long) {
- diffMap.put(key, new Long(
- (((Long) value2).longValue() - ((Long) value1)
- .longValue())));
- } else if (value1 instanceof Float) {
- diffMap.put(key, new Float(((Float) value2).floatValue()
- - ((Float) value1).floatValue()));
- } else if (value1 instanceof Double) {
- diffMap.put(key, new Double(
- (((Double) value2).shortValue() - ((Double) value1)
- .shortValue())));
- } else if (value1 instanceof BigDecimal) {
- diffMap.put(key, ((BigDecimal) value2)
- .subtract((BigDecimal) value1));
- } else if (value1 instanceof BigInteger) {
- diffMap.put(key, ((BigInteger) value2)
- .subtract((BigInteger) value1));
- }
- }
-
- return diffMap;
- }
-
- public static List loadExtensions(Connection conn,
- Properties props, String extensionClassNames,
- String errorMessageKey, ExceptionInterceptor exceptionInterceptor) throws SQLException {
- List extensionList = new LinkedList();
-
- List interceptorsToCreate = StringUtils.split(extensionClassNames, ",",
- true);
-
- Iterator iter = interceptorsToCreate.iterator();
-
- String className = null;
-
- try {
- while (iter.hasNext()) {
- className = iter.next().toString();
- Extension extensionInstance = (Extension) Class.forName(
- className).newInstance();
- extensionInstance.init(conn, props);
-
- extensionList.add(extensionInstance);
- }
- } catch (Throwable t) {
- SQLException sqlEx = SQLError.createSQLException(Messages
- .getString(errorMessageKey, new Object[] { className }), exceptionInterceptor);
- sqlEx.initCause(t);
-
- throw sqlEx;
- }
-
- return extensionList;
- }
-
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/WatchableOutputStream.java b/src/com/mysql/jdbc/WatchableOutputStream.java
deleted file mode 100644
index 03c79490a..000000000
--- a/src/com/mysql/jdbc/WatchableOutputStream.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-/**
- * A java.io.OutputStream used to write ASCII data into Blobs and Clobs
- *
- * @author Mark Matthews
- */
-class WatchableOutputStream extends ByteArrayOutputStream {
- // ~ Instance fields
- // --------------------------------------------------------
-
- private OutputStreamWatcher watcher;
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- super.close();
-
- if (this.watcher != null) {
- this.watcher.streamClosed(this);
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param watcher
- * DOCUMENT ME!
- */
- public void setWatcher(OutputStreamWatcher watcher) {
- this.watcher = watcher;
- }
-}
diff --git a/src/com/mysql/jdbc/WatchableWriter.java b/src/com/mysql/jdbc/WatchableWriter.java
deleted file mode 100644
index b7578ef34..000000000
--- a/src/com/mysql/jdbc/WatchableWriter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-import java.io.CharArrayWriter;
-
-/**
- * A java.io.Writer used to write unicode data into Blobs and Clobs
- *
- * @author Mark Matthews
- */
-class WatchableWriter extends CharArrayWriter {
- // ~ Instance fields
- // --------------------------------------------------------
-
- private WriterWatcher watcher;
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * @see java.io.Writer#close()
- */
- public void close() {
- super.close();
-
- // Send data to watcher
- if (this.watcher != null) {
- this.watcher.writerClosed(this);
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param watcher
- * DOCUMENT ME!
- */
- public void setWatcher(WriterWatcher watcher) {
- this.watcher = watcher;
- }
-}
diff --git a/src/com/mysql/jdbc/WriterWatcher.java b/src/com/mysql/jdbc/WriterWatcher.java
deleted file mode 100644
index 862d6f44d..000000000
--- a/src/com/mysql/jdbc/WriterWatcher.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc;
-
-/**
- * Objects that want to be notified of lifecycle events on a WatchableWriter
- * should implement this interface, and register themselves with setWatcher() on
- * the WatchableWriter instance.
- *
- * @author Mark Matthews
- */
-interface WriterWatcher {
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * Called when the Writer being watched has .close() called
- */
- void writerClosed(WatchableWriter out);
-}
diff --git a/src/com/mysql/jdbc/configs/3-0-Compat.properties b/src/com/mysql/jdbc/configs/3-0-Compat.properties
deleted file mode 100644
index 17141d3e2..000000000
--- a/src/com/mysql/jdbc/configs/3-0-Compat.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Settings to maintain Connector/J 3.0.x compatibility
-# (as much as it can be)
-#
-
-emptyStringsConvertToZero=true
-jdbcCompliantTruncation=false
-noDatetimeStringSync=true
-nullCatalogMeansCurrent=true
-nullNamePatternMatchesAll=true
-transformedBitIsBoolean=false
-dontTrackOpenResources=true
-zeroDateTimeBehavior=convertToNull
-useServerPrepStmts=false
-autoClosePStmtStreams=true
-processEscapeCodesForPrepStmts=false
-useFastDateParsing=false
-populateInsertRowWithDefaultValues=false
-useDirectRowUnpack=false
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/configs/5-0-Compat.properties b/src/com/mysql/jdbc/configs/5-0-Compat.properties
deleted file mode 100644
index c300f75d1..000000000
--- a/src/com/mysql/jdbc/configs/5-0-Compat.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Settings to maintain Connector/J 5.0.x compatibility
-# (as much as it can be)
-#
-
-useDirectRowUnpack=false
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/configs/clusterBase.properties b/src/com/mysql/jdbc/configs/clusterBase.properties
deleted file mode 100644
index e87a6046a..000000000
--- a/src/com/mysql/jdbc/configs/clusterBase.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-# Basic properties for clusters
-autoReconnect=true
-failOverReadOnly=false
-roundRobinLoadBalance=true
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/configs/coldFusion.properties b/src/com/mysql/jdbc/configs/coldFusion.properties
deleted file mode 100644
index 22bdec5c9..000000000
--- a/src/com/mysql/jdbc/configs/coldFusion.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Properties for optimal usage in ColdFusion
-#
-# Automagically pulled in if "autoConfigureForColdFusion" is "true"
-# which is the default configuration of the driver
-#
-
-#
-# CF uses a _lot_ of RSMD.isCaseSensitive() - this optimizes it
-#
-
-useDynamicCharsetInfo=false
-
-#
-# CF's pool tends to be "chatty" like DBCP
-#
-
-alwaysSendSetIsolation=false
-useLocalSessionState=true
-
-#
-# CF's pool seems to loose connectivity on page restart
-#
-
-autoReconnect=true
diff --git a/src/com/mysql/jdbc/exceptions/DeadlockTimeoutRollbackMarker.java b/src/com/mysql/jdbc/exceptions/DeadlockTimeoutRollbackMarker.java
deleted file mode 100644
index 7162b155c..000000000
--- a/src/com/mysql/jdbc/exceptions/DeadlockTimeoutRollbackMarker.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright 2008 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-/**
- * Marker interface for exceptions that are caused by deadlock/wait timeout
- */
-public interface DeadlockTimeoutRollbackMarker {
-
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLDataException.java b/src/com/mysql/jdbc/exceptions/MySQLDataException.java
deleted file mode 100644
index 1ae94a177..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLDataException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLDataException extends MySQLNonTransientException {
-
- public MySQLDataException() {
- super();
- }
-
- public MySQLDataException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLDataException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLDataException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java b/src/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java
deleted file mode 100644
index a849d9310..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLIntegrityConstraintViolationException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLIntegrityConstraintViolationException extends
- MySQLNonTransientException {
-
- public MySQLIntegrityConstraintViolationException() {
- super();
- }
-
- public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLIntegrityConstraintViolationException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLIntegrityConstraintViolationException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLInvalidAuthorizationSpecException.java b/src/com/mysql/jdbc/exceptions/MySQLInvalidAuthorizationSpecException.java
deleted file mode 100644
index 91e2f342c..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLInvalidAuthorizationSpecException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLInvalidAuthorizationSpecException extends
- MySQLNonTransientException {
-
- public MySQLInvalidAuthorizationSpecException() {
- super();
- }
-
- public MySQLInvalidAuthorizationSpecException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLInvalidAuthorizationSpecException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLInvalidAuthorizationSpecException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java b/src/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java
deleted file mode 100644
index 3ae0a863e..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLNonTransientConnectionException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLNonTransientConnectionException extends
- MySQLNonTransientException {
-
- public MySQLNonTransientConnectionException() {
- super();
- }
-
- public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLNonTransientConnectionException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLNonTransientConnectionException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLNonTransientException.java b/src/com/mysql/jdbc/exceptions/MySQLNonTransientException.java
deleted file mode 100644
index 8a2e01941..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLNonTransientException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-import java.sql.SQLException;
-
-public class MySQLNonTransientException extends SQLException {
-
- public MySQLNonTransientException() {
- super();
- }
-
- public MySQLNonTransientException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLNonTransientException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLNonTransientException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLStatementCancelledException.java b/src/com/mysql/jdbc/exceptions/MySQLStatementCancelledException.java
deleted file mode 100644
index 9254a1924..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLStatementCancelledException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLStatementCancelledException extends MySQLNonTransientException {
- public MySQLStatementCancelledException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLStatementCancelledException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLStatementCancelledException(String reason) {
- super(reason);
- }
-
- public MySQLStatementCancelledException() {
- super("Statement cancelled due to client request");
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java b/src/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java
deleted file mode 100644
index 1210f3ae7..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLSyntaxErrorException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLSyntaxErrorException extends MySQLNonTransientException {
-
- public MySQLSyntaxErrorException() {
- super();
- }
-
- public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLSyntaxErrorException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLSyntaxErrorException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLTimeoutException.java b/src/com/mysql/jdbc/exceptions/MySQLTimeoutException.java
deleted file mode 100644
index c874f8bef..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLTimeoutException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLTimeoutException extends MySQLTransientException {
-
- public MySQLTimeoutException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTimeoutException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTimeoutException(String reason) {
- super(reason);
- }
-
- public MySQLTimeoutException() {
- super("Statement cancelled due to timeout or client request");
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java b/src/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java
deleted file mode 100644
index 84d7c51a5..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLTransactionRollbackException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLTransactionRollbackException extends MySQLTransientException implements DeadlockTimeoutRollbackMarker {
-
- public MySQLTransactionRollbackException(String reason, String SQLState,
- int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTransactionRollbackException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTransactionRollbackException(String reason) {
- super(reason);
- }
-
- public MySQLTransactionRollbackException() {
- super();
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java b/src/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java
deleted file mode 100644
index a59033d29..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLTransientConnectionException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-public class MySQLTransientConnectionException extends MySQLTransientException {
-
- public MySQLTransientConnectionException(String reason, String SQLState,
- int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTransientConnectionException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTransientConnectionException(String reason) {
- super(reason);
- }
-
- public MySQLTransientConnectionException() {
- super();
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/MySQLTransientException.java b/src/com/mysql/jdbc/exceptions/MySQLTransientException.java
deleted file mode 100644
index ab4e3a6b8..000000000
--- a/src/com/mysql/jdbc/exceptions/MySQLTransientException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions;
-
-import java.sql.SQLException;
-
-public class MySQLTransientException extends SQLException {
-
- public MySQLTransientException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTransientException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTransientException(String reason) {
- super(reason);
- }
-
- public MySQLTransientException() {
- super();
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/CommunicationsException.java b/src/com/mysql/jdbc/exceptions/jdbc4/CommunicationsException.java
deleted file mode 100644
index c30b7db8c..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/CommunicationsException.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.net.BindException;
-
-import java.sql.SQLRecoverableException;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.StreamingNotifiable;
-
-/**
- * An exception to represent communications errors with the database.
- *
- * Attempts to provide 'friendler' error messages to end-users, including last
- * time a packet was sent to the database, what the client-timeout is set to,
- * and whether the idle time has been exceeded.
- *
- * @author Mark Matthews
- *
- * @version $Id: CommunicationsException.java,v 1.1.2.1 2005/05/13 18:58:37
- * mmatthews Exp $
- */
-public class CommunicationsException extends SQLRecoverableException implements StreamingNotifiable {
-
- private String exceptionMessage;
-
- private boolean streamingResultSetInPlay = false;
-
- public CommunicationsException(ConnectionImpl conn, long lastPacketSentTimeMs,
- long lastPacketReceivedTimeMs,
- Exception underlyingException) {
-
- this.exceptionMessage = SQLError.createLinkFailureMessageBasedOnHeuristics(conn,
- lastPacketSentTimeMs, lastPacketReceivedTimeMs, underlyingException, this.streamingResultSetInPlay);
-
- if (underlyingException != null) {
- initCause(underlyingException);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Throwable#getMessage()
- */
- public String getMessage() {
- return this.exceptionMessage;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.SQLException#getSQLState()
- */
- public String getSQLState() {
- return SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE;
- }
-
- public void setWasStreamingResults() {
- this.streamingResultSetInPlay = true;
- }
-
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLDataException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLDataException.java
deleted file mode 100644
index 3c3a001de..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLDataException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLDataException;
-
-public class MySQLDataException extends SQLDataException {
-
- public MySQLDataException() {
- super();
- }
-
- public MySQLDataException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLDataException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLDataException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLIntegrityConstraintViolationException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLIntegrityConstraintViolationException.java
deleted file mode 100644
index 29f2a46aa..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLIntegrityConstraintViolationException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLIntegrityConstraintViolationException;
-
-public class MySQLIntegrityConstraintViolationException extends
- SQLIntegrityConstraintViolationException {
-
- public MySQLIntegrityConstraintViolationException() {
- super();
- }
-
- public MySQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLIntegrityConstraintViolationException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLIntegrityConstraintViolationException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLInvalidAuthorizationSpecException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLInvalidAuthorizationSpecException.java
deleted file mode 100644
index 24eb00318..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLInvalidAuthorizationSpecException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLInvalidAuthorizationSpecException;
-
-public class MySQLInvalidAuthorizationSpecException extends
- SQLInvalidAuthorizationSpecException {
-
- public MySQLInvalidAuthorizationSpecException() {
- super();
- }
-
- public MySQLInvalidAuthorizationSpecException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLInvalidAuthorizationSpecException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLInvalidAuthorizationSpecException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLNonTransientConnectionException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLNonTransientConnectionException.java
deleted file mode 100644
index e5db44c31..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLNonTransientConnectionException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLNonTransientConnectionException;
-
-public class MySQLNonTransientConnectionException extends
- SQLNonTransientConnectionException {
-
- public MySQLNonTransientConnectionException() {
- super();
- }
-
- public MySQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLNonTransientConnectionException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLNonTransientConnectionException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLNonTransientException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLNonTransientException.java
deleted file mode 100644
index be98dc522..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLNonTransientException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLException;
-import java.sql.SQLNonTransientException;
-
-public class MySQLNonTransientException extends SQLNonTransientException {
-
- public MySQLNonTransientException() {
- super();
- }
-
- public MySQLNonTransientException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLNonTransientException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLNonTransientException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLSyntaxErrorException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLSyntaxErrorException.java
deleted file mode 100644
index 2c02d69c9..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLSyntaxErrorException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLSyntaxErrorException;
-
-public class MySQLSyntaxErrorException extends SQLSyntaxErrorException {
-
- public MySQLSyntaxErrorException() {
- super();
- }
-
- public MySQLSyntaxErrorException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLSyntaxErrorException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLSyntaxErrorException(String reason) {
- super(reason);
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTimeoutException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTimeoutException.java
deleted file mode 100644
index 20471f8e2..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTimeoutException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLTimeoutException;
-
-public class MySQLTimeoutException extends SQLTimeoutException {
-
- public MySQLTimeoutException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTimeoutException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTimeoutException(String reason) {
- super(reason);
- }
-
- public MySQLTimeoutException() {
- super("Statement cancelled due to timeout or client request");
- }
-
- public int getErrorCode() {
- // TODO Auto-generated method stub
- return super.getErrorCode();
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransactionRollbackException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransactionRollbackException.java
deleted file mode 100644
index 7dc8237ee..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransactionRollbackException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLTransactionRollbackException;
-
-import com.mysql.jdbc.exceptions.DeadlockTimeoutRollbackMarker;
-
-public class MySQLTransactionRollbackException extends SQLTransactionRollbackException implements DeadlockTimeoutRollbackMarker {
-
- public MySQLTransactionRollbackException(String reason, String SQLState,
- int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTransactionRollbackException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTransactionRollbackException(String reason) {
- super(reason);
- }
-
- public MySQLTransactionRollbackException() {
- super();
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransientConnectionException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransientConnectionException.java
deleted file mode 100644
index e2ac58db3..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransientConnectionException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLTransientConnectionException;
-
-public class MySQLTransientConnectionException extends SQLTransientConnectionException {
-
- public MySQLTransientConnectionException(String reason, String SQLState,
- int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTransientConnectionException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTransientConnectionException(String reason) {
- super(reason);
- }
-
- public MySQLTransientConnectionException() {
- super();
- }
-}
diff --git a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransientException.java b/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransientException.java
deleted file mode 100644
index 04f5f76ca..000000000
--- a/src/com/mysql/jdbc/exceptions/jdbc4/MySQLTransientException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.exceptions.jdbc4;
-
-import java.sql.SQLException;
-import java.sql.SQLTransientException;
-
-public class MySQLTransientException extends SQLTransientException {
-
- public MySQLTransientException(String reason, String SQLState, int vendorCode) {
- super(reason, SQLState, vendorCode);
- }
-
- public MySQLTransientException(String reason, String SQLState) {
- super(reason, SQLState);
- }
-
- public MySQLTransientException(String reason) {
- super(reason);
- }
-
- public MySQLTransientException() {
- super();
- }
-}
diff --git a/src/com/mysql/jdbc/integration/c3p0/MysqlConnectionTester.java b/src/com/mysql/jdbc/integration/c3p0/MysqlConnectionTester.java
deleted file mode 100644
index c848cb9d0..000000000
--- a/src/com/mysql/jdbc/integration/c3p0/MysqlConnectionTester.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- Copyright 2002-2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc.integration.c3p0;
-
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import com.mchange.v2.c3p0.C3P0ProxyConnection;
-import com.mchange.v2.c3p0.QueryConnectionTester;
-import com.mysql.jdbc.CommunicationsException;
-
-/**
- * ConnectionTester for C3P0 connection pool that uses the more efficient
- * COM_PING method of testing connection 'liveness' for MySQL, and 'sorts'
- * exceptions based on SQLState or class of 'CommunicationsException' for
- * handling exceptions.
- *
- * @version $Id: MysqlConnectionTester.java,v 1.1.2.1 2005/05/13 18:58:39
- * mmatthews Exp $
- */
-public final class MysqlConnectionTester implements QueryConnectionTester {
-
- private static final long serialVersionUID = 3256444690067896368L;
-
- private static final Object[] NO_ARGS_ARRAY = new Object[0];
-
- private Method pingMethod;
-
- public MysqlConnectionTester() {
- try {
- pingMethod = com.mysql.jdbc.Connection.class
- .getMethod("ping", null);
- } catch (Exception ex) {
- // punt, we have no way to recover, other than we now use 'SELECT 1'
- // for
- // handling the connection testing.
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mchange.v2.c3p0.ConnectionTester#activeCheckConnection(java.sql.Connection)
- */
- public int activeCheckConnection(Connection con) {
- try {
- if (pingMethod != null) {
- if (con instanceof com.mysql.jdbc.Connection) {
- // We've been passed an instance of a MySQL connection --
- // no need for reflection
- ((com.mysql.jdbc.Connection) con).ping();
- } else {
- // Assume the connection is a C3P0 proxy
- C3P0ProxyConnection castCon = (C3P0ProxyConnection) con;
- castCon.rawConnectionOperation(pingMethod,
- C3P0ProxyConnection.RAW_CONNECTION, NO_ARGS_ARRAY);
- }
- } else {
- Statement pingStatement = null;
-
- try {
- pingStatement = con.createStatement();
- pingStatement.executeQuery("SELECT 1").close();
- } finally {
- if (pingStatement != null) {
- pingStatement.close();
- }
- }
- }
-
- return CONNECTION_IS_OKAY;
- } catch (Exception ex) {
- return CONNECTION_IS_INVALID;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mchange.v2.c3p0.ConnectionTester#statusOnException(java.sql.Connection,
- * java.lang.Throwable)
- */
- public int statusOnException(Connection arg0, Throwable throwable) {
- if (throwable instanceof CommunicationsException
- || "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException"
- .equals(throwable.getClass().getName())) {
- return CONNECTION_IS_INVALID;
- }
-
- if (throwable instanceof SQLException) {
- String sqlState = ((SQLException) throwable).getSQLState();
-
- if (sqlState != null && sqlState.startsWith("08")) {
- return CONNECTION_IS_INVALID;
- }
-
- return CONNECTION_IS_OKAY;
- }
-
- // Runtime/Unchecked?
-
- return CONNECTION_IS_INVALID;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mchange.v2.c3p0.QueryConnectionTester#activeCheckConnection(java.sql.Connection,
- * java.lang.String)
- */
- public int activeCheckConnection(Connection arg0, String arg1) {
- return CONNECTION_IS_OKAY;
- }
-}
diff --git a/src/com/mysql/jdbc/integration/jboss/ExtendedMysqlExceptionSorter.java b/src/com/mysql/jdbc/integration/jboss/ExtendedMysqlExceptionSorter.java
deleted file mode 100644
index ebc6c89e9..000000000
--- a/src/com/mysql/jdbc/integration/jboss/ExtendedMysqlExceptionSorter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright 2002-2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc.integration.jboss;
-
-import java.sql.SQLException;
-
-import org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter;
-
-/**
- * Exception sorter used for JBoss to make recovery of downed/stale connections
- * work more consistently.
- *
- * @version $Id: ExtendedMysqlExceptionSorter.java,v 1.1.2.1 2005/05/13 18:58:42
- * mmatthews Exp $
- */
-public final class ExtendedMysqlExceptionSorter extends MySQLExceptionSorter {
-
- /*
- * (non-Javadoc)
- *
- * @see org.jboss.resource.adapter.jdbc.ExceptionSorter#isExceptionFatal(java.sql.SQLException)
- */
- public boolean isExceptionFatal(SQLException ex) {
- String sqlState = ex.getSQLState();
-
- if (sqlState != null && sqlState.startsWith("08")) {
- return true;
- }
-
- return super.isExceptionFatal(ex);
- }
-
-}
diff --git a/src/com/mysql/jdbc/integration/jboss/MysqlValidConnectionChecker.java b/src/com/mysql/jdbc/integration/jboss/MysqlValidConnectionChecker.java
deleted file mode 100644
index 8f656da40..000000000
--- a/src/com/mysql/jdbc/integration/jboss/MysqlValidConnectionChecker.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- Copyright 2002-2006 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-package com.mysql.jdbc.integration.jboss;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.jboss.resource.adapter.jdbc.ValidConnectionChecker;
-
-/**
- * A more efficient connection checker for JBoss.
- *
- * @version $Id: MysqlValidConnectionChecker.java,v 1.1.2.1 2005/05/13 18:58:42
- * mmatthews Exp $
- */
-public final class MysqlValidConnectionChecker implements
- ValidConnectionChecker, Serializable {
-
- private static final long serialVersionUID = 8909421133577519177L;
-
- public MysqlValidConnectionChecker() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.jboss.resource.adapter.jdbc.ValidConnectionChecker#isValidConnection(java.sql.Connection)
- */
- public SQLException isValidConnection(Connection conn) {
-
- // Use "/* ping */ SELECT 1" which will send
- // pings across multi-connections too in case the connection
- // was "wrapped" by Jboss in any way...
-
- Statement pingStatement = null;
-
- try {
- pingStatement = conn.createStatement();
-
- pingStatement.executeQuery("/* ping */ SELECT 1").close();
-
- return null;
- } catch (SQLException sqlEx) {
- return sqlEx;
- } finally {
- if (pingStatement != null) {
- try {
- pingStatement.close();
- } catch (SQLException sqlEx) {
- // can't do anything about it here
- }
- }
- }
- }
-}
diff --git a/src/com/mysql/jdbc/interceptors/ResultSetScannerInterceptor.java b/src/com/mysql/jdbc/interceptors/ResultSetScannerInterceptor.java
deleted file mode 100644
index c2bd9d345..000000000
--- a/src/com/mysql/jdbc/interceptors/ResultSetScannerInterceptor.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.interceptors;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.SQLException;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.ResultSetInternalMethods;
-import com.mysql.jdbc.Statement;
-import com.mysql.jdbc.StatementInterceptor;
-
-public class ResultSetScannerInterceptor implements StatementInterceptor {
-
- private Pattern regexP;
-
- public void init(Connection conn, Properties props) throws SQLException {
- String regexFromUser = props.getProperty("resultSetScannerRegex");
-
- if (regexFromUser == null || regexFromUser.length() == 0) {
- throw new SQLException("resultSetScannerRegex must be configured, and must be > 0 characters");
- }
-
- try {
- this.regexP = Pattern.compile(regexFromUser);
- } catch (Throwable t) {
- SQLException sqlEx = new SQLException("Can't use configured regex due to underlying exception.");
- sqlEx.initCause(t);
-
- throw sqlEx;
- }
-
- }
-
- public ResultSetInternalMethods postProcess(String sql, Statement interceptedStatement,
- ResultSetInternalMethods originalResultSet, Connection connection)
- throws SQLException {
-
- // requirement of anonymous class
- final ResultSetInternalMethods finalResultSet = originalResultSet;
-
- return (ResultSetInternalMethods)Proxy.newProxyInstance(originalResultSet.getClass().getClassLoader(),
- new Class[] {ResultSetInternalMethods.class},
- new InvocationHandler() {
-
- public Object invoke(Object proxy, Method method,
- Object[] args) throws Throwable {
-
- Object invocationResult = method.invoke(finalResultSet, args);
-
- String methodName = method.getName();
-
- if (invocationResult != null && invocationResult instanceof String
- || "getString".equals(methodName)
- || "getObject".equals(methodName)
- || "getObjectStoredProc".equals(methodName)) {
- Matcher matcher = regexP.matcher(invocationResult.toString());
-
- if (matcher.matches()) {
- throw new SQLException("value disallowed by filter");
- }
- }
-
- return invocationResult;
- }});
-
- }
-
- public ResultSetInternalMethods preProcess(String sql, Statement interceptedStatement,
- Connection connection) throws SQLException {
- // we don't care about this event
-
- return null;
- }
-
- // we don't issue queries, so it should be safe to intercept
- // at any point
- public boolean executeTopLevelOnly() {
- return false;
- }
-
- public void destroy() {
-
-
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/interceptors/ServerStatusDiffInterceptor.java b/src/com/mysql/jdbc/interceptors/ServerStatusDiffInterceptor.java
deleted file mode 100644
index bdb4c404c..000000000
--- a/src/com/mysql/jdbc/interceptors/ServerStatusDiffInterceptor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.interceptors;
-
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.ResultSetInternalMethods;
-import com.mysql.jdbc.Statement;
-import com.mysql.jdbc.StatementInterceptor;
-import com.mysql.jdbc.Util;
-
-public class ServerStatusDiffInterceptor implements StatementInterceptor {
-
- private Map preExecuteValues = new HashMap();
-
- private Map postExecuteValues = new HashMap();
-
- public void init(Connection conn, Properties props) throws SQLException {
-
- }
-
- public ResultSetInternalMethods postProcess(String sql,
- Statement interceptedStatement,
- ResultSetInternalMethods originalResultSet, Connection connection)
- throws SQLException {
-
- if (connection.versionMeetsMinimum(5, 0, 2)) {
- populateMapWithSessionStatusValues(connection, this.postExecuteValues);
-
- connection.getLog().logInfo(
- "Server status change for statement:\n"
- + Util.calculateDifferences(this.preExecuteValues,
- this.postExecuteValues));
- }
-
- return null; // we don't actually modify a result set
-
- }
-
- private void populateMapWithSessionStatusValues(Connection connection,
- Map toPopulate) throws SQLException {
- java.sql.Statement stmt = null;
- java.sql.ResultSet rs = null;
-
- try {
- toPopulate.clear();
-
- stmt = connection.createStatement();
- rs = stmt.executeQuery("SHOW SESSION STATUS");
- Util.resultSetToMap(toPopulate, rs);
- } finally {
- if (rs != null) {
- rs.close();
- }
-
- if (stmt != null) {
- stmt.close();
- }
- }
- }
-
- public ResultSetInternalMethods preProcess(String sql,
- Statement interceptedStatement, Connection connection)
- throws SQLException {
-
- if (connection.versionMeetsMinimum(5, 0, 2)) {
- populateMapWithSessionStatusValues(connection,
- this.preExecuteValues);
- }
-
- return null; // we don't actually modify a result set
- }
-
- public boolean executeTopLevelOnly() {
- return true;
- }
-
- public void destroy() {
-
- }
-}
diff --git a/src/com/mysql/jdbc/interceptors/SessionAssociationInterceptor.java b/src/com/mysql/jdbc/interceptors/SessionAssociationInterceptor.java
deleted file mode 100644
index 138a3cbcf..000000000
--- a/src/com/mysql/jdbc/interceptors/SessionAssociationInterceptor.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.mysql.jdbc.interceptors;
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.ResultSetInternalMethods;
-import com.mysql.jdbc.Statement;
-import com.mysql.jdbc.StatementInterceptor;
-
-public class SessionAssociationInterceptor implements StatementInterceptor {
-
- protected String currentSessionKey;
- protected static ThreadLocal sessionLocal = new ThreadLocal();
-
- public static final void setSessionKey(String key) {
- sessionLocal.set(key);
- }
-
- public static final void resetSessionKey() {
- sessionLocal.set(null);
- }
-
- public static final String getSessionKey() {
- return (String)sessionLocal.get();
- }
-
- public boolean executeTopLevelOnly() {
- return true;
- }
-
- public void init(Connection conn, Properties props) throws SQLException {
-
- }
-
- public ResultSetInternalMethods postProcess(String sql,
- Statement interceptedStatement,
- ResultSetInternalMethods originalResultSet, Connection connection)
- throws SQLException {
- return null;
- }
-
- public ResultSetInternalMethods preProcess(String sql,
- Statement interceptedStatement, Connection connection)
- throws SQLException {
- String key = getSessionKey();
-
- if (key != null && !key.equals(this.currentSessionKey)) {
- PreparedStatement pstmt = connection.clientPrepareStatement("SET @mysql_proxy_session=?");
-
- try {
- pstmt.setString(1, key);
- pstmt.execute();
- } finally {
- pstmt.close();
- }
-
- this.currentSessionKey = key;
- }
-
- return null;
- }
-
- public void destroy() {
-
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/CallableStatementWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/CallableStatementWrapper.java
deleted file mode 100644
index 4c372b7d9..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/CallableStatementWrapper.java
+++ /dev/null
@@ -1,2638 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
- */
-
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.Constructor;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Map;
-
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.Util;
-
-/**
- * Wraps callable statements created by pooled connections.
- *
- * @version $Id: CallableStatementWrapper.java,v 1.1.2.1 2005/05/13 18:58:38
- * mmatthews Exp $
- */
-public class CallableStatementWrapper extends PreparedStatementWrapper
- implements CallableStatement {
-
-private static final Constructor JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR = Class.forName(
- "com.mysql.jdbc.jdbc2.optional.JDBC4CallableStatementWrapper").getConstructor(
- new Class[] { ConnectionWrapper.class,
- MysqlPooledConnection.class,
- CallableStatement.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR = null;
- }
- }
-
- protected static CallableStatementWrapper getInstance(ConnectionWrapper c,
- MysqlPooledConnection conn,
- CallableStatement toWrap) throws SQLException {
- if (!Util.isJdbc4()) {
- return new CallableStatementWrapper(c,
- conn, toWrap);
- }
-
- return (CallableStatementWrapper) Util.handleNewInstance(
- JDBC_4_CALLABLE_STATEMENT_WRAPPER_CTOR,
- new Object[] {c,
- conn, toWrap }, conn.getExceptionInterceptor());
- }
-
-
-
- /**
- * @param c
- * @param conn
- * @param toWrap
- */
- public CallableStatementWrapper(ConnectionWrapper c,
- MysqlPooledConnection conn, CallableStatement toWrap) {
- super(c, conn, toWrap);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#registerOutParameter(int, int)
- */
- public void registerOutParameter(int parameterIndex, int sqlType)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).registerOutParameter(
- parameterIndex, sqlType);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#registerOutParameter(int, int, int)
- */
- public void registerOutParameter(int parameterIndex, int sqlType, int scale)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).registerOutParameter(
- parameterIndex, sqlType, scale);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#wasNull()
- */
- public boolean wasNull() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).wasNull();
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getString(int)
- */
- public String getString(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getString(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBoolean(int)
- */
- public boolean getBoolean(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBoolean(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getByte(int)
- */
- public byte getByte(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getByte(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getShort(int)
- */
- public short getShort(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getShort(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getInt(int)
- */
- public int getInt(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getInt(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getLong(int)
- */
- public long getLong(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getLong(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getFloat(int)
- */
- public float getFloat(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getFloat(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getDouble(int)
- */
- public double getDouble(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getDouble(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBigDecimal(int, int)
- */
- public BigDecimal getBigDecimal(int parameterIndex, int scale)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getBigDecimal(
- parameterIndex, scale);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBytes(int)
- */
- public byte[] getBytes(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBytes(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getDate(int)
- */
- public Date getDate(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getDate(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTime(int)
- */
- public Time getTime(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getTime(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTimestamp(int)
- */
- public Timestamp getTimestamp(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getTimestamp(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getObject(int)
- */
- public Object getObject(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getObject(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBigDecimal(int)
- */
- public BigDecimal getBigDecimal(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBigDecimal(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getObject(int, java.util.Map)
- */
- public Object getObject(int parameterIndex, Map typeMap)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getObject(
- parameterIndex, typeMap);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getRef(int)
- */
- public Ref getRef(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getRef(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBlob(int)
- */
- public Blob getBlob(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBlob(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getClob(int)
- */
- public Clob getClob(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getClob(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getArray(int)
- */
- public Array getArray(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getArray(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getDate(int, java.util.Calendar)
- */
- public Date getDate(int parameterIndex, Calendar cal) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getDate(
- parameterIndex, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTime(int, java.util.Calendar)
- */
- public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getTime(
- parameterIndex, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar)
- */
- public Timestamp getTimestamp(int parameterIndex, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getTimestamp(
- parameterIndex, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#registerOutParameter(int, int,
- * java.lang.String)
- */
- public void registerOutParameter(int paramIndex, int sqlType,
- String typeName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).registerOutParameter(
- paramIndex, sqlType, typeName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#registerOutParameter(java.lang.String,
- * int)
- */
- public void registerOutParameter(String parameterName, int sqlType)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).registerOutParameter(
- parameterName, sqlType);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#registerOutParameter(java.lang.String,
- * int, int)
- */
- public void registerOutParameter(String parameterName, int sqlType,
- int scale) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).registerOutParameter(
- parameterName, sqlType, scale);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#registerOutParameter(java.lang.String,
- * int, java.lang.String)
- */
- public void registerOutParameter(String parameterName, int sqlType,
- String typeName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).registerOutParameter(
- parameterName, sqlType, typeName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getURL(int)
- */
- public URL getURL(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getURL(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setURL(java.lang.String, java.net.URL)
- */
- public void setURL(String parameterName, URL val) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setURL(parameterName,
- val);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setNull(java.lang.String, int)
- */
- public void setNull(String parameterName, int sqlType) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNull(parameterName,
- sqlType);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setBoolean(java.lang.String, boolean)
- */
- public void setBoolean(String parameterName, boolean x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBoolean(
- parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setByte(java.lang.String, byte)
- */
- public void setByte(String parameterName, byte x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt)
- .setByte(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setShort(java.lang.String, short)
- */
- public void setShort(String parameterName, short x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setShort(parameterName,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setInt(java.lang.String, int)
- */
- public void setInt(String parameterName, int x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setInt(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setLong(java.lang.String, long)
- */
- public void setLong(String parameterName, long x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt)
- .setLong(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setFloat(java.lang.String, float)
- */
- public void setFloat(String parameterName, float x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setFloat(parameterName,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setDouble(java.lang.String, double)
- */
- public void setDouble(String parameterName, double x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setDouble(parameterName,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setBigDecimal(java.lang.String,
- * java.math.BigDecimal)
- */
- public void setBigDecimal(String parameterName, BigDecimal x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBigDecimal(
- parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setString(java.lang.String,
- * java.lang.String)
- */
- public void setString(String parameterName, String x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setString(parameterName,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setBytes(java.lang.String, byte[])
- */
- public void setBytes(String parameterName, byte[] x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBytes(parameterName,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date)
- */
- public void setDate(String parameterName, Date x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt)
- .setDate(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time)
- */
- public void setTime(String parameterName, Time x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt)
- .setTime(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setTimestamp(java.lang.String,
- * java.sql.Timestamp)
- */
- public void setTimestamp(String parameterName, Timestamp x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setTimestamp(
- parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setAsciiStream(java.lang.String,
- * java.io.InputStream, int)
- */
- public void setAsciiStream(String parameterName, InputStream x, int length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setAsciiStream(
- parameterName, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setBinaryStream(java.lang.String,
- * java.io.InputStream, int)
- */
- public void setBinaryStream(String parameterName, InputStream x, int length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBinaryStream(
- parameterName, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setObject(java.lang.String,
- * java.lang.Object, int, int)
- */
- public void setObject(String parameterName, Object x, int targetSqlType,
- int scale) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setObject(parameterName,
- x, targetSqlType, scale);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setObject(java.lang.String,
- * java.lang.Object, int)
- */
- public void setObject(String parameterName, Object x, int targetSqlType)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setObject(parameterName,
- x, targetSqlType);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setObject(java.lang.String,
- * java.lang.Object)
- */
- public void setObject(String parameterName, Object x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setObject(parameterName,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setCharacterStream(java.lang.String,
- * java.io.Reader, int)
- */
- public void setCharacterStream(String parameterName, Reader reader,
- int length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setCharacterStream(
- parameterName, reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setDate(java.lang.String, java.sql.Date,
- * java.util.Calendar)
- */
- public void setDate(String parameterName, Date x, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setDate(parameterName,
- x, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setTime(java.lang.String, java.sql.Time,
- * java.util.Calendar)
- */
- public void setTime(String parameterName, Time x, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setTime(parameterName,
- x, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setTimestamp(java.lang.String,
- * java.sql.Timestamp, java.util.Calendar)
- */
- public void setTimestamp(String parameterName, Timestamp x, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setTimestamp(
- parameterName, x, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#setNull(java.lang.String, int,
- * java.lang.String)
- */
- public void setNull(String parameterName, int sqlType, String typeName)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNull(parameterName,
- sqlType, typeName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getString(int)
- */
- public String getString(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getString(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBoolean(int)
- */
- public boolean getBoolean(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBoolean(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getByte(int)
- */
- public byte getByte(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getByte(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getShort(int)
- */
- public short getShort(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getShort(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getInt(int)
- */
- public int getInt(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getInt(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getLong(int)
- */
- public long getLong(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getLong(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getFloat(int)
- */
- public float getFloat(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getFloat(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getDouble(int)
- */
- public double getDouble(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getDouble(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBytes(int)
- */
- public byte[] getBytes(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBytes(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getDate(int)
- */
- public Date getDate(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getDate(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTime(int)
- */
- public Time getTime(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getTime(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTimestamp(int)
- */
- public Timestamp getTimestamp(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getTimestamp(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getObject(int)
- */
- public Object getObject(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getObject(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBigDecimal(int)
- */
- public BigDecimal getBigDecimal(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBigDecimal(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getObject(int, java.util.Map)
- */
- public Object getObject(String parameterName, Map typeMap)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getObject(
- parameterName, typeMap);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getRef(int)
- */
- public Ref getRef(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getRef(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getBlob(int)
- */
- public Blob getBlob(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getBlob(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getClob(int)
- */
- public Clob getClob(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getClob(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getArray(int)
- */
- public Array getArray(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getArray(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getDate(int, java.util.Calendar)
- */
- public Date getDate(String parameterName, Calendar cal) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getDate(
- parameterName, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTime(int, java.util.Calendar)
- */
- public Time getTime(String parameterName, Calendar cal) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getTime(
- parameterName, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar)
- */
- public Timestamp getTimestamp(String parameterName, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getTimestamp(
- parameterName, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.CallableStatement#getURL(java.lang.String)
- */
- public URL getURL(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt)
- .getURL(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-//
-// public Reader getCharacterStream(int parameterIndex) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getCharacterStream(parameterIndex);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public Reader getCharacterStream(String parameterName) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getCharacterStream(parameterName);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public Reader getNCharacterStream(int parameterIndex) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getCharacterStream(parameterIndex);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public Reader getNCharacterStream(String parameterName) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getNCharacterStream(parameterName);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public NClob getNClob(int parameterIndex) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getNClob(parameterIndex);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public NClob getNClob(String parameterName) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getNClob(parameterName);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public String getNString(int parameterIndex) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getNString(parameterIndex);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public String getNString(String parameterName) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getNString(parameterName);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public RowId getRowId(int parameterIndex) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getRowId(parameterIndex);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public RowId getRowId(String parameterName) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getRowId(parameterName);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public SQLXML getSQLXML(int parameterIndex) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getSQLXML(parameterIndex);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public SQLXML getSQLXML(String parameterName) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .getSQLXML(parameterName);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return null;
-// }
-//
-// public void setAsciiStream(String parameterName, InputStream x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setAsciiStream(parameterName, x) ;
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setAsciiStream(String parameterName, InputStream x, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setAsciiStream(parameterName, x, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBinaryStream(String parameterName, InputStream x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBinaryStream(parameterName, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBinaryStream(String parameterName, InputStream x, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBinaryStream(parameterName, x, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBlob(String parameterName, Blob x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBlob(parameterName, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBlob(String parameterName, InputStream inputStream) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBlob(parameterName, inputStream);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBlob(parameterName, inputStream, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setCharacterStream(parameterName, reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setCharacterStream(String parameterName, Reader reader, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setCharacterStream(parameterName, reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setClob(String parameterName, Clob x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setClob(parameterName, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setClob(String parameterName, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setClob(parameterName, reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setClob(String parameterName, Reader reader, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setClob(parameterName, reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNCharacterStream(String parameterName, Reader value) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNCharacterStream(parameterName, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNCharacterStream(parameterName, value, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(String parameterName, NClob value) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNClob(parameterName, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(String parameterName, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNClob(parameterName, reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(String parameterName, Reader reader, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNClob(parameterName, reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNString(String parameterName, String value) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNString(parameterName, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setRowId(String parameterName, RowId x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setRowId(parameterName, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setSQLXML(parameterName, xmlObject);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setAsciiStream(parameterIndex, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setAsciiStream(parameterIndex, x, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBinaryStream(parameterIndex, x) ;
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBinaryStream(parameterIndex, x, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBlob(parameterIndex, inputStream);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setBlob(parameterIndex, inputStream, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setCharacterStream(parameterIndex, reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .getCharacterStream(parameterIndex);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setClob(int parameterIndex, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setClob(parameterIndex, reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setClob(parameterIndex, reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNCharacterStream(parameterIndex, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// }
-//
-// public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNCharacterStream(parameterIndex, value, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(int parameterIndex, NClob value) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNClob(parameterIndex, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(int parameterIndex, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNClob(parameterIndex, reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNClob(parameterIndex, reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNString(int parameterIndex, String value) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setNString(parameterIndex, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setRowId(int parameterIndex, RowId x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setRowId(parameterIndex, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setSQLXML(parameterIndex, xmlObject);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// }
-//
-// public boolean isClosed() throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// .isClosed();
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return true;
-// }
-//
-// public boolean isPoolable() throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((CallableStatement) this.wrappedStmt)
-// . isPoolable();
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return false;
-// }
-//
-// public void setPoolable(boolean poolable) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((CallableStatement) this.wrappedStmt)
-// .setPoolable(poolable);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// }
-//
-// public boolean isWrapperFor(Class arg0) throws SQLException {
-// throw SQLError.notImplemented();
-// }
-//
-// public Object unwrap(Class arg0) throws SQLException {
-// throw SQLError.notImplemented();
-// }
-
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/ConnectionWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/ConnectionWrapper.java
deleted file mode 100644
index 88909e577..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/ConnectionWrapper.java
+++ /dev/null
@@ -1,2622 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008-2009 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.lang.reflect.Constructor;
-import java.sql.SQLException;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.util.Map;
-import java.util.TimeZone;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.ExceptionInterceptor;
-import com.mysql.jdbc.Extension;
-import com.mysql.jdbc.MysqlErrorNumbers;
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.Util;
-import com.mysql.jdbc.log.Log;
-
-/**
- * This class serves as a wrapper for the org.gjt.mm.mysql.jdbc2.Connection
- * class. It is returned to the application server which may wrap it again and
- * then return it to the application client in response to
- * dataSource.getConnection().
- *
- *
- * All method invocations are forwarded to org.gjt.mm.mysql.jdbc2.Connection
- * unless the close method was previously called, in which case a sqlException
- * is thrown. The close method performs a 'logical close' on the connection.
- *
- *
- *
- * All sqlExceptions thrown by the physical connection are intercepted and sent
- * to connectionEvent listeners before being thrown to client.
- *
- *
- * @author Todd Wolff todd.wolff_at_prodigy.net
- *
- * @see org.gjt.mm.mysql.jdbc2.Connection
- * @see org.gjt.mm.mysql.jdbc2.optional.MysqlPooledConnection
- */
-public class ConnectionWrapper extends WrapperBase implements Connection {
- protected Connection mc = null;
-
- private String invalidHandleStr = "Logical handle no longer valid";
-
- private boolean closed;
-
- private boolean isForXa;
-
- private static final Constructor JDBC_4_CONNECTION_WRAPPER_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_CONNECTION_WRAPPER_CTOR = Class.forName(
- "com.mysql.jdbc.jdbc2.optional.JDBC4ConnectionWrapper")
- .getConstructor(
- new Class[] { MysqlPooledConnection.class,
- Connection.class, Boolean.TYPE });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_CONNECTION_WRAPPER_CTOR = null;
- }
- }
-
- protected static ConnectionWrapper getInstance(
- MysqlPooledConnection mysqlPooledConnection,
- Connection mysqlConnection, boolean forXa) throws SQLException {
- if (!Util.isJdbc4()) {
- return new ConnectionWrapper(mysqlPooledConnection,
- mysqlConnection, forXa);
- }
-
- return (ConnectionWrapper) Util.handleNewInstance(
- JDBC_4_CONNECTION_WRAPPER_CTOR, new Object[] {
- mysqlPooledConnection, mysqlConnection,
- Boolean.valueOf(forXa) }, mysqlPooledConnection.getExceptionInterceptor());
- }
-
- /**
- * Construct a new LogicalHandle and set instance variables
- *
- * @param mysqlPooledConnection
- * reference to object that instantiated this object
- * @param mysqlConnection
- * physical connection to db
- *
- * @throws SQLException
- * if an error occurs.
- */
- public ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection,
- Connection mysqlConnection, boolean forXa) throws SQLException {
- super(mysqlPooledConnection);
-
- this.mc = mysqlConnection;
- this.closed = false;
- this.isForXa = forXa;
-
- if (this.isForXa) {
- setInGlobalTx(false);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#setAutoCommit
- */
- public void setAutoCommit(boolean autoCommit) throws SQLException {
- checkClosed();
-
- if (autoCommit && isInGlobalTx()) {
- throw SQLError.createSQLException(
- "Can't set autocommit to 'true' on an XAConnection",
- SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
- MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
- }
-
- try {
- this.mc.setAutoCommit(autoCommit);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#getAutoCommit()
- */
- public boolean getAutoCommit() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.getAutoCommit();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return false; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#setCatalog()
- */
- public void setCatalog(String catalog) throws SQLException {
- checkClosed();
-
- try {
- this.mc.setCatalog(catalog);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @return the current catalog
- *
- * @throws SQLException
- * if an error occurs
- */
- public String getCatalog() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.getCatalog();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#isClosed()
- */
- public boolean isClosed() throws SQLException {
- return (this.closed || this.mc.isClosed());
- }
-
- public boolean isMasterConnection() {
- return this.mc.isMasterConnection();
- }
-
- /**
- * @see Connection#setHoldability(int)
- */
- public void setHoldability(int arg0) throws SQLException {
- checkClosed();
-
- try {
- this.mc.setHoldability(arg0);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * @see Connection#getHoldability()
- */
- public int getHoldability() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.getHoldability();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return Statement.CLOSE_CURRENT_RESULT; // we don't reach this code,
- // compiler can't tell
- }
-
- /**
- * Allows clients to determine how long this connection has been idle.
- *
- * @return how long the connection has been idle.
- */
- public long getIdleFor() {
- return this.mc.getIdleFor();
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @return a metadata instance
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.sql.DatabaseMetaData getMetaData() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.getMetaData();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#setReadOnly()
- */
- public void setReadOnly(boolean readOnly) throws SQLException {
- checkClosed();
-
- try {
- this.mc.setReadOnly(readOnly);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#isReadOnly()
- */
- public boolean isReadOnly() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.isReadOnly();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return false; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#setSavepoint()
- */
- public java.sql.Savepoint setSavepoint() throws SQLException {
- checkClosed();
-
- if (isInGlobalTx()) {
- throw SQLError.createSQLException(
- "Can't set autocommit to 'true' on an XAConnection",
- SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
- MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
- }
-
- try {
- return this.mc.setSavepoint();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#setSavepoint(String)
- */
- public java.sql.Savepoint setSavepoint(String arg0) throws SQLException {
- checkClosed();
-
- if (isInGlobalTx()) {
- throw SQLError.createSQLException(
- "Can't set autocommit to 'true' on an XAConnection",
- SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
- MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
- }
-
- try {
- return this.mc.setSavepoint(arg0);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#setTransactionIsolation()
- */
- public void setTransactionIsolation(int level) throws SQLException {
- checkClosed();
-
- try {
- this.mc.setTransactionIsolation(level);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#getTransactionIsolation()
- */
- public int getTransactionIsolation() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.getTransactionIsolation();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return TRANSACTION_REPEATABLE_READ; // we don't reach this code,
- // compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#setTypeMap()
- */
- public void setTypeMap(java.util.Map map) throws SQLException {
- checkClosed();
-
- try {
- this.mc.setTypeMap(map);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#getTypeMap()
- */
- public java.util.Map getTypeMap() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.getTypeMap();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#getWarnings
- */
- public java.sql.SQLWarning getWarnings() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.getWarnings();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @throws SQLException
- * if an error occurs
- */
- public void clearWarnings() throws SQLException {
- checkClosed();
-
- try {
- this.mc.clearWarnings();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * The physical connection is not actually closed. the physical connection
- * is closed when the application server calls
- * mysqlPooledConnection.close(). this object is de-referenced by the pooled
- * connection each time mysqlPooledConnection.getConnection() is called by
- * app server.
- *
- * @throws SQLException
- * if an error occurs
- */
- public void close() throws SQLException {
- close(true);
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @throws SQLException
- * if an error occurs
- */
- public void commit() throws SQLException {
- checkClosed();
-
- if (isInGlobalTx()) {
- throw SQLError
- .createSQLException(
- "Can't call commit() on an XAConnection associated with a global transaction",
- SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
- MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
- }
-
- try {
- this.mc.commit();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#createStatement()
- */
- public java.sql.Statement createStatement() throws SQLException {
- checkClosed();
-
- try {
- return StatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .createStatement());
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#createStatement()
- */
- public java.sql.Statement createStatement(int resultSetType,
- int resultSetConcurrency) throws SQLException {
- checkClosed();
-
- try {
- return StatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .createStatement(resultSetType, resultSetConcurrency));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#createStatement(int, int, int)
- */
- public java.sql.Statement createStatement(int arg0, int arg1, int arg2)
- throws SQLException {
- checkClosed();
-
- try {
- return StatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .createStatement(arg0, arg1, arg2));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#nativeSQL()
- */
- public String nativeSQL(String sql) throws SQLException {
- checkClosed();
-
- try {
- return this.mc.nativeSQL(sql);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#prepareCall()
- */
- public java.sql.CallableStatement prepareCall(String sql)
- throws SQLException {
- checkClosed();
-
- try {
- return CallableStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareCall(sql));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#prepareCall()
- */
- public java.sql.CallableStatement prepareCall(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- checkClosed();
-
- try {
- return CallableStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareCall(sql, resultSetType, resultSetConcurrency));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#prepareCall(String, int, int, int)
- */
- public java.sql.CallableStatement prepareCall(String arg0, int arg1,
- int arg2, int arg3) throws SQLException {
- checkClosed();
-
- try {
- return CallableStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareCall(arg0, arg1, arg2, arg3));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- public java.sql.PreparedStatement clientPrepare(String sql)
- throws SQLException {
- checkClosed();
-
- try {
- return new PreparedStatementWrapper(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement clientPrepare(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- checkClosed();
-
- try {
- return new PreparedStatementWrapper(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql, resultSetType,
- resultSetConcurrency));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#prepareStatement()
- */
- public java.sql.PreparedStatement prepareStatement(String sql)
- throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareStatement(sql));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#prepareStatement()
- */
- public java.sql.PreparedStatement prepareStatement(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper
- .getInstance(this, this.pooledConnection, this.mc.prepareStatement(sql,
- resultSetType, resultSetConcurrency));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#prepareStatement(String, int, int, int)
- */
- public java.sql.PreparedStatement prepareStatement(String arg0, int arg1,
- int arg2, int arg3) throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareStatement(arg0, arg1, arg2, arg3));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#prepareStatement(String, int)
- */
- public java.sql.PreparedStatement prepareStatement(String arg0, int arg1)
- throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareStatement(arg0, arg1));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#prepareStatement(String, int[])
- */
- public java.sql.PreparedStatement prepareStatement(String arg0, int[] arg1)
- throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareStatement(arg0, arg1));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#prepareStatement(String, String[])
- */
- public java.sql.PreparedStatement prepareStatement(String arg0,
- String[] arg1) throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .prepareStatement(arg0, arg1));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // we don't reach this code, compiler can't tell
- }
-
- /**
- * @see Connection#releaseSavepoint(Savepoint)
- */
- public void releaseSavepoint(Savepoint arg0) throws SQLException {
- checkClosed();
-
- try {
- this.mc.releaseSavepoint(arg0);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * Passes call to method on physical connection instance. Notifies listeners
- * of any caught exceptions before re-throwing to client.
- *
- * @see java.sql.Connection#rollback()
- */
- public void rollback() throws SQLException {
- checkClosed();
-
- if (isInGlobalTx()) {
- throw SQLError
- .createSQLException(
- "Can't call rollback() on an XAConnection associated with a global transaction",
- SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
- MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
- }
-
- try {
- this.mc.rollback();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- /**
- * @see Connection#rollback(Savepoint)
- */
- public void rollback(Savepoint arg0) throws SQLException {
- checkClosed();
-
- if (isInGlobalTx()) {
- throw SQLError
- .createSQLException(
- "Can't call rollback() on an XAConnection associated with a global transaction",
- SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
- MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
- }
-
- try {
- this.mc.rollback(arg0);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- public boolean isSameResource(Connection c) {
- if (c instanceof ConnectionWrapper) {
- return this.mc.isSameResource(((ConnectionWrapper) c).mc);
- } else if (c instanceof com.mysql.jdbc.Connection) {
- return this.mc.isSameResource((com.mysql.jdbc.Connection) c);
- }
-
- return false;
- }
-
- protected void close(boolean fireClosedEvent) throws SQLException {
- synchronized (this.pooledConnection) {
- if (this.closed) {
- return;
- }
-
- if (!isInGlobalTx() && this.mc.getRollbackOnPooledClose()
- && !this.getAutoCommit()) {
- rollback();
- }
-
- if (fireClosedEvent) {
- this.pooledConnection.callConnectionEventListeners(
- MysqlPooledConnection.CONNECTION_CLOSED_EVENT, null);
- }
-
- // set closed status to true so that if application client tries to
- // make additional
- // calls a sqlException will be thrown. The physical connection is
- // re-used by the pooled connection each time getConnection is
- // called.
- this.closed = true;
- }
- }
-
- protected void checkClosed() throws SQLException {
- if (this.closed) {
- throw SQLError.createSQLException(this.invalidHandleStr, this.exceptionInterceptor);
- }
- }
-
- public boolean isInGlobalTx() {
- return this.mc.isInGlobalTx();
- }
-
- public void setInGlobalTx(boolean flag) {
- this.mc.setInGlobalTx(flag);
- }
-
- public void ping() throws SQLException {
- if (this.mc != null) {
- this.mc.ping();
- }
- }
-
- public void changeUser(String userName, String newPassword)
- throws SQLException {
- checkClosed();
-
- try {
- this.mc.changeUser(userName, newPassword);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- public void clearHasTriedMaster() {
- this.mc.clearHasTriedMaster();
- }
-
- public java.sql.PreparedStatement clientPrepareStatement(String sql)
- throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement clientPrepareStatement(String sql,
- int autoGenKeyIndex) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql, autoGenKeyIndex));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement clientPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql, resultSetType,
- resultSetConcurrency));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement clientPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql, resultSetType,
- resultSetConcurrency, resultSetHoldability));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement clientPrepareStatement(String sql,
- int[] autoGenKeyIndexes) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql, autoGenKeyIndexes));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement clientPrepareStatement(String sql,
- String[] autoGenKeyColNames) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .clientPrepareStatement(sql, autoGenKeyColNames));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public int getActiveStatementCount() {
- return this.mc.getActiveStatementCount();
- }
-
- public Log getLog() throws SQLException {
- return this.mc.getLog();
- }
-
- public String getServerCharacterEncoding() {
- return this.mc.getServerCharacterEncoding();
- }
-
- public TimeZone getServerTimezoneTZ() {
- return this.mc.getServerTimezoneTZ();
- }
-
- public String getStatementComment() {
- return this.mc.getStatementComment();
- }
-
- public boolean hasTriedMaster() {
- return this.mc.hasTriedMaster();
- }
-
- public boolean isAbonormallyLongQuery(long millisOrNanos) {
- return this.mc.isAbonormallyLongQuery(millisOrNanos);
- }
-
- public boolean isNoBackslashEscapesSet() {
- return this.mc.isNoBackslashEscapesSet();
- }
-
- public boolean lowerCaseTableNames() {
- return this.mc.lowerCaseTableNames();
- }
-
- public boolean parserKnowsUnicode() {
- return this.mc.parserKnowsUnicode();
- }
-
- public void reportQueryTime(long millisOrNanos) {
- this.mc.reportQueryTime(millisOrNanos);
- }
-
- public void resetServerState() throws SQLException {
- checkClosed();
-
- try {
- this.mc.resetServerState();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
- }
-
- public java.sql.PreparedStatement serverPrepareStatement(String sql)
- throws SQLException {
- checkClosed();
-
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .serverPrepareStatement(sql));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement serverPrepareStatement(String sql,
- int autoGenKeyIndex) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .serverPrepareStatement(sql, autoGenKeyIndex));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement serverPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .serverPrepareStatement(sql, resultSetType,
- resultSetConcurrency));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement serverPrepareStatement(String sql,
- int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .serverPrepareStatement(sql, resultSetType,
- resultSetConcurrency, resultSetHoldability));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement serverPrepareStatement(String sql,
- int[] autoGenKeyIndexes) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .serverPrepareStatement(sql, autoGenKeyIndexes));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public java.sql.PreparedStatement serverPrepareStatement(String sql,
- String[] autoGenKeyColNames) throws SQLException {
- try {
- return PreparedStatementWrapper.getInstance(this, this.pooledConnection, this.mc
- .serverPrepareStatement(sql, autoGenKeyColNames));
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public void setFailedOver(boolean flag) {
- this.mc.setFailedOver(flag);
-
- }
-
- public void setPreferSlaveDuringFailover(boolean flag) {
- this.mc.setPreferSlaveDuringFailover(flag);
- }
-
- public void setStatementComment(String comment) {
- this.mc.setStatementComment(comment);
-
- }
-
- public void shutdownServer() throws SQLException {
- checkClosed();
-
- try {
- this.mc.shutdownServer();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- }
-
- public boolean supportsIsolationLevel() {
- return this.mc.supportsIsolationLevel();
- }
-
- public boolean supportsQuotedIdentifiers() {
- return this.mc.supportsQuotedIdentifiers();
- }
-
- public boolean supportsTransactions() {
- return this.mc.supportsTransactions();
- }
-
- public boolean versionMeetsMinimum(int major, int minor, int subminor)
- throws SQLException {
- checkClosed();
-
- try {
- return this.mc.versionMeetsMinimum(major, minor, subminor);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return false;
- }
-
- public String exposeAsXml() throws SQLException {
- checkClosed();
-
- try {
- return this.mc.exposeAsXml();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null;
- }
-
- public boolean getAllowLoadLocalInfile() {
- return this.mc.getAllowLoadLocalInfile();
- }
-
- public boolean getAllowMultiQueries() {
- return this.mc.getAllowMultiQueries();
- }
-
- public boolean getAllowNanAndInf() {
- return this.mc.getAllowNanAndInf();
- }
-
- public boolean getAllowUrlInLocalInfile() {
- return this.mc.getAllowUrlInLocalInfile();
- }
-
- public boolean getAlwaysSendSetIsolation() {
- return this.mc.getAlwaysSendSetIsolation();
- }
-
- public boolean getAutoClosePStmtStreams() {
- return this.mc.getAutoClosePStmtStreams();
- }
-
- public boolean getAutoDeserialize() {
- return this.mc.getAutoDeserialize();
- }
-
- public boolean getAutoGenerateTestcaseScript() {
- return this.mc.getAutoGenerateTestcaseScript();
- }
-
- public boolean getAutoReconnectForPools() {
- return this.mc.getAutoReconnectForPools();
- }
-
- public boolean getAutoSlowLog() {
- return this.mc.getAutoSlowLog();
- }
-
- public int getBlobSendChunkSize() {
- return this.mc.getBlobSendChunkSize();
- }
-
- public boolean getBlobsAreStrings() {
- return this.mc.getBlobsAreStrings();
- }
-
- public boolean getCacheCallableStatements() {
- return this.mc.getCacheCallableStatements();
- }
-
- public boolean getCacheCallableStmts() {
- return this.mc.getCacheCallableStmts();
- }
-
- public boolean getCachePrepStmts() {
- return this.mc.getCachePrepStmts();
- }
-
- public boolean getCachePreparedStatements() {
- return this.mc.getCachePreparedStatements();
- }
-
- public boolean getCacheResultSetMetadata() {
- return this.mc.getCacheResultSetMetadata();
- }
-
- public boolean getCacheServerConfiguration() {
- return this.mc.getCacheServerConfiguration();
- }
-
- public int getCallableStatementCacheSize() {
- return this.mc.getCallableStatementCacheSize();
- }
-
- public int getCallableStmtCacheSize() {
- return this.mc.getCallableStmtCacheSize();
- }
-
- public boolean getCapitalizeTypeNames() {
- return this.mc.getCapitalizeTypeNames();
- }
-
- public String getCharacterSetResults() {
- return this.mc.getCharacterSetResults();
- }
-
- public String getClientCertificateKeyStorePassword() {
- return this.mc.getClientCertificateKeyStorePassword();
- }
-
- public String getClientCertificateKeyStoreType() {
- return this.mc.getClientCertificateKeyStoreType();
- }
-
- public String getClientCertificateKeyStoreUrl() {
- return this.mc.getClientCertificateKeyStoreUrl();
- }
-
- public String getClientInfoProvider() {
- return this.mc.getClientInfoProvider();
- }
-
- public String getClobCharacterEncoding() {
- return this.mc.getClobCharacterEncoding();
- }
-
- public boolean getClobberStreamingResults() {
- return this.mc.getClobberStreamingResults();
- }
-
- public int getConnectTimeout() {
- return this.mc.getConnectTimeout();
- }
-
- public String getConnectionCollation() {
- return this.mc.getConnectionCollation();
- }
-
- public String getConnectionLifecycleInterceptors() {
- return this.mc.getConnectionLifecycleInterceptors();
- }
-
- public boolean getContinueBatchOnError() {
- return this.mc.getContinueBatchOnError();
- }
-
- public boolean getCreateDatabaseIfNotExist() {
- return this.mc.getCreateDatabaseIfNotExist();
- }
-
- public int getDefaultFetchSize() {
- return this.mc.getDefaultFetchSize();
- }
-
- public boolean getDontTrackOpenResources() {
- return this.mc.getDontTrackOpenResources();
- }
-
- public boolean getDumpMetadataOnColumnNotFound() {
- return this.mc.getDumpMetadataOnColumnNotFound();
- }
-
- public boolean getDumpQueriesOnException() {
- return this.mc.getDumpQueriesOnException();
- }
-
- public boolean getDynamicCalendars() {
- return this.mc.getDynamicCalendars();
- }
-
- public boolean getElideSetAutoCommits() {
- return this.mc.getElideSetAutoCommits();
- }
-
- public boolean getEmptyStringsConvertToZero() {
- return this.mc.getEmptyStringsConvertToZero();
- }
-
- public boolean getEmulateLocators() {
- return this.mc.getEmulateLocators();
- }
-
- public boolean getEmulateUnsupportedPstmts() {
- return this.mc.getEmulateUnsupportedPstmts();
- }
-
- public boolean getEnablePacketDebug() {
- return this.mc.getEnablePacketDebug();
- }
-
- public boolean getEnableQueryTimeouts() {
- return this.mc.getEnableQueryTimeouts();
- }
-
- public String getEncoding() {
- return this.mc.getEncoding();
- }
-
- public boolean getExplainSlowQueries() {
- return this.mc.getExplainSlowQueries();
- }
-
- public boolean getFailOverReadOnly() {
- return this.mc.getFailOverReadOnly();
- }
-
- public boolean getFunctionsNeverReturnBlobs() {
- return this.mc.getFunctionsNeverReturnBlobs();
- }
-
- public boolean getGatherPerfMetrics() {
- return this.mc.getGatherPerfMetrics();
- }
-
- public boolean getGatherPerformanceMetrics() {
- return this.mc.getGatherPerformanceMetrics();
- }
-
- public boolean getGenerateSimpleParameterMetadata() {
- return this.mc.getGenerateSimpleParameterMetadata();
- }
-
- public boolean getHoldResultsOpenOverStatementClose() {
- return this.mc.getHoldResultsOpenOverStatementClose();
- }
-
- public boolean getIgnoreNonTxTables() {
- return this.mc.getIgnoreNonTxTables();
- }
-
- public boolean getIncludeInnodbStatusInDeadlockExceptions() {
- return this.mc.getIncludeInnodbStatusInDeadlockExceptions();
- }
-
- public int getInitialTimeout() {
- return this.mc.getInitialTimeout();
- }
-
- public boolean getInteractiveClient() {
- return this.mc.getInteractiveClient();
- }
-
- public boolean getIsInteractiveClient() {
- return this.mc.getIsInteractiveClient();
- }
-
- public boolean getJdbcCompliantTruncation() {
- return this.mc.getJdbcCompliantTruncation();
- }
-
- public boolean getJdbcCompliantTruncationForReads() {
- return this.mc.getJdbcCompliantTruncationForReads();
- }
-
- public String getLargeRowSizeThreshold() {
- return this.mc.getLargeRowSizeThreshold();
- }
-
- public String getLoadBalanceStrategy() {
- return this.mc.getLoadBalanceStrategy();
- }
-
- public String getLocalSocketAddress() {
- return this.mc.getLocalSocketAddress();
- }
-
- public int getLocatorFetchBufferSize() {
- return this.mc.getLocatorFetchBufferSize();
- }
-
- public boolean getLogSlowQueries() {
- return this.mc.getLogSlowQueries();
- }
-
- public boolean getLogXaCommands() {
- return this.mc.getLogXaCommands();
- }
-
- public String getLogger() {
- return this.mc.getLogger();
- }
-
- public String getLoggerClassName() {
- return this.mc.getLoggerClassName();
- }
-
- public boolean getMaintainTimeStats() {
- return this.mc.getMaintainTimeStats();
- }
-
- public int getMaxQuerySizeToLog() {
- return this.mc.getMaxQuerySizeToLog();
- }
-
- public int getMaxReconnects() {
- return this.mc.getMaxReconnects();
- }
-
- public int getMaxRows() {
- return this.mc.getMaxRows();
- }
-
- public int getMetadataCacheSize() {
- return this.mc.getMetadataCacheSize();
- }
-
- public int getNetTimeoutForStreamingResults() {
- return this.mc.getNetTimeoutForStreamingResults();
- }
-
- public boolean getNoAccessToProcedureBodies() {
- return this.mc.getNoAccessToProcedureBodies();
- }
-
- public boolean getNoDatetimeStringSync() {
- return this.mc.getNoDatetimeStringSync();
- }
-
- public boolean getNoTimezoneConversionForTimeType() {
- return this.mc.getNoTimezoneConversionForTimeType();
- }
-
- public boolean getNullCatalogMeansCurrent() {
- return this.mc.getNullCatalogMeansCurrent();
- }
-
- public boolean getNullNamePatternMatchesAll() {
- return this.mc.getNullNamePatternMatchesAll();
- }
-
- public boolean getOverrideSupportsIntegrityEnhancementFacility() {
- return this.mc.getOverrideSupportsIntegrityEnhancementFacility();
- }
-
- public int getPacketDebugBufferSize() {
- return this.mc.getPacketDebugBufferSize();
- }
-
- public boolean getPadCharsWithSpace() {
- return this.mc.getPadCharsWithSpace();
- }
-
- public boolean getParanoid() {
- return this.mc.getParanoid();
- }
-
- public boolean getPedantic() {
- return this.mc.getPedantic();
- }
-
- public boolean getPinGlobalTxToPhysicalConnection() {
- return this.mc.getPinGlobalTxToPhysicalConnection();
- }
-
- public boolean getPopulateInsertRowWithDefaultValues() {
- return this.mc.getPopulateInsertRowWithDefaultValues();
- }
-
- public int getPrepStmtCacheSize() {
- return this.mc.getPrepStmtCacheSize();
- }
-
- public int getPrepStmtCacheSqlLimit() {
- return this.mc.getPrepStmtCacheSqlLimit();
- }
-
- public int getPreparedStatementCacheSize() {
- return this.mc.getPreparedStatementCacheSize();
- }
-
- public int getPreparedStatementCacheSqlLimit() {
- return this.mc.getPreparedStatementCacheSqlLimit();
- }
-
- public boolean getProcessEscapeCodesForPrepStmts() {
- return this.mc.getProcessEscapeCodesForPrepStmts();
- }
-
- public boolean getProfileSQL() {
- return this.mc.getProfileSQL();
- }
-
- public boolean getProfileSql() {
- return this.mc.getProfileSql();
- }
-
- public String getPropertiesTransform() {
- return this.mc.getPropertiesTransform();
- }
-
- public int getQueriesBeforeRetryMaster() {
- return this.mc.getQueriesBeforeRetryMaster();
- }
-
- public boolean getReconnectAtTxEnd() {
- return this.mc.getReconnectAtTxEnd();
- }
-
- public boolean getRelaxAutoCommit() {
- return this.mc.getRelaxAutoCommit();
- }
-
- public int getReportMetricsIntervalMillis() {
- return this.mc.getReportMetricsIntervalMillis();
- }
-
- public boolean getRequireSSL() {
- return this.mc.getRequireSSL();
- }
-
- public String getResourceId() {
- return this.mc.getResourceId();
- }
-
- public int getResultSetSizeThreshold() {
- return this.mc.getResultSetSizeThreshold();
- }
-
- public boolean getRewriteBatchedStatements() {
- return this.mc.getRewriteBatchedStatements();
- }
-
- public boolean getRollbackOnPooledClose() {
- return this.mc.getRollbackOnPooledClose();
- }
-
- public boolean getRoundRobinLoadBalance() {
- return this.mc.getRoundRobinLoadBalance();
- }
-
- public boolean getRunningCTS13() {
- return this.mc.getRunningCTS13();
- }
-
- public int getSecondsBeforeRetryMaster() {
- return this.mc.getSecondsBeforeRetryMaster();
- }
-
- public String getServerTimezone() {
- return this.mc.getServerTimezone();
- }
-
- public String getSessionVariables() {
- return this.mc.getSessionVariables();
- }
-
- public int getSlowQueryThresholdMillis() {
- return this.mc.getSlowQueryThresholdMillis();
- }
-
- public long getSlowQueryThresholdNanos() {
- return this.mc.getSlowQueryThresholdNanos();
- }
-
- public String getSocketFactory() {
- return this.mc.getSocketFactory();
- }
-
- public String getSocketFactoryClassName() {
- return this.mc.getSocketFactoryClassName();
- }
-
- public int getSocketTimeout() {
- return this.mc.getSocketTimeout();
- }
-
- public String getStatementInterceptors() {
- return this.mc.getStatementInterceptors();
- }
-
- public boolean getStrictFloatingPoint() {
- return this.mc.getStrictFloatingPoint();
- }
-
- public boolean getStrictUpdates() {
- return this.mc.getStrictUpdates();
- }
-
- public boolean getTcpKeepAlive() {
- return this.mc.getTcpKeepAlive();
- }
-
- public boolean getTcpNoDelay() {
- return this.mc.getTcpNoDelay();
- }
-
- public int getTcpRcvBuf() {
- return this.mc.getTcpRcvBuf();
- }
-
- public int getTcpSndBuf() {
- return this.mc.getTcpSndBuf();
- }
-
- public int getTcpTrafficClass() {
- return this.mc.getTcpTrafficClass();
- }
-
- public boolean getTinyInt1isBit() {
- return this.mc.getTinyInt1isBit();
- }
-
- public boolean getTraceProtocol() {
- return this.mc.getTraceProtocol();
- }
-
- public boolean getTransformedBitIsBoolean() {
- return this.mc.getTransformedBitIsBoolean();
- }
-
- public boolean getTreatUtilDateAsTimestamp() {
- return this.mc.getTreatUtilDateAsTimestamp();
- }
-
- public String getTrustCertificateKeyStorePassword() {
- return this.mc.getTrustCertificateKeyStorePassword();
- }
-
- public String getTrustCertificateKeyStoreType() {
- return this.mc.getTrustCertificateKeyStoreType();
- }
-
- public String getTrustCertificateKeyStoreUrl() {
- return this.mc.getTrustCertificateKeyStoreUrl();
- }
-
- public boolean getUltraDevHack() {
- return this.mc.getUltraDevHack();
- }
-
- public boolean getUseBlobToStoreUTF8OutsideBMP() {
- return this.mc.getUseBlobToStoreUTF8OutsideBMP();
- }
-
- public boolean getUseCompression() {
- return this.mc.getUseCompression();
- }
-
- public String getUseConfigs() {
- return this.mc.getUseConfigs();
- }
-
- public boolean getUseCursorFetch() {
- return this.mc.getUseCursorFetch();
- }
-
- public boolean getUseDirectRowUnpack() {
- return this.mc.getUseDirectRowUnpack();
- }
-
- public boolean getUseDynamicCharsetInfo() {
- return this.mc.getUseDynamicCharsetInfo();
- }
-
- public boolean getUseFastDateParsing() {
- return this.mc.getUseFastDateParsing();
- }
-
- public boolean getUseFastIntParsing() {
- return this.mc.getUseFastIntParsing();
- }
-
- public boolean getUseGmtMillisForDatetimes() {
- return this.mc.getUseGmtMillisForDatetimes();
- }
-
- public boolean getUseHostsInPrivileges() {
- return this.mc.getUseHostsInPrivileges();
- }
-
- public boolean getUseInformationSchema() {
- return this.mc.getUseInformationSchema();
- }
-
- public boolean getUseJDBCCompliantTimezoneShift() {
- return this.mc.getUseJDBCCompliantTimezoneShift();
- }
-
- public boolean getUseJvmCharsetConverters() {
- return this.mc.getUseJvmCharsetConverters();
- }
-
- public boolean getUseLocalSessionState() {
- return this.mc.getUseLocalSessionState();
- }
-
- public boolean getUseNanosForElapsedTime() {
- return this.mc.getUseNanosForElapsedTime();
- }
-
- public boolean getUseOldAliasMetadataBehavior() {
- return this.mc.getUseOldAliasMetadataBehavior();
- }
-
- public boolean getUseOldUTF8Behavior() {
- return this.mc.getUseOldUTF8Behavior();
- }
-
- public boolean getUseOnlyServerErrorMessages() {
- return this.mc.getUseOnlyServerErrorMessages();
- }
-
- public boolean getUseReadAheadInput() {
- return this.mc.getUseReadAheadInput();
- }
-
- public boolean getUseSSL() {
- return this.mc.getUseSSL();
- }
-
- public boolean getUseSSPSCompatibleTimezoneShift() {
- return this.mc.getUseSSPSCompatibleTimezoneShift();
- }
-
- public boolean getUseServerPrepStmts() {
- return this.mc.getUseServerPrepStmts();
- }
-
- public boolean getUseServerPreparedStmts() {
- return this.mc.getUseServerPreparedStmts();
- }
-
- public boolean getUseSqlStateCodes() {
- return this.mc.getUseSqlStateCodes();
- }
-
- public boolean getUseStreamLengthsInPrepStmts() {
- return this.mc.getUseStreamLengthsInPrepStmts();
- }
-
- public boolean getUseTimezone() {
- return this.mc.getUseTimezone();
- }
-
- public boolean getUseUltraDevWorkAround() {
- return this.mc.getUseUltraDevWorkAround();
- }
-
- public boolean getUseUnbufferedInput() {
- return this.mc.getUseUnbufferedInput();
- }
-
- public boolean getUseUnicode() {
- return this.mc.getUseUnicode();
- }
-
- public boolean getUseUsageAdvisor() {
- return this.mc.getUseUsageAdvisor();
- }
-
- public String getUtf8OutsideBmpExcludedColumnNamePattern() {
- return this.mc.getUtf8OutsideBmpExcludedColumnNamePattern();
- }
-
- public String getUtf8OutsideBmpIncludedColumnNamePattern() {
- return this.mc.getUtf8OutsideBmpIncludedColumnNamePattern();
- }
-
- public boolean getYearIsDateType() {
- return this.mc.getYearIsDateType();
- }
-
- public String getZeroDateTimeBehavior() {
- return this.mc.getZeroDateTimeBehavior();
- }
-
- public void setAllowLoadLocalInfile(boolean property) {
- this.mc.setAllowLoadLocalInfile(property);
- }
-
- public void setAllowMultiQueries(boolean property) {
- this.mc.setAllowMultiQueries(property);
- }
-
- public void setAllowNanAndInf(boolean flag) {
- this.mc.setAllowNanAndInf(flag);
- }
-
- public void setAllowUrlInLocalInfile(boolean flag) {
- this.mc.setAllowUrlInLocalInfile(flag);
- }
-
- public void setAlwaysSendSetIsolation(boolean flag) {
- this.mc.setAlwaysSendSetIsolation(flag);
- }
-
- public void setAutoClosePStmtStreams(boolean flag) {
- this.mc.setAutoClosePStmtStreams(flag);
- }
-
- public void setAutoDeserialize(boolean flag) {
- this.mc.setAutoDeserialize(flag);
- }
-
- public void setAutoGenerateTestcaseScript(boolean flag) {
- this.mc.setAutoGenerateTestcaseScript(flag);
- }
-
- public void setAutoReconnect(boolean flag) {
- this.mc.setAutoReconnect(flag);
- }
-
- public void setAutoReconnectForConnectionPools(boolean property) {
- this.mc.setAutoReconnectForConnectionPools(property);
- }
-
- public void setAutoReconnectForPools(boolean flag) {
- this.mc.setAutoReconnectForPools(flag);
- }
-
- public void setAutoSlowLog(boolean flag) {
- this.mc.setAutoSlowLog(flag);
- }
-
- public void setBlobSendChunkSize(String value) throws SQLException {
- this.mc.setBlobSendChunkSize(value);
- }
-
- public void setBlobsAreStrings(boolean flag) {
- this.mc.setBlobsAreStrings(flag);
- }
-
- public void setCacheCallableStatements(boolean flag) {
- this.mc.setCacheCallableStatements(flag);
- }
-
- public void setCacheCallableStmts(boolean flag) {
- this.mc.setCacheCallableStmts(flag);
- }
-
- public void setCachePrepStmts(boolean flag) {
- this.mc.setCachePrepStmts(flag);
- }
-
- public void setCachePreparedStatements(boolean flag) {
- this.mc.setCachePreparedStatements(flag);
- }
-
- public void setCacheResultSetMetadata(boolean property) {
- this.mc.setCacheResultSetMetadata(property);
- }
-
- public void setCacheServerConfiguration(boolean flag) {
- this.mc.setCacheServerConfiguration(flag);
- }
-
- public void setCallableStatementCacheSize(int size) {
- this.mc.setCallableStatementCacheSize(size);
- }
-
- public void setCallableStmtCacheSize(int cacheSize) {
- this.mc.setCallableStmtCacheSize(cacheSize);
- }
-
- public void setCapitalizeDBMDTypes(boolean property) {
- this.mc.setCapitalizeDBMDTypes(property);
- }
-
- public void setCapitalizeTypeNames(boolean flag) {
- this.mc.setCapitalizeTypeNames(flag);
- }
-
- public void setCharacterEncoding(String encoding) {
- this.mc.setCharacterEncoding(encoding);
- }
-
- public void setCharacterSetResults(String characterSet) {
- this.mc.setCharacterSetResults(characterSet);
- }
-
- public void setClientCertificateKeyStorePassword(String value) {
- this.mc.setClientCertificateKeyStorePassword(value);
- }
-
- public void setClientCertificateKeyStoreType(String value) {
- this.mc.setClientCertificateKeyStoreType(value);
- }
-
- public void setClientCertificateKeyStoreUrl(String value) {
- this.mc.setClientCertificateKeyStoreUrl(value);
- }
-
- public void setClientInfoProvider(String classname) {
- this.mc.setClientInfoProvider(classname);
- }
-
- public void setClobCharacterEncoding(String encoding) {
- this.mc.setClobCharacterEncoding(encoding);
- }
-
- public void setClobberStreamingResults(boolean flag) {
- this.mc.setClobberStreamingResults(flag);
- }
-
- public void setConnectTimeout(int timeoutMs) {
- this.mc.setConnectTimeout(timeoutMs);
- }
-
- public void setConnectionCollation(String collation) {
- this.mc.setConnectionCollation(collation);
- }
-
- public void setConnectionLifecycleInterceptors(String interceptors) {
- this.mc.setConnectionLifecycleInterceptors(interceptors);
- }
-
- public void setContinueBatchOnError(boolean property) {
- this.mc.setContinueBatchOnError(property);
- }
-
- public void setCreateDatabaseIfNotExist(boolean flag) {
- this.mc.setCreateDatabaseIfNotExist(flag);
- }
-
- public void setDefaultFetchSize(int n) {
- this.mc.setDefaultFetchSize(n);
- }
-
- public void setDetectServerPreparedStmts(boolean property) {
- this.mc.setDetectServerPreparedStmts(property);
- }
-
- public void setDontTrackOpenResources(boolean flag) {
- this.mc.setDontTrackOpenResources(flag);
- }
-
- public void setDumpMetadataOnColumnNotFound(boolean flag) {
- this.mc.setDumpMetadataOnColumnNotFound(flag);
- }
-
- public void setDumpQueriesOnException(boolean flag) {
- this.mc.setDumpQueriesOnException(flag);
- }
-
- public void setDynamicCalendars(boolean flag) {
- this.mc.setDynamicCalendars(flag);
- }
-
- public void setElideSetAutoCommits(boolean flag) {
- this.mc.setElideSetAutoCommits(flag);
- }
-
- public void setEmptyStringsConvertToZero(boolean flag) {
- this.mc.setEmptyStringsConvertToZero(flag);
- }
-
- public void setEmulateLocators(boolean property) {
- this.mc.setEmulateLocators(property);
- }
-
- public void setEmulateUnsupportedPstmts(boolean flag) {
- this.mc.setEmulateUnsupportedPstmts(flag);
- }
-
- public void setEnablePacketDebug(boolean flag) {
- this.mc.setEnablePacketDebug(flag);
- }
-
- public void setEnableQueryTimeouts(boolean flag) {
- this.mc.setEnableQueryTimeouts(flag);
- }
-
- public void setEncoding(String property) {
- this.mc.setEncoding(property);
- }
-
- public void setExplainSlowQueries(boolean flag) {
- this.mc.setExplainSlowQueries(flag);
- }
-
- public void setFailOverReadOnly(boolean flag) {
- this.mc.setFailOverReadOnly(flag);
- }
-
- public void setFunctionsNeverReturnBlobs(boolean flag) {
- this.mc.setFunctionsNeverReturnBlobs(flag);
- }
-
- public void setGatherPerfMetrics(boolean flag) {
- this.mc.setGatherPerfMetrics(flag);
- }
-
- public void setGatherPerformanceMetrics(boolean flag) {
- this.mc.setGatherPerformanceMetrics(flag);
- }
-
- public void setGenerateSimpleParameterMetadata(boolean flag) {
- this.mc.setGenerateSimpleParameterMetadata(flag);
- }
-
- public void setHoldResultsOpenOverStatementClose(boolean flag) {
- this.mc.setHoldResultsOpenOverStatementClose(flag);
- }
-
- public void setIgnoreNonTxTables(boolean property) {
- this.mc.setIgnoreNonTxTables(property);
- }
-
- public void setIncludeInnodbStatusInDeadlockExceptions(boolean flag) {
- this.mc.setIncludeInnodbStatusInDeadlockExceptions(flag);
- }
-
- public void setInitialTimeout(int property) {
- this.mc.setInitialTimeout(property);
- }
-
- public void setInteractiveClient(boolean property) {
- this.mc.setInteractiveClient(property);
- }
-
- public void setIsInteractiveClient(boolean property) {
- this.mc.setIsInteractiveClient(property);
- }
-
- public void setJdbcCompliantTruncation(boolean flag) {
- this.mc.setJdbcCompliantTruncation(flag);
- }
-
- public void setJdbcCompliantTruncationForReads(
- boolean jdbcCompliantTruncationForReads) {
- this.mc
- .setJdbcCompliantTruncationForReads(jdbcCompliantTruncationForReads);
- }
-
- public void setLargeRowSizeThreshold(String value) {
- this.mc.setLargeRowSizeThreshold(value);
- }
-
- public void setLoadBalanceStrategy(String strategy) {
- this.mc.setLoadBalanceStrategy(strategy);
- }
-
- public void setLocalSocketAddress(String address) {
- this.mc.setLocalSocketAddress(address);
- }
-
- public void setLocatorFetchBufferSize(String value) throws SQLException {
- this.mc.setLocatorFetchBufferSize(value);
- }
-
- public void setLogSlowQueries(boolean flag) {
- this.mc.setLogSlowQueries(flag);
- }
-
- public void setLogXaCommands(boolean flag) {
- this.mc.setLogXaCommands(flag);
- }
-
- public void setLogger(String property) {
- this.mc.setLogger(property);
- }
-
- public void setLoggerClassName(String className) {
- this.mc.setLoggerClassName(className);
- }
-
- public void setMaintainTimeStats(boolean flag) {
- this.mc.setMaintainTimeStats(flag);
- }
-
- public void setMaxQuerySizeToLog(int sizeInBytes) {
- this.mc.setMaxQuerySizeToLog(sizeInBytes);
- }
-
- public void setMaxReconnects(int property) {
- this.mc.setMaxReconnects(property);
- }
-
- public void setMaxRows(int property) {
- this.mc.setMaxRows(property);
- }
-
- public void setMetadataCacheSize(int value) {
- this.mc.setMetadataCacheSize(value);
- }
-
- public void setNetTimeoutForStreamingResults(int value) {
- this.mc.setNetTimeoutForStreamingResults(value);
- }
-
- public void setNoAccessToProcedureBodies(boolean flag) {
- this.mc.setNoAccessToProcedureBodies(flag);
- }
-
- public void setNoDatetimeStringSync(boolean flag) {
- this.mc.setNoDatetimeStringSync(flag);
- }
-
- public void setNoTimezoneConversionForTimeType(boolean flag) {
- this.mc.setNoTimezoneConversionForTimeType(flag);
- }
-
- public void setNullCatalogMeansCurrent(boolean value) {
- this.mc.setNullCatalogMeansCurrent(value);
- }
-
- public void setNullNamePatternMatchesAll(boolean value) {
- this.mc.setNullNamePatternMatchesAll(value);
- }
-
- public void setOverrideSupportsIntegrityEnhancementFacility(boolean flag) {
- this.mc.setOverrideSupportsIntegrityEnhancementFacility(flag);
- }
-
- public void setPacketDebugBufferSize(int size) {
- this.mc.setPacketDebugBufferSize(size);
- }
-
- public void setPadCharsWithSpace(boolean flag) {
- this.mc.setPadCharsWithSpace(flag);
- }
-
- public void setParanoid(boolean property) {
- this.mc.setParanoid(property);
- }
-
- public void setPedantic(boolean property) {
- this.mc.setPedantic(property);
- }
-
- public void setPinGlobalTxToPhysicalConnection(boolean flag) {
- this.mc.setPinGlobalTxToPhysicalConnection(flag);
- }
-
- public void setPopulateInsertRowWithDefaultValues(boolean flag) {
- this.mc.setPopulateInsertRowWithDefaultValues(flag);
- }
-
- public void setPrepStmtCacheSize(int cacheSize) {
- this.mc.setPrepStmtCacheSize(cacheSize);
- }
-
- public void setPrepStmtCacheSqlLimit(int sqlLimit) {
- this.mc.setPrepStmtCacheSqlLimit(sqlLimit);
- }
-
- public void setPreparedStatementCacheSize(int cacheSize) {
- this.mc.setPreparedStatementCacheSize(cacheSize);
- }
-
- public void setPreparedStatementCacheSqlLimit(int cacheSqlLimit) {
- this.mc.setPreparedStatementCacheSqlLimit(cacheSqlLimit);
- }
-
- public void setProcessEscapeCodesForPrepStmts(boolean flag) {
- this.mc.setProcessEscapeCodesForPrepStmts(flag);
- }
-
- public void setProfileSQL(boolean flag) {
- this.mc.setProfileSQL(flag);
- }
-
- public void setProfileSql(boolean property) {
- this.mc.setProfileSql(property);
- }
-
- public void setPropertiesTransform(String value) {
- this.mc.setPropertiesTransform(value);
- }
-
- public void setQueriesBeforeRetryMaster(int property) {
- this.mc.setQueriesBeforeRetryMaster(property);
- }
-
- public void setReconnectAtTxEnd(boolean property) {
- this.mc.setReconnectAtTxEnd(property);
- }
-
- public void setRelaxAutoCommit(boolean property) {
- this.mc.setRelaxAutoCommit(property);
- }
-
- public void setReportMetricsIntervalMillis(int millis) {
- this.mc.setReportMetricsIntervalMillis(millis);
- }
-
- public void setRequireSSL(boolean property) {
- this.mc.setRequireSSL(property);
- }
-
- public void setResourceId(String resourceId) {
- this.mc.setResourceId(resourceId);
- }
-
- public void setResultSetSizeThreshold(int threshold) {
- this.mc.setResultSetSizeThreshold(threshold);
- }
-
- public void setRetainStatementAfterResultSetClose(boolean flag) {
- this.mc.setRetainStatementAfterResultSetClose(flag);
- }
-
- public void setRewriteBatchedStatements(boolean flag) {
- this.mc.setRewriteBatchedStatements(flag);
- }
-
- public void setRollbackOnPooledClose(boolean flag) {
- this.mc.setRollbackOnPooledClose(flag);
- }
-
- public void setRoundRobinLoadBalance(boolean flag) {
- this.mc.setRoundRobinLoadBalance(flag);
- }
-
- public void setRunningCTS13(boolean flag) {
- this.mc.setRunningCTS13(flag);
- }
-
- public void setSecondsBeforeRetryMaster(int property) {
- this.mc.setSecondsBeforeRetryMaster(property);
- }
-
- public void setServerTimezone(String property) {
- this.mc.setServerTimezone(property);
- }
-
- public void setSessionVariables(String variables) {
- this.mc.setSessionVariables(variables);
- }
-
- public void setSlowQueryThresholdMillis(int millis) {
- this.mc.setSlowQueryThresholdMillis(millis);
- }
-
- public void setSlowQueryThresholdNanos(long nanos) {
- this.mc.setSlowQueryThresholdNanos(nanos);
- }
-
- public void setSocketFactory(String name) {
- this.mc.setSocketFactory(name);
- }
-
- public void setSocketFactoryClassName(String property) {
- this.mc.setSocketFactoryClassName(property);
- }
-
- public void setSocketTimeout(int property) {
- this.mc.setSocketTimeout(property);
- }
-
- public void setStatementInterceptors(String value) {
- this.mc.setStatementInterceptors(value);
- }
-
- public void setStrictFloatingPoint(boolean property) {
- this.mc.setStrictFloatingPoint(property);
- }
-
- public void setStrictUpdates(boolean property) {
- this.mc.setStrictUpdates(property);
- }
-
- public void setTcpKeepAlive(boolean flag) {
- this.mc.setTcpKeepAlive(flag);
- }
-
- public void setTcpNoDelay(boolean flag) {
- this.mc.setTcpNoDelay(flag);
- }
-
- public void setTcpRcvBuf(int bufSize) {
- this.mc.setTcpRcvBuf(bufSize);
- }
-
- public void setTcpSndBuf(int bufSize) {
- this.mc.setTcpSndBuf(bufSize);
- }
-
- public void setTcpTrafficClass(int classFlags) {
- this.mc.setTcpTrafficClass(classFlags);
- }
-
- public void setTinyInt1isBit(boolean flag) {
- this.mc.setTinyInt1isBit(flag);
- }
-
- public void setTraceProtocol(boolean flag) {
- this.mc.setTraceProtocol(flag);
- }
-
- public void setTransformedBitIsBoolean(boolean flag) {
- this.mc.setTransformedBitIsBoolean(flag);
- }
-
- public void setTreatUtilDateAsTimestamp(boolean flag) {
- this.mc.setTreatUtilDateAsTimestamp(flag);
- }
-
- public void setTrustCertificateKeyStorePassword(String value) {
- this.mc.setTrustCertificateKeyStorePassword(value);
- }
-
- public void setTrustCertificateKeyStoreType(String value) {
- this.mc.setTrustCertificateKeyStoreType(value);
- }
-
- public void setTrustCertificateKeyStoreUrl(String value) {
- this.mc.setTrustCertificateKeyStoreUrl(value);
- }
-
- public void setUltraDevHack(boolean flag) {
- this.mc.setUltraDevHack(flag);
- }
-
- public void setUseBlobToStoreUTF8OutsideBMP(boolean flag) {
- this.mc.setUseBlobToStoreUTF8OutsideBMP(flag);
- }
-
- public void setUseCompression(boolean property) {
- this.mc.setUseCompression(property);
- }
-
- public void setUseConfigs(String configs) {
- this.mc.setUseConfigs(configs);
- }
-
- public void setUseCursorFetch(boolean flag) {
- this.mc.setUseCursorFetch(flag);
- }
-
- public void setUseDirectRowUnpack(boolean flag) {
- this.mc.setUseDirectRowUnpack(flag);
- }
-
- public void setUseDynamicCharsetInfo(boolean flag) {
- this.mc.setUseDynamicCharsetInfo(flag);
- }
-
- public void setUseFastDateParsing(boolean flag) {
- this.mc.setUseFastDateParsing(flag);
- }
-
- public void setUseFastIntParsing(boolean flag) {
- this.mc.setUseFastIntParsing(flag);
- }
-
- public void setUseGmtMillisForDatetimes(boolean flag) {
- this.mc.setUseGmtMillisForDatetimes(flag);
- }
-
- public void setUseHostsInPrivileges(boolean property) {
- this.mc.setUseHostsInPrivileges(property);
- }
-
- public void setUseInformationSchema(boolean flag) {
- this.mc.setUseInformationSchema(flag);
- }
-
- public void setUseJDBCCompliantTimezoneShift(boolean flag) {
- this.mc.setUseJDBCCompliantTimezoneShift(flag);
- }
-
- public void setUseJvmCharsetConverters(boolean flag) {
- this.mc.setUseJvmCharsetConverters(flag);
- }
-
- public void setUseLocalSessionState(boolean flag) {
- this.mc.setUseLocalSessionState(flag);
- }
-
- public void setUseNanosForElapsedTime(boolean flag) {
- this.mc.setUseNanosForElapsedTime(flag);
- }
-
- public void setUseOldAliasMetadataBehavior(boolean flag) {
- this.mc.setUseOldAliasMetadataBehavior(flag);
- }
-
- public void setUseOldUTF8Behavior(boolean flag) {
- this.mc.setUseOldUTF8Behavior(flag);
- }
-
- public void setUseOnlyServerErrorMessages(boolean flag) {
- this.mc.setUseOnlyServerErrorMessages(flag);
- }
-
- public void setUseReadAheadInput(boolean flag) {
- this.mc.setUseReadAheadInput(flag);
- }
-
- public void setUseSSL(boolean property) {
- this.mc.setUseSSL(property);
- }
-
- public void setUseSSPSCompatibleTimezoneShift(boolean flag) {
- this.mc.setUseSSPSCompatibleTimezoneShift(flag);
- }
-
- public void setUseServerPrepStmts(boolean flag) {
- this.mc.setUseServerPrepStmts(flag);
- }
-
- public void setUseServerPreparedStmts(boolean flag) {
- this.mc.setUseServerPreparedStmts(flag);
- }
-
- public void setUseSqlStateCodes(boolean flag) {
- this.mc.setUseSqlStateCodes(flag);
- }
-
- public void setUseStreamLengthsInPrepStmts(boolean property) {
- this.mc.setUseStreamLengthsInPrepStmts(property);
- }
-
- public void setUseTimezone(boolean property) {
- this.mc.setUseTimezone(property);
- }
-
- public void setUseUltraDevWorkAround(boolean property) {
- this.mc.setUseUltraDevWorkAround(property);
- }
-
- public void setUseUnbufferedInput(boolean flag) {
- this.mc.setUseUnbufferedInput(flag);
- }
-
- public void setUseUnicode(boolean flag) {
- this.mc.setUseUnicode(flag);
- }
-
- public void setUseUsageAdvisor(boolean useUsageAdvisorFlag) {
- this.mc.setUseUsageAdvisor(useUsageAdvisorFlag);
- }
-
- public void setUtf8OutsideBmpExcludedColumnNamePattern(String regexPattern) {
- this.mc.setUtf8OutsideBmpExcludedColumnNamePattern(regexPattern);
- }
-
- public void setUtf8OutsideBmpIncludedColumnNamePattern(String regexPattern) {
- this.mc.setUtf8OutsideBmpIncludedColumnNamePattern(regexPattern);
- }
-
- public void setYearIsDateType(boolean flag) {
- this.mc.setYearIsDateType(flag);
- }
-
- public void setZeroDateTimeBehavior(String behavior) {
- this.mc.setZeroDateTimeBehavior(behavior);
- }
-
- public boolean useUnbufferedInput() {
- return this.mc.useUnbufferedInput();
- }
-
- public void initializeExtension(Extension ex) throws SQLException {
- this.mc.initializeExtension(ex);
- }
-
- public String getProfilerEventHandler() {
- return this.mc.getProfilerEventHandler();
- }
-
- public void setProfilerEventHandler(String handler) {
- this.mc.setProfilerEventHandler(handler);
- }
-
- public boolean getVerifyServerCertificate() {
- return this.mc.getVerifyServerCertificate();
- }
-
- public void setVerifyServerCertificate(boolean flag) {
- this.mc.setVerifyServerCertificate(flag);
- }
-
- public boolean getUseLegacyDatetimeCode() {
- return this.mc.getUseLegacyDatetimeCode();
- }
-
- public void setUseLegacyDatetimeCode(boolean flag) {
- this.mc.setUseLegacyDatetimeCode(flag);
- }
-
- public int getSelfDestructOnPingMaxOperations() {
- return this.mc.getSelfDestructOnPingMaxOperations();
- }
-
- public int getSelfDestructOnPingSecondsLifetime() {
- return this.mc.getSelfDestructOnPingSecondsLifetime();
- }
-
- public void setSelfDestructOnPingMaxOperations(int maxOperations) {
- this.mc.setSelfDestructOnPingMaxOperations(maxOperations);
- }
-
- public void setSelfDestructOnPingSecondsLifetime(int seconds) {
- this.mc.setSelfDestructOnPingSecondsLifetime(seconds);
- }
-
- public boolean getUseColumnNamesInFindColumn() {
- return this.mc.getUseColumnNamesInFindColumn();
- }
-
- public void setUseColumnNamesInFindColumn(boolean flag) {
- this.mc.setUseColumnNamesInFindColumn(flag);
- }
-
- public boolean getUseLocalTransactionState() {
- return this.mc.getUseLocalTransactionState();
- }
-
- public void setUseLocalTransactionState(boolean flag) {
- this.mc.setUseLocalTransactionState(flag);
- }
-
- public boolean getCompensateOnDuplicateKeyUpdateCounts() {
- return this.mc.getCompensateOnDuplicateKeyUpdateCounts();
- }
-
- public void setCompensateOnDuplicateKeyUpdateCounts(boolean flag) {
- this.mc.setCompensateOnDuplicateKeyUpdateCounts(flag);
- }
-
- public boolean getUseAffectedRows() {
- return this.mc.getUseAffectedRows();
- }
-
- public void setUseAffectedRows(boolean flag) {
- this.mc.setUseAffectedRows(flag);
- }
-
- public String getPasswordCharacterEncoding() {
- return this.mc.getPasswordCharacterEncoding();
- }
-
- public void setPasswordCharacterEncoding(String characterSet) {
- this.mc.setPasswordCharacterEncoding(characterSet);
- }
-
- public int getAutoIncrementIncrement() {
- return this.mc.getAutoIncrementIncrement();
- }
-
- public int getLoadBalanceBlacklistTimeout() {
- return this.mc.getLoadBalanceBlacklistTimeout();
- }
-
- public void setLoadBalanceBlacklistTimeout(int loadBalanceBlacklistTimeout) {
- this.mc.setLoadBalanceBlacklistTimeout(loadBalanceBlacklistTimeout);
- }
-
- public void setRetriesAllDown(int retriesAllDown) {
- this.mc.setRetriesAllDown(retriesAllDown);
- }
-
- public int getRetriesAllDown() {
- return this.mc.getRetriesAllDown();
- }
-
- public ExceptionInterceptor getExceptionInterceptor() {
- return this.pooledConnection.getExceptionInterceptor();
- }
-
- public String getExceptionInterceptors() {
- return this.mc.getExceptionInterceptors();
- }
-
- public void setExceptionInterceptors(String exceptionInterceptors) {
- this.mc.setExceptionInterceptors(exceptionInterceptors);
- }
-
- public boolean getQueryTimeoutKillsConnection() {
- return this.mc.getQueryTimeoutKillsConnection();
- }
-
- public void setQueryTimeoutKillsConnection(
- boolean queryTimeoutKillsConnection) {
- this.mc.setQueryTimeoutKillsConnection(queryTimeoutKillsConnection);
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/JDBC4CallableStatementWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/JDBC4CallableStatementWrapper.java
deleted file mode 100644
index 56ca9713f..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/JDBC4CallableStatementWrapper.java
+++ /dev/null
@@ -1,1008 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.RowId;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Statement;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.SQLError;
-
-import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper;
-import com.mysql.jdbc.jdbc2.optional.MysqlPooledConnection;
-
-/**
- */
-public class JDBC4CallableStatementWrapper extends CallableStatementWrapper {
-
- public JDBC4CallableStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn,
- CallableStatement toWrap) {
- super(c, conn, toWrap);
- }
-
- public void close() throws SQLException {
- try {
- super.close();
- } finally {
- this.unwrappedInterfaces = null;
- }
- }
-
- public boolean isClosed() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.isClosed();
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // never get here - compiler can't tell
- }
-
- public void setPoolable(boolean poolable) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setPoolable(poolable);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public boolean isPoolable() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.isPoolable();
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // never get here - compiler can't tell
- }
-
- public void setRowId(int parameterIndex, RowId x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setRowId(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(int parameterIndex, NClob value) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
- value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setSQLXML(int parameterIndex, SQLXML xmlObject)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setSQLXML(parameterIndex,
- xmlObject);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
-
- public void setNString(int parameterIndex,
- String value)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNString(parameterIndex,
- value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNCharacterStream(int parameterIndex,
- Reader value,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNCharacterStream(parameterIndex,
- value, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setClob(int parameterIndex,
- Reader reader,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
- reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBlob(int parameterIndex,
- InputStream inputStream,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
- inputStream, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(int parameterIndex,
- Reader reader,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
- reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setAsciiStream(int parameterIndex,
- InputStream x,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setAsciiStream(parameterIndex,
- x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBinaryStream(int parameterIndex,
- InputStream x,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBinaryStream(parameterIndex,
- x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setCharacterStream(int parameterIndex,
- Reader reader,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setCharacterStream(parameterIndex,
- reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setAsciiStream(int parameterIndex,
- InputStream x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setAsciiStream(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBinaryStream(int parameterIndex,
- InputStream x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBinaryStream(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setCharacterStream(int parameterIndex,
- Reader reader)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setCharacterStream(parameterIndex,
- reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- }
-
- public void setNCharacterStream(int parameterIndex,
- Reader value)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNCharacterStream(parameterIndex,
- value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- }
-
- public void setClob(int parameterIndex,
- Reader reader)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
- reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- }
-
- public void setBlob(int parameterIndex,
- InputStream inputStream)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
- inputStream);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(int parameterIndex,
- Reader reader)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
- reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /**
- * Returns true if this either implements the interface argument or is
- * directly or indirectly a wrapper for an object that does. Returns false
- * otherwise. If this implements the interface then return true, else if
- * this is a wrapper then return the result of recursively calling
- * isWrapperFor on the wrapped object. If this does not
- * implement the interface and is not a wrapper, return false. This method
- * should be implemented as a low-cost operation compared to
- * unwrap so that callers can use this method to avoid
- * expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument
- * should succeed.
- *
- * @param interfaces
- * a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly
- * wraps an object that does.
- * @throws java.sql.SQLException
- * if an error occurs while determining whether this is a
- * wrapper for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
-
- boolean isInstance = iface.isInstance(this);
-
- if (isInstance) {
- return true;
- }
-
- String interfaceClassName = iface.getName();
-
- return (interfaceClassName.equals("com.mysql.jdbc.Statement")
- || interfaceClassName.equals("java.sql.Statement")
- || interfaceClassName.equals("java.sql.PreparedStatement")
- || interfaceClassName.equals("java.sql.Wrapper"));
- }
-
- /**
- * Returns an object that implements the given interface to allow access to
- * non-standard methods, or standard methods not exposed by the proxy. The
- * result may be either the object found to implement the interface or a
- * proxy for that object. If the receiver implements the interface then that
- * is the object. If the receiver is a wrapper and the wrapped object
- * implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped
- * object. If the receiver is not a wrapper and does not implement the
- * interface, then an SQLException is thrown.
- *
- * @param iface
- * A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the
- * actual implementing object.
- * @throws java.sql.SQLException
- * If no object found that implements the interface
- * @since 1.6
- */
- public synchronized T unwrap(java.lang.Class iface)
- throws java.sql.SQLException {
- try {
- if ("java.sql.Statement".equals(iface.getName())
- || "java.sql.PreparedStatement".equals(iface.getName())
- || "java.sql.Wrapper.class".equals(iface.getName())) {
- return iface.cast(this);
- }
-
- if (unwrappedInterfaces == null) {
- unwrappedInterfaces = new HashMap();
- }
-
- Object cachedUnwrapped = unwrappedInterfaces.get(iface);
-
- if (cachedUnwrapped == null) {
- if (cachedUnwrapped == null) {
- cachedUnwrapped = Proxy.newProxyInstance(
- this.wrappedStmt.getClass().getClassLoader(),
- new Class[] { iface },
- new ConnectionErrorFiringInvocationHandler(this.wrappedStmt));
- unwrappedInterfaces.put(iface, cachedUnwrapped);
- }
- unwrappedInterfaces.put(iface, cachedUnwrapped);
- }
-
- return iface.cast(cachedUnwrapped);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to "
- + iface.toString(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-
- public void setRowId(String parameterName, RowId x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setRowId(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setSQLXML(parameterName, xmlObject);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public SQLXML getSQLXML(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getSQLXML(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
-
- }
-
- public SQLXML getSQLXML(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getSQLXML(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- public RowId getRowId(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getRowId(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- public void setNClob(String parameterName, NClob value) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNClob(parameterName, value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(String parameterName, Reader reader) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNClob(parameterName, reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(String parameterName, Reader reader, long length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNClob(parameterName, reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNString(String parameterName, String value) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNString(parameterName, value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#getCharacterStream(int)
- */
- public Reader getCharacterStream(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getCharacterStream(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /**
- * @see java.sql.CallableStatement#getCharacterStream(java.lang.String)
- */
- public Reader getCharacterStream(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getCharacterStream(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /**
- * @see java.sql.CallableStatement#getNCharacterStream(int)
- */
- public Reader getNCharacterStream(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getNCharacterStream(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /**
- * @see java.sql.CallableStatement#getNCharacterStream(java.lang.String)
- */
- public Reader getNCharacterStream(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getNCharacterStream(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /**
- * @see java.sql.CallableStatement#getNClob(java.lang.String)
- */
- public NClob getNClob(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getNClob(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /**
- * @see java.sql.CallableStatement#getNString(java.lang.String)
- */
- public String getNString(String parameterName) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getNString(parameterName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- public void setAsciiStream(String parameterName, InputStream x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setAsciiStream(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setAsciiStream(String parameterName, InputStream x, long length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setAsciiStream(parameterName, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBinaryStream(String parameterName, InputStream x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBinaryStream(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBinaryStream(String parameterName, InputStream x, long length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBinaryStream(parameterName, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBlob(String parameterName, InputStream x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBlob(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBlob(String parameterName, InputStream x, long length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBlob(parameterName, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBlob(String parameterName, Blob x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setBlob(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setCharacterStream(parameterName, reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setCharacterStream(String parameterName, Reader reader, long length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setCharacterStream(parameterName, reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setClob(String parameterName, Clob x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setClob(parameterName, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setClob(String parameterName, Reader reader) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setClob(parameterName, reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setClob(String parameterName, Reader reader, long length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setClob(parameterName, reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNCharacterStream(String parameterName, Reader reader) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNCharacterStream(parameterName, reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNCharacterStream(String parameterName, Reader reader, long length) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((CallableStatement) this.wrappedStmt).setNCharacterStream(parameterName, reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public NClob getNClob(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getNClob(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- public String getNString(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getNString(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- public RowId getRowId(int parameterIndex) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((CallableStatement) this.wrappedStmt).getRowId(parameterIndex);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/JDBC4ConnectionWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/JDBC4ConnectionWrapper.java
deleted file mode 100644
index 0c699569d..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/JDBC4ConnectionWrapper.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.NClob;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.sql.Struct;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.SQLError;
-
-/**
- */
-public class JDBC4ConnectionWrapper extends ConnectionWrapper {
-
- /**
- * Construct a new LogicalHandle and set instance variables
- *
- * @param mysqlPooledConnection
- * reference to object that instantiated this object
- * @param mysqlConnection
- * physical connection to db
- *
- * @throws SQLException
- * if an error occurs.
- */
- public JDBC4ConnectionWrapper(MysqlPooledConnection mysqlPooledConnection,
- com.mysql.jdbc.Connection mysqlConnection, boolean forXa)
- throws SQLException {
- super(mysqlPooledConnection, mysqlConnection, forXa);
- }
-
- public void close() throws SQLException {
- try {
- super.close();
- } finally {
- this.unwrappedInterfaces = null;
- }
- }
-
- public SQLXML createSQLXML() throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).createSQLXML();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-
- public java.sql.Array createArrayOf(String typeName, Object[] elements)
- throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).createArrayOf(typeName,
- elements);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-
- public Struct createStruct(String typeName, Object[] attributes)
- throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).createStruct(typeName,
- attributes);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-
- public Properties getClientInfo() throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).getClientInfo();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-
- public String getClientInfo(String name) throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).getClientInfo(name);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-
- /**
- * Returns true if the connection has not been closed and is still valid.
- * The driver shall submit a query on the connection or use some other
- * mechanism that positively verifies the connection is still valid when
- * this method is called.
- *
- * The query submitted by the driver to validate the connection shall be
- * executed in the context of the current transaction.
- *
- * @param timeout -
- * The time in seconds to wait for the database operation used to
- * validate the connection to complete. If the timeout period
- * expires before the operation completes, this method returns
- * false. A value of 0 indicates a timeout is not applied to the
- * database operation.
- *
- * @return true if the connection is valid, false otherwise
- * @exception SQLException
- * if the value supplied for timeout is less
- * then 0
- * @since 1.6
- */
- public synchronized boolean isValid(int timeout) throws SQLException {
- try {
- return ((java.sql.Connection) this.mc).isValid(timeout);
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return false; // never reached, but compiler can't tell
- }
-
- public void setClientInfo(Properties properties)
- throws SQLClientInfoException {
- try {
- checkClosed();
-
- ((java.sql.Connection) this.mc).setClientInfo(properties);
- } catch (SQLException sqlException) {
- try {
- checkAndFireConnectionError(sqlException);
- } catch (SQLException sqlEx2) {
- SQLClientInfoException clientEx = new SQLClientInfoException();
- clientEx.initCause(sqlEx2);
-
- throw clientEx;
- }
- }
- }
-
- public void setClientInfo(String name, String value)
- throws SQLClientInfoException {
- try {
- checkClosed();
-
- ((java.sql.Connection) this.mc).setClientInfo(name, value);
- } catch (SQLException sqlException) {
- try {
- checkAndFireConnectionError(sqlException);
- } catch (SQLException sqlEx2) {
- SQLClientInfoException clientEx = new SQLClientInfoException();
- clientEx.initCause(sqlEx2);
-
- throw clientEx;
- }
- }
- }
-
- /**
- * Returns true if this either implements the interface argument or is
- * directly or indirectly a wrapper for an object that does. Returns false
- * otherwise. If this implements the interface then return true, else if
- * this is a wrapper then return the result of recursively calling
- * isWrapperFor on the wrapped object. If this does not
- * implement the interface and is not a wrapper, return false. This method
- * should be implemented as a low-cost operation compared to
- * unwrap so that callers can use this method to avoid
- * expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument
- * should succeed.
- *
- * @param interfaces
- * a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly
- * wraps an object that does.
- * @throws java.sql.SQLException
- * if an error occurs while determining whether this is a
- * wrapper for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
- checkClosed();
-
- boolean isInstance = iface.isInstance(this);
-
- if (isInstance) {
- return true;
- }
-
- return (iface.getName().equals("com.mysql.jdbc.Connection") ||
- iface.getName().equals("com.mysql.jdbc.ConnectionProperties"));
- }
-
- /**
- * Returns an object that implements the given interface to allow access to
- * non-standard methods, or standard methods not exposed by the proxy. The
- * result may be either the object found to implement the interface or a
- * proxy for that object. If the receiver implements the interface then that
- * is the object. If the receiver is a wrapper and the wrapped object
- * implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped
- * object. If the receiver is not a wrapper and does not implement the
- * interface, then an SQLException is thrown.
- *
- * @param iface
- * A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the
- * actual implementing object.
- * @throws java.sql.SQLException
- * If no object found that implements the interface
- * @since 1.6
- */
- public synchronized T unwrap(java.lang.Class iface)
- throws java.sql.SQLException {
- try {
- if ("java.sql.Connection".equals(iface.getName())
- || "java.sql.Wrapper.class".equals(iface.getName())) {
- return iface.cast(this);
- }
-
- if (unwrappedInterfaces == null) {
- unwrappedInterfaces = new HashMap();
- }
-
- Object cachedUnwrapped = unwrappedInterfaces.get(iface);
-
- if (cachedUnwrapped == null) {
- cachedUnwrapped = Proxy.newProxyInstance(this.mc.getClass()
- .getClassLoader(), new Class[] { iface },
- new ConnectionErrorFiringInvocationHandler(this.mc));
- unwrappedInterfaces.put(iface, cachedUnwrapped);
- }
-
- return iface.cast(cachedUnwrapped);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to "
- + iface.toString(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-
- /**
- * @see java.sql.Connection#createBlob()
- */
- public Blob createBlob() throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).createBlob();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-
- /**
- * @see java.sql.Connection#createClob()
- */
- public Clob createClob() throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).createClob();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-
- /**
- * @see java.sql.Connection#createNClob()
- */
- public NClob createNClob() throws SQLException {
- checkClosed();
-
- try {
- return ((java.sql.Connection) this.mc).createNClob();
- } catch (SQLException sqlException) {
- checkAndFireConnectionError(sqlException);
- }
-
- return null; // never reached, but compiler can't tell
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/JDBC4MysqlPooledConnection.java b/src/com/mysql/jdbc/jdbc2/optional/JDBC4MysqlPooledConnection.java
deleted file mode 100644
index 7c4fcc296..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/JDBC4MysqlPooledConnection.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.sql.SQLException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.sql.StatementEvent;
-import javax.sql.StatementEventListener;
-
-
-/**
- * This class is used to wrap and return a physical connection within a logical
- * handle. It also registers and notifies ConnectionEventListeners of any
- * ConnectionEvents
- *
- * @see javax.sql.PooledConnection
- * @see org.gjt.mm.mysql.jdbc2.optional.LogicalHandle
- * @author Todd Wolff
- */
-public class JDBC4MysqlPooledConnection extends MysqlPooledConnection {
-
- private Map statementEventListeners;
-
- public JDBC4MysqlPooledConnection(com.mysql.jdbc.Connection connection) {
- super(connection);
-
- this.statementEventListeners = new HashMap();
- }
-
- public synchronized void close() throws SQLException {
- super.close();
-
- if (this.statementEventListeners != null) {
- this.statementEventListeners.clear();
-
- this.statementEventListeners = null;
- }
- }
-
-
- /**
- * Registers a StatementEventListener with this PooledConnection object. Components that
- * wish to be notified when PreparedStatements created by the
- * connection are closed or are detected to be invalid may use this method
- * to register a StatementEventListener with this PooledConnection object.
- *
- * @param listener an component which implements the StatementEventListener
- * interface that is to be registered with this PooledConnection object
- *
- * @since 1.6
- */
- public void addStatementEventListener(StatementEventListener listener) {
- synchronized (this.statementEventListeners) {
- this.statementEventListeners.put(listener, listener);
- }
- }
-
- /**
- * Removes the specified StatementEventListener from the list of
- * components that will be notified when the driver detects that a
- * PreparedStatement has been closed or is invalid.
- *
- * @param listener the component which implements the
- * StatementEventListener interface that was previously
- * registered with this PooledConnection object
- *
- * @since 1.6
- */
- public void removeStatementEventListener(StatementEventListener listener) {
- synchronized (this.statementEventListeners) {
- this.statementEventListeners.remove(listener);
- }
- }
-
- void fireStatementEvent(StatementEvent event) throws SQLException {
- synchronized (this.statementEventListeners) {
- for (StatementEventListener listener : this.statementEventListeners.keySet()) {
- listener.statementClosed(event);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/JDBC4MysqlXAConnection.java b/src/com/mysql/jdbc/jdbc2/optional/JDBC4MysqlXAConnection.java
deleted file mode 100644
index b5dbcb19e..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/JDBC4MysqlXAConnection.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.sql.SQLException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.sql.StatementEvent;
-import javax.sql.StatementEventListener;
-
-import com.mysql.jdbc.ConnectionImpl;
-
-public class JDBC4MysqlXAConnection extends MysqlXAConnection {
-
- private Map statementEventListeners;
-
- public JDBC4MysqlXAConnection(ConnectionImpl connection, boolean logXaCommands) throws SQLException {
- super(connection, logXaCommands);
-
- this.statementEventListeners = new HashMap();
- }
-
- public synchronized void close() throws SQLException {
- super.close();
-
- if (this.statementEventListeners != null) {
- this.statementEventListeners.clear();
-
- this.statementEventListeners = null;
- }
- }
-
-
- /**
- * Registers a StatementEventListener with this PooledConnection object. Components that
- * wish to be notified when PreparedStatements created by the
- * connection are closed or are detected to be invalid may use this method
- * to register a StatementEventListener with this PooledConnection object.
- *
- * @param listener an component which implements the StatementEventListener
- * interface that is to be registered with this PooledConnection object
- *
- * @since 1.6
- */
- public void addStatementEventListener(StatementEventListener listener) {
- synchronized (this.statementEventListeners) {
- this.statementEventListeners.put(listener, listener);
- }
- }
-
- /**
- * Removes the specified StatementEventListener from the list of
- * components that will be notified when the driver detects that a
- * PreparedStatement has been closed or is invalid.
- *
- * @param listener the component which implements the
- * StatementEventListener interface that was previously
- * registered with this PooledConnection object
- *
- * @since 1.6
- */
- public void removeStatementEventListener(StatementEventListener listener) {
- synchronized (this.statementEventListeners) {
- this.statementEventListeners.remove(listener);
- }
- }
-
- void fireStatementEvent(StatementEvent event) throws SQLException {
- synchronized (this.statementEventListeners) {
- for (StatementEventListener listener : this.statementEventListeners.keySet()) {
- listener.statementClosed(event);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/JDBC4PreparedStatementWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/JDBC4PreparedStatementWrapper.java
deleted file mode 100644
index 825e991ea..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/JDBC4PreparedStatementWrapper.java
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.RowId;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Statement;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.sql.StatementEvent;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper;
-import com.mysql.jdbc.jdbc2.optional.MysqlPooledConnection;
-
-/**
- */
-public class JDBC4PreparedStatementWrapper extends PreparedStatementWrapper {
-
- public JDBC4PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn,
- PreparedStatement toWrap) {
- super(c, conn, toWrap);
- }
-
- public synchronized void close() throws SQLException {
- if (this.pooledConnection == null) {
- // no-op
- return;
- }
-
- MysqlPooledConnection con = this.pooledConnection; // we need this
- // later...
-
- try {
- super.close();
- } finally {
- try {
- StatementEvent e = new StatementEvent(con, this);
- // todo: pull this all up into base classes when we support *only* JDK6 or newer
- if (con instanceof JDBC4MysqlPooledConnection) {
- ((JDBC4MysqlPooledConnection) con).fireStatementEvent(e);
- } else if (con instanceof JDBC4MysqlXAConnection) {
- ((JDBC4MysqlXAConnection) con).fireStatementEvent(e);
- } else if (con instanceof JDBC4SuspendableXAConnection) {
- ((JDBC4SuspendableXAConnection) con).fireStatementEvent(e);
- }
- } finally {
- this.unwrappedInterfaces = null;
- }
- }
- }
-
- public boolean isClosed() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.isClosed();
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // never get here - compiler can't tell
- }
-
- public void setPoolable(boolean poolable) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setPoolable(poolable);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public boolean isPoolable() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.isPoolable();
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // never get here - compiler can't tell
- }
-
- public void setRowId(int parameterIndex, RowId x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setRowId(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(int parameterIndex, NClob value) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
- value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setSQLXML(int parameterIndex, SQLXML xmlObject)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setSQLXML(parameterIndex,
- xmlObject);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
-
- public void setNString(int parameterIndex,
- String value)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNString(parameterIndex,
- value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNCharacterStream(int parameterIndex,
- Reader value,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNCharacterStream(parameterIndex,
- value, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setClob(int parameterIndex,
- Reader reader,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
- reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBlob(int parameterIndex,
- InputStream inputStream,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
- inputStream, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(int parameterIndex,
- Reader reader,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
- reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setAsciiStream(int parameterIndex,
- InputStream x,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setAsciiStream(parameterIndex,
- x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBinaryStream(int parameterIndex,
- InputStream x,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBinaryStream(parameterIndex,
- x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setCharacterStream(int parameterIndex,
- Reader reader,
- long length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setCharacterStream(parameterIndex,
- reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setAsciiStream(int parameterIndex,
- InputStream x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setAsciiStream(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setBinaryStream(int parameterIndex,
- InputStream x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBinaryStream(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setCharacterStream(int parameterIndex,
- Reader reader)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setCharacterStream(parameterIndex,
- reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- }
-
- public void setNCharacterStream(int parameterIndex,
- Reader value)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNCharacterStream(parameterIndex,
- value);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- }
-
- public void setClob(int parameterIndex,
- Reader reader)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
- reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- }
-
- public void setBlob(int parameterIndex,
- InputStream inputStream)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
- inputStream);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public void setNClob(int parameterIndex,
- Reader reader)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
- reader);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /**
- * Returns true if this either implements the interface argument or is
- * directly or indirectly a wrapper for an object that does. Returns false
- * otherwise. If this implements the interface then return true, else if
- * this is a wrapper then return the result of recursively calling
- * isWrapperFor on the wrapped object. If this does not
- * implement the interface and is not a wrapper, return false. This method
- * should be implemented as a low-cost operation compared to
- * unwrap so that callers can use this method to avoid
- * expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument
- * should succeed.
- *
- * @param interfaces
- * a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly
- * wraps an object that does.
- * @throws java.sql.SQLException
- * if an error occurs while determining whether this is a
- * wrapper for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
-
- boolean isInstance = iface.isInstance(this);
-
- if (isInstance) {
- return true;
- }
-
- String interfaceClassName = iface.getName();
-
- return (interfaceClassName.equals("com.mysql.jdbc.Statement")
- || interfaceClassName.equals("java.sql.Statement")
- || interfaceClassName.equals("java.sql.PreparedStatement")
- || interfaceClassName.equals("java.sql.Wrapper"));
- }
-
- /**
- * Returns an object that implements the given interface to allow access to
- * non-standard methods, or standard methods not exposed by the proxy. The
- * result may be either the object found to implement the interface or a
- * proxy for that object. If the receiver implements the interface then that
- * is the object. If the receiver is a wrapper and the wrapped object
- * implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped
- * object. If the receiver is not a wrapper and does not implement the
- * interface, then an SQLException is thrown.
- *
- * @param iface
- * A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the
- * actual implementing object.
- * @throws java.sql.SQLException
- * If no object found that implements the interface
- * @since 1.6
- */
- public synchronized T unwrap(java.lang.Class iface)
- throws java.sql.SQLException {
- try {
- if ("java.sql.Statement".equals(iface.getName())
- || "java.sql.PreparedStatement".equals(iface.getName())
- || "java.sql.Wrapper.class".equals(iface.getName())) {
- return iface.cast(this);
- }
-
- if (unwrappedInterfaces == null) {
- unwrappedInterfaces = new HashMap();
- }
-
- Object cachedUnwrapped = unwrappedInterfaces.get(iface);
-
- if (cachedUnwrapped == null) {
- if (cachedUnwrapped == null) {
- cachedUnwrapped = Proxy.newProxyInstance(
- this.wrappedStmt.getClass().getClassLoader(),
- new Class[] { iface },
- new ConnectionErrorFiringInvocationHandler(this.wrappedStmt));
- unwrappedInterfaces.put(iface, cachedUnwrapped);
- }
- unwrappedInterfaces.put(iface, cachedUnwrapped);
- }
-
- return iface.cast(cachedUnwrapped);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to "
- + iface.toString(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/JDBC4StatementWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/JDBC4StatementWrapper.java
deleted file mode 100644
index c1d824400..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/JDBC4StatementWrapper.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.NClob;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.sql.Struct;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.jdbc2.optional.ConnectionWrapper;
-import com.mysql.jdbc.jdbc2.optional.MysqlPooledConnection;
-
-/**
- */
-public class JDBC4StatementWrapper extends StatementWrapper {
-
- public JDBC4StatementWrapper(ConnectionWrapper c,
- MysqlPooledConnection conn,
- Statement toWrap) {
- super(c, conn, toWrap);
- }
-
- public void close() throws SQLException {
- try {
- super.close();
- } finally {
- this.unwrappedInterfaces = null;
- }
- }
-
- public boolean isClosed() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.isClosed();
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // We never get here, compiler can't tell
- }
-
- public void setPoolable(boolean poolable) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setPoolable(poolable);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- public boolean isPoolable() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.isPoolable();
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // We never get here, compiler can't tell
- }
-
- /**
- * Returns true if this either implements the interface argument or is
- * directly or indirectly a wrapper for an object that does. Returns false
- * otherwise. If this implements the interface then return true, else if
- * this is a wrapper then return the result of recursively calling
- * isWrapperFor on the wrapped object. If this does not
- * implement the interface and is not a wrapper, return false. This method
- * should be implemented as a low-cost operation compared to
- * unwrap so that callers can use this method to avoid
- * expensive unwrap calls that may fail. If this method
- * returns true then calling unwrap with the same argument
- * should succeed.
- *
- * @param interfaces
- * a Class defining an interface.
- * @return true if this implements the interface or directly or indirectly
- * wraps an object that does.
- * @throws java.sql.SQLException
- * if an error occurs while determining whether this is a
- * wrapper for an object with the given interface.
- * @since 1.6
- */
- public boolean isWrapperFor(Class> iface) throws SQLException {
-
- boolean isInstance = iface.isInstance(this);
-
- if (isInstance) {
- return true;
- }
-
- String interfaceClassName = iface.getName();
-
- return (interfaceClassName.equals("com.mysql.jdbc.Statement")
- || interfaceClassName.equals("java.sql.Statement")
- || interfaceClassName.equals("java.sql.Wrapper"));
- }
-
- /**
- * Returns an object that implements the given interface to allow access to
- * non-standard methods, or standard methods not exposed by the proxy. The
- * result may be either the object found to implement the interface or a
- * proxy for that object. If the receiver implements the interface then that
- * is the object. If the receiver is a wrapper and the wrapped object
- * implements the interface then that is the object. Otherwise the object is
- * the result of calling unwrap recursively on the wrapped
- * object. If the receiver is not a wrapper and does not implement the
- * interface, then an SQLException is thrown.
- *
- * @param iface
- * A Class defining an interface that the result must implement.
- * @return an object that implements the interface. May be a proxy for the
- * actual implementing object.
- * @throws java.sql.SQLException
- * If no object found that implements the interface
- * @since 1.6
- */
- public synchronized T unwrap(java.lang.Class iface)
- throws java.sql.SQLException {
- try {
- if ("java.sql.Statement".equals(iface.getName())
- || "java.sql.Wrapper.class".equals(iface.getName())) {
- return iface.cast(this);
- }
-
- if (unwrappedInterfaces == null) {
- unwrappedInterfaces = new HashMap();
- }
-
- Object cachedUnwrapped = unwrappedInterfaces.get(iface);
-
- if (cachedUnwrapped == null) {
- cachedUnwrapped = Proxy.newProxyInstance(
- this.wrappedStmt.getClass().getClassLoader(),
- new Class[] { iface },
- new ConnectionErrorFiringInvocationHandler(this.wrappedStmt));
- unwrappedInterfaces.put(iface, cachedUnwrapped);
- }
-
- return iface.cast(cachedUnwrapped);
- } catch (ClassCastException cce) {
- throw SQLError.createSQLException("Unable to unwrap to "
- + iface.toString(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/JDBC4SuspendableXAConnection.java b/src/com/mysql/jdbc/jdbc2/optional/JDBC4SuspendableXAConnection.java
deleted file mode 100644
index bf54be0bd..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/JDBC4SuspendableXAConnection.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.sql.SQLException;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.sql.StatementEvent;
-import javax.sql.StatementEventListener;
-
-import com.mysql.jdbc.ConnectionImpl;
-
-public class JDBC4SuspendableXAConnection extends SuspendableXAConnection {
-
- private Map statementEventListeners;
-
- public JDBC4SuspendableXAConnection(ConnectionImpl connection) throws SQLException {
- super(connection);
-
- this.statementEventListeners = new HashMap();
- }
-
- public synchronized void close() throws SQLException {
- super.close();
-
- if (this.statementEventListeners != null) {
- this.statementEventListeners.clear();
-
- this.statementEventListeners = null;
- }
- }
-
-
- /**
- * Registers a StatementEventListener with this PooledConnection object. Components that
- * wish to be notified when PreparedStatements created by the
- * connection are closed or are detected to be invalid may use this method
- * to register a StatementEventListener with this PooledConnection object.
- *
- * @param listener an component which implements the StatementEventListener
- * interface that is to be registered with this PooledConnection object
- *
- * @since 1.6
- */
- public void addStatementEventListener(StatementEventListener listener) {
- synchronized (this.statementEventListeners) {
- this.statementEventListeners.put(listener, listener);
- }
- }
-
- /**
- * Removes the specified StatementEventListener from the list of
- * components that will be notified when the driver detects that a
- * PreparedStatement has been closed or is invalid.
- *
- * @param listener the component which implements the
- * StatementEventListener interface that was previously
- * registered with this PooledConnection object
- *
- * @since 1.6
- */
- public void removeStatementEventListener(StatementEventListener listener) {
- synchronized (this.statementEventListeners) {
- this.statementEventListeners.remove(listener);
- }
- }
-
- void fireStatementEvent(StatementEvent event) throws SQLException {
- synchronized (this.statementEventListeners) {
- for (StatementEventListener listener : this.statementEventListeners.keySet()) {
- listener.statementClosed(event);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlConnectionPoolDataSource.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlConnectionPoolDataSource.java
deleted file mode 100644
index ff6c61e53..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlConnectionPoolDataSource.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.ConnectionPoolDataSource;
-import javax.sql.PooledConnection;
-
-/**
- * This class is used to obtain a physical connection and instantiate and return
- * a MysqlPooledConnection. J2EE application servers map client calls to
- * dataSource.getConnection to this class based upon mapping set within
- * deployment descriptor. This class extends MysqlDataSource.
- *
- * @see javax.sql.PooledConnection
- * @see javax.sql.ConnectionPoolDataSource
- * @see org.gjt.mm.mysql.MysqlDataSource
- * @author Todd Wolff
- */
-public class MysqlConnectionPoolDataSource extends MysqlDataSource implements
- ConnectionPoolDataSource {
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * Returns a pooled connection.
- *
- * @exception SQLException
- * if an error occurs
- * @return a PooledConnection
- */
- public synchronized PooledConnection getPooledConnection()
- throws SQLException {
- Connection connection = getConnection();
- MysqlPooledConnection mysqlPooledConnection = MysqlPooledConnection.getInstance(
- (com.mysql.jdbc.Connection)connection);
-
- return mysqlPooledConnection;
- }
-
- /**
- * This method is invoked by the container. Obtains physical connection
- * using mySql.Driver class and returns a mysqlPooledConnection object.
- *
- * @param s
- * user name
- * @param s1
- * password
- * @exception SQLException
- * if an error occurs
- * @return a PooledConnection
- */
- public synchronized PooledConnection getPooledConnection(String s, String s1)
- throws SQLException {
- Connection connection = getConnection(s, s1);
- MysqlPooledConnection mysqlPooledConnection = MysqlPooledConnection.getInstance(
- (com.mysql.jdbc.Connection)connection);
-
- return mysqlPooledConnection;
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java
deleted file mode 100644
index 2c937ddc0..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.Properties;
-
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
-import javax.sql.DataSource;
-
-import com.mysql.jdbc.ConnectionPropertiesImpl;
-import com.mysql.jdbc.NonRegisteringDriver;
-
-/**
- * A JNDI DataSource for a Mysql JDBC connection
- *
- * @author Mark Matthews
- */
-public class MysqlDataSource extends ConnectionPropertiesImpl implements
- DataSource, Referenceable, Serializable {
- /** The driver to create connections with */
- protected static NonRegisteringDriver mysqlDriver = null;
-
- static {
- try {
- mysqlDriver = new NonRegisteringDriver();
- } catch (Exception E) {
- throw new RuntimeException(
- "Can not load Driver class com.mysql.jdbc.Driver");
- }
- }
-
- /** Log stream */
- protected PrintWriter logWriter = null;
-
- /** Database Name */
- protected String databaseName = null;
-
- /** Character Encoding */
- protected String encoding = null;
-
- /** Hostname */
- protected String hostName = null;
-
- /** Password */
- protected String password = null;
-
- /** The profileSql property */
- protected String profileSql = "false";
-
- /** The JDBC URL */
- protected String url = null;
-
- /** User name */
- protected String user = null;
-
- /** Should we construct the URL, or has it been set explicitly */
- protected boolean explicitUrl = false;
-
- /** Port number */
- protected int port = 3306;
-
- /**
- * Default no-arg constructor for Serialization
- */
- public MysqlDataSource() {
- }
-
- /**
- * Creates a new connection using the already configured username and
- * password.
- *
- * @return a connection to the database
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.sql.Connection getConnection() throws SQLException {
- return getConnection(this.user, this.password);
- }
-
- /**
- * Creates a new connection with the given username and password
- *
- * @param userID
- * the user id to connect with
- * @param password
- * the password to connect with
- *
- * @return a connection to the database
- *
- * @throws SQLException
- * if an error occurs
- */
- public java.sql.Connection getConnection(String userID, String pass)
- throws SQLException {
- Properties props = new Properties();
-
- if (userID != null) {
- props.setProperty(NonRegisteringDriver.USER_PROPERTY_KEY, userID);
- }
-
- if (pass != null) {
- props.setProperty(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, pass);
- }
-
- exposeAsProperties(props);
-
- return getConnection(props);
- }
-
- /**
- * Sets the database name.
- *
- * @param dbName
- * the name of the database
- */
- public void setDatabaseName(String dbName) {
- this.databaseName = dbName;
- }
-
- /**
- * Gets the name of the database
- *
- * @return the name of the database for this data source
- */
- public String getDatabaseName() {
- return (this.databaseName != null) ? this.databaseName : "";
- }
-
- /**
- * Sets the log writer for this data source.
- *
- * @see javax.sql.DataSource#setLogWriter(PrintWriter)
- */
- public void setLogWriter(PrintWriter output) throws SQLException {
- this.logWriter = output;
- }
-
- /**
- * Returns the log writer for this data source
- *
- * @return the log writer for this data source
- */
- public java.io.PrintWriter getLogWriter() {
- return this.logWriter;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param seconds
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public void setLoginTimeout(int seconds) throws SQLException {
- }
-
- /**
- * Returns the login timeout
- *
- * @return the login timeout
- */
- public int getLoginTimeout() {
- return 0;
- }
-
- /**
- * Sets the password
- *
- * @param pass
- * the password
- */
- public void setPassword(String pass) {
- this.password = pass;
- }
-
- /**
- * Sets the database port.
- *
- * @param p
- * the port
- */
- public void setPort(int p) {
- this.port = p;
- }
-
- /**
- * Returns the port number
- *
- * @return the port number
- */
- public int getPort() {
- return this.port;
- }
-
- /**
- * Sets the port number
- *
- * @param p
- * the port
- *
- * @see #setPort
- */
- public void setPortNumber(int p) {
- setPort(p);
- }
-
- /**
- * Returns the port number
- *
- * @return the port number
- */
- public int getPortNumber() {
- return getPort();
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param ref
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- */
- public void setPropertiesViaRef(Reference ref) throws SQLException {
- super.initializeFromRef(ref);
- }
-
- /**
- * Required method to support this class as a Referenceable.
- *
- * @return a Reference to this data source
- *
- * @throws NamingException
- * if a JNDI error occurs
- */
- public Reference getReference() throws NamingException {
- String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
- Reference ref = new Reference(getClass().getName(), factoryName, null);
- ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY,
- getUser()));
- ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY,
- this.password));
- ref.add(new StringRefAddr("serverName", getServerName()));
- ref.add(new StringRefAddr("port", "" + getPort()));
- ref.add(new StringRefAddr("databaseName", getDatabaseName()));
- ref.add(new StringRefAddr("url", getUrl()));
- ref.add(new StringRefAddr("explicitUrl", String
- .valueOf(this.explicitUrl)));
-
- //
- // Now store all of the 'non-standard' properties...
- //
- try {
- storeToRef(ref);
- } catch (SQLException sqlEx) {
- throw new NamingException(sqlEx.getMessage());
- }
-
- return ref;
- }
-
- /**
- * Sets the server name.
- *
- * @param serverName
- * the server name
- */
- public void setServerName(String serverName) {
- this.hostName = serverName;
- }
-
- /**
- * Returns the name of the database server
- *
- * @return the name of the database server
- */
- public String getServerName() {
- return (this.hostName != null) ? this.hostName : "";
- }
-
- //
- // I've seen application servers use both formats
- // URL or url (doh)
- //
-
- /**
- * Sets the URL for this connection
- *
- * @param url
- * the URL for this connection
- */
- public void setURL(String url) {
- setUrl(url);
- }
-
- /**
- * Returns the URL for this connection
- *
- * @return the URL for this connection
- */
- public String getURL() {
- return getUrl();
- }
-
- /**
- * This method is used by the app server to set the url string specified
- * within the datasource deployment descriptor. It is discovered using
- * introspection and matches if property name in descriptor is "url".
- *
- * @param url
- * url to be used within driver.connect
- */
- public void setUrl(String url) {
- this.url = url;
- this.explicitUrl = true;
- }
-
- /**
- * Returns the JDBC URL that will be used to create the database connection.
- *
- * @return the URL for this connection
- */
- public String getUrl() {
- if (!this.explicitUrl) {
- String builtUrl = "jdbc:mysql://";
- builtUrl = builtUrl + getServerName() + ":" + getPort() + "/"
- + getDatabaseName();
-
- return builtUrl;
- }
-
- return this.url;
- }
-
- /**
- * Sets the user ID.
- *
- * @param userID
- * the User ID
- */
- public void setUser(String userID) {
- this.user = userID;
- }
-
- /**
- * Returns the configured user for this connection
- *
- * @return the user for this connection
- */
- public String getUser() {
- return this.user;
- }
-
- /**
- * Creates a connection using the specified properties.
- *
- * @param props
- * the properties to connect with
- *
- * @return a connection to the database
- *
- * @throws SQLException
- * if an error occurs
- */
- protected java.sql.Connection getConnection(Properties props)
- throws SQLException {
- String jdbcUrlToUse = null;
-
- if (!this.explicitUrl) {
- StringBuffer jdbcUrl = new StringBuffer("jdbc:mysql://");
-
- if (this.hostName != null) {
- jdbcUrl.append(this.hostName);
- }
-
- jdbcUrl.append(":");
- jdbcUrl.append(this.port);
- jdbcUrl.append("/");
-
- if (this.databaseName != null) {
- jdbcUrl.append(this.databaseName);
- }
-
- jdbcUrlToUse = jdbcUrl.toString();
- } else {
- jdbcUrlToUse = this.url;
- }
-
- //
- // URL should take precedence over properties
- //
-
- Properties urlProps = mysqlDriver.parseURL(jdbcUrlToUse, null);
- urlProps.remove(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
- urlProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
- urlProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);
-
- Iterator keys = urlProps.keySet().iterator();
-
- while (keys.hasNext()) {
- String key = (String)keys.next();
-
- props.setProperty(key, urlProps.getProperty(key));
- }
-
- return mysqlDriver.connect(jdbcUrlToUse, props);
- }
-//
-// public boolean isWrapperFor(Class> iface) throws SQLException {
-// throw SQLError.notImplemented();
-// }
-//
-// public T unwrap(Class iface) throws SQLException {
-// throw SQLError.notImplemented();
-// }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSourceFactory.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSourceFactory.java
deleted file mode 100644
index 66fb338e4..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlDataSourceFactory.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-
-import com.mysql.jdbc.NonRegisteringDriver;
-
-/**
- * Factory class for MysqlDataSource objects
- *
- * @author Mark Matthews
- */
-public class MysqlDataSourceFactory implements ObjectFactory {
- /**
- * The class name for a standard MySQL DataSource.
- */
- protected final static String DATA_SOURCE_CLASS_NAME = "com.mysql.jdbc.jdbc2.optional.MysqlDataSource";
-
- /**
- * The class name for a poolable MySQL DataSource.
- */
- protected final static String POOL_DATA_SOURCE_CLASS_NAME = "com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource";
-
- /**
- * The class name for a MysqlXADataSource
- */
-
- protected final static String XA_DATA_SOURCE_CLASS_NAME = "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource";
-
- /**
- * DOCUMENT ME!
- *
- * @param refObj
- * DOCUMENT ME!
- * @param nm
- * DOCUMENT ME!
- * @param ctx
- * DOCUMENT ME!
- * @param env
- * DOCUMENT ME!
- * @return DOCUMENT ME!
- * @throws Exception
- * DOCUMENT ME!
- */
- public Object getObjectInstance(Object refObj, Name nm, Context ctx,
- Hashtable env) throws Exception {
- Reference ref = (Reference) refObj;
- String className = ref.getClassName();
-
- if ((className != null)
- && (className.equals(DATA_SOURCE_CLASS_NAME) || className
- .equals(POOL_DATA_SOURCE_CLASS_NAME) ||
- className.equals(XA_DATA_SOURCE_CLASS_NAME))) {
- MysqlDataSource dataSource = null;
-
- try {
- dataSource = (MysqlDataSource) Class.forName(className)
- .newInstance();
- } catch (Exception ex) {
- throw new RuntimeException("Unable to create DataSource of "
- + "class '" + className + "', reason: " + ex.toString());
- }
-
- int portNumber = 3306;
-
- String portNumberAsString = nullSafeRefAddrStringGet("port", ref);
-
- if (portNumberAsString != null) {
- portNumber = Integer.parseInt(portNumberAsString);
- }
-
- dataSource.setPort(portNumber);
-
- String user = nullSafeRefAddrStringGet(NonRegisteringDriver.USER_PROPERTY_KEY, ref);
-
- if (user != null) {
- dataSource.setUser(user);
- }
-
- String password = nullSafeRefAddrStringGet(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, ref);
-
- if (password != null) {
- dataSource.setPassword(password);
- }
-
- String serverName = nullSafeRefAddrStringGet("serverName", ref);
-
- if (serverName != null) {
- dataSource.setServerName(serverName);
- }
-
- String databaseName = nullSafeRefAddrStringGet("databaseName", ref);
-
- if (databaseName != null) {
- dataSource.setDatabaseName(databaseName);
- }
-
- String explicitUrlAsString = nullSafeRefAddrStringGet("explicitUrl", ref);
-
- if (explicitUrlAsString != null) {
- if (Boolean.valueOf(explicitUrlAsString).booleanValue()) {
- dataSource.setUrl(nullSafeRefAddrStringGet("url", ref));
- }
- }
-
- dataSource.setPropertiesViaRef(ref);
-
- return dataSource;
- }
-
- // We can't create an instance of the reference
- return null;
- }
-
- private String nullSafeRefAddrStringGet(String referenceName, Reference ref) {
- RefAddr refAddr = ref.get(referenceName);
-
- String asString = refAddr != null ? (String)refAddr.getContent() : null;
-
- return asString;
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlPooledConnection.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlPooledConnection.java
deleted file mode 100644
index bbaf363d2..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlPooledConnection.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.lang.reflect.Constructor;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.sql.ConnectionEvent;
-import javax.sql.ConnectionEventListener;
-import javax.sql.PooledConnection;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.ExceptionInterceptor;
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.Util;
-
-/**
- * This class is used to wrap and return a physical connection within a logical
- * handle. It also registers and notifies ConnectionEventListeners of any
- * ConnectionEvents
- *
- * @see javax.sql.PooledConnection
- * @see org.gjt.mm.mysql.jdbc2.optional.LogicalHandle
- * @author Todd Wolff
- */
-public class MysqlPooledConnection implements PooledConnection {
-
- private static final Constructor JDBC_4_POOLED_CONNECTION_WRAPPER_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_POOLED_CONNECTION_WRAPPER_CTOR = Class.forName(
- "com.mysql.jdbc.jdbc2.optional.JDBC4MysqlPooledConnection")
- .getConstructor(
- new Class[] { com.mysql.jdbc.Connection.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_POOLED_CONNECTION_WRAPPER_CTOR = null;
- }
- }
-
- protected static MysqlPooledConnection getInstance(com.mysql.jdbc.Connection connection) throws SQLException {
- if (!Util.isJdbc4()) {
- return new MysqlPooledConnection(connection);
- }
-
- return (MysqlPooledConnection) Util.handleNewInstance(
- JDBC_4_POOLED_CONNECTION_WRAPPER_CTOR, new Object[] {
- connection}, connection.getExceptionInterceptor());
- }
-
- /**
- * The flag for an exception being thrown.
- */
- public static final int CONNECTION_ERROR_EVENT = 1;
-
- /**
- * The flag for a connection being closed.
- */
- public static final int CONNECTION_CLOSED_EVENT = 2;
-
- // ~ Instance/static variables .............................................
-
- private Map connectionEventListeners;
-
- private Connection logicalHandle;
-
- private com.mysql.jdbc.Connection physicalConn;
-
- private ExceptionInterceptor exceptionInterceptor;
-
- // ~ Constructors ..........................................................
-
- /**
- * Construct a new MysqlPooledConnection and set instance variables
- *
- * @param connection
- * physical connection to db
- */
- public MysqlPooledConnection(com.mysql.jdbc.Connection connection) {
- this.logicalHandle = null;
- this.physicalConn = connection;
- this.connectionEventListeners = new HashMap();
- this.exceptionInterceptor = this.physicalConn.getExceptionInterceptor();
- }
-
- /**
- * Adds ConnectionEventListeners to a hash table to be used for notification
- * of ConnectionEvents
- *
- * @param connectioneventlistener
- * listener to be notified with ConnectionEvents
- */
- public synchronized void addConnectionEventListener(
- ConnectionEventListener connectioneventlistener) {
-
- if (this.connectionEventListeners != null) {
- this.connectionEventListeners.put(connectioneventlistener,
- connectioneventlistener);
- }
- }
-
- /**
- * Removes ConnectionEventListeners from hash table used for notification of
- * ConnectionEvents
- *
- * @param connectioneventlistener
- * listener to be removed
- */
- public synchronized void removeConnectionEventListener(
- ConnectionEventListener connectioneventlistener) {
-
- if (this.connectionEventListeners != null) {
- this.connectionEventListeners.remove(connectioneventlistener);
- }
- }
-
- /**
- * Invoked by the container. Return a logicalHandle object that wraps a
- * physical connection.
- *
- * @see java.sql.DataSource#getConnection()
- */
- public synchronized Connection getConnection() throws SQLException {
- return getConnection(true, false);
-
- }
-
- protected synchronized Connection getConnection(boolean resetServerState,
- boolean forXa)
- throws SQLException {
- if (this.physicalConn == null) {
-
- SQLException sqlException = SQLError.createSQLException(
- "Physical Connection doesn't exist", this.exceptionInterceptor);
- callConnectionEventListeners(CONNECTION_ERROR_EVENT, sqlException);
-
- throw sqlException;
- }
-
- try {
-
- if (this.logicalHandle != null) {
- ((ConnectionWrapper) this.logicalHandle).close(false);
- }
-
- if (resetServerState) {
- this.physicalConn.resetServerState();
- }
-
- this.logicalHandle = ConnectionWrapper.getInstance(this,
- this.physicalConn,
- forXa);
- } catch (SQLException sqlException) {
- callConnectionEventListeners(CONNECTION_ERROR_EVENT, sqlException);
-
- throw sqlException;
- }
-
- return this.logicalHandle;
- }
-
- /**
- * Invoked by the container (not the client), and should close the physical
- * connection. This will be called if the pool is destroyed or the
- * connectionEventListener receives a connectionErrorOccurred event.
- *
- * @see java.sql.DataSource#close()
- */
- public synchronized void close() throws SQLException {
- if (this.physicalConn != null) {
- this.physicalConn.close();
-
- this.physicalConn = null;
- }
-
- if (this.connectionEventListeners != null) {
- this.connectionEventListeners.clear();
-
- this.connectionEventListeners = null;
- }
- }
-
- /**
- * Notifies all registered ConnectionEventListeners of ConnectionEvents.
- * Instantiates a new ConnectionEvent which wraps sqlException and invokes
- * either connectionClose or connectionErrorOccurred on listener as
- * appropriate.
- *
- * @param eventType
- * value indicating whether connectionClosed or
- * connectionErrorOccurred called
- * @param sqlException
- * the exception being thrown
- */
- protected synchronized void callConnectionEventListeners(int eventType,
- SQLException sqlException) {
-
- if (this.connectionEventListeners == null) {
-
- return;
- }
-
- Iterator iterator = this.connectionEventListeners.entrySet().iterator();
-
- ConnectionEvent connectionevent = new ConnectionEvent(this,
- sqlException);
-
- while (iterator.hasNext()) {
-
- ConnectionEventListener connectioneventlistener = (ConnectionEventListener) ((Map.Entry)iterator
- .next()).getValue();
-
- if (eventType == CONNECTION_CLOSED_EVENT) {
- connectioneventlistener.connectionClosed(connectionevent);
- } else if (eventType == CONNECTION_ERROR_EVENT) {
- connectioneventlistener
- .connectionErrorOccurred(connectionevent);
- }
- }
- }
-
- protected ExceptionInterceptor getExceptionInterceptor() {
- return this.exceptionInterceptor;
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlXAConnection.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlXAConnection.java
deleted file mode 100644
index ef32c28c5..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlXAConnection.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.lang.reflect.Constructor;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.sql.XAConnection;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.Constants;
-import com.mysql.jdbc.Util;
-import com.mysql.jdbc.log.Log;
-
-/*
- * XA BEGIN [JOIN | RESUME] XA START TRANSACTION [JOIN | RESUME] XA
- * COMMIT [ONE PHASE] XA END [SUSPEND [FOR MIGRATE]] XA PREPARE
- * XA RECOVER XA ROLLBACK
- */
-
-/**
- * An object that provides support for distributed transactions. An
- * XAConnection object may be enlisted in a distributed
- * transaction by means of an XAResource object. A transaction
- * manager, usually part of a middle tier server, manages an
- * XAConnection object through the XAResource
- * object.
- *
- * An application programmer does not use this interface directly; rather, it is
- * used by a transaction manager working in the middle tier server.
- *
- * @since 1.4
- */
-public class MysqlXAConnection extends MysqlPooledConnection implements
- XAConnection, XAResource {
-
- private com.mysql.jdbc.ConnectionImpl underlyingConnection;
-
- private final static Map MYSQL_ERROR_CODES_TO_XA_ERROR_CODES;
-
- private Log log;
-
- protected boolean logXaCommands;
-
- static {
- HashMap temp = new HashMap();
-
- temp.put(Constants.integerValueOf(1397), Constants.integerValueOf(XAException.XAER_NOTA));
- temp.put(Constants.integerValueOf(1398), Constants.integerValueOf(XAException.XAER_INVAL));
- temp.put(Constants.integerValueOf(1399), Constants.integerValueOf(XAException.XAER_RMFAIL));
- temp.put(Constants.integerValueOf(1400), Constants.integerValueOf(XAException.XAER_OUTSIDE));
- temp.put(Constants.integerValueOf(1401), Constants.integerValueOf(XAException.XAER_RMERR));
- temp.put(Constants.integerValueOf(1402), Constants.integerValueOf(XAException.XA_RBROLLBACK));
-
- MYSQL_ERROR_CODES_TO_XA_ERROR_CODES = Collections.unmodifiableMap(temp);
- }
-
- private static final Constructor JDBC_4_XA_CONNECTION_WRAPPER_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_XA_CONNECTION_WRAPPER_CTOR = Class.forName(
- "com.mysql.jdbc.jdbc2.optional.JDBC4MysqlXAConnection")
- .getConstructor(
- new Class[] { ConnectionImpl.class, Boolean.TYPE });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_XA_CONNECTION_WRAPPER_CTOR = null;
- }
- }
-
- protected static MysqlXAConnection getInstance(ConnectionImpl mysqlConnection,
- boolean logXaCommands) throws SQLException {
- if (!Util.isJdbc4()) {
- return new MysqlXAConnection(mysqlConnection, logXaCommands);
- }
-
- return (MysqlXAConnection) Util.handleNewInstance(
- JDBC_4_XA_CONNECTION_WRAPPER_CTOR, new Object[] {
- mysqlConnection,
- Boolean.valueOf(logXaCommands) }, mysqlConnection.getExceptionInterceptor());
- }
-
- /**
- * @param connection
- */
- public MysqlXAConnection(ConnectionImpl connection, boolean logXaCommands)
- throws SQLException {
- super(connection);
- this.underlyingConnection = connection;
- this.log = connection.getLog();
- this.logXaCommands = logXaCommands;
- }
-
- /**
- * Retrieves an XAResource object that the transaction
- * manager will use to manage this XAConnection object's
- * participation in a distributed transaction.
- *
- * @return the XAResource object
- * @exception SQLException
- * if a database access error occurs
- */
- public XAResource getXAResource() throws SQLException {
- return this;
- }
-
- /**
- * Obtains the current transaction timeout value set for this XAResource
- * instance. If XAResource.setTransactionTimeout was not used prior to
- * invoking this method, the return value is the default timeout set for the
- * resource manager; otherwise, the value used in the previous
- * setTransactionTimeout call is returned.
- *
- * @return the transaction timeout value in seconds.
- *
- * @throws XAException
- * An error has occurred. Possible exception values are
- * XAER_RMERR and XAER_RMFAIL.
- */
- public int getTransactionTimeout() throws XAException {
- return 0;
- }
-
- /**
- * Sets the current transaction timeout value for this XAResource instance.
- * Once set, this timeout value is effective until setTransactionTimeout is
- * invoked again with a different value.
- *
- * To reset the timeout value to the default value used by the resource
- * manager, set the value to zero. If the timeout operation is performed
- * successfully, the method returns true; otherwise false.
- *
- * If a resource manager does not support explicitly setting the transaction
- * timeout value, this method returns false.
- *
- * @parameter seconds The transaction timeout value in seconds.
- *
- * @return true if the transaction timeout value is set successfully;
- * otherwise false.
- *
- * @throws XAException
- * An error has occurred. Possible exception values are
- * XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
- */
- public boolean setTransactionTimeout(int arg0) throws XAException {
- return false;
- }
-
- /**
- * This method is called to determine if the resource manager instance
- * represented by the target object is the same as the resouce manager
- * instance represented by the parameter xares.
- *
- * @parameter xares An XAResource object whose resource manager instance is
- * to be compared with the resource manager instance of the
- * target object.
- *
- * @return true if it's the same RM instance; otherwise false.
- *
- * @throws XAException
- * An error has occurred. Possible exception values are
- * XAER_RMERR and XAER_RMFAIL.
- */
- public boolean isSameRM(XAResource xares) throws XAException {
-
- if (xares instanceof MysqlXAConnection) {
- return this.underlyingConnection
- .isSameResource(((MysqlXAConnection) xares).underlyingConnection);
- }
-
- return false;
- }
-
- /**
- * This method is called to obtain a list of prepared transaction branches
- * from a resource manager. The transaction manager calls this method during
- * recovery to obtain the list of transaction branches that are currently in
- * prepared or heuristically completed states.
- *
- * The flag parameter indicates where the recover scan should start or end,
- * or start and end. This method may be invoked one or more times during a
- * recovery scan. The resource manager maintains a cursor which marks the
- * current position of the prepared or heuristically completed transaction list.
- * Each invocation of the recover method moves the cursor passed the set of Xids
- * that are returned.
- *
- * Two consecutive invocation of this method that starts from the
- * beginning of the list must return the same list of transaction branches
- * unless one of the following takes place:
- *
- * - the transaction manager invokes the commit, forget, prepare, or rollback method for that resource
- * manager, between the two consecutive invocation of the recovery scan.
- *
- * - the resource manager heuristically completes some transaction branches
- * between the two invocation of the recovery scan.
- *
- * @param flag
- * One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be
- * used when no other flags are set in the parameter.
- *
- * @returns The resource manager returns zero or more XIDs of the
- * transaction branches that are currently in a prepared or
- * heuristically completed state. If an error occurs during the
- * operation, the resource manager should throw the appropriate
- * XAException.
- *
- * @throws XAException
- * An error has occurred. Possible values are XAER_RMERR,
- * XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
- */
- public Xid[] recover(int flag) throws XAException {
- return recover(this.underlyingConnection, flag);
- }
-
- protected static Xid[] recover(Connection c, int flag) throws XAException {
- /*
- The XA RECOVER statement returns information for those XA transactions on the MySQL server that are in the PREPARED state. (See Section 13.4.7.2, �XA Transaction States�.) The output includes a row for each such XA transaction on the server, regardless of which client started it.
-
- XA RECOVER output rows look like this (for an example xid value consisting of the parts 'abc', 'def', and 7):
-
- mysql> XA RECOVER;
- +----------+--------------+--------------+--------+
- | formatID | gtrid_length | bqual_length | data |
- +----------+--------------+--------------+--------+
- | 7 | 3 | 3 | abcdef |
- +----------+--------------+--------------+--------+
-
- The output columns have the following meanings:
-
- formatID is the formatID part of the transaction xid
- gtrid_length is the length in bytes of the gtrid part of the xid
- bqual_length is the length in bytes of the bqual part of the xid
- data is the concatenation of the gtrid and bqual parts of the xid
- */
-
- boolean startRscan = ((flag & TMSTARTRSCAN) > 0);
- boolean endRscan = ((flag & TMENDRSCAN) > 0);
-
- if (!startRscan && !endRscan && flag != TMNOFLAGS) {
- throw new MysqlXAException(XAException.XAER_INVAL,
- "Invalid flag, must use TMNOFLAGS, or any combination of TMSTARTRSCAN and TMENDRSCAN",
- null);
- }
-
- //
- // We return all recovered XIDs at once, so if not
- // TMSTARTRSCAN, return no new XIDs
- //
- // We don't attempt to maintain state to check for TMNOFLAGS
- // "outside" of a scan
- //
-
- if (!startRscan) {
- return new Xid[0];
- }
-
- ResultSet rs = null;
- Statement stmt = null;
-
- List recoveredXidList = new ArrayList();
-
- try {
- // TODO: Cache this for lifetime of XAConnection
- stmt = c.createStatement();
-
- rs = stmt.executeQuery("XA RECOVER");
-
- while (rs.next()) {
- final int formatId = rs.getInt(1);
- int gtridLength = rs.getInt(2);
- int bqualLength = rs.getInt(3);
- byte[] gtridAndBqual = rs.getBytes(4);
-
- final byte[] gtrid = new byte[gtridLength];
- final byte[] bqual = new byte[bqualLength];
-
- if (gtridAndBqual.length != (gtridLength + bqualLength)) {
- throw new MysqlXAException(XAException.XA_RBPROTO,
- "Error while recovering XIDs from RM. GTRID and BQUAL are wrong sizes",
- null);
- }
-
- System.arraycopy(gtridAndBqual, 0, gtrid, 0,
- gtridLength);
- System.arraycopy(gtridAndBqual, gtridLength, bqual, 0,
- bqualLength);
-
- recoveredXidList.add(new MysqlXid(gtrid, bqual,
- formatId));
- }
- } catch (SQLException sqlEx) {
- throw mapXAExceptionFromSQLException(sqlEx);
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException sqlEx) {
- throw mapXAExceptionFromSQLException(sqlEx);
- }
- }
-
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException sqlEx) {
- throw mapXAExceptionFromSQLException(sqlEx);
- }
- }
- }
-
- int numXids = recoveredXidList.size();
-
- Xid[] asXids = new Xid[numXids];
- Object[] asObjects = recoveredXidList.toArray();
-
- for (int i = 0; i < numXids; i++) {
- asXids[i] = (Xid) asObjects[i];
- }
-
- return asXids;
- }
-
- /**
- * Asks the resource manager to prepare for a transaction commit of the
- * transaction specified in xid.
- *
- * @parameter xid A global transaction identifier.
- *
- * @returns A value indicating the resource manager's vote on the outcome of
- * the transaction.
- *
- * The possible values are: XA_RDONLY or XA_OK. If the resource manager
- * wants to roll back the transaction, it should do so by raising an
- * appropriate XAException in the prepare method.
- *
- * @throws XAException
- * An error has occurred. Possible exception values are: XA_RB*,
- * XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or
- * XAER_PROTO.
- */
- public int prepare(Xid xid) throws XAException {
- StringBuffer commandBuf = new StringBuffer();
- commandBuf.append("XA PREPARE ");
- commandBuf.append(xidToString(xid));
-
- dispatchCommand(commandBuf.toString());
-
- return XA_OK; // TODO: Check for read-only
- }
-
- /**
- * Tells the resource manager to forget about a heuristically completed
- * transaction branch.
- *
- * @parameter xid A global transaction identifier.
- *
- * @throws XAException
- * An error has occurred. Possible exception values are
- * XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or
- * XAER_PROTO.
- */
- public void forget(Xid xid) throws XAException {
- // mysql doesn't support this
- }
-
- /**
- * Informs the resource manager to roll back work done on behalf of a
- * transaction branch.
- *
- * @parameter xid A global transaction identifier.
- *
- * @throws XAException
- * An error has occurred. Possible XAExceptions are XA_HEURHAZ,
- * XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR, XAER_RMFAIL,
- * XAER_NOTA, XAER_INVAL, or XAER_PROTO.
- *
- * If the transaction branch is already marked rollback-only the resource
- * manager may throw one of the XA_RB* exceptions.
- *
- * Upon return, the resource manager has rolled back the branch's work and
- * has released all held resources.
- */
- public void rollback(Xid xid) throws XAException {
- StringBuffer commandBuf = new StringBuffer();
- commandBuf.append("XA ROLLBACK ");
- commandBuf.append(xidToString(xid));
-
- try {
- dispatchCommand(commandBuf.toString());
- } finally {
- this.underlyingConnection.setInGlobalTx(false);
- }
- }
-
- /**
- * Ends the work performed on behalf of a transaction branch.
- *
- * The resource manager disassociates the XA resource from the transaction
- * branch specified and lets the transaction complete.
- *
- * If TMSUSPEND is specified in the flags, the transaction branch is
- * temporarily suspended in an incomplete state. The transaction context is
- * in a suspended state and must be resumed via the start method with
- * TMRESUME specified.
- *
- * If TMFAIL is specified, the portion of work has failed. The resource
- * manager may mark the transaction as rollback-only
- *
- * If TMSUCCESS is specified, the portion of work has completed
- * successfully.
- *
- * @parameter xid A global transaction identifier that is the same as the
- * identifier used previously in the start method.
- *
- * @parameter flags One of TMSUCCESS, TMFAIL, or TMSUSPEND.
- *
- * @throws XAException -
- * An error has occurred. Possible XAException values are
- * XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, XAER_PROTO,
- * or XA_RB*.
- */
- public void end(Xid xid, int flags) throws XAException {
- StringBuffer commandBuf = new StringBuffer();
- commandBuf.append("XA END ");
- commandBuf.append(xidToString(xid));
-
- switch (flags) {
- case TMSUCCESS:
- break; // no-op
- case TMSUSPEND:
- commandBuf.append(" SUSPEND");
- break;
- case TMFAIL:
- break; // no-op
- default:
- throw new XAException(XAException.XAER_INVAL);
- }
-
- dispatchCommand(commandBuf.toString());
- }
-
- /**
- * Starts work on behalf of a transaction branch specified in xid.
- *
- * If TMJOIN is specified, the start applies to joining a transaction
- * previously seen by the resource manager.
- *
- * If TMRESUME is specified, the start applies to resuming a suspended
- * transaction specified in the parameter xid.
- *
- * If neither TMJOIN nor TMRESUME is specified and the transaction specified
- * by xid has previously been seen by the resource manager, the resource
- * manager throws the XAException exception with XAER_DUPID error code.
- *
- * @parameter xid A global transaction identifier to be associated with the
- * resource.
- *
- * @parameter flags One of TMNOFLAGS, TMJOIN, or TMRESUME.
- *
- * @throws XAException
- * An error has occurred. Possible exceptions are XA_RB*,
- * XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE, XAER_NOTA,
- * XAER_INVAL, or XAER_PROTO.
- */
- public void start(Xid xid, int flags) throws XAException {
- StringBuffer commandBuf = new StringBuffer();
- commandBuf.append("XA START ");
- commandBuf.append(xidToString(xid));
-
- switch (flags) {
- case TMJOIN:
- commandBuf.append(" JOIN");
- break;
- case TMRESUME:
- commandBuf.append(" RESUME");
- break;
- case TMNOFLAGS:
- // no-op
- break;
- default:
- throw new XAException(XAException.XAER_INVAL);
- }
-
- dispatchCommand(commandBuf.toString());
-
- this.underlyingConnection.setInGlobalTx(true);
- }
-
- /**
- * Commits the global transaction specified by xid.
- *
- * @parameter xid A global transaction identifier
- * @parameter onePhase - If true, the resource manager should use a
- * one-phase commit protocol to commit the work done on behalf of
- * xid.
- *
- * @throws XAException
- * An error has occurred. Possible XAExceptions are XA_HEURHAZ,
- * XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR, XAER_RMFAIL,
- * XAER_NOTA, XAER_INVAL, or XAER_PROTO.
- *
- * If the resource manager did not commit the transaction and the parameter
- * onePhase is set to true, the resource manager may throw one of the XA_RB*
- * exceptions.
- *
- * Upon return, the resource manager has rolled back the branch's work and
- * has released all held resources.
- */
-
- public void commit(Xid xid, boolean onePhase) throws XAException {
- StringBuffer commandBuf = new StringBuffer();
- commandBuf.append("XA COMMIT ");
- commandBuf.append(xidToString(xid));
-
- if (onePhase) {
- commandBuf.append(" ONE PHASE");
- }
-
- try {
- dispatchCommand(commandBuf.toString());
- } finally {
- this.underlyingConnection.setInGlobalTx(false);
- }
- }
-
- private ResultSet dispatchCommand(String command) throws XAException {
- Statement stmt = null;
-
- try {
- if (this.logXaCommands) {
- this.log.logDebug("Executing XA statement: " + command);
- }
-
- // TODO: Cache this for lifetime of XAConnection
- stmt = this.underlyingConnection.createStatement();
-
-
- stmt.execute(command);
-
- ResultSet rs = stmt.getResultSet();
-
- return rs;
- } catch (SQLException sqlEx) {
- throw mapXAExceptionFromSQLException(sqlEx);
- } finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException sqlEx) {
- }
- }
- }
- }
-
- protected static XAException mapXAExceptionFromSQLException(SQLException sqlEx) {
-
- Integer xaCode = (Integer) MYSQL_ERROR_CODES_TO_XA_ERROR_CODES
- .get(Constants.integerValueOf(sqlEx.getErrorCode()));
-
- if (xaCode != null) {
- return new MysqlXAException(xaCode.intValue(), sqlEx.getMessage(), null);
- }
-
- // Punt? We don't know what the error code is here
- return new MysqlXAException(sqlEx.getMessage(), null);
- }
-
- private static String xidToString(Xid xid) {
- byte[] gtrid = xid.getGlobalTransactionId();
-
- byte[] btrid = xid.getBranchQualifier();
-
- int lengthAsString = 6; // for (0x and ,) * 2
-
- if (gtrid != null) {
- lengthAsString += (2 * gtrid.length);
- }
-
- if (btrid != null) {
- lengthAsString += (2 * btrid.length);
- }
-
- String formatIdInHex = Integer.toHexString(xid.getFormatId());
-
- lengthAsString += formatIdInHex.length();
- lengthAsString += 3; // for the '.' after formatId
-
- StringBuffer asString = new StringBuffer(lengthAsString);
-
- asString.append("0x");
-
- if (gtrid != null) {
- for (int i = 0; i < gtrid.length; i++) {
- String asHex = Integer.toHexString(gtrid[i] & 0xff);
-
- if (asHex.length() == 1) {
- asString.append("0");
- }
-
- asString.append(asHex);
- }
- }
-
- asString.append(",");
-
- if (btrid != null) {
- asString.append("0x");
-
- for (int i = 0; i < btrid.length; i++) {
- String asHex = Integer.toHexString(btrid[i] & 0xff);
-
- if (asHex.length() == 1) {
- asString.append("0");
- }
-
- asString.append(asHex);
- }
- }
-
- asString.append(",0x");
- asString.append(formatIdInHex);
-
- return asString.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.sql.PooledConnection#getConnection()
- */
- public synchronized Connection getConnection() throws SQLException {
- Connection connToWrap = getConnection(false, true);
-
- return connToWrap;
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlXADataSource.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlXADataSource.java
deleted file mode 100644
index bb7bbd646..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlXADataSource.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.XAConnection;
-
-/**
- * @author mmatthew
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates. To enable and disable the creation of type
- * comments go to Window>Preferences>Java>Code Generation.
- */
-public class MysqlXADataSource extends MysqlDataSource implements
- javax.sql.XADataSource {
-
- /**
- * @see javax.sql.XADataSource#getXAConnection()
- */
- public XAConnection getXAConnection() throws SQLException {
-
- Connection conn = getConnection();
-
- return wrapConnection(conn);
- }
-
- /**
- * @see javax.sql.XADataSource#getXAConnection(String, String)
- */
- public XAConnection getXAConnection(String u, String p)
- throws SQLException {
-
- Connection conn = getConnection(u, p);
-
- return wrapConnection(conn);
- }
-
- /**
- * Wraps a connection as a 'fake' XAConnection
- */
-
- private XAConnection wrapConnection(Connection conn) throws SQLException {
- if (getPinGlobalTxToPhysicalConnection() ||
- ((com.mysql.jdbc.Connection)conn).getPinGlobalTxToPhysicalConnection()) {
- return SuspendableXAConnection.getInstance((com.mysql.jdbc.ConnectionImpl) conn);
- }
-
- return MysqlXAConnection.getInstance((com.mysql.jdbc.ConnectionImpl) conn, getLogXaCommands());
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlXAException.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlXAException.java
deleted file mode 100644
index 777d793dc..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlXAException.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.jdbc2.optional;
-
-import javax.transaction.xa.XAException;
-
-/**
- * The stock XAException class isn't too friendly (i.e. no
- * error messages), so we extend it a bit.
- */
-class MysqlXAException extends XAException {
- private static final long serialVersionUID = -9075817535836563004L;
-
- private String message;
- private String xidAsString;
-
- public MysqlXAException(int errorCode, String message, String xidAsString) {
- super(errorCode);
- this.message = message;
- this.xidAsString = xidAsString;
- }
-
- public MysqlXAException(String message, String xidAsString) {
- super();
-
- this.message = message;
- this.xidAsString = xidAsString;
- }
-
- public String getMessage() {
- String superMessage = super.getMessage();
- StringBuffer returnedMessage = new StringBuffer();
-
- if (superMessage != null) {
- returnedMessage.append(superMessage);
- returnedMessage.append(":");
- }
-
- if (this.message != null) {
- returnedMessage.append(this.message);
- }
-
- return returnedMessage.toString();
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/jdbc2/optional/MysqlXid.java b/src/com/mysql/jdbc/jdbc2/optional/MysqlXid.java
deleted file mode 100644
index d434b3367..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/MysqlXid.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- Copyright 2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-package com.mysql.jdbc.jdbc2.optional;
-
-import javax.transaction.xa.Xid;
-
-/**
- * Implementation of the XID interface for MySQL XA
- *
- * @version $Id: $
- */
-public class MysqlXid implements Xid {
-
- int hash = 0;
-
- byte[] myBqual;
-
- int myFormatId;
-
- byte[] myGtrid;
-
- public MysqlXid(byte[] gtrid, byte[] bqual, int formatId) {
- this.myGtrid = gtrid;
- this.myBqual = bqual;
- this.myFormatId = formatId;
- }
-
- public boolean equals(Object another) {
-
- if (another instanceof Xid) {
- Xid anotherAsXid = (Xid) another;
-
- if (this.myFormatId != anotherAsXid.getFormatId()) {
- return false;
- }
-
- byte[] otherBqual = anotherAsXid.getBranchQualifier();
- byte[] otherGtrid = anotherAsXid.getGlobalTransactionId();
-
- if (otherGtrid != null && otherGtrid.length == this.myGtrid.length) {
- int length = otherGtrid.length;
-
- for (int i = 0; i < length; i++) {
- if (otherGtrid[i] != this.myGtrid[i]) {
- return false;
- }
- }
-
- if (otherBqual != null && otherBqual.length == myBqual.length) {
- length = otherBqual.length;
-
- for (int i = 0; i < length; i++) {
- if (otherBqual[i] != this.myBqual[i]) {
- return false;
- }
- }
- } else {
- return false;
- }
-
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-
- public byte[] getBranchQualifier() {
- return this.myBqual;
- }
-
- public int getFormatId() {
- return this.myFormatId;
- };
-
- public byte[] getGlobalTransactionId() {
- return this.myGtrid;
- }
-
- public synchronized int hashCode() {
- if (this.hash == 0) {
- for (int i = 0; i < this.myGtrid.length; i++) {
- this.hash = 33 * this.hash + this.myGtrid[i];
- }
- }
-
- return this.hash;
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/PreparedStatementWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/PreparedStatementWrapper.java
deleted file mode 100644
index 7e72a0576..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/PreparedStatementWrapper.java
+++ /dev/null
@@ -1,1226 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.lang.reflect.Constructor;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.ParameterMetaData;
-import java.sql.PreparedStatement;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.Util;
-
-/**
- * Wraps prepared statements so that errors can be reported correctly to
- * ConnectionEventListeners.
- *
- * @author Mark Matthews
- *
- * @version $Id: PreparedStatementWrapper.java,v 1.1.2.1 2005/05/13 18:58:38
- * mmatthews Exp $
- */
-public class PreparedStatementWrapper extends StatementWrapper implements
- PreparedStatement {
- private static final Constructor JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR = Class.forName(
- "com.mysql.jdbc.jdbc2.optional.JDBC4PreparedStatementWrapper").getConstructor(
- new Class[] { ConnectionWrapper.class,
- MysqlPooledConnection.class,
- PreparedStatement.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR = null;
- }
- }
-
- protected static PreparedStatementWrapper getInstance(ConnectionWrapper c,
- MysqlPooledConnection conn,
- PreparedStatement toWrap) throws SQLException {
- if (!Util.isJdbc4()) {
- return new PreparedStatementWrapper(c,
- conn, toWrap);
- }
-
- return (PreparedStatementWrapper) Util.handleNewInstance(
- JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR,
- new Object[] {c,
- conn, toWrap }, conn.getExceptionInterceptor());
- }
-
- PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn,
- PreparedStatement toWrap) {
- super(c, conn, toWrap);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)
- */
- public void setArray(int parameterIndex, Array x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setArray(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream,
- * int)
- */
- public void setAsciiStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setAsciiStream(
- parameterIndex, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)
- */
- public void setBigDecimal(int parameterIndex, BigDecimal x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBigDecimal(
- parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream,
- * int)
- */
- public void setBinaryStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBinaryStream(
- parameterIndex, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)
- */
- public void setBlob(int parameterIndex, Blob x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setBoolean(int, boolean)
- */
- public void setBoolean(int parameterIndex, boolean x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBoolean(
- parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setByte(int, byte)
- */
- public void setByte(int parameterIndex, byte x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setByte(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setBytes(int, byte[])
- */
- public void setBytes(int parameterIndex, byte[] x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setBytes(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader,
- * int)
- */
- public void setCharacterStream(int parameterIndex, Reader reader, int length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setCharacterStream(
- parameterIndex, reader, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)
- */
- public void setClob(int parameterIndex, Clob x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)
- */
- public void setDate(int parameterIndex, Date x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setDate(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setDate(int, java.sql.Date,
- * java.util.Calendar)
- */
- public void setDate(int parameterIndex, Date x, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setDate(parameterIndex,
- x, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setDouble(int, double)
- */
- public void setDouble(int parameterIndex, double x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setDouble(
- parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setFloat(int, float)
- */
- public void setFloat(int parameterIndex, float x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setFloat(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setInt(int, int)
- */
- public void setInt(int parameterIndex, int x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt)
- .setInt(parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setLong(int, long)
- */
- public void setLong(int parameterIndex, long x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setLong(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#getMetaData()
- */
- public ResultSetMetaData getMetaData() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((PreparedStatement) this.wrappedStmt).getMetaData();
- }
-
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setNull(int, int)
- */
- public void setNull(int parameterIndex, int sqlType) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNull(parameterIndex,
- sqlType);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)
- */
- public void setNull(int parameterIndex, int sqlType, String typeName)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setNull(parameterIndex,
- sqlType, typeName);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setObject(int, java.lang.Object)
- */
- public void setObject(int parameterIndex, Object x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setObject(
- parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int)
- */
- public void setObject(int parameterIndex, Object x, int targetSqlType)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setObject(
- parameterIndex, x, targetSqlType);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int,
- * int)
- */
- public void setObject(int parameterIndex, Object x, int targetSqlType,
- int scale) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setObject(
- parameterIndex, x, targetSqlType, scale);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#getParameterMetaData()
- */
- public ParameterMetaData getParameterMetaData() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((PreparedStatement) this.wrappedStmt)
- .getParameterMetaData();
- }
-
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)
- */
- public void setRef(int parameterIndex, Ref x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt)
- .setRef(parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setShort(int, short)
- */
- public void setShort(int parameterIndex, short x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setShort(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setString(int, java.lang.String)
- */
- public void setString(int parameterIndex, String x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setString(
- parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setTime(int, java.sql.Time)
- */
- public void setTime(int parameterIndex, Time x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setTime(parameterIndex,
- x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setTime(int, java.sql.Time,
- * java.util.Calendar)
- */
- public void setTime(int parameterIndex, Time x, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setTime(parameterIndex,
- x, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp)
- */
- public void setTimestamp(int parameterIndex, Timestamp x)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setTimestamp(
- parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp,
- * java.util.Calendar)
- */
- public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setTimestamp(
- parameterIndex, x, cal);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#setURL(int, java.net.URL)
- */
- public void setURL(int parameterIndex, URL x) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt)
- .setURL(parameterIndex, x);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param parameterIndex
- * DOCUMENT ME!
- * @param x
- * DOCUMENT ME!
- * @param length
- * DOCUMENT ME!
- *
- * @throws SQLException
- * DOCUMENT ME!
- *
- * @see java.sql.PreparedStatement#setUnicodeStream(int,
- * java.io.InputStream, int)
- * @deprecated
- */
- public void setUnicodeStream(int parameterIndex, InputStream x, int length)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).setUnicodeStream(
- parameterIndex, x, length);
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#addBatch()
- */
- public void addBatch() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).addBatch();
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#clearParameters()
- */
- public void clearParameters() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((PreparedStatement) this.wrappedStmt).clearParameters();
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#execute()
- */
- public boolean execute() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((PreparedStatement) this.wrappedStmt).execute();
- }
-
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#executeQuery()
- */
- public ResultSet executeQuery() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ResultSet rs = ((PreparedStatement) this.wrappedStmt)
- .executeQuery();
-
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).setWrapperStatement(this);
-
- return rs;
- }
-
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.PreparedStatement#executeUpdate()
- */
- public int executeUpdate() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return ((PreparedStatement) this.wrappedStmt).executeUpdate();
- }
-
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return -1; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-//
-// public void setAsciiStream(int parameterIndex, InputStream x)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setAsciiStream(
-// parameterIndex, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setAsciiStream(int parameterIndex, InputStream x, long length)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setAsciiStream(
-// parameterIndex, x, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBinaryStream(int parameterIndex, InputStream x)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setBinaryStream(
-// parameterIndex, x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBinaryStream(int parameterIndex, InputStream x, long length)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setBinaryStream(
-// parameterIndex, x, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBlob(int parameterIndex, InputStream inputStream)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
-// inputStream);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setBlob(int parameterIndex, InputStream inputStream, long length)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
-// inputStream, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setCharacterStream(int parameterIndex, Reader reader)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setCharacterStream(
-// parameterIndex, reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setCharacterStream(int parameterIndex, Reader reader,
-// long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setCharacterStream(
-// parameterIndex, reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setClob(int parameterIndex, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
-// reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setClob(int parameterIndex, Reader reader, long length)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
-// reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNCharacterStream(int parameterIndex, Reader value)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setNCharacterStream(
-// parameterIndex, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNCharacterStream(int parameterIndex, Reader value,
-// long length) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setNCharacterStream(
-// parameterIndex, value, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(int parameterIndex, NClob value) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
-// value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(int parameterIndex, Reader reader) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
-// reader);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNClob(int parameterIndex, Reader reader, long length)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
-// reader, length);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setNString(int parameterIndex, String value)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setNString(
-// parameterIndex, value);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setRowId(int parameterIndex, RowId x) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setRowId(parameterIndex,
-// x);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public void setSQLXML(int parameterIndex, SQLXML xmlObject)
-// throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setSQLXML(
-// parameterIndex, xmlObject);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public boolean isClosed() throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((PreparedStatement) this.wrappedStmt).isClosed();
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return true;
-// }
-//
-// public boolean isPoolable() throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// return ((PreparedStatement) this.wrappedStmt).isPoolable();
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-//
-// return false;
-// }
-//
-// public void setPoolable(boolean poolable) throws SQLException {
-// try {
-// if (this.wrappedStmt != null) {
-// ((PreparedStatement) this.wrappedStmt).setPoolable(poolable);
-// } else {
-// throw SQLError.createSQLException(
-// "No operations allowed after statement closed",
-// SQLError.SQL_STATE_GENERAL_ERROR);
-// }
-// } catch (SQLException sqlEx) {
-// checkAndFireConnectionError(sqlEx);
-// }
-// }
-//
-// public boolean isWrapperFor(Class arg0) throws SQLException {
-// throw SQLError.notImplemented();
-// }
-//
-// public Object unwrap(Class arg0) throws SQLException {
-// throw SQLError.notImplemented();
-// }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/StatementWrapper.java b/src/com/mysql/jdbc/jdbc2/optional/StatementWrapper.java
deleted file mode 100644
index d7044e943..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/StatementWrapper.java
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.lang.reflect.Constructor;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Statement;
-
-import com.mysql.jdbc.SQLError;
-import com.mysql.jdbc.Util;
-
-/**
- * Wraps statements so that errors can be reported correctly to
- * ConnectionEventListeners.
- *
- * @author Mark Matthews
- *
- * @version $Id: StatementWrapper.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews
- * Exp $
- */
-public class StatementWrapper extends WrapperBase implements Statement {
- private static final Constructor JDBC_4_STATEMENT_WRAPPER_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_STATEMENT_WRAPPER_CTOR = Class.forName(
- "com.mysql.jdbc.jdbc2.optional.JDBC4StatementWrapper").getConstructor(
- new Class[] { ConnectionWrapper.class,
- MysqlPooledConnection.class,
- Statement.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_STATEMENT_WRAPPER_CTOR = null;
- }
- }
-
- protected static StatementWrapper getInstance(ConnectionWrapper c,
- MysqlPooledConnection conn,
- Statement toWrap) throws SQLException {
- if (!Util.isJdbc4()) {
- return new StatementWrapper(c,
- conn, toWrap);
- }
-
- return (StatementWrapper) Util.handleNewInstance(
- JDBC_4_STATEMENT_WRAPPER_CTOR,
- new Object[] {c,
- conn, toWrap }, conn.getExceptionInterceptor());
- }
-
- protected Statement wrappedStmt;
-
- protected ConnectionWrapper wrappedConn;
-
- public StatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn,
- Statement toWrap) {
- super(conn);
- this.wrappedStmt = toWrap;
- this.wrappedConn = c;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getConnection()
- */
- public Connection getConnection() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedConn;
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#setCursorName(java.lang.String)
- */
- public void setCursorName(String name) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setCursorName(name);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#setEscapeProcessing(boolean)
- */
- public void setEscapeProcessing(boolean enable) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setEscapeProcessing(enable);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#setFetchDirection(int)
- */
- public void setFetchDirection(int direction) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setFetchDirection(direction);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getFetchDirection()
- */
- public int getFetchDirection() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getFetchDirection();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return ResultSet.FETCH_FORWARD; // we actually never get here, but the
- // compiler can't figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#setFetchSize(int)
- */
- public void setFetchSize(int rows) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setFetchSize(rows);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getFetchSize()
- */
- public int getFetchSize() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getFetchSize();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getGeneratedKeys()
- */
- public ResultSet getGeneratedKeys() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getGeneratedKeys();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#setMaxFieldSize(int)
- */
- public void setMaxFieldSize(int max) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setMaxFieldSize(max);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getMaxFieldSize()
- */
- public int getMaxFieldSize() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getMaxFieldSize();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#setMaxRows(int)
- */
- public void setMaxRows(int max) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setMaxRows(max);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getMaxRows()
- */
- public int getMaxRows() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getMaxRows();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getMoreResults()
- */
- public boolean getMoreResults() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getMoreResults();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getMoreResults(int)
- */
- public boolean getMoreResults(int current) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getMoreResults(current);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#setQueryTimeout(int)
- */
- public void setQueryTimeout(int seconds) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.setQueryTimeout(seconds);
- } else {
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getQueryTimeout()
- */
- public int getQueryTimeout() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getQueryTimeout();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getResultSet()
- */
- public ResultSet getResultSet() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ResultSet rs = this.wrappedStmt.getResultSet();
-
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).setWrapperStatement(this);
-
- return rs;
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getResultSetConcurrency()
- */
- public int getResultSetConcurrency() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getResultSetConcurrency();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getResultSetHoldability()
- */
- public int getResultSetHoldability() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getResultSetHoldability();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return Statement.CLOSE_CURRENT_RESULT;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getResultSetType()
- */
- public int getResultSetType() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getResultSetType();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return ResultSet.TYPE_FORWARD_ONLY;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getUpdateCount()
- */
- public int getUpdateCount() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getUpdateCount();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return -1;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#getWarnings()
- */
- public SQLWarning getWarnings() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.getWarnings();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#addBatch(java.lang.String)
- */
- public void addBatch(String sql) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.addBatch(sql);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#cancel()
- */
- public void cancel() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.cancel();
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#clearBatch()
- */
- public void clearBatch() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.clearBatch();
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#clearWarnings()
- */
- public void clearWarnings() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.clearWarnings();
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#close()
- */
- public void close() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- this.wrappedStmt.close();
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- } finally {
- this.wrappedStmt = null;
- this.pooledConnection = null;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#execute(java.lang.String, int)
- */
- public boolean execute(String sql, int autoGeneratedKeys)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.execute(sql, autoGeneratedKeys);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#execute(java.lang.String, int[])
- */
- public boolean execute(String sql, int[] columnIndexes) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.execute(sql, columnIndexes);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])
- */
- public boolean execute(String sql, String[] columnNames)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.execute(sql, columnNames);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#execute(java.lang.String)
- */
- public boolean execute(String sql) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.execute(sql);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return false; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#executeBatch()
- */
- public int[] executeBatch() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.executeBatch();
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#executeQuery(java.lang.String)
- */
- public ResultSet executeQuery(String sql) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
-
- ResultSet rs = this.wrappedStmt.executeQuery(sql);
- ((com.mysql.jdbc.ResultSetInternalMethods) rs).setWrapperStatement(this);
-
- return rs;
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return null; // we actually never get here, but the compiler can't
- // figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#executeUpdate(java.lang.String, int)
- */
- public int executeUpdate(String sql, int autoGeneratedKeys)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.executeUpdate(sql, autoGeneratedKeys);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return -1; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#executeUpdate(java.lang.String, int[])
- */
- public int executeUpdate(String sql, int[] columnIndexes)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.executeUpdate(sql, columnIndexes);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return -1; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#executeUpdate(java.lang.String,
- * java.lang.String[])
- */
- public int executeUpdate(String sql, String[] columnNames)
- throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.executeUpdate(sql, columnNames);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return -1; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.sql.Statement#executeUpdate(java.lang.String)
- */
- public int executeUpdate(String sql) throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- return this.wrappedStmt.executeUpdate(sql);
- }
-
- throw SQLError.createSQLException("Statement already closed",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
-
- return -1; // we actually never get here, but the compiler can't figure
-
- // that out
- }
-
- public void enableStreamingResults() throws SQLException {
- try {
- if (this.wrappedStmt != null) {
- ((com.mysql.jdbc.Statement) this.wrappedStmt)
- .enableStreamingResults();
- } else {
- throw SQLError.createSQLException(
- "No operations allowed after statement closed",
- SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
- }
- } catch (SQLException sqlEx) {
- checkAndFireConnectionError(sqlEx);
- }
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/SuspendableXAConnection.java b/src/com/mysql/jdbc/jdbc2/optional/SuspendableXAConnection.java
deleted file mode 100644
index 48e138234..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/SuspendableXAConnection.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package com.mysql.jdbc.jdbc2.optional;
-
-
-import java.lang.reflect.Constructor;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sql.XAConnection;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.Util;
-
-public class SuspendableXAConnection extends MysqlPooledConnection implements
-XAConnection, XAResource {
-
- private static final Constructor JDBC_4_XA_CONNECTION_WRAPPER_CTOR;
-
- static {
- if (Util.isJdbc4()) {
- try {
- JDBC_4_XA_CONNECTION_WRAPPER_CTOR = Class.forName(
- "com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection")
- .getConstructor(
- new Class[] { ConnectionImpl.class });
- } catch (SecurityException e) {
- throw new RuntimeException(e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- } else {
- JDBC_4_XA_CONNECTION_WRAPPER_CTOR = null;
- }
- }
-
- protected static SuspendableXAConnection getInstance(ConnectionImpl mysqlConnection) throws SQLException {
- if (!Util.isJdbc4()) {
- return new SuspendableXAConnection(mysqlConnection);
- }
-
- return (SuspendableXAConnection) Util.handleNewInstance(
- JDBC_4_XA_CONNECTION_WRAPPER_CTOR, new Object[] {
- mysqlConnection}, mysqlConnection.getExceptionInterceptor());
- }
-
- public SuspendableXAConnection(ConnectionImpl connection) {
- super(connection);
- this.underlyingConnection = connection;
- }
-
- private static final Map XIDS_TO_PHYSICAL_CONNECTIONS =
- new HashMap();
-
- private Xid currentXid;
-
- private XAConnection currentXAConnection;
- private XAResource currentXAResource;
-
- private ConnectionImpl underlyingConnection;
-
- private static synchronized XAConnection findConnectionForXid(ConnectionImpl connectionToWrap, Xid xid)
- throws SQLException {
- // TODO: check for same GTRID, but different BQUALs...MySQL doesn't allow this yet
-
- // Note, we don't need to check for XIDs here, because MySQL itself will complain
- // with a XAER_NOTA if need be.
-
- XAConnection conn = (XAConnection)XIDS_TO_PHYSICAL_CONNECTIONS.get(xid);
-
- if (conn == null) {
- conn = new MysqlXAConnection(connectionToWrap,
- connectionToWrap.getLogXaCommands());
- XIDS_TO_PHYSICAL_CONNECTIONS.put(xid, conn);
- }
-
- return conn;
- }
-
- private static synchronized void removeXAConnectionMapping(Xid xid) {
- XIDS_TO_PHYSICAL_CONNECTIONS.remove(xid);
- }
-
- private synchronized void switchToXid(Xid xid) throws XAException {
- if (xid == null) {
- throw new XAException();
- }
-
- try {
- if (!xid.equals(this.currentXid)) {
- XAConnection toSwitchTo = findConnectionForXid(this.underlyingConnection, xid);
- this.currentXAConnection = toSwitchTo;
- this.currentXid = xid;
- this.currentXAResource = toSwitchTo.getXAResource();
- }
- } catch (SQLException sqlEx) {
- throw new XAException();
- }
- }
-
- public XAResource getXAResource() throws SQLException {
- return this;
- }
-
- public void commit(Xid xid, boolean arg1) throws XAException {
- switchToXid(xid);
- this.currentXAResource.commit(xid, arg1);
- removeXAConnectionMapping(xid);
- }
-
- public void end(Xid xid, int arg1) throws XAException {
- switchToXid(xid);
- this.currentXAResource.end(xid, arg1);
- }
-
- public void forget(Xid xid) throws XAException {
- switchToXid(xid);
- this.currentXAResource.forget(xid);
- // remove?
- removeXAConnectionMapping(xid);
- }
-
- public int getTransactionTimeout() throws XAException {
- return 0;
- }
-
- public boolean isSameRM(XAResource xaRes) throws XAException {
- return xaRes == this;
- }
-
- public int prepare(Xid xid) throws XAException {
- switchToXid(xid);
- return this.currentXAResource.prepare(xid);
- }
-
- public Xid[] recover(int flag) throws XAException {
- return MysqlXAConnection.recover(this.underlyingConnection, flag);
- }
-
- public void rollback(Xid xid) throws XAException {
- switchToXid(xid);
- this.currentXAResource.rollback(xid);
- removeXAConnectionMapping(xid);
- }
-
- public boolean setTransactionTimeout(int arg0) throws XAException {
- return false;
- }
-
- public void start(Xid xid, int arg1) throws XAException {
- switchToXid(xid);
-
- if (arg1 != XAResource.TMJOIN) {
- this.currentXAResource.start(xid, arg1);
-
- return;
- }
-
- //
- // Emulate join, by using resume on the same physical connection
- //
-
- this.currentXAResource.start(xid, XAResource.TMRESUME);
- }
-
- public synchronized java.sql.Connection getConnection() throws SQLException {
- if (this.currentXAConnection == null) {
- return getConnection(false, true);
- }
-
- return this.currentXAConnection.getConnection();
- }
-
- public void close() throws SQLException {
- if (this.currentXAConnection == null) {
- super.close();
- } else {
- removeXAConnectionMapping(this.currentXid);
- this.currentXAConnection.close();
- }
- }
-}
diff --git a/src/com/mysql/jdbc/jdbc2/optional/WrapperBase.java b/src/com/mysql/jdbc/jdbc2/optional/WrapperBase.java
deleted file mode 100644
index 48db43957..000000000
--- a/src/com/mysql/jdbc/jdbc2/optional/WrapperBase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.jdbc2.optional;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.SQLException;
-import java.util.Map;
-
-import com.mysql.jdbc.ExceptionInterceptor;
-import com.mysql.jdbc.SQLError;
-
-/**
- * Base class for all wrapped instances created by LogicalHandle
- *
- * @author Mark matthews
- *
- * @version $Id$
- */
-abstract class WrapperBase {
- protected MysqlPooledConnection pooledConnection;
-
- /**
- * Fires connection error event if required, before re-throwing exception
- *
- * @param sqlEx
- * the SQLException that has ocurred
- * @throws SQLException
- * (rethrown)
- */
- protected void checkAndFireConnectionError(SQLException sqlEx)
- throws SQLException {
- if (this.pooledConnection != null) {
- if (SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE.equals(sqlEx
- .getSQLState())) {
- this.pooledConnection.callConnectionEventListeners(
- MysqlPooledConnection.CONNECTION_ERROR_EVENT, sqlEx);
- }
- }
-
- throw sqlEx;
- }
-
- protected Map unwrappedInterfaces = null;
- protected ExceptionInterceptor exceptionInterceptor;
-
- protected WrapperBase(MysqlPooledConnection pooledConnection) {
- this.pooledConnection = pooledConnection;
- this.exceptionInterceptor = this.pooledConnection.getExceptionInterceptor();
- }
-
- protected class ConnectionErrorFiringInvocationHandler implements InvocationHandler {
- Object invokeOn = null;
-
- public ConnectionErrorFiringInvocationHandler(Object toInvokeOn) {
- invokeOn = toInvokeOn;
- }
-
- public Object invoke(Object proxy, Method method,
- Object[] args) throws Throwable {
- Object result = null;
-
- try {
- result = method.invoke(invokeOn, args);
-
- if (result != null) {
- result = proxyIfInterfaceIsJdbc(result,
- result.getClass());
- }
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof SQLException) {
- checkAndFireConnectionError((SQLException) e
- .getTargetException());
- } else {
- throw e;
- }
- }
-
- return result;
- }
-
- /**
- * Recursively checks for interfaces on the given object to determine
- * if it implements a java.sql interface, and if so, proxies the
- * instance so that we can catch and fire SQL errors.
- * @param toProxy
- * @param clazz
- * @return
- */
- private Object proxyIfInterfaceIsJdbc(Object toProxy, Class clazz) {
- Class[] interfaces = clazz.getInterfaces();
-
- for (int i = 0; i < interfaces.length; i++) {
- String packageName = interfaces[i].getPackage().getName();
-
- if ("java.sql".equals(packageName) ||
- "javax.sql".equals(packageName)) {
- return Proxy.newProxyInstance(toProxy.getClass()
- .getClassLoader(), interfaces,
- new ConnectionErrorFiringInvocationHandler(toProxy));
- }
-
- return proxyIfInterfaceIsJdbc(toProxy, interfaces[i]);
- }
-
- return toProxy;
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/log/CommonsLogger.java b/src/com/mysql/jdbc/log/CommonsLogger.java
deleted file mode 100644
index 70af79fa6..000000000
--- a/src/com/mysql/jdbc/log/CommonsLogger.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- Copyright 2006 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.log;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class CommonsLogger implements com.mysql.jdbc.log.Log {
- private Log logger;
-
- public CommonsLogger(String instanceName) {
- logger = LogFactory.getLog(instanceName);
- }
-
- public boolean isDebugEnabled() {
- return this.logger.isInfoEnabled();
- }
-
- public boolean isErrorEnabled() {
- return this.logger.isErrorEnabled();
- }
-
- public boolean isFatalEnabled() {
- return this.logger.isFatalEnabled();
- }
-
- public boolean isInfoEnabled() {
- return this.logger.isInfoEnabled();
- }
-
- public boolean isTraceEnabled() {
- return this.logger.isTraceEnabled();
- }
-
- public boolean isWarnEnabled() {
- return this.logger.isWarnEnabled();
- }
-
- public void logDebug(Object msg) {
- this.logger.debug(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- public void logDebug(Object msg, Throwable thrown) {
- this.logger.debug(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- public void logError(Object msg) {
- this.logger.error(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- public void logError(Object msg, Throwable thrown) {
- this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- public void logFatal(Object msg) {
- this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- public void logFatal(Object msg, Throwable thrown) {
- this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- public void logInfo(Object msg) {
- this.logger.info(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- public void logInfo(Object msg, Throwable thrown) {
- this.logger.info(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- public void logTrace(Object msg) {
- this.logger.trace(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- public void logTrace(Object msg, Throwable thrown) {
- this.logger.trace(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- public void logWarn(Object msg) {
- this.logger.warn(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- public void logWarn(Object msg, Throwable thrown) {
- this.logger.warn(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
-}
diff --git a/src/com/mysql/jdbc/log/Jdk14Logger.java b/src/com/mysql/jdbc/log/Jdk14Logger.java
deleted file mode 100644
index 1910cd568..000000000
--- a/src/com/mysql/jdbc/log/Jdk14Logger.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.log;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.mysql.jdbc.profiler.ProfilerEvent;
-
-/**
- * Logging functionality for JDK1.4
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public class Jdk14Logger implements Log {
- private static final Level DEBUG = Level.FINE;
-
- private static final Level ERROR = Level.SEVERE;
-
- private static final Level FATAL = Level.SEVERE;
-
- private static final Level INFO = Level.INFO;
-
- private static final Level TRACE = Level.FINEST;
-
- private static final Level WARN = Level.WARNING;
-
- /**
- * The underlying logger from JDK-1.4
- */
- protected Logger jdkLogger = null;
-
- /**
- * Creates a new Jdk14Logger object.
- *
- * @param name
- * DOCUMENT ME!
- */
- public Jdk14Logger(String name) {
- this.jdkLogger = Logger.getLogger(name);
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- return this.jdkLogger.isLoggable(Level.FINE);
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- return this.jdkLogger.isLoggable(Level.SEVERE);
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isFatalEnabled()
- */
- public boolean isFatalEnabled() {
- return this.jdkLogger.isLoggable(Level.SEVERE);
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- return this.jdkLogger.isLoggable(Level.INFO);
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isTraceEnabled()
- */
- public boolean isTraceEnabled() {
- return this.jdkLogger.isLoggable(Level.FINEST);
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- return this.jdkLogger.isLoggable(Level.WARNING);
- }
-
- /**
- * Logs the given message instance using the 'debug' level
- *
- * @param message
- * the message to log
- */
- public void logDebug(Object message) {
- logInternal(DEBUG, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'debug' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logDebug(Object message, Throwable exception) {
- logInternal(DEBUG, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'error' level
- *
- * @param message
- * the message to log
- */
- public void logError(Object message) {
- logInternal(ERROR, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'error' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logError(Object message, Throwable exception) {
- logInternal(ERROR, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'fatal' level
- *
- * @param message
- * the message to log
- */
- public void logFatal(Object message) {
- logInternal(FATAL, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'fatal' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logFatal(Object message, Throwable exception) {
- logInternal(FATAL, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'info' level
- *
- * @param message
- * the message to log
- */
- public void logInfo(Object message) {
- logInternal(INFO, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'info' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logInfo(Object message, Throwable exception) {
- logInternal(INFO, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'trace' level
- *
- * @param message
- * the message to log
- */
- public void logTrace(Object message) {
- logInternal(TRACE, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'trace' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logTrace(Object message, Throwable exception) {
- logInternal(TRACE, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'warn' level
- *
- * @param message
- * the message to log
- */
- public void logWarn(Object message) {
- logInternal(WARN, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'warn' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logWarn(Object message, Throwable exception) {
- logInternal(WARN, message, exception);
- }
-
- private static final int findCallerStackDepth(StackTraceElement[] stackTrace) {
- int numFrames = stackTrace.length;
-
- for (int i = 0; i < numFrames; i++) {
- String callerClassName = stackTrace[i].getClassName();
-
- if (!callerClassName.startsWith("com.mysql.jdbc")
- || callerClassName.startsWith("com.mysql.jdbc.compliance")) {
- return i;
- }
- }
-
- return 0;
- }
-
- private void logInternal(Level level, Object msg, Throwable exception) {
- //
- // only go through this exercise if the message will actually
- // be logged.
- //
-
- if (this.jdkLogger.isLoggable(level)) {
- String messageAsString = null;
- String callerMethodName = "N/A";
- String callerClassName = "N/A";
- int lineNumber = 0;
- String fileName = "N/A";
-
- if (msg instanceof ProfilerEvent) {
- messageAsString = LogUtils.expandProfilerEventIfNecessary(msg)
- .toString();
- } else {
- Throwable locationException = new Throwable();
- StackTraceElement[] locations = locationException
- .getStackTrace();
-
- int frameIdx = findCallerStackDepth(locations);
-
- if (frameIdx != 0) {
- callerClassName = locations[frameIdx].getClassName();
- callerMethodName = locations[frameIdx].getMethodName();
- lineNumber = locations[frameIdx].getLineNumber();
- fileName = locations[frameIdx].getFileName();
- }
-
- messageAsString = String.valueOf(msg);
- }
-
- if (exception == null) {
- this.jdkLogger.logp(level, callerClassName, callerMethodName,
- messageAsString);
- } else {
- this.jdkLogger.logp(level, callerClassName, callerMethodName,
- messageAsString, exception);
- }
- }
- }
-}
diff --git a/src/com/mysql/jdbc/log/Log.java b/src/com/mysql/jdbc/log/Log.java
deleted file mode 100644
index 190ab629b..000000000
--- a/src/com/mysql/jdbc/log/Log.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.log;
-
-/**
- * Unified interface to logging facilities on different platforms
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public interface Log {
- /**
- * Is the 'debug' log level enabled?
- *
- * @return true if so.
- */
- boolean isDebugEnabled();
-
- /**
- * Is the 'error' log level enabled?
- *
- * @return true if so.
- */
- boolean isErrorEnabled();
-
- /**
- * Is the 'fatal' log level enabled?
- *
- * @return true if so.
- */
- boolean isFatalEnabled();
-
- /**
- * Is the 'info' log level enabled?
- *
- * @return true if so.
- */
- boolean isInfoEnabled();
-
- /**
- * Is the 'trace' log level enabled?
- *
- * @return true if so.
- */
- boolean isTraceEnabled();
-
- /**
- * Is the 'warn' log level enabled?
- *
- * @return true if so.
- */
- boolean isWarnEnabled();
-
- /**
- * Logs the given message instance using the 'debug' level
- *
- * @param msg
- * the message to log
- */
- void logDebug(Object msg);
-
- /**
- * Logs the given message and Throwable at the 'debug' level.
- *
- * @param msg
- * the message to log
- * @param thrown
- * the throwable to log (may be null)
- */
- void logDebug(Object msg, Throwable thrown);
-
- /**
- * Logs the given message instance using the 'error' level
- *
- * @param msg
- * the message to log
- */
- void logError(Object msg);
-
- /**
- * Logs the given message and Throwable at the 'error' level.
- *
- * @param msg
- * the message to log
- * @param thrown
- * the throwable to log (may be null)
- */
- void logError(Object msg, Throwable thrown);
-
- /**
- * Logs the given message instance using the 'fatal' level
- *
- * @param msg
- * the message to log
- */
- void logFatal(Object msg);
-
- /**
- * Logs the given message and Throwable at the 'fatal' level.
- *
- * @param msg
- * the message to log
- * @param thrown
- * the throwable to log (may be null)
- */
- void logFatal(Object msg, Throwable thrown);
-
- /**
- * Logs the given message instance using the 'info' level
- *
- * @param msg
- * the message to log
- */
- void logInfo(Object msg);
-
- /**
- * Logs the given message and Throwable at the 'info' level.
- *
- * @param msg
- * the message to log
- * @param thrown
- * the throwable to log (may be null)
- */
- void logInfo(Object msg, Throwable thrown);
-
- /**
- * Logs the given message instance using the 'trace' level
- *
- * @param msg
- * the message to log
- */
- void logTrace(Object msg);
-
- /**
- * Logs the given message and Throwable at the 'trace' level.
- *
- * @param msg
- * the message to log
- * @param thrown
- * the throwable to log (may be null)
- */
- void logTrace(Object msg, Throwable thrown);
-
- /**
- * Logs the given message instance using the 'warn' level
- *
- * @param msg
- * the message to log
- */
- void logWarn(Object msg);
-
- /**
- * Logs the given message and Throwable at the 'warn' level.
- *
- * @param msg
- * the message to log
- * @param thrown
- * the throwable to log (may be null)
- */
- void logWarn(Object msg, Throwable thrown);
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/log/Log4JLogger.java b/src/com/mysql/jdbc/log/Log4JLogger.java
deleted file mode 100644
index ae2e08183..000000000
--- a/src/com/mysql/jdbc/log/Log4JLogger.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.log;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-/**
- * Implementation of log interface for Apache Log4j
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public class Log4JLogger implements Log {
-
- private Logger logger;
-
- public Log4JLogger(String instanceName) {
- this.logger = Logger.getLogger(instanceName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- return this.logger.isDebugEnabled();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- return this.logger.isEnabledFor(Level.ERROR);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#isFatalEnabled()
- */
- public boolean isFatalEnabled() {
- return this.logger.isEnabledFor(Level.FATAL);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- return this.logger.isInfoEnabled();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#isTraceEnabled()
- */
- public boolean isTraceEnabled() {
- return this.logger.isDebugEnabled();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- return this.logger.isEnabledFor(Level.WARN);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logDebug(java.lang.Object)
- */
- public void logDebug(Object msg) {
- this.logger.debug(LogUtils.expandProfilerEventIfNecessary(LogUtils
- .expandProfilerEventIfNecessary(msg)));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logDebug(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logDebug(Object msg, Throwable thrown) {
- this.logger.debug(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logError(java.lang.Object)
- */
- public void logError(Object msg) {
- this.logger.error(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logError(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logError(Object msg, Throwable thrown) {
- this.logger.error(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logFatal(java.lang.Object)
- */
- public void logFatal(Object msg) {
- this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logFatal(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logFatal(Object msg, Throwable thrown) {
- this.logger.fatal(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logInfo(java.lang.Object)
- */
- public void logInfo(Object msg) {
- this.logger.info(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logInfo(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logInfo(Object msg, Throwable thrown) {
- this.logger.info(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logTrace(java.lang.Object)
- */
- public void logTrace(Object msg) {
- this.logger.debug(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logTrace(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logTrace(Object msg, Throwable thrown) {
- this.logger.debug(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logWarn(java.lang.Object)
- */
- public void logWarn(Object msg) {
- this.logger.warn(LogUtils.expandProfilerEventIfNecessary(msg));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.mysql.jdbc.log.Log#logWarn(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logWarn(Object msg, Throwable thrown) {
- this.logger.warn(LogUtils.expandProfilerEventIfNecessary(msg), thrown);
- }
-}
diff --git a/src/com/mysql/jdbc/log/LogFactory.java b/src/com/mysql/jdbc/log/LogFactory.java
deleted file mode 100644
index 4ec60a2bb..000000000
--- a/src/com/mysql/jdbc/log/LogFactory.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.log;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
-
-import com.mysql.jdbc.ExceptionInterceptor;
-import com.mysql.jdbc.SQLError;
-
-/**
- * Creates instances of loggers for the driver to use.
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public class LogFactory {
-
- /**
- * Returns a logger instance of the given class, with the given instance
- * name.
- *
- * @param className
- * the class to instantiate
- * @param instanceName
- * the instance name
- * @return a logger instance
- * @throws SQLException
- * if unable to create a logger instance
- */
- public static Log getLogger(String className, String instanceName, ExceptionInterceptor exceptionInterceptor)
- throws SQLException {
-
- if (className == null) {
- throw SQLError.createSQLException("Logger class can not be NULL",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- if (instanceName == null) {
- throw SQLError.createSQLException(
- "Logger instance name can not be NULL",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- }
-
- try {
- Class loggerClass = null;
-
- try {
- loggerClass = Class.forName(className);
- } catch (ClassNotFoundException nfe) {
- loggerClass = Class.forName(Log.class.getPackage().getName()
- + "." + className);
- }
-
- Constructor constructor = loggerClass
- .getConstructor(new Class[] { String.class });
-
- return (Log) constructor.newInstance(new Object[] { instanceName });
- } catch (ClassNotFoundException cnfe) {
- SQLException sqlEx = SQLError.createSQLException(
- "Unable to load class for logger '" + className + "'",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- sqlEx.initCause(cnfe);
-
- throw sqlEx;
- } catch (NoSuchMethodException nsme) {
- SQLException sqlEx = SQLError
- .createSQLException(
- "Logger class does not have a single-arg constructor that takes an instance name",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- sqlEx.initCause(nsme);
-
- throw sqlEx;
- } catch (InstantiationException inse) {
- SQLException sqlEx = SQLError.createSQLException(
- "Unable to instantiate logger class '" + className
- + "', exception in constructor?",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- sqlEx.initCause(inse);
-
- throw sqlEx;
- } catch (InvocationTargetException ite) {
- SQLException sqlEx = SQLError.createSQLException(
- "Unable to instantiate logger class '" + className
- + "', exception in constructor?",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- sqlEx.initCause(ite);
-
- throw sqlEx;
- } catch (IllegalAccessException iae) {
- SQLException sqlEx = SQLError.createSQLException(
- "Unable to instantiate logger class '" + className
- + "', constructor not public",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- sqlEx.initCause(iae);
-
- throw sqlEx;
- } catch (ClassCastException cce) {
- SQLException sqlEx = SQLError.createSQLException("Logger class '"
- + className + "' does not implement the '"
- + Log.class.getName() + "' interface",
- SQLError.SQL_STATE_ILLEGAL_ARGUMENT, exceptionInterceptor);
- sqlEx.initCause(cce);
-
- throw sqlEx;
- }
- }
-}
diff --git a/src/com/mysql/jdbc/log/LogUtils.java b/src/com/mysql/jdbc/log/LogUtils.java
deleted file mode 100644
index 4db481f66..000000000
--- a/src/com/mysql/jdbc/log/LogUtils.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- Copyright 2005-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-package com.mysql.jdbc.log;
-
-import com.mysql.jdbc.Util;
-import com.mysql.jdbc.profiler.ProfilerEvent;
-
-public class LogUtils {
-
- public static final String CALLER_INFORMATION_NOT_AVAILABLE = "Caller information not available";
-
- private static final String LINE_SEPARATOR = System
- .getProperty("line.separator");
-
- private static final int LINE_SEPARATOR_LENGTH = LINE_SEPARATOR.length();
-
- public static Object expandProfilerEventIfNecessary(
- Object possibleProfilerEvent) {
-
- if (possibleProfilerEvent instanceof ProfilerEvent) {
- StringBuffer msgBuf = new StringBuffer();
-
- ProfilerEvent evt = (ProfilerEvent) possibleProfilerEvent;
-
- Throwable locationException = evt.getEventCreationPoint();
-
- if (locationException == null) {
- locationException = new Throwable();
- }
-
- msgBuf.append("Profiler Event: [");
-
- boolean appendLocationInfo = false;
-
- switch (evt.getEventType()) {
- case ProfilerEvent.TYPE_EXECUTE:
- msgBuf.append("EXECUTE");
-
- break;
-
- case ProfilerEvent.TYPE_FETCH:
- msgBuf.append("FETCH");
-
- break;
-
- case ProfilerEvent.TYPE_OBJECT_CREATION:
- msgBuf.append("CONSTRUCT");
-
- break;
-
- case ProfilerEvent.TYPE_PREPARE:
- msgBuf.append("PREPARE");
-
- break;
-
- case ProfilerEvent.TYPE_QUERY:
- msgBuf.append("QUERY");
-
- break;
-
- case ProfilerEvent.TYPE_WARN:
- msgBuf.append("WARN");
- appendLocationInfo = true;
-
- break;
-
- case ProfilerEvent.TYPE_SLOW_QUERY:
- msgBuf.append("SLOW QUERY");
- appendLocationInfo = false;
-
- break;
-
- default:
- msgBuf.append("UNKNOWN");
- }
-
- msgBuf.append("] ");
- msgBuf.append(findCallingClassAndMethod(locationException));
- msgBuf.append(" duration: ");
- msgBuf.append(evt.getEventDuration());
- msgBuf.append(" ");
- msgBuf.append(evt.getDurationUnits());
- msgBuf.append(", connection-id: ");
- msgBuf.append(evt.getConnectionId());
- msgBuf.append(", statement-id: ");
- msgBuf.append(evt.getStatementId());
- msgBuf.append(", resultset-id: ");
- msgBuf.append(evt.getResultSetId());
-
- String evtMessage = evt.getMessage();
-
- if (evtMessage != null) {
- msgBuf.append(", message: ");
- msgBuf.append(evtMessage);
- }
-
- if (appendLocationInfo) {
- msgBuf
- .append("\n\nFull stack trace of location where event occurred:\n\n");
- msgBuf.append(Util.stackTraceToString(locationException));
- msgBuf.append("\n");
- }
-
- return msgBuf;
- }
-
- return possibleProfilerEvent;
- }
-
- public static String findCallingClassAndMethod(Throwable t) {
- String stackTraceAsString = Util.stackTraceToString(t);
-
- String callingClassAndMethod = CALLER_INFORMATION_NOT_AVAILABLE;
-
- int endInternalMethods = stackTraceAsString
- .lastIndexOf("com.mysql.jdbc");
-
- if (endInternalMethods != -1) {
- int endOfLine = -1;
- int compliancePackage = stackTraceAsString.indexOf(
- "com.mysql.jdbc.compliance", endInternalMethods);
-
- if (compliancePackage != -1) {
- endOfLine = compliancePackage - LINE_SEPARATOR_LENGTH;
- } else {
- endOfLine = stackTraceAsString.indexOf(LINE_SEPARATOR,
- endInternalMethods);
- }
-
- if (endOfLine != -1) {
- int nextEndOfLine = stackTraceAsString.indexOf(LINE_SEPARATOR,
- endOfLine + LINE_SEPARATOR_LENGTH);
-
- if (nextEndOfLine != -1) {
- callingClassAndMethod = stackTraceAsString.substring(
- endOfLine + LINE_SEPARATOR_LENGTH, nextEndOfLine);
- } else {
- callingClassAndMethod = stackTraceAsString
- .substring(endOfLine + LINE_SEPARATOR_LENGTH);
- }
- }
- }
-
- if (!callingClassAndMethod.startsWith("\tat ") &&
- !callingClassAndMethod.startsWith("at ")) {
- return "at " + callingClassAndMethod;
- }
-
- return callingClassAndMethod;
- }
-}
diff --git a/src/com/mysql/jdbc/log/NullLogger.java b/src/com/mysql/jdbc/log/NullLogger.java
deleted file mode 100644
index 70326777e..000000000
--- a/src/com/mysql/jdbc/log/NullLogger.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.log;
-
-/**
- * A logger that does nothing. Used before the log is configured via the URL or
- * properties.
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public class NullLogger implements Log {
-
- /**
- * Creates a new NullLogger with the given name
- *
- * @param instanceName
- * (ignored)
- */
- public NullLogger(String instanceName) {
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- // XXX Auto-generated method stub
- return false;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- // XXX Auto-generated method stub
- return false;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isFatalEnabled()
- */
- public boolean isFatalEnabled() {
- // XXX Auto-generated method stub
- return false;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- // XXX Auto-generated method stub
- return false;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isTraceEnabled()
- */
- public boolean isTraceEnabled() {
- // XXX Auto-generated method stub
- return false;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- // XXX Auto-generated method stub
- return false;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logDebug(java.lang.Object)
- */
- public void logDebug(Object msg) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logDebug(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logDebug(Object msg, Throwable thrown) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logError(java.lang.Object)
- */
- public void logError(Object msg) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logError(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logError(Object msg, Throwable thrown) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logFatal(java.lang.Object)
- */
- public void logFatal(Object msg) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logFatal(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logFatal(Object msg, Throwable thrown) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logInfo(java.lang.Object)
- */
- public void logInfo(Object msg) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logInfo(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logInfo(Object msg, Throwable thrown) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logTrace(java.lang.Object)
- */
- public void logTrace(Object msg) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logTrace(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logTrace(Object msg, Throwable thrown) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logWarn(java.lang.Object)
- */
- public void logWarn(Object msg) {
- // XXX Auto-generated method stub
-
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#logWarn(java.lang.Object,
- * java.lang.Throwable)
- */
- public void logWarn(Object msg, Throwable thrown) {
- // XXX Auto-generated method stub
-
- }
-
-}
diff --git a/src/com/mysql/jdbc/log/StandardLogger.java b/src/com/mysql/jdbc/log/StandardLogger.java
deleted file mode 100644
index e3259d54e..000000000
--- a/src/com/mysql/jdbc/log/StandardLogger.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.log;
-
-import java.util.Date;
-
-import com.mysql.jdbc.Util;
-import com.mysql.jdbc.profiler.ProfilerEvent;
-
-/**
- * Provides logging facilities for those platforms that don't have built-in
- * facilities. Simply logs messages to STDERR.
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public class StandardLogger implements Log {
- private static final int FATAL = 0;
-
- private static final int ERROR = 1;
-
- private static final int WARN = 2;
-
- private static final int INFO = 3;
-
- private static final int DEBUG = 4;
-
- private static final int TRACE = 5;
-
- public static StringBuffer bufferedLog = null;
-
- private boolean logLocationInfo = true;
-
- /**
- * Creates a new StandardLogger object.
- *
- * @param name
- * the name of the configuration to use -- ignored
- */
- public StandardLogger(String name) {
- this(name, false);
- }
-
- public StandardLogger(String name, boolean logLocationInfo) {
- this.logLocationInfo = logLocationInfo;
- }
-
- public static void saveLogsToBuffer() {
- if (bufferedLog == null) {
- bufferedLog = new StringBuffer();
- }
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- return true;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- return true;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isFatalEnabled()
- */
- public boolean isFatalEnabled() {
- return true;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- return true;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isTraceEnabled()
- */
- public boolean isTraceEnabled() {
- return true;
- }
-
- /**
- * @see com.mysql.jdbc.log.Log#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- return true;
- }
-
- /**
- * Logs the given message instance using the 'debug' level
- *
- * @param message
- * the message to log
- */
- public void logDebug(Object message) {
- logInternal(DEBUG, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'debug' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logDebug(Object message, Throwable exception) {
- logInternal(DEBUG, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'error' level
- *
- * @param message
- * the message to log
- */
- public void logError(Object message) {
- logInternal(ERROR, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'error' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logError(Object message, Throwable exception) {
- logInternal(ERROR, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'fatal' level
- *
- * @param message
- * the message to log
- */
- public void logFatal(Object message) {
- logInternal(FATAL, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'fatal' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logFatal(Object message, Throwable exception) {
- logInternal(FATAL, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'info' level
- *
- * @param message
- * the message to log
- */
- public void logInfo(Object message) {
- logInternal(INFO, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'info' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logInfo(Object message, Throwable exception) {
- logInternal(INFO, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'trace' level
- *
- * @param message
- * the message to log
- */
- public void logTrace(Object message) {
- logInternal(TRACE, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'trace' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logTrace(Object message, Throwable exception) {
- logInternal(TRACE, message, exception);
- }
-
- /**
- * Logs the given message instance using the 'warn' level
- *
- * @param message
- * the message to log
- */
- public void logWarn(Object message) {
- logInternal(WARN, message, null);
- }
-
- /**
- * Logs the given message and Throwable at the 'warn' level.
- *
- * @param message
- * the message to log
- * @param exception
- * the throwable to log (may be null)
- */
- public void logWarn(Object message, Throwable exception) {
- logInternal(WARN, message, exception);
- }
-
- private void logInternal(int level, Object msg, Throwable exception) {
- StringBuffer msgBuf = new StringBuffer();
- msgBuf.append(new Date().toString());
- msgBuf.append(" ");
-
- switch (level) {
- case FATAL:
- msgBuf.append("FATAL: ");
-
- break;
-
- case ERROR:
- msgBuf.append("ERROR: ");
-
- break;
-
- case WARN:
- msgBuf.append("WARN: ");
-
- break;
-
- case INFO:
- msgBuf.append("INFO: ");
-
- break;
-
- case DEBUG:
- msgBuf.append("DEBUG: ");
-
- break;
-
- case TRACE:
- msgBuf.append("TRACE: ");
-
- break;
- }
-
- if (msg instanceof ProfilerEvent) {
- msgBuf.append(LogUtils.expandProfilerEventIfNecessary(msg));
-
- } else {
- if (this.logLocationInfo && level != TRACE) {
- Throwable locationException = new Throwable();
- msgBuf.append(LogUtils
- .findCallingClassAndMethod(locationException));
- msgBuf.append(" ");
- }
-
- if (msg != null) {
- msgBuf.append(String.valueOf(msg));
- }
- }
-
- if (exception != null) {
- msgBuf.append("\n");
- msgBuf.append("\n");
- msgBuf.append("EXCEPTION STACK TRACE:");
- msgBuf.append("\n");
- msgBuf.append("\n");
- msgBuf.append(Util.stackTraceToString(exception));
- }
-
- String messageAsString = msgBuf.toString();
-
- System.err.println(messageAsString);
-
- if (bufferedLog != null) {
- bufferedLog.append(messageAsString);
- }
- }
-}
diff --git a/src/com/mysql/jdbc/profiler/LoggingProfilerEventHandler.java b/src/com/mysql/jdbc/profiler/LoggingProfilerEventHandler.java
deleted file mode 100644
index b904cf4e6..000000000
--- a/src/com/mysql/jdbc/profiler/LoggingProfilerEventHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.profiler;
-
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.log.Log;
-
-/**
- * A profile event handler that just logs to the standard
- * logging mechanism of the JDBC driver.
- *
- */
-public class LoggingProfilerEventHandler implements ProfilerEventHandler {
- private Log log;
-
- public LoggingProfilerEventHandler() {}
-
- public void consumeEvent(ProfilerEvent evt) {
- if (evt.eventType == ProfilerEvent.TYPE_WARN) {
- this.log.logWarn(evt);
- } else {
- this.log.logInfo(evt);
- }
- }
-
- public void destroy() {
- this.log = null;
- }
-
- public void init(Connection conn, Properties props) throws SQLException {
- this.log = conn.getLog();
- }
-
-}
diff --git a/src/com/mysql/jdbc/profiler/ProfilerEvent.java b/src/com/mysql/jdbc/profiler/ProfilerEvent.java
deleted file mode 100644
index 0a099f5a4..000000000
--- a/src/com/mysql/jdbc/profiler/ProfilerEvent.java
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.profiler;
-
-import java.util.Date;
-
-import com.mysql.jdbc.Util;
-
-/**
- * @author mmatthew
- */
-public class ProfilerEvent {
-
- /**
- * A Profiler warning event
- */
- public static final byte TYPE_WARN = 0;
-
- /**
- * Profiler creating object type event
- */
- public static final byte TYPE_OBJECT_CREATION = 1;
-
- /**
- * Profiler event for prepared statements being prepared
- */
- public static final byte TYPE_PREPARE = 2;
-
- /**
- * Profiler event for a query being executed
- */
- public static final byte TYPE_QUERY = 3;
-
- /**
- * Profiler event for prepared statements being executed
- */
- public static final byte TYPE_EXECUTE = 4;
-
- /**
- * Profiler event for result sets being retrieved
- */
- public static final byte TYPE_FETCH = 5;
-
- /**
- * Profiler event for slow query
- */
- public static final byte TYPE_SLOW_QUERY = 6;
-
- /**
- * Type of event
- */
- protected byte eventType;
-
- /**
- * Associated connection (-1 for none)
- */
- protected long connectionId;
-
- /**
- * Associated statement (-1 for none)
- */
- protected int statementId;
-
- /**
- * Associated result set (-1 for none)
- */
- protected int resultSetId;
-
- /**
- * When was the event created?
- */
- protected long eventCreationTime;
-
- /**
- * How long did the event last?
- */
- protected long eventDuration;
-
- /**
- * What units was the duration measured in?
- */
- protected String durationUnits;
-
- /**
- * The hostname the event occurred on (as an index into a dictionary, used
- * by 'remote' profilers for efficiency)?
- */
- protected int hostNameIndex;
-
- /**
- * The hostname the event occurred on
- */
- protected String hostName;
-
- /**
- * The catalog the event occurred on (as an index into a dictionary, used by
- * 'remote' profilers for efficiency)?
- */
- protected int catalogIndex;
-
- /**
- * The catalog the event occurred on
- */
- protected String catalog;
-
- /**
- * Where was the event created (as an index into a dictionary, used by
- * 'remote' profilers for efficiency)?
- */
- protected int eventCreationPointIndex;
-
- /**
- * Where was the event created (as a Throwable)?
- */
- protected Throwable eventCreationPoint;
-
- /**
- * Where was the event created (as a string description of the
- * eventCreationPoint)?
- */
- protected String eventCreationPointDesc;
-
- /**
- * Optional event message
- */
- protected String message;
-
- /**
- * Creates a new profiler event
- *
- * @param eventType
- * the event type (from the constants TYPE_????)
- * @param hostName
- * the hostname where the event occurs
- * @param catalog
- * the catalog in use
- * @param connectionId
- * the connection id (-1 if N/A)
- * @param statementId
- * the statement id (-1 if N/A)
- * @param resultSetId
- * the result set id (-1 if N/A)
- * @param eventCreationTime
- * when was the event created?
- * @param eventDurationMillis
- * how long did the event last?
- * @param eventCreationPointDesc
- * event creation point as a string
- * @param eventCreationPoint
- * event creation point as a Throwable
- * @param message
- * optional message
- */
- public ProfilerEvent(byte eventType, String hostName, String catalog,
- long connectionId, int statementId, int resultSetId,
- long eventCreationTime, long eventDuration, String durationUnits,
- String eventCreationPointDesc, Throwable eventCreationPoint,
- String message) {
- this.eventType = eventType;
- this.connectionId = connectionId;
- this.statementId = statementId;
- this.resultSetId = resultSetId;
- this.eventCreationTime = eventCreationTime;
- this.eventDuration = eventDuration;
- this.durationUnits = durationUnits;
- this.eventCreationPoint = eventCreationPoint;
- this.eventCreationPointDesc = eventCreationPointDesc;
- this.message = message;
- }
-
- /**
- * Returns the description of when this event was created.
- *
- * @return a description of when this event was created.
- */
- public String getEventCreationPointAsString() {
- if (this.eventCreationPointDesc == null) {
- this.eventCreationPointDesc = Util
- .stackTraceToString(this.eventCreationPoint);
- }
-
- return this.eventCreationPointDesc;
- }
-
- /**
- * Returns a representation of this event as a String.
- *
- * @return a String representation of this event.
- */
- public String toString() {
- StringBuffer buf = new StringBuffer(32);
-
- switch (this.eventType) {
- case TYPE_EXECUTE:
- buf.append("EXECUTE");
- break;
-
- case TYPE_FETCH:
- buf.append("FETCH");
- break;
-
- case TYPE_OBJECT_CREATION:
- buf.append("CONSTRUCT");
- break;
-
- case TYPE_PREPARE:
- buf.append("PREPARE");
- break;
-
- case TYPE_QUERY:
- buf.append("QUERY");
- break;
-
- case TYPE_WARN:
- buf.append("WARN");
- break;
- case TYPE_SLOW_QUERY:
- buf.append("SLOW QUERY");
- break;
- default:
- buf.append("UNKNOWN");
- }
-
- buf.append(" created: ");
- buf.append(new Date(this.eventCreationTime));
- buf.append(" duration: ");
- buf.append(this.eventDuration);
- buf.append(" connection: ");
- buf.append(this.connectionId);
- buf.append(" statement: ");
- buf.append(this.statementId);
- buf.append(" resultset: ");
- buf.append(this.resultSetId);
-
- if (this.message != null) {
- buf.append(" message: ");
- buf.append(this.message);
-
- }
-
- if (this.eventCreationPointDesc != null) {
- buf.append("\n\nEvent Created at:\n");
- buf.append(this.eventCreationPointDesc);
- }
-
- return buf.toString();
- }
-
- /**
- * Unpacks a binary representation of this event.
- *
- * @param buf
- * the binary representation of this event
- * @return the unpacked Event
- * @throws Exception
- * if an error occurs while unpacking the event
- */
- public static ProfilerEvent unpack(byte[] buf) throws Exception {
- int pos = 0;
-
- byte eventType = buf[pos++];
- long connectionId = readInt(buf, pos);
- pos += 8;
- int statementId = readInt(buf, pos);
- pos += 4;
- int resultSetId = readInt(buf, pos);
- pos += 4;
- long eventCreationTime = readLong(buf, pos);
- pos += 8;
- long eventDuration = readLong(buf, pos);
- pos += 4;
-
- byte[] eventDurationUnits = readBytes(buf, pos);
- pos += 4;
-
- if (eventDurationUnits != null) {
- pos += eventDurationUnits.length;
- }
-
- int eventCreationPointIndex = readInt(buf, pos);
- pos += 4;
- byte[] eventCreationAsBytes = readBytes(buf, pos);
- pos += 4;
-
- if (eventCreationAsBytes != null) {
- pos += eventCreationAsBytes.length;
- }
-
- byte[] message = readBytes(buf, pos);
- pos += 4;
-
- if (message != null) {
- pos += message.length;
- }
-
- return new ProfilerEvent(eventType, "", "", connectionId, statementId,
- resultSetId, eventCreationTime, eventDuration,
- new String(eventDurationUnits, "ISO8859_1"),
- new String(eventCreationAsBytes, "ISO8859_1"), null,
- new String(message, "ISO8859_1"));
- }
-
- /**
- * Creates a binary representation of this event.
- *
- * @return a binary representation of this event
- * @throws Exception
- * if an error occurs while packing this event.
- */
- public byte[] pack() throws Exception {
-
- int len = 1 + 4 + 4 + 4 + 8 + 4 + 4;
-
- byte[] eventCreationAsBytes = null;
-
- getEventCreationPointAsString();
-
- if (this.eventCreationPointDesc != null) {
- eventCreationAsBytes = this.eventCreationPointDesc
- .getBytes("ISO8859_1");
- len += (4 + eventCreationAsBytes.length);
- } else {
- len += 4;
- }
-
- byte[] messageAsBytes = null;
-
- if (messageAsBytes != null) {
- messageAsBytes = this.message.getBytes("ISO8859_1");
- len += (4 + messageAsBytes.length);
- } else {
- len += 4;
- }
-
- byte[] durationUnitsAsBytes = null;
-
- if (durationUnits != null) {
- durationUnitsAsBytes = this.durationUnits.getBytes("ISO8859_1");
- len += (4 + durationUnitsAsBytes.length);
- } else {
- len += 4;
- }
-
- byte[] buf = new byte[len];
-
- int pos = 0;
-
- buf[pos++] = this.eventType;
- pos = writeLong(this.connectionId, buf, pos);
- pos = writeInt(this.statementId, buf, pos);
- pos = writeInt(this.resultSetId, buf, pos);
- pos = writeLong(this.eventCreationTime, buf, pos);
- pos = writeLong(this.eventDuration, buf, pos);
- pos = writeBytes(durationUnitsAsBytes, buf, pos);
- pos = writeInt(this.eventCreationPointIndex, buf, pos);
-
- if (eventCreationAsBytes != null) {
- pos = writeBytes(eventCreationAsBytes, buf, pos);
- } else {
- pos = writeInt(0, buf, pos);
- }
-
- if (messageAsBytes != null) {
- pos = writeBytes(messageAsBytes, buf, pos);
- } else {
- pos = writeInt(0, buf, pos);
- }
-
- return buf;
- }
-
- private static int writeInt(int i, byte[] buf, int pos) {
-
- buf[pos++] = (byte) (i & 0xff);
- buf[pos++] = (byte) (i >>> 8);
- buf[pos++] = (byte) (i >>> 16);
- buf[pos++] = (byte) (i >>> 24);
-
- return pos;
- }
-
- private static int writeLong(long l, byte[] buf, int pos) {
- buf[pos++] = (byte) (l & 0xff);
- buf[pos++] = (byte) (l >>> 8);
- buf[pos++] = (byte) (l >>> 16);
- buf[pos++] = (byte) (l >>> 24);
- buf[pos++] = (byte) (l >>> 32);
- buf[pos++] = (byte) (l >>> 40);
- buf[pos++] = (byte) (l >>> 48);
- buf[pos++] = (byte) (l >>> 56);
-
- return pos;
- }
-
- private static int writeBytes(byte[] msg, byte[] buf, int pos) {
- pos = writeInt(msg.length, buf, pos);
-
- System.arraycopy(msg, 0, buf, pos, msg.length);
-
- return pos + msg.length;
- }
-
- private static int readInt(byte[] buf, int pos) {
- return (buf[pos++] & 0xff) | ((buf[pos++] & 0xff) << 8)
- | ((buf[pos++] & 0xff) << 16) | ((buf[pos++] & 0xff) << 24);
-
- }
-
- private static long readLong(byte[] buf, int pos) {
- return (long) (buf[pos++] & 0xff) | ((long) (buf[pos++] & 0xff) << 8)
- | ((long) (buf[pos++] & 0xff) << 16)
- | ((long) (buf[pos++] & 0xff) << 24)
- | ((long) (buf[pos++] & 0xff) << 32)
- | ((long) (buf[pos++] & 0xff) << 40)
- | ((long) (buf[pos++] & 0xff) << 48)
- | ((long) (buf[pos++] & 0xff) << 56);
- }
-
- private static byte[] readBytes(byte[] buf, int pos) {
- int length = readInt(buf, pos);
-
- pos += 4;
-
- byte[] msg = new byte[length];
- System.arraycopy(buf, pos, msg, 0, length);
-
- return msg;
- }
-
- /**
- * Returns the catalog in use
- *
- * @return the catalog in use
- */
- public String getCatalog() {
- return this.catalog;
- }
-
- /**
- * Returns the id of the connection in use when this event was created.
- *
- * @return the connection in use
- */
- public long getConnectionId() {
- return this.connectionId;
- }
-
- /**
- * Returns the point (as a Throwable stacktrace) where this event was
- * created.
- *
- * @return the point where this event was created
- */
- public Throwable getEventCreationPoint() {
- return this.eventCreationPoint;
- }
-
- /**
- * Returns the time (in System.currentTimeMillis() form) when this event was
- * created
- *
- * @return the time this event was created
- */
- public long getEventCreationTime() {
- return this.eventCreationTime;
- }
-
- /**
- * Returns the duration of the event in milliseconds
- *
- * @return the duration of the event in milliseconds
- */
- public long getEventDuration() {
- return this.eventDuration;
- }
-
- /**
- * Returns the units for getEventDuration()
- */
- public String getDurationUnits() {
- return this.durationUnits;
- }
-
- /**
- * Returns the event type flag
- *
- * @return the event type flag
- */
- public byte getEventType() {
- return this.eventType;
- }
-
- /**
- * Returns the id of the result set in use when this event was created.
- *
- * @return the result set in use
- */
- public int getResultSetId() {
- return this.resultSetId;
- }
-
- /**
- * Returns the id of the statement in use when this event was created.
- *
- * @return the statement in use
- */
- public int getStatementId() {
- return this.statementId;
- }
-
- /**
- * Returns the optional message for this event
- *
- * @return the message stored in this event
- */
- public String getMessage() {
- return this.message;
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/profiler/ProfilerEventHandler.java b/src/com/mysql/jdbc/profiler/ProfilerEventHandler.java
deleted file mode 100644
index 7f9533f99..000000000
--- a/src/com/mysql/jdbc/profiler/ProfilerEventHandler.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright 2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.profiler;
-
-import com.mysql.jdbc.Extension;
-
-public interface ProfilerEventHandler extends Extension {
-
- public void consumeEvent(ProfilerEvent evt);
-}
diff --git a/src/com/mysql/jdbc/profiler/ProfilerEventHandlerFactory.java b/src/com/mysql/jdbc/profiler/ProfilerEventHandlerFactory.java
deleted file mode 100644
index 29cda83ea..000000000
--- a/src/com/mysql/jdbc/profiler/ProfilerEventHandlerFactory.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Copyright 2002-2007 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- */
-
-package com.mysql.jdbc.profiler;
-
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.mysql.jdbc.Connection;
-import com.mysql.jdbc.ConnectionImpl;
-import com.mysql.jdbc.Util;
-import com.mysql.jdbc.log.Log;
-
-/**
- * @author mmatthew
- */
-public class ProfilerEventHandlerFactory {
-
- private static final Map CONNECTIONS_TO_SINKS = new HashMap();
-
- private Connection ownerConnection = null;
-
- private Log log = null;
-
- /**
- * Returns the ProfilerEventHandlerFactory that handles profiler events for the given
- * connection.
- *
- * @param conn
- * the connection to handle events for
- * @return the ProfilerEventHandlerFactory that handles profiler events
- */
- public static synchronized ProfilerEventHandler getInstance(ConnectionImpl conn) throws SQLException {
- ProfilerEventHandler handler = (ProfilerEventHandler) CONNECTIONS_TO_SINKS
- .get(conn);
-
- if (handler == null) {
- handler = (ProfilerEventHandler)Util.getInstance(conn.getProfilerEventHandler(), new Class[0], new Object[0], conn.getExceptionInterceptor());
-
- // we do it this way to not require
- // exposing the connection properties
- // for all who utilize it
- conn.initializeExtension(handler);
-
- CONNECTIONS_TO_SINKS.put(conn, handler);
- }
-
- return handler;
- }
-
- public static synchronized void removeInstance(Connection conn) {
- ProfilerEventHandler handler = (ProfilerEventHandler) CONNECTIONS_TO_SINKS.remove(conn);
-
- if (handler != null) {
- handler.destroy();
- }
- }
-
- private ProfilerEventHandlerFactory(Connection conn) {
- this.ownerConnection = conn;
-
- try {
- this.log = this.ownerConnection.getLog();
- } catch (SQLException sqlEx) {
- throw new RuntimeException("Unable to get logger from connection");
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/util/BaseBugReport.java b/src/com/mysql/jdbc/util/BaseBugReport.java
deleted file mode 100644
index 4f4f9a0e5..000000000
--- a/src/com/mysql/jdbc/util/BaseBugReport.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.util;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.mysql.jdbc.Driver;
-
-/**
- * Base class to help file bug reports for Connector/J.
- *
- *
- * MySQL AB, 2008 Sun Microsystems
- *
- * really
- *
- * appreciates repeatable testcases when reporting bugs, so we're giving you
- * this class to make that job a bit easier (and standarized).
- *
- *
- * To create a testcase, create a class that inherits from this class
- * (com.mysql.jdbc.util.BaseBugReport), and override the methods 'setUp',
- * 'tearDown' and 'runTest'.
- *
- *
- * In the 'setUp' method, create code that creates your tables, and populates
- * them with any data needed to demonstrate the bug.
- *
- *
- * In the 'runTest' method, create code that demonstrates the bug using the
- * tables and data you created in the 'setUp' method.
- *
- *
- * In the 'tearDown' method, drop any tables you created in the 'setUp' method.
- *
- *
- * In any of the above three methods, you should use one of the variants of the
- * 'getConnection' method to create a JDBC connection to MySQL, which will use
- * the default JDBC URL of 'jdbc:mysql:///test'.
- *
- *
- * If you need to use a JDBC URL that is different than 'jdbc:mysql:///test',
- * then override the method 'getUrl' as well.
- *
- *
- * Use the 'assertTrue' methods to create conditions that must be met in your
- * testcase demonstrating the behavior you are expecting (vs. the behavior you
- * are observing, which is why you are most likely filing a bug report).
- *
- *
- * Finally, create a 'main' method that creates a new instance of your testcase,
- * and calls the 'run' method:
- *
- *
- *
- *
- * public static void main(String[] args) throws Exception {
- * new MyBugReport().run();
- * }
- *
- *
- *
- * When filing a potential bug with MySQL Connector/J at http://bugs.mysql.com/
- * or on the bugs mailing list, please include the code that you have just
- * written using this class.
- *
- * @author Mark Matthews
- * @version $Id$
- */
-public abstract class BaseBugReport {
-
- private Connection conn;
-
- private Driver driver;
-
- /**
- * Constructor for this BugReport, sets up JDBC driver used to create
- * connections.
- */
- public BaseBugReport() {
- try {
- this.driver = new Driver();
- } catch (SQLException ex) {
- throw new RuntimeException(ex.toString());
- }
- }
-
- /**
- * Override this method with code that sets up the testcase for
- * demonstrating your bug (creating tables, populating data, etc).
- *
- * @throws Exception
- * if an error occurs during the 'setUp' phase.
- */
- public abstract void setUp() throws Exception;
-
- /**
- * Override this method with code that cleans up anything created in the
- * setUp() method.
- *
- * @throws Exception
- * if an error occurs during the 'tearDown' phase.
- */
- public abstract void tearDown() throws Exception;
-
- /**
- * Override this method with code that demonstrates the bug. This method
- * will be called after setUp(), and before tearDown().
- *
- * @throws Exception
- * if an error occurs during your test run.
- */
- public abstract void runTest() throws Exception;
-
- /**
- * Runs the testcase by calling the setUp(), runTest() and tearDown()
- * methods. The tearDown() method is run regardless of any errors occuring
- * in the other methods.
- *
- * @throws Exception
- * if an error occurs in any of the aforementioned methods.
- */
- public final void run() throws Exception {
- try {
- setUp();
- runTest();
-
- } finally {
- tearDown();
- }
- }
-
- /**
- * Throws an exception with the given message if condition evalutates to
- * 'false'.
- *
- * @param message
- * the message to use in the exception
- * @param condition
- * the condition to test for
- * @throws Exception
- * if !condition
- */
- protected final void assertTrue(String message, boolean condition)
- throws Exception {
- if (!condition) {
- throw new Exception("Assertion failed: " + message);
- }
- }
-
- /**
- * Throws an exception if condition evalutates to 'false'.
- *
- * @param condition
- * the condition to test for
- * @throws Exception
- * if !condition
- */
- protected final void assertTrue(boolean condition) throws Exception {
- assertTrue("(no message given)", condition);
- }
-
- /**
- * Provides the JDBC URL to use to demonstrate the bug. The
- * java.sql.Connection that you use to demonstrate this bug will be provided
- * by the getConnection() method using this URL.
- *
- * The default value is 'jdbc:mysql:///test'
- */
- public String getUrl() {
- return "jdbc:mysql:///test";
- }
-
- /**
- * Provides a connection to the JDBC URL specified in getUrl().
- *
- * If a connection already exists, that connection is returned. Otherwise a
- * new connection is created.
- *
- * @return a connection to the JDBC URL specified in getUrl().
- *
- * @throws SQLException
- * if an error is caused while creating the connection.
- */
- public final synchronized Connection getConnection() throws SQLException {
- if (this.conn == null || this.conn.isClosed()) {
- this.conn = getNewConnection();
- }
-
- return this.conn;
- }
-
- /**
- * Use this if you need to get a new connection for your bug report (i.e.
- * there's more than one connection involved).
- *
- * @return a new connection to the JDBC URL specified in getUrl().
- *
- * @throws SQLException
- * if an error is caused while creating the connection.
- */
- public final synchronized Connection getNewConnection() throws SQLException {
- return getConnection(getUrl());
- }
-
- /**
- * Returns a connection using the given URL.
- *
- * @param url
- * the JDBC URL to use
- * @return a new java.sql.Connection to the JDBC URL.
- * @throws SQLException
- * if an error occurs getting the connection.
- */
- public final synchronized Connection getConnection(String url)
- throws SQLException {
- return getConnection(url, null);
- }
-
- /**
- * Returns a connection using the given URL and properties.
- *
- * @param url
- * the JDBC URL to use
- * @param props
- * the JDBC properties to use
- * @return a new java.sql.Connection to the JDBC URL.
- * @throws SQLException
- * if an error occurs getting the connection.
- */
- public final synchronized Connection getConnection(String url,
- Properties props) throws SQLException {
-
- // Don't follow this example in your own code
- // This is to bypass the java.sql.DriverManager
-
- return this.driver.connect(url, props);
- }
-}
\ No newline at end of file
diff --git a/src/com/mysql/jdbc/util/ErrorMappingsDocGenerator.java b/src/com/mysql/jdbc/util/ErrorMappingsDocGenerator.java
deleted file mode 100644
index a0807accc..000000000
--- a/src/com/mysql/jdbc/util/ErrorMappingsDocGenerator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.util;
-
-import com.mysql.jdbc.SQLError;
-
-/**
- * Creates XML file describing mapping of MySQL error #'s to SQL92 and X/Open
- * states.
- *
- * @author Mark Matthews
- *
- * @version $Id: ErrorMappingsDocGenerator.java,v 1.1.2.1 2005/05/13 18:58:39
- * mmatthews Exp $
- */
-public class ErrorMappingsDocGenerator {
-
- public static void main(String[] args) throws Exception {
- SQLError.dumpSqlStatesMappingsAsXml();
- }
-}
diff --git a/src/com/mysql/jdbc/util/LRUCache.java b/src/com/mysql/jdbc/util/LRUCache.java
deleted file mode 100644
index 854e258d4..000000000
--- a/src/com/mysql/jdbc/util/LRUCache.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.util;
-
-import java.util.LinkedHashMap;
-import java.util.Map.Entry;
-
-/**
- * @author Mark Matthews
- * @version $Id$
- */
-public class LRUCache extends LinkedHashMap {
- private static final long serialVersionUID = 1L;
- protected int maxElements;
-
- public LRUCache(int maxSize) {
- super(maxSize);
- this.maxElements = maxSize;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.LinkedHashMap#removeEldestEntry(java.util.Map.Entry)
- */
- protected boolean removeEldestEntry(Entry eldest) {
- return (size() > this.maxElements);
- }
-}
diff --git a/src/com/mysql/jdbc/util/PropertiesDocGenerator.java b/src/com/mysql/jdbc/util/PropertiesDocGenerator.java
deleted file mode 100644
index 441c403d7..000000000
--- a/src/com/mysql/jdbc/util/PropertiesDocGenerator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.util;
-
-import java.sql.SQLException;
-
-import com.mysql.jdbc.ConnectionPropertiesImpl;
-
-/**
- * Creates docbook table of connection properties from ConnectionProperties
- * class.
- */
-public class PropertiesDocGenerator extends ConnectionPropertiesImpl {
-
- public static void main(String[] args) throws SQLException {
- System.out.println(new PropertiesDocGenerator().exposeAsXml());
- }
-}
diff --git a/src/com/mysql/jdbc/util/ReadAheadInputStream.java b/src/com/mysql/jdbc/util/ReadAheadInputStream.java
deleted file mode 100644
index 7138ed46f..000000000
--- a/src/com/mysql/jdbc/util/ReadAheadInputStream.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- Copyright 2002-2005 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
- */
-
-package com.mysql.jdbc.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.mysql.jdbc.log.Log;
-
-/**
- * A non-blocking buffered input stream. Reads more if it can, won't block to
- * fill the buffer, only blocks to satisfy a request of read(byte[])
- *
- * @author Mark Matthews
- *
- * @version $Id: ReadAheadInputStream.java,v 1.1.2.1 2005/05/13 18:58:39
- * mmatthews Exp $
- */
-public class ReadAheadInputStream extends InputStream {
-
- private final static int DEFAULT_BUFFER_SIZE = 4096;
-
- private InputStream underlyingStream;
-
- private byte buf[];
-
- protected int endOfCurrentData;
-
- protected int currentPosition;
-
- protected boolean doDebug = false;
-
- protected Log log;
-
- private void fill(int readAtLeastTheseManyBytes) throws IOException {
- checkClosed();
-
- this.currentPosition = 0; /* no mark: throw away the buffer */
-
- this.endOfCurrentData = currentPosition;
-
- // Read at least as many bytes as the caller wants, but don't
- // block to fill the whole buffer (like java.io.BufferdInputStream
- // does)
-
- int bytesToRead = Math.min(this.buf.length - currentPosition,
- readAtLeastTheseManyBytes);
-
- int bytesAvailable = this.underlyingStream.available();
-
- if (bytesAvailable > bytesToRead) {
-
- // Great, there's more available, let's grab those
- // bytes too! (read-ahead)
-
- bytesToRead = Math.min(this.buf.length - currentPosition,
- bytesAvailable);
- }
-
- if (this.doDebug) {
- StringBuffer debugBuf = new StringBuffer();
- debugBuf.append(" ReadAheadInputStream.fill(");
- debugBuf.append(readAtLeastTheseManyBytes);
- debugBuf.append("), buffer_size=");
- debugBuf.append(this.buf.length);
- debugBuf.append(", current_position=");
- debugBuf.append(currentPosition);
- debugBuf.append(", need to read ");
- debugBuf.append(Math.min(this.buf.length - currentPosition,
- readAtLeastTheseManyBytes));
- debugBuf.append(" bytes to fill request,");
-
- if (bytesAvailable > 0) {
- debugBuf.append(" underlying InputStream reports ");
- debugBuf.append(bytesAvailable);
-
- debugBuf.append(" total bytes available,");
- }
-
- debugBuf.append(" attempting to read ");
- debugBuf.append(bytesToRead);
- debugBuf.append(" bytes.");
-
- if (this.log != null) {
- this.log.logTrace(debugBuf.toString());
- } else {
- System.err.println(debugBuf.toString());
- }
- }
-
- int n = this.underlyingStream.read(this.buf, currentPosition,
- bytesToRead);
-
- if (n > 0) {
- endOfCurrentData = n + currentPosition;
- }
- }
-
- private int readFromUnderlyingStreamIfNecessary(byte[] b, int off, int len)
- throws IOException {
- checkClosed();
-
- int avail = endOfCurrentData - currentPosition;
-
- if (this.doDebug) {
- StringBuffer debugBuf = new StringBuffer();
- debugBuf.append("ReadAheadInputStream.readIfNecessary(");
- debugBuf.append(b);
- debugBuf.append(",");
- debugBuf.append(off);
- debugBuf.append(",");
- debugBuf.append(len);
- debugBuf.append(")");
-
- if (avail <= 0) {
- debugBuf
- .append(" not all data available in buffer, must read from stream");
-
- if (len >= this.buf.length) {
- debugBuf
- .append(", amount requested > buffer, returning direct read() from stream");
- }
- }
-
- if (this.log != null) {
- this.log.logTrace(debugBuf.toString());
- } else {
- System.err.println(debugBuf.toString());
- }
- }
-
- if (avail <= 0) {
-
- if (len >= this.buf.length) {
- return this.underlyingStream.read(b, off, len);
- }
-
- fill(len);
-
- avail = endOfCurrentData - currentPosition;
-
- if (avail <= 0)
- return -1;
- }
-
- int bytesActuallyRead = (avail < len) ? avail : len;
-
- System.arraycopy(this.buf, currentPosition, b, off, bytesActuallyRead);
-
- this.currentPosition += bytesActuallyRead;
-
- return bytesActuallyRead;
- }
-
- public synchronized int read(byte b[], int off, int len) throws IOException {
- checkClosed(); // Check for closed stream
- if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return 0;
- }
-
- int totalBytesRead = 0;
-
- while (true) {
- int bytesReadThisRound = readFromUnderlyingStreamIfNecessary(b, off
- + totalBytesRead, len - totalBytesRead);
-
- // end-of-stream?
- if (bytesReadThisRound <= 0) {
- if (totalBytesRead == 0) {
- totalBytesRead = bytesReadThisRound;
- }
-
- break;
- }
-
- totalBytesRead += bytesReadThisRound;
-
- // Read _at_least_ enough bytes
- if (totalBytesRead >= len) {
- break;
- }
-
- // Nothing to read?
- if (this.underlyingStream.available() <= 0) {
- break;
- }
- }
-
- return totalBytesRead;
- }
-
- public int read() throws IOException {
- checkClosed();
-
- if (currentPosition >= endOfCurrentData) {
- fill(1);
- if (currentPosition >= endOfCurrentData)
- return -1;
- }
-
- return this.buf[currentPosition++] & 0xff;
- }
-
- public int available() throws IOException {
- checkClosed();
-
- return this.underlyingStream.available()
- + (this.endOfCurrentData - this.currentPosition);
- }
-
- private void checkClosed() throws IOException {
-
- if (this.buf == null) {
- throw new IOException("Stream closed");
- }
- }
-
- /**
- *
- */
- public ReadAheadInputStream(InputStream toBuffer, boolean debug, Log logTo) {
- this(toBuffer, DEFAULT_BUFFER_SIZE, debug, logTo);
- }
-
- public ReadAheadInputStream(InputStream toBuffer, int bufferSize,
- boolean debug,
- Log logTo) {
- this.underlyingStream = toBuffer;
- this.buf = new byte[bufferSize];
- this.doDebug = debug;
- this.log = logTo;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Closeable#close()
- */
- public void close() throws IOException {
- if (this.underlyingStream != null) {
- try {
- this.underlyingStream.close();
- } finally {
- this.underlyingStream = null;
- this.buf = null;
- this.log = null;
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#markSupported()
- */
- public boolean markSupported() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#skip(long)
- */
- public long skip(long n) throws IOException {
- checkClosed();
- if (n <= 0) {
- return 0;
- }
-
- long bytesAvailInBuffer = this.endOfCurrentData - this.currentPosition;
-
- if (bytesAvailInBuffer <= 0) {
-
- fill((int) n);
- bytesAvailInBuffer = this.endOfCurrentData - this.currentPosition;
- if (bytesAvailInBuffer <= 0)
- return 0;
- }
-
- long bytesSkipped = (bytesAvailInBuffer < n) ? bytesAvailInBuffer : n;
- this.currentPosition += bytesSkipped;
- return bytesSkipped;
- }
-}
diff --git a/src/com/mysql/jdbc/util/ResultSetUtil.java b/src/com/mysql/jdbc/util/ResultSetUtil.java
deleted file mode 100644
index 9af31eca1..000000000
--- a/src/com/mysql/jdbc/util/ResultSetUtil.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.util;
-
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-/**
- * Utilities for dealing with result sets (used in testcases and profiler).
- *
- * @author Mark Matthews
- *
- * @version $Id$
- */
-public class ResultSetUtil {
-
- public static StringBuffer appendResultSetSlashGStyle(
- StringBuffer appendTo, ResultSet rs) throws SQLException {
- ResultSetMetaData rsmd = rs.getMetaData();
-
- int numFields = rsmd.getColumnCount();
- int maxWidth = 0;
-
- String[] fieldNames = new String[numFields];
-
- for (int i = 0; i < numFields; i++) {
- fieldNames[i] = rsmd.getColumnLabel(i + 1);
-
- if (fieldNames[i].length() > maxWidth) {
- maxWidth = fieldNames[i].length();
- }
- }
-
- int rowCount = 1;
-
- while (rs.next()) {
- appendTo.append("*************************** ");
- appendTo.append(rowCount++);
- appendTo.append(". row ***************************\n");
-
- for (int i = 0; i < numFields; i++) {
- int leftPad = maxWidth - fieldNames[i].length();
-
- for (int j = 0; j < leftPad; j++) {
- appendTo.append(" ");
- }
-
- appendTo.append(fieldNames[i]);
- appendTo.append(": ");
-
- String stringVal = rs.getString(i + 1);
-
- if (stringVal != null) {
- appendTo.append(stringVal);
- } else {
- appendTo.append("NULL");
- }
-
- appendTo.append("\n");
- }
-
- appendTo.append("\n");
- }
-
- return appendTo;
- }
-}
diff --git a/src/com/mysql/jdbc/util/ServerController.java b/src/com/mysql/jdbc/util/ServerController.java
deleted file mode 100644
index 42955007d..000000000
--- a/src/com/mysql/jdbc/util/ServerController.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Properties;
-
-import com.mysql.jdbc.StringUtils;
-
-/**
- * Controls a MySQL server using Java RunTime methods
- *
- * @version $Id: ServerController.java,v 1.1.2.1 2005/05/13 18:58:39 mmatthews
- * Exp $
- * @author Mark Matthews
- */
-public class ServerController {
-
- /**
- * Where is the server installed?
- */
- public static final String BASEDIR_KEY = "basedir";
-
- /**
- * Where are the databases installed?
- */
- public static final String DATADIR_KEY = "datadir";
-
- /**
- * Where is the config file located?
- */
-
- public static final String DEFAULTS_FILE_KEY = "defaults-file";
-
- /**
- * What is the name of the executable to run?
- */
-
- public static final String EXECUTABLE_NAME_KEY = "executable";
-
- /**
- * What is the path to the mysql server executable (if not standard?)
- */
-
- public static final String EXECUTABLE_PATH_KEY = "executablePath";
-
- /**
- * The default executable to run
- */
-
- /**
- * The process representing the MySQL server
- */
- private Process serverProcess = null;
-
- /**
- * The list of properties for this server
- */
- private Properties serverProps = null;
-
- /**
- * The system properties
- */
- private Properties systemProps = null;
-
- /**
- * Creates a ServerController with the directory for the MySQL server.
- *
- * The 'datadir' is set to the same directory.
- *
- * @param baseDir
- * the base directory for the MySQL server.
- */
- public ServerController(String baseDir) {
- setBaseDir(baseDir);
- }
-
- /**
- * Creates a server controller for the MySQL server with the given basedir
- * and datadir.
- *
- * @param basedir
- * the basedir to use when starting MySQL.
- * @param datadir
- * the datadir to use when starting MySQL.
- */
- public ServerController(String basedir, String datadir) {
- }
-
- /**
- * Sets the basedir to use when starting MySQL.
- *
- * @param baseDir
- * the basedir to use when starting MySQL.
- */
- public void setBaseDir(String baseDir) {
- getServerProps().setProperty(BASEDIR_KEY, baseDir);
- }
-
- /**
- * Sets the data to use when starting MySQL.
- *
- * @param dataDir
- * the basedir to use when starting MySQL.
- */
- public void setDataDir(String dataDir) {
- getServerProps().setProperty(DATADIR_KEY, dataDir);
- }
-
- /**
- * Starts the server, returning a java.lang.Process instance that represents
- * the mysql server.
- *
- * @return Process a java.lang.Process instance representing the mysql
- * server process.
- * @throws IOException
- * if an error occurs while starting the mysql server.
- */
- public Process start() throws IOException {
- if (this.serverProcess != null) {
- throw new IllegalArgumentException("Server already started");
- } else {
- this.serverProcess = Runtime.getRuntime().exec(getCommandLine());
-
- return this.serverProcess;
- }
- }
-
- /**
- * Stops the server (if started)
- *
- * @param forceIfNecessary
- * use forceStop if mysqladmin doesn't shut the server down
- *
- * @throws IOException
- * if an error occurs while stopping the server
- */
- public void stop(boolean forceIfNecessary) throws IOException {
- if (this.serverProcess != null) {
-
- String basedir = getServerProps().getProperty(BASEDIR_KEY);
-
- StringBuffer pathBuf = new StringBuffer(basedir);
-
- if (!basedir.endsWith(File.separator)) {
- pathBuf.append(File.separator);
- }
-
- String defaultsFilePath = getServerProps().getProperty(
- DEFAULTS_FILE_KEY);
-
- pathBuf.append("bin");
- pathBuf.append(File.separator);
- pathBuf.append("mysqladmin shutdown");
-
- System.out.println(pathBuf.toString());
-
- Process mysqladmin = Runtime.getRuntime().exec(pathBuf.toString());
-
- int exitStatus = -1;
-
- try {
- exitStatus = mysqladmin.waitFor();
- } catch (InterruptedException ie) {
- ; // ignore
- }
-
- //
- // Terminate the process if mysqladmin couldn't
- // do it, and the user requested a force stop.
- //
- if (exitStatus != 0 && forceIfNecessary) {
- forceStop();
- }
- }
- }
-
- /**
- * Forcefully terminates the server process (if started).
- */
- public void forceStop() {
- if (this.serverProcess != null) {
- this.serverProcess.destroy();
- this.serverProcess = null;
- }
- }
-
- /**
- * Returns the list of properties that will be used to start/control the
- * server.
- *
- * @return Properties the list of properties.
- */
- public synchronized Properties getServerProps() {
- if (this.serverProps == null) {
- this.serverProps = new Properties();
- }
-
- return this.serverProps;
- }
-
- /**
- * Returns the full commandline used to start the mysql server, including
- * and arguments to be passed to the server process.
- *
- * @return String the commandline used to start the mysql server.
- */
- private String getCommandLine() {
- StringBuffer commandLine = new StringBuffer(getFullExecutablePath());
- commandLine.append(buildOptionalCommandLine());
-
- return commandLine.toString();
- }
-
- /**
- * Returns the fully-qualifed path to the 'mysqld' executable
- *
- * @return String the path to the server executable.
- */
- private String getFullExecutablePath() {
- StringBuffer pathBuf = new StringBuffer();
-
- String optionalExecutablePath = getServerProps().getProperty(
- EXECUTABLE_PATH_KEY);
-
- if (optionalExecutablePath == null) {
- // build the path using the defaults
- String basedir = getServerProps().getProperty(BASEDIR_KEY);
- pathBuf.append(basedir);
-
- if (!basedir.endsWith(File.separator)) {
- pathBuf.append(File.separatorChar);
- }
-
- if (runningOnWindows()) {
- pathBuf.append("bin");
- } else {
- pathBuf.append("libexec");
- }
-
- pathBuf.append(File.separatorChar);
- } else {
- pathBuf.append(optionalExecutablePath);
-
- if (!optionalExecutablePath.endsWith(File.separator)) {
- pathBuf.append(File.separatorChar);
- }
- }
-
- String executableName = getServerProps().getProperty(
- EXECUTABLE_NAME_KEY, "mysqld");
-
- pathBuf.append(executableName);
-
- return pathBuf.toString();
- }
-
- /**
- * Builds the list of command-line arguments that will be passed to the
- * mysql server to be started.
- *
- * @return String the list of command-line arguments.
- */
- private String buildOptionalCommandLine() {
- StringBuffer commandLineBuf = new StringBuffer();
-
- if (this.serverProps != null) {
-
- for (Iterator iter = this.serverProps.keySet().iterator(); iter
- .hasNext();) {
- String key = (String) iter.next();
- String value = this.serverProps.getProperty(key);
-
- if (!isNonCommandLineArgument(key)) {
- if (value != null && value.length() > 0) {
- commandLineBuf.append(" \"");
- commandLineBuf.append("--");
- commandLineBuf.append(key);
- commandLineBuf.append("=");
- commandLineBuf.append(value);
- commandLineBuf.append("\"");
- } else {
- commandLineBuf.append(" --");
- commandLineBuf.append(key);
- }
- }
- }
- }
-
- return commandLineBuf.toString();
- }
-
- /**
- * Returns true if the property does not belong as a command-line argument
- *
- * @return boolean if the property should not be a command-line argument.
- */
- private boolean isNonCommandLineArgument(String propName) {
- return propName.equals(EXECUTABLE_NAME_KEY)
- || propName.equals(EXECUTABLE_PATH_KEY);
- }
-
- /**
- * Lazily creates a list of system properties.
- *
- * @return Properties the properties from System.getProperties()
- */
- private synchronized Properties getSystemProperties() {
- if (this.systemProps == null) {
- this.systemProps = System.getProperties();
- }
-
- return this.systemProps;
- }
-
- /**
- * Is this ServerController running on a Windows operating system?
- *
- * @return boolean if this ServerController is running on Windows
- */
- private boolean runningOnWindows() {
- return StringUtils.indexOfIgnoreCase(getSystemProperties().getProperty(
- "os.name"), "WINDOWS") != -1;
- }
-}
diff --git a/src/com/mysql/jdbc/util/TimezoneDump.java b/src/com/mysql/jdbc/util/TimezoneDump.java
deleted file mode 100644
index 9b5dc13c5..000000000
--- a/src/com/mysql/jdbc/util/TimezoneDump.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- Copyright 2002-2004 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-
- */
-package com.mysql.jdbc.util;
-
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-
-import com.mysql.jdbc.TimeUtil;
-
-/**
- * Dumps the timezone of the MySQL server represented by the JDBC url given on
- * the commandline (or localhost/test if none provided).
- *
- * @author Mark Matthews
- */
-public class TimezoneDump {
- // ~ Static fields/initializers
- // ---------------------------------------------
-
- private static final String DEFAULT_URL = "jdbc:mysql:///test";
-
- // ~ Constructors
- // -----------------------------------------------------------
-
- /**
- * Constructor for TimezoneDump.
- */
- public TimezoneDump() {
- super();
- }
-
- // ~ Methods
- // ----------------------------------------------------------------
-
- /**
- * Entry point for program when called from the command line.
- *
- * @param args
- * command-line args. Arg 1 is JDBC URL.
- * @throws Exception
- * if any errors occur
- */
- public static void main(String[] args) throws Exception {
- String jdbcUrl = DEFAULT_URL;
-
- if ((args.length == 1) && (args[0] != null)) {
- jdbcUrl = args[0];
- }
-
- Class.forName("com.mysql.jdbc.Driver").newInstance();
-
- ResultSet rs = DriverManager.getConnection(jdbcUrl).createStatement()
- .executeQuery("SHOW VARIABLES LIKE 'timezone'");
-
- while (rs.next()) {
- String timezoneFromServer = rs.getString(2);
- System.out.println("MySQL timezone name: " + timezoneFromServer);
-
- String canonicalTimezone = TimeUtil
- .getCanoncialTimezone(timezoneFromServer, null);
- System.out.println("Java timezone name: " + canonicalTimezone);
- }
- }
-}
diff --git a/src/com/mysql/jdbc/util/VersionFSHierarchyMaker.java b/src/com/mysql/jdbc/util/VersionFSHierarchyMaker.java
deleted file mode 100644
index ed618e4df..000000000
--- a/src/com/mysql/jdbc/util/VersionFSHierarchyMaker.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- Copyright 2005-2006 MySQL AB, 2008 Sun Microsystems
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- There are special exceptions to the terms and conditions of the GPL
- as it is applied to this software. View the full text of the
- exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
- software distribution.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-package com.mysql.jdbc.util;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.sql.Connection;
-import java.sql.ResultSet;
-
-import com.mysql.jdbc.NonRegisteringDriver;
-
-/**
- * Creates output directory structure for multi-jvm, multi-url
- * unit, regression and compliance tests.
- */
-public class VersionFSHierarchyMaker {
-
- /**
- * @param args
- */
- public static void main(String[] args) throws Exception {
- if (args.length < 3) {
- usage();
- System.exit(1);
- }
-
- String jdbcUrl = null;
-
- String jvmVersion = removeWhitespaceChars(System.getProperty("java.version"));
- String jvmVendor = removeWhitespaceChars(System.getProperty("java.vendor"));
- String osName = removeWhitespaceChars(System.getProperty("os.name"));
- String osArch = removeWhitespaceChars(System.getProperty("os.arch"));
- String osVersion = removeWhitespaceChars(System.getProperty("os.version"));
-
- jdbcUrl = System.getProperty("com.mysql.jdbc.testsuite.url");
-
- String mysqlVersion = "not-available";
-
- try {
- Connection conn = new NonRegisteringDriver().connect(jdbcUrl, null);
-
- ResultSet rs = conn.createStatement().executeQuery("SELECT VERSION()");
- rs.next();
- mysqlVersion = removeWhitespaceChars(rs.getString(1));
- } catch (Throwable t) {
- mysqlVersion = "no-server-running-on-" + removeWhitespaceChars(jdbcUrl);
- }
-
- String jvmSubdirName = jvmVendor + "-" + jvmVersion;
- String osSubdirName = osName + "-" + osArch + "-" + osVersion;
-
- File baseDir = new File(args[1]);
- File mysqlVersionDir = new File(baseDir, mysqlVersion);
- File osVersionDir = new File(mysqlVersionDir, osSubdirName);
- File jvmVersionDir = new File(osVersionDir, jvmSubdirName);
-
- jvmVersionDir.mkdirs();
-
-
- FileOutputStream pathOut = null;
-
- try {
- String propsOutputPath = args[2];
- pathOut = new FileOutputStream(propsOutputPath);
- String baseDirStr = baseDir.getAbsolutePath();
- String jvmVersionDirStr = jvmVersionDir.getAbsolutePath();
-
- if (jvmVersionDirStr.startsWith(baseDirStr)) {
- jvmVersionDirStr = jvmVersionDirStr.substring(baseDirStr.length() + 1);
- }
-
- pathOut.write(jvmVersionDirStr.getBytes());
- } finally {
- if (pathOut != null) {
- pathOut.flush();
- pathOut.close();
- }
- }
- }
-
- public static String removeWhitespaceChars(String input) {
- if (input == null) {
- return input;
- }
-
- int strLen = input.length();
-
- StringBuffer output = new StringBuffer(strLen);
-
- for (int i = 0; i < strLen; i++) {
- char c = input.charAt(i);
- if (!Character.isDigit(c) && !Character.isLetter(c)) {
- if (Character.isWhitespace(c)) {
- output.append("_");
- } else {
- output.append(".");
- }
- } else {
- output.append(c);
- }
- }
-
- return output.toString();
- }
-
- private static void usage() {
- System.err.println("Creates a fs hierarchy representing MySQL version, OS version and JVM version.");
- System.err.println("Stores the full path as 'outputDirectory' property in file 'directoryPropPath'");
- System.err.println();
- System.err.println("Usage: java VersionFSHierarchyMaker unit|compliance baseDirectory directoryPropPath");
- }
-}
diff --git a/src/demo/java/demo/x/devapi/DevApiSample.java b/src/demo/java/demo/x/devapi/DevApiSample.java
new file mode 100644
index 000000000..4ef89e7e0
--- /dev/null
+++ b/src/demo/java/demo/x/devapi/DevApiSample.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 2.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is also distributed with certain software (including but not
+ * limited to OpenSSL) that is licensed under separate terms, as designated in a
+ * particular file or component or in included license documentation. The
+ * authors of MySQL hereby grant you an additional permission to link the
+ * program and your derivative works with the separately licensed software that
+ * they have included with MySQL.
+ *
+ * Without limiting anything contained in the foregoing, this file, which is
+ * part of MySQL Connector/J, is also subject to the Universal FOSS Exception,
+ * version 1.0, a copy of which can be found at
+ * http://oss.oracle.com/licenses/universal-foss-exception.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package demo.x.devapi;
+
+import com.mysql.cj.xdevapi.Collection;
+import com.mysql.cj.xdevapi.DbDoc;
+import com.mysql.cj.xdevapi.DbDocImpl;
+import com.mysql.cj.xdevapi.DocResult;
+import com.mysql.cj.xdevapi.JsonNumber;
+import com.mysql.cj.xdevapi.JsonString;
+import com.mysql.cj.xdevapi.Schema;
+import com.mysql.cj.xdevapi.Session;
+import com.mysql.cj.xdevapi.SessionFactory;
+
+/*
+ * Sample program showing how to use Connector/J's Dev API support.
+ */
+public class DevApiSample {
+ public static void main(String[] args) {
+ Session session = new SessionFactory().getSession("mysqlx://localhost:33060/test?user=user&password=password1234");
+ System.err.println("Connected!");
+ Schema schema = session.getDefaultSchema();
+ System.err.println("Default schema is: " + schema);
+
+ documentWalkthrough(schema);
+ }
+
+ public static void documentWalkthrough(Schema schema) {
+ // document walthrough
+ Collection coll = schema.createCollection("myBooks", /* reuseExisting? */ true);
+ DbDoc newDoc = new DbDocImpl().add("isbn", new JsonString().setValue("12345"));
+ newDoc.add("title", new JsonString().setValue("Effi Briest"));
+ newDoc.add("author", new JsonString().setValue("Theodor Fontane"));
+ newDoc.add("currentlyReadingPage", new JsonNumber().setValue(String.valueOf(42)));
+ coll.add(newDoc).execute();
+
+ // note: "$" prefix for document paths is optional. "$.title.somethingElse[0]" is the same as "title.somethingElse[0]" in document expressions
+ DocResult docs = coll.find("$.title = 'Effi Briest' and $.currentlyReadingPage > 10").execute();
+ DbDoc book = docs.next();
+ System.err.println("Currently reading " + ((JsonString) book.get("title")).getString() + " on page "
+ + ((JsonNumber) book.get("currentlyReadingPage")).getInteger());
+
+ // increment the page number and fetch it again
+ coll.modify("$.isbn = 12345").set("$.currentlyReadingPage", ((JsonNumber) book.get("currentlyReadingPage")).getInteger() + 1).execute();
+
+ docs = coll.find("$.title = 'Effi Briest' and $.currentlyReadingPage > 10").execute();
+ book = docs.next();
+ System.err.println("Currently reading " + ((JsonString) book.get("title")).getString() + " on page "
+ + ((JsonNumber) book.get("currentlyReadingPage")).getInteger());
+
+ // remove the doc
+ coll.remove("true").execute();
+ System.err.println("Number of books in collection: " + coll.count());
+
+ schema.dropCollection(coll.getName());
+ }
+}
diff --git a/src/doc/sources/connPropsToDocbook.xsl b/src/doc/sources/connPropsToDocbook.xsl
deleted file mode 100644
index c80b33074..000000000
--- a/src/doc/sources/connPropsToDocbook.xsl
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 4
-
- 30*
- cj_propstbl_prop_name
-
-
- 50*
- cj_propstbl_prop_defn
-
-
- 10*
- cj_propstbl_default
-
-
- 10*
- cj_propstbl_since_version
-
-
-
-
-
- bold
- Property Name
-
-
-
-
- bold
- Definition
-
-
-
-
- bold
- Default Value
-
-
-
-
- bold
- Since Version
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/doc/sources/errorMapToDocbook.xsl b/src/doc/sources/errorMapToDocbook.xsl
deleted file mode 100644
index 7a420a7a4..000000000
--- a/src/doc/sources/errorMapToDocbook.xsl
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
- Mapping of MySQL Error Numbers to SQLStates
- 4
- 20
- 40
- 20
- 20
-
-
- MySQL Error Number
- MySQL Error Name
- Legacy (X/Open) SQLState
- SQL Standard SQLState
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/doc/sources/placeholder.txt b/src/doc/sources/placeholder.txt
deleted file mode 100644
index 7ed2393df..000000000
--- a/src/doc/sources/placeholder.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-This file is here to enable this directory to be checked into the
-source repository.
-
-The ant build script will copy the latest version of the documentation
-into this directory.
\ No newline at end of file
diff --git a/src/doc/sources/pom.xml b/src/doc/sources/pom.xml
deleted file mode 100644
index cb4e61fd4..000000000
--- a/src/doc/sources/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
- 4.0.0
- mysql
- mysql-connector-java
- @MYSQL_CJ_MAJOR_VERSION@.@MYSQL_CJ_MINOR_VERSION@.@MYSQL_CJ_SUBMINOR_VERSION@
- jar
-
- MySQL java connector
- MySQL java connector
-
-
-
- The GNU General Public License, Version 2
- http://www.gnu.org/licenses/gpl.txt
- repo
- MySQL Connector/J contains exceptions to GPL requirements when linking with other components
- that are licensed under OSI-approved open source licenses, see EXCEPTIONS-CONNECTOR-J
- in this distribution for more details.
-
-
-
- http://dev.mysql.com/usingmysql/java/
-
-
-
- scm:svn:http://svn.mysql.com/svnpublic/connector-j/trunk/connector-j
-
-
- scm:svn:http://svn.mysql.com/svnpublic/connector-j/trunk/connector-j
-
-
- http://svn.mysql.com/svnpublic/connector-j/trunk/connector-j
-
-
-
-
diff --git a/src/generated/java/com/mysql/cj/x/protobuf/Mysqlx.java b/src/generated/java/com/mysql/cj/x/protobuf/Mysqlx.java
new file mode 100644
index 000000000..0dd44d0b3
--- /dev/null
+++ b/src/generated/java/com/mysql/cj/x/protobuf/Mysqlx.java
@@ -0,0 +1,3417 @@
+/*
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 2.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is also distributed with certain software (including but not
+ * limited to OpenSSL) that is licensed under separate terms, as designated in a
+ * particular file or component or in included license documentation. The
+ * authors of MySQL hereby grant you an additional permission to link the
+ * program and your derivative works with the separately licensed software that
+ * they have included with MySQL.
+ *
+ * Without limiting anything contained in the foregoing, this file, which is
+ * part of MySQL Connector/J, is also subject to the Universal FOSS Exception,
+ * version 1.0, a copy of which can be found at
+ * http://oss.oracle.com/licenses/universal-foss-exception.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package com.mysql.cj.x.protobuf;
+
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: mysqlx.proto
+
+public final class Mysqlx {
+ private Mysqlx() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistryLite registry) {
+ registry.add(com.mysql.cj.x.protobuf.Mysqlx.clientMessageId);
+ registry.add(com.mysql.cj.x.protobuf.Mysqlx.serverMessageId);
+ }
+
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ registerAllExtensions(
+ (com.google.protobuf.ExtensionRegistryLite) registry);
+ }
+ public interface ClientMessagesOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:Mysqlx.ClientMessages)
+ com.google.protobuf.MessageOrBuilder {
+ }
+ /**
+ *
+ **
+ *IDs of messages that can be sent from client to the server.
+ *@note
+ *This message is never sent on the wire. It is only used to let ``protoc``:
+ *- generate constants
+ *- check for uniqueness
+ *
+ *
+ * Protobuf type {@code Mysqlx.ClientMessages}
+ */
+ public static final class ClientMessages extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:Mysqlx.ClientMessages)
+ ClientMessagesOrBuilder {
+ private static final long serialVersionUID = 0L;
+ // Use ClientMessages.newBuilder() to construct.
+ private ClientMessages(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private ClientMessages() {
+ }
+
+ @java.lang.Override
+ @SuppressWarnings({"unused"})
+ protected java.lang.Object newInstance(
+ UnusedPrivateParameter unused) {
+ return new ClientMessages();
+ }
+
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private ClientMessages(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new java.lang.NullPointerException();
+ }
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownField(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.Mysqlx.internal_static_Mysqlx_ClientMessages_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.mysql.cj.x.protobuf.Mysqlx.internal_static_Mysqlx_ClientMessages_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.class, com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Builder.class);
+ }
+
+ /**
+ * Protobuf enum {@code Mysqlx.ClientMessages.Type}
+ */
+ public enum Type
+ implements com.google.protobuf.ProtocolMessageEnum {
+ /**
+ * CON_CAPABILITIES_GET = 1;
+ */
+ CON_CAPABILITIES_GET(1),
+ /**
+ * CON_CAPABILITIES_SET = 2;
+ */
+ CON_CAPABILITIES_SET(2),
+ /**
+ * CON_CLOSE = 3;
+ */
+ CON_CLOSE(3),
+ /**
+ * SESS_AUTHENTICATE_START = 4;
+ */
+ SESS_AUTHENTICATE_START(4),
+ /**
+ * SESS_AUTHENTICATE_CONTINUE = 5;
+ */
+ SESS_AUTHENTICATE_CONTINUE(5),
+ /**
+ * SESS_RESET = 6;
+ */
+ SESS_RESET(6),
+ /**
+ * SESS_CLOSE = 7;
+ */
+ SESS_CLOSE(7),
+ /**
+ * SQL_STMT_EXECUTE = 12;
+ */
+ SQL_STMT_EXECUTE(12),
+ /**
+ * CRUD_FIND = 17;
+ */
+ CRUD_FIND(17),
+ /**
+ * CRUD_INSERT = 18;
+ */
+ CRUD_INSERT(18),
+ /**
+ * CRUD_UPDATE = 19;
+ */
+ CRUD_UPDATE(19),
+ /**
+ * CRUD_DELETE = 20;
+ */
+ CRUD_DELETE(20),
+ /**
+ * EXPECT_OPEN = 24;
+ */
+ EXPECT_OPEN(24),
+ /**
+ * EXPECT_CLOSE = 25;
+ */
+ EXPECT_CLOSE(25),
+ /**
+ * CRUD_CREATE_VIEW = 30;
+ */
+ CRUD_CREATE_VIEW(30),
+ /**
+ * CRUD_MODIFY_VIEW = 31;
+ */
+ CRUD_MODIFY_VIEW(31),
+ /**
+ * CRUD_DROP_VIEW = 32;
+ */
+ CRUD_DROP_VIEW(32),
+ /**
+ * PREPARE_PREPARE = 40;
+ */
+ PREPARE_PREPARE(40),
+ /**
+ * PREPARE_EXECUTE = 41;
+ */
+ PREPARE_EXECUTE(41),
+ /**
+ * PREPARE_DEALLOCATE = 42;
+ */
+ PREPARE_DEALLOCATE(42),
+ /**
+ * CURSOR_OPEN = 43;
+ */
+ CURSOR_OPEN(43),
+ /**
+ * CURSOR_CLOSE = 44;
+ */
+ CURSOR_CLOSE(44),
+ /**
+ * CURSOR_FETCH = 45;
+ */
+ CURSOR_FETCH(45),
+ /**
+ * COMPRESSION = 46;
+ */
+ COMPRESSION(46),
+ ;
+
+ /**
+ * CON_CAPABILITIES_GET = 1;
+ */
+ public static final int CON_CAPABILITIES_GET_VALUE = 1;
+ /**
+ * CON_CAPABILITIES_SET = 2;
+ */
+ public static final int CON_CAPABILITIES_SET_VALUE = 2;
+ /**
+ * CON_CLOSE = 3;
+ */
+ public static final int CON_CLOSE_VALUE = 3;
+ /**
+ * SESS_AUTHENTICATE_START = 4;
+ */
+ public static final int SESS_AUTHENTICATE_START_VALUE = 4;
+ /**
+ * SESS_AUTHENTICATE_CONTINUE = 5;
+ */
+ public static final int SESS_AUTHENTICATE_CONTINUE_VALUE = 5;
+ /**
+ * SESS_RESET = 6;
+ */
+ public static final int SESS_RESET_VALUE = 6;
+ /**
+ * SESS_CLOSE = 7;
+ */
+ public static final int SESS_CLOSE_VALUE = 7;
+ /**
+ * SQL_STMT_EXECUTE = 12;
+ */
+ public static final int SQL_STMT_EXECUTE_VALUE = 12;
+ /**
+ * CRUD_FIND = 17;
+ */
+ public static final int CRUD_FIND_VALUE = 17;
+ /**
+ * CRUD_INSERT = 18;
+ */
+ public static final int CRUD_INSERT_VALUE = 18;
+ /**
+ * CRUD_UPDATE = 19;
+ */
+ public static final int CRUD_UPDATE_VALUE = 19;
+ /**
+ * CRUD_DELETE = 20;
+ */
+ public static final int CRUD_DELETE_VALUE = 20;
+ /**
+ * EXPECT_OPEN = 24;
+ */
+ public static final int EXPECT_OPEN_VALUE = 24;
+ /**
+ * EXPECT_CLOSE = 25;
+ */
+ public static final int EXPECT_CLOSE_VALUE = 25;
+ /**
+ * CRUD_CREATE_VIEW = 30;
+ */
+ public static final int CRUD_CREATE_VIEW_VALUE = 30;
+ /**
+ * CRUD_MODIFY_VIEW = 31;
+ */
+ public static final int CRUD_MODIFY_VIEW_VALUE = 31;
+ /**
+ * CRUD_DROP_VIEW = 32;
+ */
+ public static final int CRUD_DROP_VIEW_VALUE = 32;
+ /**
+ * PREPARE_PREPARE = 40;
+ */
+ public static final int PREPARE_PREPARE_VALUE = 40;
+ /**
+ * PREPARE_EXECUTE = 41;
+ */
+ public static final int PREPARE_EXECUTE_VALUE = 41;
+ /**
+ * PREPARE_DEALLOCATE = 42;
+ */
+ public static final int PREPARE_DEALLOCATE_VALUE = 42;
+ /**
+ * CURSOR_OPEN = 43;
+ */
+ public static final int CURSOR_OPEN_VALUE = 43;
+ /**
+ * CURSOR_CLOSE = 44;
+ */
+ public static final int CURSOR_CLOSE_VALUE = 44;
+ /**
+ * CURSOR_FETCH = 45;
+ */
+ public static final int CURSOR_FETCH_VALUE = 45;
+ /**
+ * COMPRESSION = 46;
+ */
+ public static final int COMPRESSION_VALUE = 46;
+
+
+ public final int getNumber() {
+ return value;
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @java.lang.Deprecated
+ public static Type valueOf(int value) {
+ return forNumber(value);
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ */
+ public static Type forNumber(int value) {
+ switch (value) {
+ case 1: return CON_CAPABILITIES_GET;
+ case 2: return CON_CAPABILITIES_SET;
+ case 3: return CON_CLOSE;
+ case 4: return SESS_AUTHENTICATE_START;
+ case 5: return SESS_AUTHENTICATE_CONTINUE;
+ case 6: return SESS_RESET;
+ case 7: return SESS_CLOSE;
+ case 12: return SQL_STMT_EXECUTE;
+ case 17: return CRUD_FIND;
+ case 18: return CRUD_INSERT;
+ case 19: return CRUD_UPDATE;
+ case 20: return CRUD_DELETE;
+ case 24: return EXPECT_OPEN;
+ case 25: return EXPECT_CLOSE;
+ case 30: return CRUD_CREATE_VIEW;
+ case 31: return CRUD_MODIFY_VIEW;
+ case 32: return CRUD_DROP_VIEW;
+ case 40: return PREPARE_PREPARE;
+ case 41: return PREPARE_EXECUTE;
+ case 42: return PREPARE_DEALLOCATE;
+ case 43: return CURSOR_OPEN;
+ case 44: return CURSOR_CLOSE;
+ case 45: return CURSOR_FETCH;
+ case 46: return COMPRESSION;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ Type> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public Type findValueByNumber(int number) {
+ return Type.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final Type[] VALUES = values();
+
+ public static Type valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private Type(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:Mysqlx.ClientMessages.Type)
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ unknownFields.writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof com.mysql.cj.x.protobuf.Mysqlx.ClientMessages)) {
+ return super.equals(obj);
+ }
+ com.mysql.cj.x.protobuf.Mysqlx.ClientMessages other = (com.mysql.cj.x.protobuf.Mysqlx.ClientMessages) obj;
+
+ if (!unknownFields.equals(other.unknownFields)) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ClientMessages parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(com.mysql.cj.x.protobuf.Mysqlx.ClientMessages prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ *
+ **
+ *IDs of messages that can be sent from client to the server.
+ *@note
+ *This message is never sent on the wire. It is only used to let ``protoc``:
+ *- generate constants
+ *- check for uniqueness
+ *
+ **
+ *IDs of messages that can be sent from server to client.
+ *@note
+ *This message is never sent on the wire. It is only used to let ``protoc``:
+ *- generate constants
+ *- check for uniqueness
+ *
+ *
+ * NOTICE = 11;
+ */
+ public static final int NOTICE_VALUE = 11;
+ /**
+ * RESULTSET_COLUMN_META_DATA = 12;
+ */
+ public static final int RESULTSET_COLUMN_META_DATA_VALUE = 12;
+ /**
+ * RESULTSET_ROW = 13;
+ */
+ public static final int RESULTSET_ROW_VALUE = 13;
+ /**
+ * RESULTSET_FETCH_DONE = 14;
+ */
+ public static final int RESULTSET_FETCH_DONE_VALUE = 14;
+ /**
+ * RESULTSET_FETCH_SUSPENDED = 15;
+ */
+ public static final int RESULTSET_FETCH_SUSPENDED_VALUE = 15;
+ /**
+ * RESULTSET_FETCH_DONE_MORE_RESULTSETS = 16;
+ */
+ public static final int RESULTSET_FETCH_DONE_MORE_RESULTSETS_VALUE = 16;
+ /**
+ * SQL_STMT_EXECUTE_OK = 17;
+ */
+ public static final int SQL_STMT_EXECUTE_OK_VALUE = 17;
+ /**
+ * RESULTSET_FETCH_DONE_MORE_OUT_PARAMS = 18;
+ */
+ public static final int RESULTSET_FETCH_DONE_MORE_OUT_PARAMS_VALUE = 18;
+ /**
+ * COMPRESSION = 19;
+ */
+ public static final int COMPRESSION_VALUE = 19;
+
+
+ public final int getNumber() {
+ return value;
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @java.lang.Deprecated
+ public static Type valueOf(int value) {
+ return forNumber(value);
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ */
+ public static Type forNumber(int value) {
+ switch (value) {
+ case 0: return OK;
+ case 1: return ERROR;
+ case 2: return CONN_CAPABILITIES;
+ case 3: return SESS_AUTHENTICATE_CONTINUE;
+ case 4: return SESS_AUTHENTICATE_OK;
+ case 11: return NOTICE;
+ case 12: return RESULTSET_COLUMN_META_DATA;
+ case 13: return RESULTSET_ROW;
+ case 14: return RESULTSET_FETCH_DONE;
+ case 15: return RESULTSET_FETCH_SUSPENDED;
+ case 16: return RESULTSET_FETCH_DONE_MORE_RESULTSETS;
+ case 17: return SQL_STMT_EXECUTE_OK;
+ case 18: return RESULTSET_FETCH_DONE_MORE_OUT_PARAMS;
+ case 19: return COMPRESSION;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ Type> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public Type findValueByNumber(int number) {
+ return Type.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final Type[] VALUES = values();
+
+ public static Type valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private Type(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:Mysqlx.ServerMessages.Type)
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ unknownFields.writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof com.mysql.cj.x.protobuf.Mysqlx.ServerMessages)) {
+ return super.equals(obj);
+ }
+ com.mysql.cj.x.protobuf.Mysqlx.ServerMessages other = (com.mysql.cj.x.protobuf.Mysqlx.ServerMessages) obj;
+
+ if (!unknownFields.equals(other.unknownFields)) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.Mysqlx.ServerMessages parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(com.mysql.cj.x.protobuf.Mysqlx.ServerMessages prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ *
+ **
+ *IDs of messages that can be sent from server to client.
+ *@note
+ *This message is never sent on the wire. It is only used to let ``protoc``:
+ *- generate constants
+ *- check for uniqueness
+ *
+ **
+ *Set connection capabilities atomically.
+ *Only provided values are changed, other values are left
+ *unchanged. If any of the changes fails, all changes are
+ *discarded.
+ *@pre active sessions == 0
+ *@returns @ref Mysqlx::Ok or @ref Mysqlx::Error
+ *
+ **
+ *Set connection capabilities atomically.
+ *Only provided values are changed, other values are left
+ *unchanged. If any of the changes fails, all changes are
+ *discarded.
+ *@pre active sessions == 0
+ *@returns @ref Mysqlx::Ok or @ref Mysqlx::Error
+ *
+ **
+ *Announce to the server that the client wants to close the connection.
+ *It discards any session state of the server.
+ *@returns @ref Mysqlx::Ok
+ *
+ **
+ *Announce to the server that the client wants to close the connection.
+ *It discards any session state of the server.
+ *@returns @ref Mysqlx::Ok
+ *
+ *
+ * Protobuf type {@code Mysqlx.Connection.Close}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:Mysqlx.Connection.Close)
+ com.mysql.cj.x.protobuf.MysqlxConnection.CloseOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Close_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Close_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.mysql.cj.x.protobuf.MysqlxConnection.Close.class, com.mysql.cj.x.protobuf.MysqlxConnection.Close.Builder.class);
+ }
+
+ // Construct using com.mysql.cj.x.protobuf.MysqlxConnection.Close.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ }
+ }
+ @java.lang.Override
+ public Builder clear() {
+ super.clear();
+ return this;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Close_descriptor;
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Close getDefaultInstanceForType() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.Close.getDefaultInstance();
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Close build() {
+ com.mysql.cj.x.protobuf.MysqlxConnection.Close result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Close buildPartial() {
+ com.mysql.cj.x.protobuf.MysqlxConnection.Close result = new com.mysql.cj.x.protobuf.MysqlxConnection.Close(this);
+ onBuilt();
+ return result;
+ }
+
+ @java.lang.Override
+ public Builder clone() {
+ return super.clone();
+ }
+ @java.lang.Override
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.setField(field, value);
+ }
+ @java.lang.Override
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return super.clearField(field);
+ }
+ @java.lang.Override
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return super.clearOneof(oneof);
+ }
+ @java.lang.Override
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, java.lang.Object value) {
+ return super.setRepeatedField(field, index, value);
+ }
+ @java.lang.Override
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.addRepeatedField(field, value);
+ }
+ @java.lang.Override
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.mysql.cj.x.protobuf.MysqlxConnection.Close) {
+ return mergeFrom((com.mysql.cj.x.protobuf.MysqlxConnection.Close)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.mysql.cj.x.protobuf.MysqlxConnection.Close other) {
+ if (other == com.mysql.cj.x.protobuf.MysqlxConnection.Close.getDefaultInstance()) return this;
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ @java.lang.Override
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.mysql.cj.x.protobuf.MysqlxConnection.Close parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (com.mysql.cj.x.protobuf.MysqlxConnection.Close) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ @java.lang.Override
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFields(unknownFields);
+ }
+
+ @java.lang.Override
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:Mysqlx.Connection.Close)
+ }
+
+ // @@protoc_insertion_point(class_scope:Mysqlx.Connection.Close)
+ private static final com.mysql.cj.x.protobuf.MysqlxConnection.Close DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new com.mysql.cj.x.protobuf.MysqlxConnection.Close();
+ }
+
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Close getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ @java.lang.Deprecated public static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ @java.lang.Override
+ public Close parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new Close(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Close getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ public interface CompressionOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:Mysqlx.Connection.Compression)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @return Whether the uncompressedSize field is set.
+ */
+ boolean hasUncompressedSize();
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @return The uncompressedSize.
+ */
+ long getUncompressedSize();
+
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @return Whether the serverMessages field is set.
+ */
+ boolean hasServerMessages();
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @return The serverMessages.
+ */
+ com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type getServerMessages();
+
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @return Whether the clientMessages field is set.
+ */
+ boolean hasClientMessages();
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @return The clientMessages.
+ */
+ com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type getClientMessages();
+
+ /**
+ * required bytes payload = 4;
+ * @return Whether the payload field is set.
+ */
+ boolean hasPayload();
+ /**
+ * required bytes payload = 4;
+ * @return The payload.
+ */
+ com.google.protobuf.ByteString getPayload();
+ }
+ /**
+ * Protobuf type {@code Mysqlx.Connection.Compression}
+ */
+ public static final class Compression extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:Mysqlx.Connection.Compression)
+ CompressionOrBuilder {
+ private static final long serialVersionUID = 0L;
+ // Use Compression.newBuilder() to construct.
+ private Compression(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private Compression() {
+ serverMessages_ = 0;
+ clientMessages_ = 1;
+ payload_ = com.google.protobuf.ByteString.EMPTY;
+ }
+
+ @java.lang.Override
+ @SuppressWarnings({"unused"})
+ protected java.lang.Object newInstance(
+ UnusedPrivateParameter unused) {
+ return new Compression();
+ }
+
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private Compression(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new java.lang.NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ case 8: {
+ bitField0_ |= 0x00000001;
+ uncompressedSize_ = input.readUInt64();
+ break;
+ }
+ case 16: {
+ int rawValue = input.readEnum();
+ @SuppressWarnings("deprecation")
+ com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type value = com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type.valueOf(rawValue);
+ if (value == null) {
+ unknownFields.mergeVarintField(2, rawValue);
+ } else {
+ bitField0_ |= 0x00000002;
+ serverMessages_ = rawValue;
+ }
+ break;
+ }
+ case 24: {
+ int rawValue = input.readEnum();
+ @SuppressWarnings("deprecation")
+ com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type value = com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type.valueOf(rawValue);
+ if (value == null) {
+ unknownFields.mergeVarintField(3, rawValue);
+ } else {
+ bitField0_ |= 0x00000004;
+ clientMessages_ = rawValue;
+ }
+ break;
+ }
+ case 34: {
+ bitField0_ |= 0x00000008;
+ payload_ = input.readBytes();
+ break;
+ }
+ default: {
+ if (!parseUnknownField(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Compression_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Compression_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.mysql.cj.x.protobuf.MysqlxConnection.Compression.class, com.mysql.cj.x.protobuf.MysqlxConnection.Compression.Builder.class);
+ }
+
+ private int bitField0_;
+ public static final int UNCOMPRESSED_SIZE_FIELD_NUMBER = 1;
+ private long uncompressedSize_;
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @return Whether the uncompressedSize field is set.
+ */
+ public boolean hasUncompressedSize() {
+ return ((bitField0_ & 0x00000001) != 0);
+ }
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @return The uncompressedSize.
+ */
+ public long getUncompressedSize() {
+ return uncompressedSize_;
+ }
+
+ public static final int SERVER_MESSAGES_FIELD_NUMBER = 2;
+ private int serverMessages_;
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @return Whether the serverMessages field is set.
+ */
+ public boolean hasServerMessages() {
+ return ((bitField0_ & 0x00000002) != 0);
+ }
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @return The serverMessages.
+ */
+ public com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type getServerMessages() {
+ @SuppressWarnings("deprecation")
+ com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type result = com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type.valueOf(serverMessages_);
+ return result == null ? com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type.OK : result;
+ }
+
+ public static final int CLIENT_MESSAGES_FIELD_NUMBER = 3;
+ private int clientMessages_;
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @return Whether the clientMessages field is set.
+ */
+ public boolean hasClientMessages() {
+ return ((bitField0_ & 0x00000004) != 0);
+ }
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @return The clientMessages.
+ */
+ public com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type getClientMessages() {
+ @SuppressWarnings("deprecation")
+ com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type result = com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type.valueOf(clientMessages_);
+ return result == null ? com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type.CON_CAPABILITIES_GET : result;
+ }
+
+ public static final int PAYLOAD_FIELD_NUMBER = 4;
+ private com.google.protobuf.ByteString payload_;
+ /**
+ * required bytes payload = 4;
+ * @return Whether the payload field is set.
+ */
+ public boolean hasPayload() {
+ return ((bitField0_ & 0x00000008) != 0);
+ }
+ /**
+ * required bytes payload = 4;
+ * @return The payload.
+ */
+ public com.google.protobuf.ByteString getPayload() {
+ return payload_;
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ if (!hasPayload()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (((bitField0_ & 0x00000001) != 0)) {
+ output.writeUInt64(1, uncompressedSize_);
+ }
+ if (((bitField0_ & 0x00000002) != 0)) {
+ output.writeEnum(2, serverMessages_);
+ }
+ if (((bitField0_ & 0x00000004) != 0)) {
+ output.writeEnum(3, clientMessages_);
+ }
+ if (((bitField0_ & 0x00000008) != 0)) {
+ output.writeBytes(4, payload_);
+ }
+ unknownFields.writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) != 0)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeUInt64Size(1, uncompressedSize_);
+ }
+ if (((bitField0_ & 0x00000002) != 0)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeEnumSize(2, serverMessages_);
+ }
+ if (((bitField0_ & 0x00000004) != 0)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeEnumSize(3, clientMessages_);
+ }
+ if (((bitField0_ & 0x00000008) != 0)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(4, payload_);
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof com.mysql.cj.x.protobuf.MysqlxConnection.Compression)) {
+ return super.equals(obj);
+ }
+ com.mysql.cj.x.protobuf.MysqlxConnection.Compression other = (com.mysql.cj.x.protobuf.MysqlxConnection.Compression) obj;
+
+ if (hasUncompressedSize() != other.hasUncompressedSize()) return false;
+ if (hasUncompressedSize()) {
+ if (getUncompressedSize()
+ != other.getUncompressedSize()) return false;
+ }
+ if (hasServerMessages() != other.hasServerMessages()) return false;
+ if (hasServerMessages()) {
+ if (serverMessages_ != other.serverMessages_) return false;
+ }
+ if (hasClientMessages() != other.hasClientMessages()) return false;
+ if (hasClientMessages()) {
+ if (clientMessages_ != other.clientMessages_) return false;
+ }
+ if (hasPayload() != other.hasPayload()) return false;
+ if (hasPayload()) {
+ if (!getPayload()
+ .equals(other.getPayload())) return false;
+ }
+ if (!unknownFields.equals(other.unknownFields)) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ if (hasUncompressedSize()) {
+ hash = (37 * hash) + UNCOMPRESSED_SIZE_FIELD_NUMBER;
+ hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
+ getUncompressedSize());
+ }
+ if (hasServerMessages()) {
+ hash = (37 * hash) + SERVER_MESSAGES_FIELD_NUMBER;
+ hash = (53 * hash) + serverMessages_;
+ }
+ if (hasClientMessages()) {
+ hash = (37 * hash) + CLIENT_MESSAGES_FIELD_NUMBER;
+ hash = (53 * hash) + clientMessages_;
+ }
+ if (hasPayload()) {
+ hash = (37 * hash) + PAYLOAD_FIELD_NUMBER;
+ hash = (53 * hash) + getPayload().hashCode();
+ }
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(com.mysql.cj.x.protobuf.MysqlxConnection.Compression prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code Mysqlx.Connection.Compression}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:Mysqlx.Connection.Compression)
+ com.mysql.cj.x.protobuf.MysqlxConnection.CompressionOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Compression_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Compression_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.mysql.cj.x.protobuf.MysqlxConnection.Compression.class, com.mysql.cj.x.protobuf.MysqlxConnection.Compression.Builder.class);
+ }
+
+ // Construct using com.mysql.cj.x.protobuf.MysqlxConnection.Compression.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ }
+ }
+ @java.lang.Override
+ public Builder clear() {
+ super.clear();
+ uncompressedSize_ = 0L;
+ bitField0_ = (bitField0_ & ~0x00000001);
+ serverMessages_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ clientMessages_ = 1;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ payload_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ return this;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.internal_static_Mysqlx_Connection_Compression_descriptor;
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Compression getDefaultInstanceForType() {
+ return com.mysql.cj.x.protobuf.MysqlxConnection.Compression.getDefaultInstance();
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Compression build() {
+ com.mysql.cj.x.protobuf.MysqlxConnection.Compression result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Compression buildPartial() {
+ com.mysql.cj.x.protobuf.MysqlxConnection.Compression result = new com.mysql.cj.x.protobuf.MysqlxConnection.Compression(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) != 0)) {
+ result.uncompressedSize_ = uncompressedSize_;
+ to_bitField0_ |= 0x00000001;
+ }
+ if (((from_bitField0_ & 0x00000002) != 0)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.serverMessages_ = serverMessages_;
+ if (((from_bitField0_ & 0x00000004) != 0)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.clientMessages_ = clientMessages_;
+ if (((from_bitField0_ & 0x00000008) != 0)) {
+ to_bitField0_ |= 0x00000008;
+ }
+ result.payload_ = payload_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ @java.lang.Override
+ public Builder clone() {
+ return super.clone();
+ }
+ @java.lang.Override
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.setField(field, value);
+ }
+ @java.lang.Override
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return super.clearField(field);
+ }
+ @java.lang.Override
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return super.clearOneof(oneof);
+ }
+ @java.lang.Override
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, java.lang.Object value) {
+ return super.setRepeatedField(field, index, value);
+ }
+ @java.lang.Override
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.addRepeatedField(field, value);
+ }
+ @java.lang.Override
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.mysql.cj.x.protobuf.MysqlxConnection.Compression) {
+ return mergeFrom((com.mysql.cj.x.protobuf.MysqlxConnection.Compression)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.mysql.cj.x.protobuf.MysqlxConnection.Compression other) {
+ if (other == com.mysql.cj.x.protobuf.MysqlxConnection.Compression.getDefaultInstance()) return this;
+ if (other.hasUncompressedSize()) {
+ setUncompressedSize(other.getUncompressedSize());
+ }
+ if (other.hasServerMessages()) {
+ setServerMessages(other.getServerMessages());
+ }
+ if (other.hasClientMessages()) {
+ setClientMessages(other.getClientMessages());
+ }
+ if (other.hasPayload()) {
+ setPayload(other.getPayload());
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ @java.lang.Override
+ public final boolean isInitialized() {
+ if (!hasPayload()) {
+ return false;
+ }
+ return true;
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.mysql.cj.x.protobuf.MysqlxConnection.Compression parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (com.mysql.cj.x.protobuf.MysqlxConnection.Compression) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ private long uncompressedSize_ ;
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @return Whether the uncompressedSize field is set.
+ */
+ public boolean hasUncompressedSize() {
+ return ((bitField0_ & 0x00000001) != 0);
+ }
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @return The uncompressedSize.
+ */
+ public long getUncompressedSize() {
+ return uncompressedSize_;
+ }
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @param value The uncompressedSize to set.
+ * @return This builder for chaining.
+ */
+ public Builder setUncompressedSize(long value) {
+ bitField0_ |= 0x00000001;
+ uncompressedSize_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * optional uint64 uncompressed_size = 1;
+ * @return This builder for chaining.
+ */
+ public Builder clearUncompressedSize() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ uncompressedSize_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ private int serverMessages_ = 0;
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @return Whether the serverMessages field is set.
+ */
+ public boolean hasServerMessages() {
+ return ((bitField0_ & 0x00000002) != 0);
+ }
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @return The serverMessages.
+ */
+ public com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type getServerMessages() {
+ @SuppressWarnings("deprecation")
+ com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type result = com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type.valueOf(serverMessages_);
+ return result == null ? com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type.OK : result;
+ }
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @param value The serverMessages to set.
+ * @return This builder for chaining.
+ */
+ public Builder setServerMessages(com.mysql.cj.x.protobuf.Mysqlx.ServerMessages.Type value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ serverMessages_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+ /**
+ * optional .Mysqlx.ServerMessages.Type server_messages = 2;
+ * @return This builder for chaining.
+ */
+ public Builder clearServerMessages() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ serverMessages_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int clientMessages_ = 1;
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @return Whether the clientMessages field is set.
+ */
+ public boolean hasClientMessages() {
+ return ((bitField0_ & 0x00000004) != 0);
+ }
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @return The clientMessages.
+ */
+ public com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type getClientMessages() {
+ @SuppressWarnings("deprecation")
+ com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type result = com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type.valueOf(clientMessages_);
+ return result == null ? com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type.CON_CAPABILITIES_GET : result;
+ }
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @param value The clientMessages to set.
+ * @return This builder for chaining.
+ */
+ public Builder setClientMessages(com.mysql.cj.x.protobuf.Mysqlx.ClientMessages.Type value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000004;
+ clientMessages_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+ /**
+ * optional .Mysqlx.ClientMessages.Type client_messages = 3;
+ * @return This builder for chaining.
+ */
+ public Builder clearClientMessages() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ clientMessages_ = 1;
+ onChanged();
+ return this;
+ }
+
+ private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY;
+ /**
+ * required bytes payload = 4;
+ * @return Whether the payload field is set.
+ */
+ public boolean hasPayload() {
+ return ((bitField0_ & 0x00000008) != 0);
+ }
+ /**
+ * required bytes payload = 4;
+ * @return The payload.
+ */
+ public com.google.protobuf.ByteString getPayload() {
+ return payload_;
+ }
+ /**
+ * required bytes payload = 4;
+ * @param value The payload to set.
+ * @return This builder for chaining.
+ */
+ public Builder setPayload(com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000008;
+ payload_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * required bytes payload = 4;
+ * @return This builder for chaining.
+ */
+ public Builder clearPayload() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ payload_ = getDefaultInstance().getPayload();
+ onChanged();
+ return this;
+ }
+ @java.lang.Override
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFields(unknownFields);
+ }
+
+ @java.lang.Override
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:Mysqlx.Connection.Compression)
+ }
+
+ // @@protoc_insertion_point(class_scope:Mysqlx.Connection.Compression)
+ private static final com.mysql.cj.x.protobuf.MysqlxConnection.Compression DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new com.mysql.cj.x.protobuf.MysqlxConnection.Compression();
+ }
+
+ public static com.mysql.cj.x.protobuf.MysqlxConnection.Compression getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ @java.lang.Deprecated public static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ @java.lang.Override
+ public Compression parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new Compression(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.mysql.cj.x.protobuf.MysqlxConnection.Compression getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_Mysqlx_Connection_Capability_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_Mysqlx_Connection_Capability_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_Mysqlx_Connection_Capabilities_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_Mysqlx_Connection_Capabilities_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_Mysqlx_Connection_CapabilitiesGet_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_Mysqlx_Connection_CapabilitiesGet_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_Mysqlx_Connection_CapabilitiesSet_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_Mysqlx_Connection_CapabilitiesSet_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_Mysqlx_Connection_Close_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_Mysqlx_Connection_Close_fieldAccessorTable;
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_Mysqlx_Connection_Compression_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_Mysqlx_Connection_Compression_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n\027mysqlx_connection.proto\022\021Mysqlx.Connec" +
+ "tion\032\026mysqlx_datatypes.proto\032\014mysqlx.pro" +
+ "to\"@\n\nCapability\022\014\n\004name\030\001 \002(\t\022$\n\005value\030" +
+ "\002 \002(\0132\025.Mysqlx.Datatypes.Any\"I\n\014Capabili" +
+ "ties\0223\n\014capabilities\030\001 \003(\0132\035.Mysqlx.Conn" +
+ "ection.Capability:\004\220\3520\002\"\027\n\017CapabilitiesG" +
+ "et:\004\210\3520\001\"N\n\017CapabilitiesSet\0225\n\014capabilit" +
+ "ies\030\001 \002(\0132\037.Mysqlx.Connection.Capabiliti" +
+ "es:\004\210\3520\002\"\r\n\005Close:\004\210\3520\003\"\257\001\n\013Compression\022" +
+ "\031\n\021uncompressed_size\030\001 \001(\004\0224\n\017server_mes" +
+ "sages\030\002 \001(\0162\033.Mysqlx.ServerMessages.Type" +
+ "\0224\n\017client_messages\030\003 \001(\0162\033.Mysqlx.Clien" +
+ "tMessages.Type\022\017\n\007payload\030\004 \002(\014:\010\220\3520\023\210\3520" +
+ ".B\031\n\027com.mysql.cj.x.protobuf"
+ };
+ descriptor = com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ com.mysql.cj.x.protobuf.MysqlxDatatypes.getDescriptor(),
+ com.mysql.cj.x.protobuf.Mysqlx.getDescriptor(),
+ });
+ internal_static_Mysqlx_Connection_Capability_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_Mysqlx_Connection_Capability_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_Mysqlx_Connection_Capability_descriptor,
+ new java.lang.String[] { "Name", "Value", });
+ internal_static_Mysqlx_Connection_Capabilities_descriptor =
+ getDescriptor().getMessageTypes().get(1);
+ internal_static_Mysqlx_Connection_Capabilities_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_Mysqlx_Connection_Capabilities_descriptor,
+ new java.lang.String[] { "Capabilities", });
+ internal_static_Mysqlx_Connection_CapabilitiesGet_descriptor =
+ getDescriptor().getMessageTypes().get(2);
+ internal_static_Mysqlx_Connection_CapabilitiesGet_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_Mysqlx_Connection_CapabilitiesGet_descriptor,
+ new java.lang.String[] { });
+ internal_static_Mysqlx_Connection_CapabilitiesSet_descriptor =
+ getDescriptor().getMessageTypes().get(3);
+ internal_static_Mysqlx_Connection_CapabilitiesSet_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_Mysqlx_Connection_CapabilitiesSet_descriptor,
+ new java.lang.String[] { "Capabilities", });
+ internal_static_Mysqlx_Connection_Close_descriptor =
+ getDescriptor().getMessageTypes().get(4);
+ internal_static_Mysqlx_Connection_Close_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_Mysqlx_Connection_Close_descriptor,
+ new java.lang.String[] { });
+ internal_static_Mysqlx_Connection_Compression_descriptor =
+ getDescriptor().getMessageTypes().get(5);
+ internal_static_Mysqlx_Connection_Compression_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_Mysqlx_Connection_Compression_descriptor,
+ new java.lang.String[] { "UncompressedSize", "ServerMessages", "ClientMessages", "Payload", });
+ com.google.protobuf.ExtensionRegistry registry =
+ com.google.protobuf.ExtensionRegistry.newInstance();
+ registry.add(com.mysql.cj.x.protobuf.Mysqlx.clientMessageId);
+ registry.add(com.mysql.cj.x.protobuf.Mysqlx.serverMessageId);
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalUpdateFileDescriptor(descriptor, registry);
+ com.mysql.cj.x.protobuf.MysqlxDatatypes.getDescriptor();
+ com.mysql.cj.x.protobuf.Mysqlx.getDescriptor();
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/src/generated/java/com/mysql/cj/x/protobuf/MysqlxCrud.java b/src/generated/java/com/mysql/cj/x/protobuf/MysqlxCrud.java
new file mode 100644
index 000000000..3c363c470
--- /dev/null
+++ b/src/generated/java/com/mysql/cj/x/protobuf/MysqlxCrud.java
@@ -0,0 +1,26227 @@
+/*
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 2.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is also distributed with certain software (including but not
+ * limited to OpenSSL) that is licensed under separate terms, as designated in a
+ * particular file or component or in included license documentation. The
+ * authors of MySQL hereby grant you an additional permission to link the
+ * program and your derivative works with the separately licensed software that
+ * they have included with MySQL.
+ *
+ * Without limiting anything contained in the foregoing, this file, which is
+ * part of MySQL Connector/J, is also subject to the Universal FOSS Exception,
+ * version 1.0, a copy of which can be found at
+ * http://oss.oracle.com/licenses/universal-foss-exception.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package com.mysql.cj.x.protobuf;
+
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: mysqlx_crud.proto
+
+@SuppressWarnings({ "deprecation" })
+public final class MysqlxCrud {
+ private MysqlxCrud() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistryLite registry) {
+ }
+
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ registerAllExtensions(
+ (com.google.protobuf.ExtensionRegistryLite) registry);
+ }
+ /**
+ *
+ **
+ *DataModel to use for filters, names, ...
+ *
+ *
+ * Protobuf enum {@code Mysqlx.Crud.DataModel}
+ */
+ public enum DataModel
+ implements com.google.protobuf.ProtocolMessageEnum {
+ /**
+ * DOCUMENT = 1;
+ */
+ DOCUMENT(1),
+ /**
+ * TABLE = 2;
+ */
+ TABLE(2),
+ ;
+
+ /**
+ * DOCUMENT = 1;
+ */
+ public static final int DOCUMENT_VALUE = 1;
+ /**
+ * TABLE = 2;
+ */
+ public static final int TABLE_VALUE = 2;
+
+
+ public final int getNumber() {
+ return value;
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @java.lang.Deprecated
+ public static DataModel valueOf(int value) {
+ return forNumber(value);
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ */
+ public static DataModel forNumber(int value) {
+ switch (value) {
+ case 1: return DOCUMENT;
+ case 2: return TABLE;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ DataModel> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public DataModel findValueByNumber(int number) {
+ return DataModel.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.MysqlxCrud.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final DataModel[] VALUES = values();
+
+ public static DataModel valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private DataModel(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:Mysqlx.Crud.DataModel)
+ }
+
+ /**
+ *
+ **
+ *ViewAlgorithm defines how MySQL Server processes the view
+ *
+ *
+ * UNDEFINED = 1;
+ */
+ public static final int UNDEFINED_VALUE = 1;
+ /**
+ *
+ ** the text of a statement that refers to the view and the view
+ *definition are merged
+ *
+ *
+ * MERGE = 2;
+ */
+ public static final int MERGE_VALUE = 2;
+ /**
+ *
+ ** the view are retrieved into a temporary table
+ *
+ *
+ * TEMPTABLE = 3;
+ */
+ public static final int TEMPTABLE_VALUE = 3;
+
+
+ public final int getNumber() {
+ return value;
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @java.lang.Deprecated
+ public static ViewAlgorithm valueOf(int value) {
+ return forNumber(value);
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ */
+ public static ViewAlgorithm forNumber(int value) {
+ switch (value) {
+ case 1: return UNDEFINED;
+ case 2: return MERGE;
+ case 3: return TEMPTABLE;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ ViewAlgorithm> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public ViewAlgorithm findValueByNumber(int number) {
+ return ViewAlgorithm.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.MysqlxCrud.getDescriptor().getEnumTypes().get(1);
+ }
+
+ private static final ViewAlgorithm[] VALUES = values();
+
+ public static ViewAlgorithm valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private ViewAlgorithm(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:Mysqlx.Crud.ViewAlgorithm)
+ }
+
+ /**
+ *
+ **
+ *ViewSqlSecurity defines the security context in which the view is going to be
+ *executed, this means that VIEW can be executed with current user permissions or
+ *with permissions of the uses who defined the VIEW
+ *
+ *
+ * INVOKER = 1;
+ */
+ public static final int INVOKER_VALUE = 1;
+ /**
+ *
+ ** use permissions of the uses who defined the VIEW
+ *
+ *
+ * DEFINER = 2;
+ */
+ public static final int DEFINER_VALUE = 2;
+
+
+ public final int getNumber() {
+ return value;
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @java.lang.Deprecated
+ public static ViewSqlSecurity valueOf(int value) {
+ return forNumber(value);
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ */
+ public static ViewSqlSecurity forNumber(int value) {
+ switch (value) {
+ case 1: return INVOKER;
+ case 2: return DEFINER;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ ViewSqlSecurity> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public ViewSqlSecurity findValueByNumber(int number) {
+ return ViewSqlSecurity.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.MysqlxCrud.getDescriptor().getEnumTypes().get(2);
+ }
+
+ private static final ViewSqlSecurity[] VALUES = values();
+
+ public static ViewSqlSecurity valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private ViewSqlSecurity(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:Mysqlx.Crud.ViewSqlSecurity)
+ }
+
+ /**
+ *
+ **
+ *ViewCheckOption limits the write operations done on a `VIEW`
+ *(`INSERT`, `UPDATE`, `DELETE`) to rows in which the `WHERE` clause is `TRUE`
+ *
+ **
+ *LimitExpr in comparison to Limit, is able to specify that row_count and
+ *offset are placeholders.
+ *This message support expressions of following types Expr/literal/UINT,
+ *Expr/PLACEHOLDER.
+ *
+ **
+ *LimitExpr in comparison to Limit, is able to specify that row_count and
+ *offset are placeholders.
+ *This message support expressions of following types Expr/literal/UINT,
+ *Expr/PLACEHOLDER.
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ *
+ * required .Mysqlx.Expr.ColumnIdentifier source = 1;
+ * @return Whether the source field is set.
+ */
+ boolean hasSource();
+ /**
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ *
+ * SET = 1;
+ */
+ public static final int SET_VALUE = 1;
+ /**
+ *
+ ** no value (removes the identified path from a object or array)
+ *
+ *
+ * ITEM_REMOVE = 2;
+ */
+ public static final int ITEM_REMOVE_VALUE = 2;
+ /**
+ *
+ ** sets the new value on the identified path
+ *
+ *
+ * ITEM_SET = 3;
+ */
+ public static final int ITEM_SET_VALUE = 3;
+ /**
+ *
+ ** replaces a value if the path exists
+ *
+ *
+ * ITEM_REPLACE = 4;
+ */
+ public static final int ITEM_REPLACE_VALUE = 4;
+ /**
+ *
+ ** source and value must be documents
+ *
+ *
+ * ITEM_MERGE = 5;
+ */
+ public static final int ITEM_MERGE_VALUE = 5;
+ /**
+ *
+ ** insert the value in the array at the index identified in the source path
+ *
+ *
+ * ARRAY_INSERT = 6;
+ */
+ public static final int ARRAY_INSERT_VALUE = 6;
+ /**
+ *
+ ** append the value on the array at the identified path
+ *
+ *
+ * ARRAY_APPEND = 7;
+ */
+ public static final int ARRAY_APPEND_VALUE = 7;
+ /**
+ *
+ ** merge JSON object value with the provided patch expression
+ *
+ *
+ * MERGE_PATCH = 8;
+ */
+ public static final int MERGE_PATCH_VALUE = 8;
+
+
+ public final int getNumber() {
+ return value;
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @java.lang.Deprecated
+ public static UpdateType valueOf(int value) {
+ return forNumber(value);
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ */
+ public static UpdateType forNumber(int value) {
+ switch (value) {
+ case 1: return SET;
+ case 2: return ITEM_REMOVE;
+ case 3: return ITEM_SET;
+ case 4: return ITEM_REPLACE;
+ case 5: return ITEM_MERGE;
+ case 6: return ARRAY_INSERT;
+ case 7: return ARRAY_APPEND;
+ case 8: return MERGE_PATCH;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ UpdateType> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public UpdateType findValueByNumber(int number) {
+ return UpdateType.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.mysql.cj.x.protobuf.MysqlxCrud.UpdateOperation.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final UpdateType[] VALUES = values();
+
+ public static UpdateType valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private UpdateType(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:Mysqlx.Crud.UpdateOperation.UpdateType)
+ }
+
+ private int bitField0_;
+ public static final int SOURCE_FIELD_NUMBER = 1;
+ private com.mysql.cj.x.protobuf.MysqlxExpr.ColumnIdentifier source_;
+ /**
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ *
+ * required .Mysqlx.Expr.ColumnIdentifier source = 1;
+ * @return Whether the source field is set.
+ */
+ public boolean hasSource() {
+ return ((bitField0_ & 0x00000001) != 0);
+ }
+ /**
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ *
+ * required .Mysqlx.Expr.ColumnIdentifier source = 1;
+ */
+ public com.mysql.cj.x.protobuf.MysqlxExpr.ColumnIdentifierOrBuilder getSourceOrBuilder() {
+ return source_ == null ? com.mysql.cj.x.protobuf.MysqlxExpr.ColumnIdentifier.getDefaultInstance() : source_;
+ }
+
+ public static final int OPERATION_FIELD_NUMBER = 2;
+ private int operation_;
+ /**
+ *
+ ** the type of operation to be performed
+ *
+ *
+ * required .Mysqlx.Crud.UpdateOperation.UpdateType operation = 2;
+ * @return Whether the operation field is set.
+ */
+ public boolean hasOperation() {
+ return ((bitField0_ & 0x00000002) != 0);
+ }
+ /**
+ *
+ ** the type of operation to be performed
+ *
+ *
+ * required .Mysqlx.Crud.UpdateOperation.UpdateType operation = 2;
+ * @return The operation.
+ */
+ public com.mysql.cj.x.protobuf.MysqlxCrud.UpdateOperation.UpdateType getOperation() {
+ @SuppressWarnings("deprecation")
+ com.mysql.cj.x.protobuf.MysqlxCrud.UpdateOperation.UpdateType result = com.mysql.cj.x.protobuf.MysqlxCrud.UpdateOperation.UpdateType.valueOf(operation_);
+ return result == null ? com.mysql.cj.x.protobuf.MysqlxCrud.UpdateOperation.UpdateType.SET : result;
+ }
+
+ public static final int VALUE_FIELD_NUMBER = 3;
+ private com.mysql.cj.x.protobuf.MysqlxExpr.Expr value_;
+ /**
+ *
+ ** an expression to be computed as the new value for the operation
+ *
+ *
+ * optional .Mysqlx.Expr.Expr value = 3;
+ * @return Whether the value field is set.
+ */
+ public boolean hasValue() {
+ return ((bitField0_ & 0x00000004) != 0);
+ }
+ /**
+ *
+ ** an expression to be computed as the new value for the operation
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ *
+ * required .Mysqlx.Expr.ColumnIdentifier source = 1;
+ * @return Whether the source field is set.
+ */
+ public boolean hasSource() {
+ return ((bitField0_ & 0x00000001) != 0);
+ }
+ /**
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *
+ ** specification of the value to be updated
+ *- if data_model is TABLE, a column name may be specified and also
+ *a document path, if the column has type JSON
+ *- if data_model is DOCUMENT, only document paths are allowed
+ *@note in both cases, schema and table must be not set
+ *