Revision 45647 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MDBHelper.java
MDBHelper.java | ||
---|---|---|
43 | 43 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCCantFetchValueException; |
44 | 44 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException; |
45 | 45 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
46 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
46 | 47 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
48 |
import org.gvsig.fmap.dal.store.jdbc2.spi.ConnectionProvider; |
|
47 | 49 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCHelperBase; |
48 | 50 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
49 | 51 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCServerExplorerBase; |
... | ... | |
106 | 108 |
return connectionURL; |
107 | 109 |
} |
108 | 110 |
|
109 |
public static class ConnectionProvider { |
|
111 |
public static class ConnectionProviderImpl implements ConnectionProvider {
|
|
110 | 112 |
|
111 | 113 |
private static boolean needRegisterDriver = true; |
112 | 114 |
|
... | ... | |
118 | 120 |
private static String server = null; |
119 | 121 |
private static boolean startServer = true; |
120 | 122 |
|
121 |
public ConnectionProvider(MDBConnectionParameters connectionParameters) { |
|
123 |
public ConnectionProviderImpl(MDBConnectionParameters connectionParameters) {
|
|
122 | 124 |
this.connectionParameters = connectionParameters; |
123 | 125 |
} |
124 | 126 |
|
127 |
@Override |
|
128 |
public String getStatus() { |
|
129 |
StringBuilder builder = new StringBuilder(); |
|
130 |
builder.append("Pool: "); |
|
131 |
builder.append(JDBCUtils.getHexId(dataSource)); |
|
132 |
builder.append(" Actives: "); |
|
133 |
builder.append(dataSource.getNumActive()); |
|
134 |
builder.append("/"); |
|
135 |
builder.append(dataSource.getMaxActive()); |
|
136 |
builder.append(" idle: "); |
|
137 |
builder.append(dataSource.getNumIdle()); |
|
138 |
builder.append("/"); |
|
139 |
builder.append(dataSource.getMinIdle()); |
|
140 |
builder.append(":"); |
|
141 |
builder.append(dataSource.getMaxIdle()); |
|
142 |
return builder.toString(); |
|
143 |
} |
|
144 |
|
|
145 |
|
|
125 | 146 |
public static void stopServer() { |
126 | 147 |
try { |
127 | 148 |
// server.shutdown(); |
... | ... | |
247 | 268 |
} |
248 | 269 |
|
249 | 270 |
private ConnectionProvider connectionProvider = null; |
250 |
|
|
251 |
/** |
|
271 |
|
|
272 |
/**
|
|
252 | 273 |
* Constructor for use only for testing purposes. |
274 |
* |
|
275 |
* @param connectionParameters |
|
276 |
* @param connectionProvider |
|
253 | 277 |
*/ |
254 |
public MDBHelper() { |
|
255 |
super(null); |
|
278 |
public MDBHelper(JDBCConnectionParameters connectionParameters, ConnectionProvider connectionProvider) { |
|
279 |
super(connectionParameters); |
|
280 |
this.srssolver = new SRSSolverDumb(this); |
|
281 |
this.connectionProvider = connectionProvider; |
|
256 | 282 |
} |
257 |
|
|
283 |
|
|
258 | 284 |
public MDBHelper(JDBCConnectionParameters connectionParameters) { |
259 | 285 |
super(connectionParameters); |
260 | 286 |
this.srssolver = new SRSSolverDumb(this); |
... | ... | |
268 | 294 |
if( connectionParameters==null ) { |
269 | 295 |
return null; // Testing mode? |
270 | 296 |
} |
271 |
this.connectionProvider = new ConnectionProvider(connectionParameters); |
|
297 |
this.connectionProvider = new ConnectionProviderImpl(connectionParameters);
|
|
272 | 298 |
} |
273 | 299 |
Connection connection = this.connectionProvider.getConnection(); |
274 | 300 |
if( LOGGER.isDebugEnabled() ) { |
Also available in: Unified diff