davidmoten / davidmoten/rxjava2-jdbc

SQLException: Operation not allowed after ResultSet closed

Open
#38 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
394
Forks
41
Avg merge
2m
Merged PRs (30d)
1

Description

===> hi, every one, hi david, does anyone encounter these problem? i am desperate!
===> i want to iterate my db records from serveral tables.

===> i have the version:

rxjava2-jdbc:0.2.1
mysql-connector-java:8.0.13

===> and some of my code looks like this:

:
`userRepository.findAll().flatMap(new Function>>>() {

@Override
public Publisher>> apply(User user) {
return Mono.zip(Mono.just(user), shopRepository.findByUserId(user.id()), companyRepository.findByUserId(user.id()), Mono.just(productRepository.findByUserId(user.id())));
}

}).subscribe(new Subscriber>>() {
private Subscription subscription;
private int onNextAmount;

@Override
public void onSubscribe(Subscription subscription) {
this.subscription = subscription;
this.subscription.request(5);
}

@Override
public void onNext(Tuple4> objects) {
// do something...
onNextAmount++;
if (onNextAmount % 5 == 0) {
this.subscription.request(5);
}
}

@Override
public void onError(Throwable throwable) {
}

@Override
public void onComplete() {
}
});`

:
public Flux findAll(Integer num) {
String sql = SELECT + "where isdelete = 0 order by id";
return Flux.from(database.select(sql).autoMap(User.class));
}

:
public Mono findByUserId(Long userId) {
String sql = SELECT + "where user_id = ? and isdelete = 0";
return Mono.from(database.select(sql).parameter(userId).autoMap(Shop.class));
}

===> database config:
database = Database.nonBlocking()
.url(url)
.user(user)
.password(password)
.healthCheck(DatabaseType.MYSQL)
.maxPoolSize(maxPoolSize)
.build();

===> but i got these errors, sometimes is "ResultSet is from UPDATE. No Data", sometimes is "Operation not allowed after ResultSet closed", the error will occur occasionally, but rarely.

Caused by: java.sql.SQLException: ResultSet is from UPDATE. No Data.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.result.ResultSetImpl.next(ResultSetImpl.java:1813)
at org.davidmoten.rx.jdbc.Select.lambda$create$6(Select.java:77)
at io.reactivex.internal.operators.flowable.FlowableInternalHelper$SimpleBiGenerator.apply(FlowableInternalHelper.java:62)
at io.reactivex.internal.operators.flowable.FlowableInternalHelper$SimpleBiGenerator.apply(FlowableInternalHelper.java:53)
at io.reactivex.internal.operators.flowable.FlowableGenerate$GeneratorSubscription.request(FlowableGenerate.java:109)

===> following is another error.

Caused by: java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.result.ResultSetImpl.checkClosed(ResultSetImpl.java:470)
at com.mysql.cj.jdbc.result.ResultSetImpl.next(ResultSetImpl.java:1808)
at org.davidmoten.rx.jdbc.Select.lambda$create$6(Select.java:77)
at io.reactivex.internal.operators.flowable.FlowableInternalHelper$SimpleBiGenerator.apply(FlowableInternalHelper.java:62)
at io.reactivex.internal.operators.flowable.FlowableInternalHelper$SimpleBiGenerator.apply(FlowableInternalHelper.java:53)
at io.reactivex.internal.operators.flowable.FlowableGenerate$GeneratorSubscription.request(FlowableGenerate.java:109)
... 44 more

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.