Please don't mark my question as duplicate I tried other solutions but they are'nt working. I am trying to place a validation that , if table doesn't exist then create.
void checkCreateMeth()
{
try{
System.out.println("Implementing the functionality of create table if not exist or not.");
Class.forName(JDBC_Driver);
con=DriverManager.getConnection(DB_URL, user, pass);
stmt=con.createStatement();
String sql="CREATE TABLE IF NOT EXISTS VGRWER(name varchar(10),stream varchar(10))";
int rs=stmt.executeUpdate(sql);
System.out.println("Value of rs is="+rs);
}catch(Exception e)
{
e.printStackTrace();
}
}
Firstly I used exexuteQuery() it gave error "Can not issue data manipulation statements with executeQuery()"
Secondly , I tried executeUpdate() , it returned "0" when table was existing. It returned same value when I provided the table_name which was not existing.