Skip to content

SQLException: Operation not allowed after ResultSet closed #38

@freddybeta

Description

@freddybeta

===> 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:

<userService.java>:
`userRepository.findAll().flatMap(new Function<User, Publisher<Tuple4<User, Shop, Company, Flux>>>() {

@OverRide
public Publisher<Tuple4<User, Shop, Company, Flux>> 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<Tuple4<User, Shop, Company, Flux>>() {
private Subscription subscription;
private int onNextAmount;

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

@OverRide
public void onNext(Tuple4<User, Shop, Company, Flux> objects) {
// do something...
onNextAmount++;
if (onNextAmount % 5 == 0) {
this.subscription.request(5);
}
}

@OverRide
public void onError(Throwable throwable) {
}

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

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

<shopRepository.java>:
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

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