Yes, you can't use the conditional operator like that. It's intended to compute one expression or another as a result. It's not intended to be a way of choosing one statement to execute or another.
Just use:
if (checkDatabaseExist()) {
connectToDB();
} else {
buildDB();
}