Revision 23180
branches/v2_0_0_prep/libraries/libFMap_dataDB/src/org/gvsig/fmap/data/feature/db/jdbc/JDBCResource.java | ||
---|---|---|
31 | 31 |
package org.gvsig.fmap.data.feature.db.jdbc; |
32 | 32 |
|
33 | 33 |
import java.sql.Connection; |
34 |
import java.sql.SQLException; |
|
34 | 35 |
|
35 | 36 |
import org.gvsig.fmap.data.CloseException; |
36 | 37 |
import org.gvsig.fmap.data.DataException; |
... | ... | |
39 | 40 |
import org.gvsig.fmap.data.ReadException; |
40 | 41 |
import org.gvsig.fmap.data.Resource; |
41 | 42 |
import org.gvsig.fmap.data.ResourceChangedException; |
42 |
import org.gvsig.fmap.data.feature.file.FileStoreParameters; |
|
43 | 43 |
|
44 | 44 |
/** |
45 | 45 |
* @author jmvivo |
... | ... | |
58 | 58 |
* @see org.gvsig.fmap.data.Resource#doDispose() |
59 | 59 |
*/ |
60 | 60 |
protected void doDispose() throws DataException { |
61 |
this.connection = this.createConnection(); |
|
62 |
this.setOpened(); |
|
63 |
|
|
61 |
Connection con =this.connection; |
|
62 |
this.connection =null; |
|
63 |
if (con != null){ |
|
64 |
try { |
|
65 |
con.close(); |
|
66 |
} catch (SQLException e) { |
|
67 |
throw new DataException("Dispose Error",e); |
|
68 |
} |
|
69 |
} |
|
64 | 70 |
} |
65 | 71 |
|
66 | 72 |
/* (non-Javadoc) |
... | ... | |
146 | 152 |
* @throws InitializeException |
147 | 153 |
*/ |
148 | 154 |
public void setPassword(String password) throws InitializeException { |
149 |
if (this.getRefencesCount() > 0){
|
|
155 |
if (inUse()){
|
|
150 | 156 |
throw new InitializeException("Resource in use",this.description()); |
151 | 157 |
} |
152 | 158 |
this.password = password; |
153 | 159 |
} |
154 | 160 |
|
161 |
public boolean inUse() { |
|
162 |
return this.connection !=null; |
|
163 |
} |
|
164 |
|
|
155 | 165 |
/** |
156 | 166 |
* @return the url |
157 | 167 |
*/ |
... | ... | |
164 | 174 |
* @throws InitializeException |
165 | 175 |
*/ |
166 | 176 |
public void setUrl(String url) throws InitializeException { |
167 |
if (this.getRefencesCount() > 0){
|
|
177 |
if (inUse()){
|
|
168 | 178 |
throw new InitializeException("Resource in use",this.description()); |
169 | 179 |
} |
170 | 180 |
this.url = url; |
... | ... | |
205 | 215 |
|
206 | 216 |
} |
207 | 217 |
|
218 |
public boolean testConnection(){ |
|
219 |
try{ |
|
220 |
this.open(); |
|
221 |
} catch (OpenException e) { |
|
222 |
return false; |
|
223 |
} |
|
224 |
return true; |
|
225 |
} |
|
208 | 226 |
} |
209 | 227 |
|
Also available in: Unified diff