KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > sql > ConnectionConfig


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.sql;
31
32 import com.caucho.config.ConfigException;
33 import com.caucho.util.L10N;
34
35 import java.sql.Connection JavaDoc;
36
37 /**
38  * Configures the connection
39  */

40 public class ConnectionConfig {
41   private static final L10N L = new L10N(ConnectionConfig.class);
42
43   private int _isolation = -1;
44   private boolean _readOnly;
45   private String JavaDoc _catalog;
46
47   /**
48    * Sets the isolation of the connection.
49    */

50   public void setTransactionIsolation(String JavaDoc name)
51     throws ConfigException
52   {
53     if ("none".equals(name))
54       _isolation = Connection.TRANSACTION_NONE;
55     else if ("read-committed".equals(name))
56       _isolation = Connection.TRANSACTION_READ_COMMITTED;
57     else if ("read-uncommitted".equals(name))
58       _isolation = Connection.TRANSACTION_READ_UNCOMMITTED;
59     else if ("repeatable-read".equals(name))
60       _isolation = Connection.TRANSACTION_REPEATABLE_READ;
61     else if ("serializable".equals(name))
62       _isolation = Connection.TRANSACTION_SERIALIZABLE;
63     else
64       throw new ConfigException(L.l("'{0}' is an unknown transaction isolation.",
65                     name));
66   }
67
68   /**
69    * Returns the isolation of the connection, with -1 for the default.
70    */

71   public int getTransactionIsolation()
72   {
73     return _isolation;
74   }
75
76   /**
77    * Sets the read-only status.
78    */

79   public void setReadOnly(boolean isReadOnly)
80   {
81     _readOnly = isReadOnly;
82   }
83
84   /**
85    * Gets the read-only status.
86    */

87   public boolean isReadOnly()
88   {
89     return _readOnly;
90   }
91
92   /**
93    * Sets the catalog
94    */

95   public void setCatalog(String JavaDoc catalog)
96   {
97     _catalog = catalog;
98   }
99
100   /**
101    * Gets the catalog.
102    */

103   public String JavaDoc getCatalog()
104   {
105     return _catalog;
106   }
107 }
108
Popular Tags