Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
feesx opened this issue Jan 31, 2019 · 2 comments
Open

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

feesx opened this issue Jan 31, 2019 · 2 comments

Comments

@feesx
Copy link

feesx commented Jan 31, 2019

@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

@davidmoten
Copy link
Owner

Did you check for an error emission from the Flux?

@davidmoten
Copy link
Owner

Instead of using spring have you tried to connect to the database directly using rxjava2-jdbc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants