Java Code Examples for org.mariadb.jdbc.MariaDbDataSource#setPassword()

The following examples show how to use org.mariadb.jdbc.MariaDbDataSource#setPassword() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtil.java    From Mycat2 with GNU General Public License v3.0 6 votes vote down vote up
@SneakyThrows
public static Connection getMariaDBConnection() {
    String username = "root";
    String password = "123456";

    Properties properties = new Properties();
    properties.put("user", username);
    properties.put("password", password);
    properties.put("useBatchMultiSend", "false");
    properties.put("usePipelineAuth", "false");

    String url = "jdbc:mysql://0.0.0.0:8066/db1?useServerPrepStmts=false&useCursorFetch=false&serverTimezone=UTC&allowMultiQueries=false&useBatchMultiSend=false&characterEncoding=utf8";

    MariaDbDataSource mysqlDataSource = new MariaDbDataSource();
    mysqlDataSource.setUrl(url);
    mysqlDataSource.setUser(username);
    mysqlDataSource.setPassword(password);

    return mysqlDataSource.getConnection();
}
 
Example 2
Source File: TestUtil.java    From Mycat2 with GNU General Public License v3.0 6 votes vote down vote up
@SneakyThrows
public static Connection getMariaDBConnection() {
    String username = "root";
    String password = "123456";

    Properties properties = new Properties();
    properties.put("user", username);
    properties.put("password", password);
    properties.put("useBatchMultiSend", "false");
    properties.put("usePipelineAuth", "false");

    String url = "jdbc:mysql://0.0.0.0:8066/db1?useServerPrepStmts=false&useCursorFetch=false&serverTimezone=UTC&allowMultiQueries=false&useBatchMultiSend=false&characterEncoding=utf8";

    MariaDbDataSource mysqlDataSource = new MariaDbDataSource();
    mysqlDataSource.setUrl(url);
    mysqlDataSource.setUser(username);
    mysqlDataSource.setPassword(password);

    return mysqlDataSource.getConnection();
}
 
Example 3
Source File: MariaDbTestSettings.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public SQLDataSourceLocator getDataSourceLocator() {
    return new SQLDataSourceLocator() {
        public DataSource lookup(SQLDataSetDef def) throws Exception {
            String server = connectionSettings.getProperty("server");
            String database = connectionSettings.getProperty("database");
            String port = connectionSettings.getProperty("port");
            String user = connectionSettings.getProperty("user");
            String password = connectionSettings.getProperty("password");

            MariaDbDataSource ds = new MariaDbDataSource();
            ds.setServerName(server);
            ds.setDatabaseName(database);
            ds.setPortNumber(Integer.parseInt(port));
            if (!StringUtils.isBlank(user)) {
                ds.setUser(user);
            }
            if (!StringUtils.isBlank(password)) {
                ds.setPassword(password);
            }
            return ds;
        }
    };
}
 
Example 4
Source File: MariaDBDataSourceFactory.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@Override
protected DataSource createDataSource() {
    try {
        final MariaDBContainer container = mariaDBContainer();
        final MariaDbDataSource dataSource = new MariaDbDataSource();
        dataSource.setUrl(container.getJdbcUrl());
        dataSource.setUser(container.getUsername());
        dataSource.setPassword(container.getPassword());
        dataSource.setDatabaseName(container.getDatabaseName());
        return dataSource;
    } catch (SQLException e) {
        throw new RuntimeException("Unable to create MariaDB DataSource", e);
    }
}
 
Example 5
Source File: MariaDbDataSourceFactory.java    From mariadb-connector-j with GNU Lesser General Public License v2.1 5 votes vote down vote up
private MariaDbDataSource createBasicDataSource(Properties props) throws SQLException {
  MariaDbDataSource dataSource = new MariaDbDataSource();

  if (props.containsKey(JDBC_URL)) {
    dataSource.setUrl(props.getProperty(JDBC_URL));
  }
  if (props.containsKey(JDBC_SERVER_NAME)) {
    dataSource.setServerName(props.getProperty(JDBC_SERVER_NAME));
  }
  if (props.containsKey(JDBC_PORT_NUMBER)) {
    try {
      dataSource.setPortNumber(Integer.parseInt(props.getProperty(JDBC_PORT_NUMBER)));
    } catch (NumberFormatException nfe) {
      throw new SQLException(
          "Port format must be integer, but value is '"
              + props.getProperty(JDBC_PORT_NUMBER)
              + "'");
    }
  }
  if (props.containsKey(JDBC_USER)) {
    dataSource.setUser(props.getProperty(JDBC_USER));
  }
  if (props.containsKey(JDBC_PASSWORD)) {
    dataSource.setPassword(props.getProperty(JDBC_PASSWORD));
  }
  if (props.containsKey(JDBC_DATABASE_NAME)) {
    dataSource.setDatabaseName(props.getProperty(JDBC_DATABASE_NAME));
  }
  return dataSource;
}
 
Example 6
Source File: ZipkinMySQLContainer.java    From zipkin-dependencies with Apache License 2.0 5 votes vote down vote up
MariaDbDataSource getDataSource() throws SQLException {
  MariaDbDataSource dataSource = new MariaDbDataSource(
    getContainerIpAddress(),
    getMappedPort(MYSQL_PORT),
    getDatabaseName()
  );
  dataSource.setUser(getUsername());
  dataSource.setPassword(getPassword());
  return dataSource;
}