Pergunta

I want to check wether a table named basestation exists in a MySQL table from a Java program using JDBC. My code is:

conn = DriverManager.getConnection(url, username, password);

DatabaseMetaData dbm = conn.getMetaData();

tables = dbm.getTables(null, null, "basestations", null);

if (tables.next())
{   
     //Table exists in database
     //...
}
else
{
     //Table does not exist
     //...
}

but although table basestations exists in my database it seems that my code never enters the first clause and always decides that table does not exist, causing naturally a table already exists in database SQL error when trying to create the table from the beginning.

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top