stmt.executeUpdate();
if(returnLastInsertId) {
ResultSet rs = stmt.getGeneratedKeys();
rs.next();
auto_id = rs.getInt(1);
}
package fs.rxtest;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Cancellable;
public class Main {
public interface Listener{
void onNewBoolean(Boolean bool);
}
Listener listener;
void registeredListener(Listener listener){
System.out.println("register");
this.listener = listener;
}
void unregisteredListener(){
System.out.println("unregister");
this.listener = null;
}
public static void main(String[] args) {
Main main = new Main();
Observable<Boolean> booleanObservable = Observable.create(
new ObservableOnSubscribe<Boolean>() {
@Override
public void subscribe(ObservableEmitter<Boolean> e) throws Exception {
main.registeredListener(new Listener() {
@Override
public void onNewBoolean(Boolean bool) {
if(!e.isDisposed()) {
e.onNext(bool);
}
}
});
e.setCancellable(new Cancellable() {
@Override
public void cancel() throws Exception {
main.unregisteredListener();
}
});
}
}
);
Disposable subscribe = booleanObservable.subscribe(System.out::println);
main.setValue(true);
main.setValue(true);
main.setValue(true);
main.setValue(true);
subscribe.dispose();
main.setValue(true);
Disposable subscribe1 = booleanObservable.subscribe(b -> System.out.println("2:"));
main.setValue(false);
}
private void setValue(boolean b) {
if (listener!=null)
listener.onNewBoolean(b);
}
}
Могу я пройти этот курс бесплатно?
You can access all videos, readings, and discussions, free of charge. You can also submit assignments and earn a grade for free. If you want to earn a Course Certificate, you can subscribe or apply for financial aid.