001package com.hfg.sql.jdbc;
002
003import com.hfg.setting.IntSetting;
004import com.hfg.setting.Settings;
005
006//------------------------------------------------------------------------------
007/**
008 Settings for a JDBC-compatible connection.
009 <div>
010 @author J. Alex Taylor, hairyfatguy.com
011 </div>
012 */
013//------------------------------------------------------------------------------
014// com.hfg XML/HTML Coding Library
015//
016// This library is free software; you can redistribute it and/or
017// modify it under the terms of the GNU Lesser General Public
018// License as published by the Free Software Foundation; either
019// version 2.1 of the License, or (at your option) any later version.
020//
021// This library is distributed in the hope that it will be useful,
022// but WITHOUT ANY WARRANTY; without even the implied warranty of
023// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
024// Lesser General Public License for more details.
025//
026// You should have received a copy of the GNU Lesser General Public
027// License along with this library; if not, write to the Free Software
028// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
029//
030// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
031// jataylor@hairyfatguy.com
032//------------------------------------------------------------------------------
033
034public class JDBCConnectionSettings extends Settings
035{
036   private static final String CONNECT_TIMEOUT_SEC = "connect_timeout_sec";
037
038   private static int    sDefaultConnectTimeoutInSeconds = 15;
039
040
041   //###########################################################################
042   // CONSTRUCTORS
043   //###########################################################################
044
045   //---------------------------------------------------------------------------
046   public JDBCConnectionSettings()
047   {
048      super();
049   }
050
051   //---------------------------------------------------------------------------
052   @Override
053   protected void init()
054   {
055      add(new IntSetting(CONNECT_TIMEOUT_SEC, sDefaultConnectTimeoutInSeconds));
056   }
057
058   //###########################################################################
059   // PUBLIC METHODS
060   //###########################################################################
061
062   //---------------------------------------------------------------------------
063   public JDBCConnectionSettings setConnectTimeoutInSeconds(Integer inValue)
064   {
065      get(CONNECT_TIMEOUT_SEC).setValue(inValue);
066      return this;
067   }
068
069   //---------------------------------------------------------------------------
070   public Integer getConnectTimeoutInSeconds()
071   {
072      return (Integer) get(CONNECT_TIMEOUT_SEC).getValue();
073   }
074}