Java Code Examples for org.springframework.data.r2dbc.core.DatabaseClient

The following examples show how to use org.springframework.data.r2dbc.core.DatabaseClient. These examples are extracted from open source projects. 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 Project: spring-fu   Source File: MssqlDatabaseClientInitializer.java    License: Apache License 2.0 7 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {

	MssqlConnectionConfiguration.Builder builder = MssqlConnectionConfiguration
			.builder()
			.host(this.properties.getHost())
			.port(this.properties.getPort())
			.database(this.properties.getDatabase())
			.username(this.properties.getUsername())
			.password(this.properties.getPassword())
			.connectTimeout(this.properties.getConnectTimeout())
			.preferCursoredExecution(this.properties.isPreferCursoredExecution());

	if (this.properties.isSsl()) {
		builder.enableSsl();
	}

	MssqlConnectionConfiguration configuration = builder.build();

	context.registerBean(DatabaseClient.class, () -> DatabaseClient.builder().connectionFactory(new MssqlConnectionFactory(configuration)).build());
}
 
Example 2
Source Project: cloud-spanner-r2dbc   Source File: SpannerR2dbcDialectIT.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the integration test environment for the Spanner R2DBC dialect.
 */
@BeforeEach
public void initializeTestEnvironment() {
  Connection connection = Mono.from(connectionFactory.create()).block();

  this.databaseClient = DatabaseClient.create(connectionFactory);

  if (SpannerTestUtils.tableExists(connection, "PRESIDENT")) {
    this.databaseClient.execute("DROP TABLE PRESIDENT")
        .fetch()
        .rowsUpdated()
        .block();
  }

  this.databaseClient.execute(
      "CREATE TABLE PRESIDENT ("
          + "  NAME STRING(256) NOT NULL,"
          + "  START_YEAR INT64 NOT NULL"
          + ") PRIMARY KEY (NAME)")
      .fetch()
      .rowsUpdated()
      .block();
}
 
Example 3
Source Project: cf-butler   Source File: R2dbcAppMetricsRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public R2dbcAppMetricsRepository(
	DatabaseClient client,
	DbmsSettings settings) {
	this.client = client;
	this.settings = settings;
}
 
Example 4
Source Project: cf-butler   Source File: R2dbcPoliciesRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public R2dbcPoliciesRepository(
	DatabaseClient dbClient,
	PolicyIdProvider idProvider,
	ObjectMapper mapper) {
	this.dbClient = dbClient;
	this.idProvider = idProvider;
	this.mapper = mapper;
}
 
Example 5
Source Project: cf-butler   Source File: DatabaseCreator.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public DatabaseCreator(
	DatabaseClient client,
	ResourceLoader resourceLoader,
	DbmsSettings settings,
	ApplicationEventPublisher publisher) {
	this.client = client;
	this.resourceLoader = resourceLoader;
	this.settings = settings;
	this.publisher = publisher;
}
 
Example 6
@Bean
ApplicationRunner runner(DatabaseClient dbc, ReservationRepository reservationRepository) {
	return args -> {

		dbc.execute("create table reservation\n" + "(\n" + "    id   serial primary key,\n"
				+ "    name varchar(255) not null\n" + ")").fetch().rowsUpdated().subscribe();

		reservationRepository.save(new Reservation(null, "Andy")).subscribe();
		reservationRepository.save(new Reservation(null, "Sebastien")).subscribe();

		reservationRepository.findAll().subscribe(System.out::println);
		;
	};
}
 
Example 7
Source Project: spring-fu   Source File: H2DatabaseClientInitializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {

	H2ConnectionConfiguration configuration = H2ConnectionConfiguration
			.builder()
			.url(this.properties.getUrl())
			.username(this.properties.getUsername())
			.password(this.properties.getPassword())
			.build();

	context.registerBean(DatabaseClient.class, () -> DatabaseClient.builder().connectionFactory(new H2ConnectionFactory(configuration)).build());

}
 
Example 8
@Override
public void initialize(GenericApplicationContext context) {

	PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration
			.builder()
			.host(this.properties.getHost())
			.port(this.properties.getPort())
			.database(this.properties.getDatabase())
			.username(this.properties.getUsername())
			.password(this.properties.getPassword())
			.build();

	context.registerBean(DatabaseClient.class, () -> DatabaseClient.builder().connectionFactory(new PostgresqlConnectionFactory(configuration)).build());
}
 
Example 9
Source Project: spring-fu   Source File: MysqlDatabaseClientInitializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {

	JasyncConnectionFactory jasyncConnectionFactory = new JasyncConnectionFactory(new MySQLConnectionFactory(
			URLParser.INSTANCE.parseOrDie(properties.getUrl(), StandardCharsets.UTF_8)));
	context.registerBean(DatabaseClient.class, () -> DatabaseClient.builder().connectionFactory(jasyncConnectionFactory).build());
}
 
Example 10
@Autowired
public R2dbcServiceInstanceMetricsRepository(
	DatabaseClient client) {
	this.client = client;
}
 
Example 11
Source Project: cf-butler   Source File: R2dbcSpaceUsersRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public R2dbcSpaceUsersRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 12
Source Project: cf-butler   Source File: R2dbcAppDetailRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public R2dbcAppDetailRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 13
Source Project: cf-butler   Source File: R2dbcOrganizationRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public R2dbcOrganizationRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 14
Source Project: cf-butler   Source File: R2dbcTkRepository.java    License: Apache License 2.0 4 votes vote down vote up
public R2dbcTkRepository(DatabaseClient client) {
    this.client = client;
}
 
Example 15
Source Project: cf-butler   Source File: R2dbcHistoricalRecordRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public R2dbcHistoricalRecordRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 16
@Autowired
public R2dbcServiceInstanceDetailRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 17
Source Project: cf-butler   Source File: R2dbcSpaceRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public R2dbcSpaceRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 18
Source Project: cf-butler   Source File: R2dbcQueryRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public R2dbcQueryRepository(DatabaseClient client) {
    this.client = client;
}
 
Example 19
Source Project: cf-butler   Source File: R2dbcAppRelationshipRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public R2dbcAppRelationshipRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 20
Source Project: spring-fu   Source File: UserRepository.java    License: Apache License 2.0 4 votes vote down vote up
public UserRepository(DatabaseClient client) {
	this.client = client;
}
 
Example 21
public DataInitializer(DatabaseClient databaseClient) {
    this.databaseClient = databaseClient;
}
 
Example 22
public DataInitializer(DatabaseClient databaseClient) {
    this.databaseClient = databaseClient;
}
 
Example 23
public DataInitializer(DatabaseClient databaseClient) {
    this.databaseClient = databaseClient;
}
 
Example 24
public DataInitializer(DatabaseClient databaseClient) {
    this.databaseClient = databaseClient;
}
 
Example 25
public DataInitializer(DatabaseClient databaseClient) {
    this.databaseClient = databaseClient;
}
 
Example 26
public R2dbcDbRepository(DatabaseClient databaseClient) {
    this.databaseClient = databaseClient;
}
 
Example 27
@Bean
public DatabaseClient databaseClient(ConnectionFactory connectionFactory) {
    return DatabaseClient.create(connectionFactory);
}
 
Example 28
Source Project: spring-data-dev-tools   Source File: R2dbcBenchmark.java    License: Apache License 2.0 3 votes vote down vote up
@Setup
public void setUp() {

	R2dbcFixture fixture = new R2dbcFixture(profile);

	ConfigurableApplicationContext context = fixture.getContext();

	this.operations = context.getBean(DatabaseClient.class);
	this.mapper = row -> new Book(row.get("id", Long.class), row.get("title", String.class),
			row.get("pages", Integer.class));

	this.repository = context.getBean(R2dbcBookRepository.class);
}