List of usage examples for org.apache.commons.dbcp BasicDataSource setPassword
public synchronized void setPassword(String password)
Sets the #password .
Note: this method currently has no effect once the pool has been initialized.
From source file:com.ameer.testweb.app.conf.ConnectionConfig.java
@Bean public DataSource dataSource() { BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUrl("jdbc:derby://localhost:1527/payroll"); ds.setUsername("testweb"); ds.setPassword("admin"); return ds;/* w ww.j av a 2 s . c o m*/ }
From source file:com.cws.esolutions.security.utils.DAOInitializer.java
/** * @param properties - The <code>AuthRepo</code> object containing connection information * @param isContainer - A <code>boolean</code> flag indicating if this is in a container * @param bean - The {@link com.cws.esolutions.security.SecurityServiceBean} <code>SecurityServiceBean</code> that holds the connection * @throws SecurityServiceException {@link com.cws.esolutions.security.exception.SecurityServiceException} * if an exception occurs opening the connection *///from w w w .j a v a 2 s.com public synchronized static void configureAndCreateAuthConnection(final InputStream properties, final boolean isContainer, final SecurityServiceBean bean) throws SecurityServiceException { String methodName = DAOInitializer.CNAME + "#configureAndCreateAuthConnection(final String properties, final boolean isContainer, final SecurityServiceBean bean) throws SecurityServiceException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("InputStream: {}", properties); DEBUGGER.debug("isContainer: {}", isContainer); DEBUGGER.debug("SecurityServiceBean: {}", bean); } try { Properties connProps = new Properties(); connProps.load(properties); if (DEBUG) { DEBUGGER.debug("Properties: {}", connProps); } AuthRepositoryType repoType = AuthRepositoryType .valueOf(connProps.getProperty(DAOInitializer.REPO_TYPE)); RepositoryConnectionType connType = RepositoryConnectionType .valueOf(connProps.getProperty(DAOInitializer.CONN_TYPE)); if (DEBUG) { DEBUGGER.debug("AuthRepositoryType: {}", repoType); DEBUGGER.debug("RepositoryConnectionType: {}", connType); } switch (repoType) { case LDAP: SSLUtil sslUtil = null; LDAPConnection ldapConn = null; LDAPConnectionPool connPool = null; LDAPConnectionOptions connOpts = new LDAPConnectionOptions(); connOpts.setAutoReconnect(true); connOpts.setAbandonOnTimeout(true); connOpts.setBindWithDNRequiresPassword(true); connOpts.setConnectTimeoutMillis( Integer.parseInt(connProps.getProperty(DAOInitializer.CONN_TIMEOUT))); connOpts.setResponseTimeoutMillis( Integer.parseInt(connProps.getProperty(DAOInitializer.READ_TIMEOUT))); if (DEBUG) { DEBUGGER.debug("LDAPConnectionOptions: {}", connOpts); } switch (connType) { case CONNECTION_TYPE_INSECURE: ldapConn = new LDAPConnection(connOpts, connProps.getProperty(DAOInitializer.REPOSITORY_HOST), Integer.parseInt(connProps.getProperty(DAOInitializer.REPOSITORY_PORT))); if (DEBUG) { DEBUGGER.debug("LDAPConnection: {}", ldapConn); } if (!(ldapConn.isConnected())) { throw new LDAPException(ResultCode.CONNECT_ERROR, "Failed to establish an LDAP connection"); } connPool = new LDAPConnectionPool(ldapConn, Integer.parseInt(connProps.getProperty(DAOInitializer.MIN_CONNECTIONS)), Integer.parseInt(connProps.getProperty(DAOInitializer.MAX_CONNECTIONS))); break; case CONNECTION_TYPE_SSL: sslUtil = new SSLUtil(new TrustStoreTrustManager( connProps.getProperty(DAOInitializer.TRUST_FILE), PasswordUtils .decryptText(connProps.getProperty(DAOInitializer.TRUST_PASS), connProps.getProperty(DAOInitializer.TRUST_SALT), secConfig.getSecretAlgorithm(), secConfig.getIterations(), secConfig.getKeyBits(), secConfig.getEncryptionAlgorithm(), secConfig.getEncryptionInstance(), systemConfig.getEncoding()) .toCharArray(), connProps.getProperty(DAOInitializer.TRUST_TYPE), true)); if (DEBUG) { DEBUGGER.debug("SSLUtil: {}", sslUtil); } SSLSocketFactory sslSocketFactory = sslUtil.createSSLSocketFactory(); if (DEBUG) { DEBUGGER.debug("SSLSocketFactory: {}", sslSocketFactory); } ldapConn = new LDAPConnection(sslSocketFactory, connOpts, connProps.getProperty(DAOInitializer.REPOSITORY_HOST), Integer.parseInt(connProps.getProperty(DAOInitializer.REPOSITORY_PORT))); if (DEBUG) { DEBUGGER.debug("LDAPConnection: {}", ldapConn); } if (!(ldapConn.isConnected())) { throw new LDAPException(ResultCode.CONNECT_ERROR, "Failed to establish an LDAP connection"); } connPool = new LDAPConnectionPool(ldapConn, Integer.parseInt(connProps.getProperty(DAOInitializer.MIN_CONNECTIONS)), Integer.parseInt(connProps.getProperty(DAOInitializer.MAX_CONNECTIONS))); break; case CONNECTION_TYPE_TLS: ldapConn = new LDAPConnection(connOpts, connProps.getProperty(DAOInitializer.REPOSITORY_HOST), Integer.parseInt(connProps.getProperty(DAOInitializer.REPOSITORY_PORT))); if (DEBUG) { DEBUGGER.debug("LDAPConnection: {}", ldapConn); } if (!(ldapConn.isConnected())) { throw new LDAPException(ResultCode.CONNECT_ERROR, "Failed to establish an LDAP connection"); } sslUtil = new SSLUtil(new TrustStoreTrustManager( connProps.getProperty(DAOInitializer.TRUST_FILE), PasswordUtils .decryptText(connProps.getProperty(DAOInitializer.TRUST_PASS), connProps.getProperty(DAOInitializer.TRUST_SALT), secConfig.getSecretAlgorithm(), secConfig.getIterations(), secConfig.getKeyBits(), secConfig.getEncryptionAlgorithm(), secConfig.getEncryptionInstance(), systemConfig.getEncoding()) .toCharArray(), connProps.getProperty(DAOInitializer.TRUST_TYPE), true)); if (DEBUG) { DEBUGGER.debug("SSLUtil: {}", sslUtil); } SSLContext sslContext = sslUtil.createSSLContext(); if (DEBUG) { DEBUGGER.debug("SSLContext: {}", sslContext); } StartTLSExtendedRequest startTLS = new StartTLSExtendedRequest(sslContext); if (DEBUG) { DEBUGGER.debug("StartTLSExtendedRequest: {}", startTLS); } ExtendedResult extendedResult = ldapConn.processExtendedOperation(startTLS); if (DEBUG) { DEBUGGER.debug("ExtendedResult: {}", extendedResult); } BindRequest bindRequest = new SimpleBindRequest( connProps.getProperty(DAOInitializer.REPOSITORY_USER), PasswordUtils.decryptText(connProps.getProperty(DAOInitializer.TRUST_PASS), connProps.getProperty(DAOInitializer.TRUST_SALT), secConfig.getSecretAlgorithm(), secConfig.getIterations(), secConfig.getKeyBits(), secConfig.getEncryptionAlgorithm(), secConfig.getEncryptionInstance(), systemConfig.getEncoding())); if (DEBUG) { DEBUGGER.debug("BindRequest: {}", bindRequest); } BindResult bindResult = ldapConn.bind(bindRequest); if (DEBUG) { DEBUGGER.debug("BindResult: {}", bindResult); } StartTLSPostConnectProcessor tlsProcessor = new StartTLSPostConnectProcessor(sslContext); if (DEBUG) { DEBUGGER.debug("StartTLSPostConnectProcessor: {}", tlsProcessor); } connPool = new LDAPConnectionPool(ldapConn, Integer.parseInt(connProps.getProperty(DAOInitializer.MIN_CONNECTIONS)), Integer.parseInt(connProps.getProperty(DAOInitializer.MAX_CONNECTIONS)), tlsProcessor); break; } if (DEBUG) { DEBUGGER.debug("LDAPConnectionPool: {}", connPool); } if ((connPool == null) || (connPool.isClosed())) { throw new LDAPException(ResultCode.CONNECT_ERROR, "Failed to establish an LDAP connection"); } bean.setAuthDataSource(connPool); break; case SQL: // the isContainer only matters here if (isContainer) { Context initContext = new InitialContext(); Context envContext = (Context) initContext.lookup(DAOInitializer.DS_CONTEXT); bean.setAuthDataSource(envContext.lookup(DAOInitializer.REPOSITORY_HOST)); } else { BasicDataSource dataSource = new BasicDataSource(); dataSource.setInitialSize( Integer.parseInt(connProps.getProperty(DAOInitializer.MIN_CONNECTIONS))); dataSource .setMaxActive(Integer.parseInt(connProps.getProperty(DAOInitializer.MAX_CONNECTIONS))); dataSource.setDriverClassName(connProps.getProperty(DAOInitializer.CONN_DRIVER)); dataSource.setUrl(connProps.getProperty(DAOInitializer.REPOSITORY_HOST)); dataSource.setUsername(connProps.getProperty(DAOInitializer.REPOSITORY_USER)); dataSource.setPassword(PasswordUtils.decryptText( connProps.getProperty(DAOInitializer.REPOSITORY_PASS), connProps.getProperty(DAOInitializer.REPOSITORY_SALT), secConfig.getSecretAlgorithm(), secConfig.getIterations(), secConfig.getKeyBits(), secConfig.getEncryptionAlgorithm(), secConfig.getEncryptionInstance(), systemConfig.getEncoding())); bean.setAuthDataSource(dataSource); } break; case NONE: return; default: throw new SecurityServiceException("Unhandled ResourceType"); } } catch (LDAPException lx) { throw new SecurityServiceException(lx.getMessage(), lx); } catch (GeneralSecurityException gsx) { throw new SecurityServiceException(gsx.getMessage(), gsx); } catch (NamingException nx) { throw new SecurityServiceException(nx.getMessage(), nx); } catch (FileNotFoundException fnfx) { throw new SecurityServiceException(fnfx.getMessage(), fnfx); } catch (IOException iox) { throw new SecurityServiceException(iox.getMessage(), iox); } }
From source file:com.startup.musicstore.app.conf.ConnectionConfig.java
@Bean public DataSource dataSource() { BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUrl("jdbc:derby://localhost:1527/musicstore"); ds.setUsername("admin1"); ds.setPassword("admin1"); return ds;//from w ww .j a va 2 s.c o m }
From source file:com.stickyd.app.conf.ConnectionConfig.java
@Bean public DataSource dataSource() { BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUrl("jdbc:derby://localhost:1527/stickyd"); ds.setUsername("admin1"); ds.setPassword("admin1"); return ds;// ww w . j ava 2 s .c om }
From source file:mx.com.pixup.portal.dao.DiscoPaisGenerateDaoJdbc.java
public DiscoPaisGenerateDaoJdbc(String archivo) throws IOException { BasicDataSource dataSource = new BasicDataSource(); //seccion de la DB dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("root"); dataSource.setPassword("admin"); //dataSource.setPassword("mysqlroot"); dataSource.setUrl("jdbc:mysql://localhost:3306/pixup"); this.dataSource = dataSource; //seccion XML this.xmlLogico = new Document(); this.xmlFisico = new XMLOutputter(); this.archivoFisico = new FileWriter(archivo); }
From source file:com.googlecode.jdbcproc.daofactory.guice.SimpleModule.java
@Provides @Singleton/*from ww w. ja v a 2 s . c om*/ DataSource provideDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://localhost:3306/jdbcprocdb"); dataSource.setUsername("jdbcproc"); dataSource.setPassword("jdbcproc"); dataSource.setDefaultAutoCommit(true); dataSource.setValidationQuery("call create_collections()"); return dataSource; }
From source file:com.sourcesense.maven.dbdep.plugin.DbDependenciesMojo.java
public void execute() throws MojoExecutionException { List activeProfiles = project.getActiveProfiles(); ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { SPRING_CONTEXT }); IDbDependenciesMojoBl dbDepMojoBl = (IDbDependenciesMojoBl) context .getBean(IDbDependenciesMojoBl.BEAN_NAME); BasicDataSource ds = (BasicDataSource) context.getBean(DATASOURCE_BEAN_NAME); ds.setDriverClassName(jdbcDriverClassName); ds.setUrl(jdbcUrl);//from w w w .j a v a 2 s.c o m ds.setUsername(jdbcUsername); ds.setPassword(jdbcPassword); String environment = dbDepMojoBl.getEnvironment(activeProfiles); dbDepMojoBl.write(project, name, environment); }
From source file:com.paballo.propertywebapp.app.conf.ConnectionConfig.java
@Bean public BasicDataSource dataSource() { BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUrl("jdbc:derby://localhost:1527/sample"); ds.setUsername("app"); ds.setPassword("app"); return ds;//from w w w. j av a 2s .c om }
From source file:com.tchouyangoko.humain.app.config.ConnectionConfig.java
@Bean public DataSource dataSource() { BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUrl("jdbc:derby://localhost:1527/sample"); ds.setUsername("app"); ds.setPassword("app"); return ds;/* w w w. j av a 2 s . c o m*/ }
From source file:com.mycompany.carshop.app.conf.ConnectionConfig.java
@Bean public DataSource dataSource() { BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); ds.setUrl("jdbc:derby://localhost:1527/carshop"); ds.setUsername("carshopadmin"); ds.setPassword("admin"); return ds;/*from w w w.j a v a2 s. c o m*/ }