1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.dbcp;
  17. /**
  18. * Configuration settings for handling abandoned db connections.
  19. *
  20. * @author Glenn L. Nielsen
  21. * @version $Revision: 1.5 $ $Date: 2004/02/28 11:48:04 $
  22. * @deprecated This will be removed in a future version of DBCP.
  23. */
  24. public class AbandonedConfig {
  25. private boolean removeAbandoned = false;
  26. /**
  27. * Flag to remove abandoned connections if they exceed the
  28. * removeAbandonedTimeout.
  29. *
  30. * Set to true or false, default false.
  31. * If set to true a connection is considered abandoned and eligible
  32. * for removal if it has been idle longer than the removeAbandonedTimeout.
  33. * Setting this to true can recover db connections from poorly written
  34. * applications which fail to close a connection.
  35. *
  36. * @return boolean
  37. */
  38. public boolean getRemoveAbandoned() {
  39. return (this.removeAbandoned);
  40. }
  41. /**
  42. * Flag to remove abandoned connections if they exceed the
  43. * removeAbandonedTimeout.
  44. *
  45. * Set to true or false, default false.
  46. * If set to true a connection is considered abandoned and eligible
  47. * for removal if it has been idle longer than the removeAbandonedTimeout.
  48. * Setting this to true can recover db connections from poorly written
  49. * applications which fail to close a connection.
  50. *
  51. * @param boolean
  52. */
  53. public void setRemoveAbandoned(boolean removeAbandoned) {
  54. this.removeAbandoned = removeAbandoned;
  55. }
  56. private int removeAbandonedTimeout = 300;
  57. /**
  58. * Timeout in seconds before an abandoned connection can be removed.
  59. *
  60. * Defaults to 300 seconds.
  61. *
  62. * @return int remove abandoned timeout in seconds
  63. */
  64. public int getRemoveAbandonedTimeout() {
  65. return (this.removeAbandonedTimeout);
  66. }
  67. /**
  68. * Timeout in seconds before an abandoned connection can be removed.
  69. *
  70. * Defaults to 300 seconds.
  71. *
  72. * @param int remove abandoned timeout in seconds
  73. */
  74. public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
  75. this.removeAbandonedTimeout = removeAbandonedTimeout;
  76. }
  77. private boolean logAbandoned = false;
  78. /**
  79. * Flag to log stack traces for application code which abandoned
  80. * a Statement or Connection.
  81. *
  82. * Defaults to false.
  83. * Logging of abandoned Statements and Connections adds overhead
  84. * for every Connection open or new Statement because a stack
  85. * trace has to be generated.
  86. *
  87. * @return boolean
  88. */
  89. public boolean getLogAbandoned() {
  90. return (this.logAbandoned);
  91. }
  92. /**
  93. * Flag to log stack traces for application code which abandoned
  94. * a Statement or Connection.
  95. *
  96. * Defaults to false.
  97. * Logging of abandoned Statements and Connections adds overhead
  98. * for every Connection open or new Statement because a stack
  99. * trace has to be generated.
  100. *
  101. * @param boolean
  102. */
  103. public void setLogAbandoned(boolean logAbandoned) {
  104. this.logAbandoned = logAbandoned;
  105. }
  106. }