MCPcopy Create free account
hub / github.com/apache/tomcat / open

Method open

java/org/apache/catalina/realm/DataSourceRealm.java:375–401  ·  view source on GitHub ↗

Open the specified database connection. @return Connection to the database

()

Source from the content-addressed store, hash-verified

373 * @return Connection to the database
374 */
375 protected Connection open() {
376
377 try {
378 Context context;
379 if (localDataSource) {
380 context = ContextBindings.getClassLoader();
381 context = (Context) context.lookup("comp/env");
382 } else {
383 Server server = getServer();
384 if (server == null) {
385 connectionSuccess = false;
386 containerLog.error(sm.getString("dataSourceRealm.noNamingContext"));
387 return null;
388 }
389 context = server.getGlobalNamingContext();
390 }
391 DataSource dataSource = (DataSource) context.lookup(dataSourceName);
392 Connection connection = dataSource.getConnection();
393 connectionSuccess = true;
394 return connection;
395 } catch (Exception e) {
396 connectionSuccess = false;
397 // Log the problem for posterity
398 containerLog.error(sm.getString("dataSourceRealm.exception"), e);
399 }
400 return null;
401 }
402
403 @Override
404 protected String getPassword(String username) {

Callers 4

authenticateMethod · 0.95
getPasswordMethod · 0.95
getPrincipalMethod · 0.95
getRolesMethod · 0.95

Calls 7

getClassLoaderMethod · 0.95
lookupMethod · 0.65
getServerMethod · 0.65
errorMethod · 0.65
getStringMethod · 0.65
getConnectionMethod · 0.45

Tested by

no test coverage detected