org.codehaus.cargo.container.configuration.entry.DataSource.getPassword()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(15.1k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.codehaus.cargo.container.configuration.entry.DataSource.getPassword()方法的一些代码示例,展示了DataSource.getPassword()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataSource.getPassword()方法的具体详情如下:
包路径:org.codehaus.cargo.container.configuration.entry.DataSource
类名称:DataSource
方法名:getPassword

DataSource.getPassword介绍

[英]The password to use when connecting to the database.
[中]连接到数据库时要使用的密码。

代码示例

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-orion

  1. /**
  2. * adds common details such as username, password, and url. used by both XA and non-XA
  3. * connections.
  4. */
  5. private void addCommonConnectionAttributes()
  6. {
  7. buffer.append(" username='").append(ds.getUsername()).append("' \n");
  8. buffer.append(" password='").append(ds.getPassword()).append("' \n");
  9. if (ds.getUrl() != null)
  10. {
  11. buffer.append(" url='" + ds.getUrl()).append("' \n");
  12. }
  13. buffer.append(" inactivity-timeout='30'");
  14. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * adds common details such as username, password, and url. used by both XA and non-XA
  3. * connections.
  4. */
  5. private void addCommonConnectionAttributes()
  6. {
  7. buffer.append(" username='").append(ds.getUsername()).append("' \n");
  8. buffer.append(" password='").append(ds.getPassword()).append("' \n");
  9. if (ds.getUrl() != null)
  10. {
  11. buffer.append(" url='" + ds.getUrl()).append("' \n");
  12. }
  13. buffer.append(" inactivity-timeout='30'");
  14. }

代码示例来源:origin: codehaus-cargo/cargo

  1. @Override
  2. protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
  3. {
  4. propertiesMap.put("cargo.datasource.id", ds.getId());
  5. propertiesMap.put("cargo.datasource.driver", ds.getDriverClass());
  6. propertiesMap.put("cargo.datasource.url", ds.getUrl());
  7. propertiesMap.put("cargo.datasource.username", ds.getUsername());
  8. propertiesMap.put("cargo.datasource.password", ds.getPassword());
  9. propertiesMap.put("cargo.datasource.jndi", ds.getJndiLocation());
  10. propertiesMap.put("cargo.datasource.driver.classpath", getDataSourceClasspath());
  11. }

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-weblogic

  1. @Override
  2. protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
  3. {
  4. propertiesMap.put("cargo.datasource.id", ds.getId());
  5. propertiesMap.put("cargo.datasource.driver", ds.getDriverClass());
  6. propertiesMap.put("cargo.datasource.url", ds.getUrl());
  7. propertiesMap.put("cargo.datasource.username", ds.getUsername());
  8. propertiesMap.put("cargo.datasource.password", ds.getPassword());
  9. propertiesMap.put("cargo.datasource.jndi", ds.getJndiLocation());
  10. propertiesMap.put("cargo.datasource.type", ds.getConnectionType());
  11. propertiesMap.put("cargo.datasource.transactionsupport", ds.getTransactionSupport().
  12. toString());
  13. }
  14. }

代码示例来源:origin: codehaus-cargo/cargo

  1. @Override
  2. protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
  3. {
  4. propertiesMap.put("cargo.datasource.id", ds.getId());
  5. propertiesMap.put("cargo.datasource.driver", ds.getDriverClass());
  6. propertiesMap.put("cargo.datasource.url", ds.getUrl());
  7. propertiesMap.put("cargo.datasource.username", ds.getUsername());
  8. propertiesMap.put("cargo.datasource.password", ds.getPassword());
  9. propertiesMap.put("cargo.datasource.jndi", ds.getJndiLocation());
  10. propertiesMap.put("cargo.datasource.type", ds.getConnectionType());
  11. propertiesMap.put("cargo.datasource.transactionsupport", ds.getTransactionSupport().
  12. toString());
  13. }
  14. }

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-wildfly

  1. @Override
  2. protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
  3. {
  4. Map<String, String> datasourceProperties = new HashMap<String, String>();
  5. datasourceProperties.put("name", ds.getId());
  6. datasourceProperties.put("jndi-name", getDataSourceJndi(ds));
  7. datasourceProperties.put("driver-name", ds.getDriverClass());
  8. datasourceProperties.put("user-name", ds.getUsername());
  9. datasourceProperties.put("password", ds.getPassword());
  10. char delimiter = ',';
  11. Map<String, String> conProperties = PropertyUtils.toMap(ds.getConnectionProperties());
  12. String customProperties = PropertyUtils.joinOnDelimiter(conProperties, delimiter);
  13. datasourceProperties.put("xa-datasource-properties", customProperties);
  14. String dsProps = mapResourceProperties(datasourceProperties);
  15. propertiesMap.put("cargo.datasource.properties", dsProps);
  16. }
  17. }

代码示例来源:origin: codehaus-cargo/cargo

  1. @Override
  2. protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
  3. {
  4. Map<String, String> datasourceProperties = new HashMap<String, String>();
  5. datasourceProperties.put("name", ds.getId());
  6. datasourceProperties.put("jndi-name", getDataSourceJndi(ds));
  7. datasourceProperties.put("driver-name", ds.getDriverClass());
  8. datasourceProperties.put("user-name", ds.getUsername());
  9. datasourceProperties.put("password", ds.getPassword());
  10. char delimiter = ',';
  11. Map<String, String> conProperties = PropertyUtils.toMap(ds.getConnectionProperties());
  12. String customProperties = PropertyUtils.joinOnDelimiter(conProperties, delimiter);
  13. datasourceProperties.put("xa-datasource-properties", customProperties);
  14. String dsProps = mapResourceProperties(datasourceProperties);
  15. propertiesMap.put("cargo.datasource.properties", dsProps);
  16. }
  17. }

代码示例来源:origin: codehaus-cargo/cargo

  1. @Override
  2. protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
  3. {
  4. Map<String, String> datasourceProperties = new HashMap<String, String>();
  5. datasourceProperties.put("name", ds.getId());
  6. datasourceProperties.put("jndi-name", getDataSourceJndi(ds));
  7. datasourceProperties.put("driver-name", ds.getDriverClass());
  8. datasourceProperties.put("connection-url", ds.getUrl());
  9. datasourceProperties.put("user-name", ds.getUsername());
  10. datasourceProperties.put("password", ds.getPassword());
  11. if (TransactionSupport.NO_TRANSACTION.equals(ds.getTransactionSupport()))
  12. {
  13. datasourceProperties.put("jta", "false");
  14. }
  15. else
  16. {
  17. datasourceProperties.put("jta", "true");
  18. }
  19. String dsProps = mapResourceProperties(datasourceProperties);
  20. propertiesMap.put("cargo.datasource.properties", dsProps);
  21. }
  22. }

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-wildfly

  1. @Override
  2. protected void addConfigurationScriptProperties(Map<String, String> propertiesMap)
  3. {
  4. Map<String, String> datasourceProperties = new HashMap<String, String>();
  5. datasourceProperties.put("name", ds.getId());
  6. datasourceProperties.put("jndi-name", getDataSourceJndi(ds));
  7. datasourceProperties.put("driver-name", ds.getDriverClass());
  8. datasourceProperties.put("connection-url", ds.getUrl());
  9. datasourceProperties.put("user-name", ds.getUsername());
  10. datasourceProperties.put("password", ds.getPassword());
  11. if (TransactionSupport.NO_TRANSACTION.equals(ds.getTransactionSupport()))
  12. {
  13. datasourceProperties.put("jta", "false");
  14. }
  15. else
  16. {
  17. datasourceProperties.put("jta", "true");
  18. }
  19. String dsProps = mapResourceProperties(datasourceProperties);
  20. propertiesMap.put("cargo.datasource.properties", dsProps);
  21. }
  22. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * Test the driver properties when the password is set on datasource.
  3. */
  4. public void testDatabaseDriverPropertiesPasswordPropertySetsPasswordOnDataSource()
  5. {
  6. String driverPropertyString = "password=egg;CreateDatabase=create";
  7. String propertyString =
  8. DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString;
  9. DataSource ds = dataSourceConverter.fromPropertyString(propertyString);
  10. assertEquals("egg", ds.getPassword());
  11. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * Test the driver properties when an empty password is set on datasource.
  3. */
  4. public void testDatabaseDriverPropertiesEmptyPasswordPropertySetsPasswordOnDataSource()
  5. {
  6. String driverPropertyString = "password=;CreateDatabase=create";
  7. String propertyString =
  8. DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString;
  9. DataSource ds = dataSourceConverter.fromPropertyString(propertyString);
  10. assertEquals("", ds.getPassword());
  11. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * Test the driver properties when the username and the password is set on datasource.
  3. */
  4. public void testDatabaseDriverPropertiesUserAndPasswordPropertyOverrideDSUserAndPassword()
  5. {
  6. String driverPropertyString = "user=APP;password=egg;CreateDatabase=create";
  7. Properties props = new Properties();
  8. props.setProperty(DatasourcePropertySet.USERNAME, "sa");
  9. props.setProperty(DatasourcePropertySet.PASSWORD, "");
  10. props.setProperty(DatasourcePropertySet.CONNECTION_PROPERTIES, driverPropertyString);
  11. DataSource ds = dataSourceConverter.fromProperties(props);
  12. assertEquals("APP", ds.getUsername());
  13. assertEquals("egg", ds.getPassword());
  14. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * Test the {@link Properties} constructor.
  3. */
  4. public void testPropertiesConstructor()
  5. {
  6. Properties props = new Properties();
  7. props.setProperty(DatasourcePropertySet.ID, "rudolf");
  8. props.setProperty(DatasourcePropertySet.TRANSACTION_SUPPORT,
  9. TransactionSupport.NO_TRANSACTION.toString());
  10. props.setProperty(DatasourcePropertySet.JNDI_LOCATION, "jdbc/JiraDS");
  11. props
  12. .setProperty(DatasourcePropertySet.CONNECTION_TYPE, ConfigurationEntryType.JDBC_DRIVER);
  13. props.setProperty(DatasourcePropertySet.DRIVER_CLASS, "org.hsqldb.jdbcDriver");
  14. props.setProperty(DatasourcePropertySet.URL, "postresql:localhost:jirads");
  15. props.setProperty(DatasourcePropertySet.USERNAME, "sa");
  16. props.setProperty(DatasourcePropertySet.PASSWORD, "");
  17. DataSource ds = dataSourceConverter.fromProperties(props);
  18. assertEquals(0, ds.getConnectionProperties().size());
  19. assertEquals("", ds.getPassword());
  20. assertEquals(props, dataSourceConverter.toProperties(ds));
  21. }

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-tomcat

  1. /**
  2. * This method converts the DataSource to a Resource used in Tomcat.
  3. *
  4. * @return a Resource that can be used in Tomcat.
  5. * @param ds the DataSource we are configuring.
  6. */
  7. protected Resource convertToResource(DataSource ds)
  8. {
  9. Properties parameters = new Properties();
  10. PropertyUtils.setPropertyIfNotNull(parameters, "url", ds.getUrl());
  11. PropertyUtils.setPropertyIfNotNull(parameters, "username", ds.getUsername());
  12. PropertyUtils.setPropertyIfNotNull(parameters, "password", ds.getPassword());
  13. parameters.putAll(ds.getConnectionProperties());
  14. Resource resource = new Resource(ds.getJndiLocation(), ConfigurationEntryType.DATASOURCE);
  15. PropertyUtils.setPropertyIfNotNull(parameters, "driverClassName", ds.getDriverClass());
  16. resource.setParameters(PropertyUtils.toMap(parameters));
  17. return resource;
  18. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * This method converts the DataSource to a Resource used in Tomcat.
  3. *
  4. * @return a Resource that can be used in Tomcat.
  5. * @param ds the DataSource we are configuring.
  6. */
  7. protected Resource convertToResource(DataSource ds)
  8. {
  9. Properties parameters = new Properties();
  10. PropertyUtils.setPropertyIfNotNull(parameters, "url", ds.getUrl());
  11. PropertyUtils.setPropertyIfNotNull(parameters, "username", ds.getUsername());
  12. PropertyUtils.setPropertyIfNotNull(parameters, "password", ds.getPassword());
  13. parameters.putAll(ds.getConnectionProperties());
  14. Resource resource = new Resource(ds.getJndiLocation(), ConfigurationEntryType.DATASOURCE);
  15. PropertyUtils.setPropertyIfNotNull(parameters, "driverClassName", ds.getDriverClass());
  16. resource.setParameters(PropertyUtils.toMap(parameters));
  17. return resource;
  18. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * Test the driver properties when the username and the password is set on datasource.
  3. */
  4. public void testDatabaseDriverPropertiesUserAndPasswordPropertySetsDataSourceUserAndPassword()
  5. {
  6. String driverPropertyString = "user=APP;password=egg;CreateDatabase=create";
  7. String propertyString =
  8. DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString;
  9. DataSource ds = dataSourceConverter.fromPropertyString(propertyString);
  10. assertEquals("APP", ds.getUsername());
  11. assertEquals("egg", ds.getPassword());
  12. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * This method converts the DataSource to a Resource.
  3. *
  4. * @param ds DataSource to convert to a resource.
  5. * @param resourceType the type of the Resource to convert to. ex.
  6. * <code>javax.sql.DataSource</code>
  7. * @param driverParameter the name of the parameter to store {@link DataSource#getDriverClass()
  8. * driverClass}.
  9. * @return a Resource representing the assignable fields of the DataSource.
  10. */
  11. public Resource convertToResource(DataSource ds, String resourceType, String driverParameter)
  12. {
  13. Properties parameters = new Properties();
  14. if (ds.getUrl() != null)
  15. {
  16. PropertyUtils.setPropertyIfNotNull(parameters, "url", ds.getUrl());
  17. }
  18. PropertyUtils.setPropertyIfNotNull(parameters, "user", ds.getUsername());
  19. PropertyUtils.setPropertyIfNotNull(parameters, "password", ds.getPassword());
  20. PropertyUtils.setPropertyIfNotNull(parameters, driverParameter, ds.getDriverClass());
  21. parameters.putAll(ds.getConnectionProperties());
  22. Resource resource = new Resource(ds.getJndiLocation(), resourceType);
  23. resource.setParameters(PropertyUtils.toMap(parameters));
  24. return resource;
  25. }

代码示例来源:origin: codehaus-cargo/cargo

  1. /**
  2. * Get a properties object containing all of the members of this datasource object. Note that
  3. * driver properties will be nested and delimited by a semicolon.
  4. *
  5. * @param data DataSource to serialize into properties.
  6. * @return a properties object corresponding to this datasource
  7. */
  8. public Properties toProperties(DataSource data)
  9. {
  10. Properties properties = new Properties();
  11. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.JNDI_LOCATION, data
  12. .getJndiLocation());
  13. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.CONNECTION_TYPE,
  14. data.getConnectionType());
  15. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.TRANSACTION_SUPPORT,
  16. data.getTransactionSupport());
  17. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.DRIVER_CLASS, data
  18. .getDriverClass());
  19. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.URL, data.getUrl());
  20. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.USERNAME, data
  21. .getUsername());
  22. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.PASSWORD, data
  23. .getPassword());
  24. PropertyUtils.setPropertyIfNotNull(properties, DatasourcePropertySet.ID, data.getId());
  25. PropertyUtils.setPropertyIfNotNull(properties,
  26. DatasourcePropertySet.CONNECTION_PROPERTIES,
  27. getConnectionPropertiesAsASemicolonDelimitedString(data));
  28. return properties;
  29. }

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-jrun

  1. createTextContentChild(datasourceElement, "url", ds.getUrl());
  2. createTextContentChild(datasourceElement, "username", ds.getUsername());
  3. createTextContentChild(datasourceElement, "password", ds.getPassword());

代码示例来源:origin: org.codehaus.cargo/cargo-core-container-jboss

  1. getAntUtils().addTokenToFilterChain(filterChain, "driverClass", ds.getDriverClass());
  2. getAntUtils().addTokenToFilterChain(filterChain, "username", ds.getUsername());
  3. getAntUtils().addTokenToFilterChain(filterChain, "password", ds.getPassword());

相关文章