java - Sqlite_master not updating -
i have function should return true if table exists in file (test.db). time working fine deleted .db file test rest of code able generate database scratch. however, instead of function returning false, continues return true though table not exist.
the code:
public static boolean tableexists(string table){ boolean tableexists = true; try{ sql = "select * sqlite_master name ='"+table+"' , type='table'; "; stmt.executeupdate(sql); }catch(exception e){ tableexists = false; } return tableexists; }
this function not check whether query returns data or not. (and executeupdate
not make sense select statements.)
you have try read query returns:
public static boolean tableexists(string table) { sql = "select 1 sqlite_master name ='"+table+"' , type='table'"; resultset rs = stmt.executequery(sql); return rs.first(); }
Comments
Post a Comment