-
Notifications
You must be signed in to change notification settings - Fork 41
Description
@configuration
public class RxJava2JdbcConfig {
/**
* https://www.programcreek.com/java-api-examples/index.php?api=com.github.davidmoten.rx.jdbc.Database
* @return
* @throws Exception
*/
@bean
public Database db() throws Exception {
ConnectionProvider connection = ConnectionProvider.from("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true", "root", "123456");
NonBlockingConnectionPool pool =
Pools.nonBlocking()
.maxPoolSize(Runtime.getRuntime().availableProcessors() * 5)
.connectionProvider(connection)
.build();
return Database.from(pool);
}
}
public Flux getAllAdverts3() {
String sql = "SELECT name,code FROM company";
return Flux.from(db.select(sql).autoMap(Company.class));
}
@query("select name, code from company")
public interface Company {
@column("name")
String name();
@Column("code")
String code();
}
result :
[
{}
]
but mysql have data