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

Provided Example doesn't work #39

Open
MuhammedSenussi opened this issue Nov 20, 2016 · 4 comments
Open

Provided Example doesn't work #39

MuhammedSenussi opened this issue Nov 20, 2016 · 4 comments

Comments

@MuhammedSenussi
Copy link

MuhammedSenussi commented Nov 20, 2016

Hi,

i've just started using postgres-async-driver and nothing from provided example worked.
here is my code:

`@Bean
Db db() {
log.info("\n\n==> @ VALUE CONNECTING>> {}/[user:{} , pass: {}]\n", DB_URL, DB_URL,DB_PASS);
return new ConnectionPoolBuilder()
.hostname("localhost")
.port(5432)
.database("eve-driver")
.username(DB_USER)
.password(DB_PASS)
.poolSize(20)
.build();
}
@Autowired
private Db db;

public static void main(String[] args) {
	SpringApplication.run(DriverApplication.class, args);
}

@Override
public void run(String... args) throws Exception {

	db.querySet("select 'Hello world!' as message")
    .map(result -> result.row(0).getString("message"))
    .subscribe(System.out::println);
	System.out.println("----------------------------------");
	db.querySet("insert into driver_event(id, type) values($1, $2)", 123, "hello")
    .subscribe(result -> System.out.printf("Inserted %d rows", result.updatedRows() ));
}`

but nothing printed at all

@haraldnh
Copy link
Contributor

As long as you don't have anything waiting for your async code to complete, I suspect your application shuts down before anything has time to run.

@MuhammedSenussi
Copy link
Author

@haraldnh

thanks for quick reply.
but the application is running not shut down. but no sign that code works even for inserting or retrieve 'hello world'

@alaisi
Copy link
Owner

alaisi commented Nov 21, 2016

Hi, as @haraldnh pointed out, you won't get any output if the JVM exits before the queries are completed.

You can also add a second argument to subscribe to get notified of possible errors (wrong password etc.).

@anko94
Copy link

anko94 commented Jun 17, 2019

@MuhammedSenussi
How did you beat this issue? I am facing the same problem now. Everything had worked just fine, but on last week i found out that query freezes and never ends. Connection is fine, query simply freezes and does nothing. I already tried migration to java 8 from 11, to spring 2.0.3 from 2.1.4. Nothing helped.

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

4 participants