Skip to content

springboot2 webflux(2.1.2)+rxjava2-jdbc nodata #40

@feesx

Description

@feesx

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions