Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class QueryExecution
- {
- public static QueryExecution queryObj;
- int flag=0;
- public QueryExecution()
- {
- }
- // This Method works for Table creation, Data Insertion, Updating Data, Data Deletion;
- public void excuteQuery(String statement,int flag)
- {
- this.flag=flag;
- try
- {
- LoadingScreen.uri=URI.create(LoadingScreen.dbLocation+"ManualRecords.db");
- LoadingScreen.database=DatabaseFactory.openOrCreate(LoadingScreen.uri, new DatabaseSecurityOptions(false));
- LoadingScreen.database.beginTransaction();
- Statement st=LoadingScreen.database.createStatement(statement);
- st.prepare();
- st.execute();
- st.close();
- LoadingScreen.database.commitTransaction();
- LoadingScreen.database.close();
- if(flag==1)
- {
- System.out.println("============================Table Created Successfully");
- }
- else if(flag==2)
- {
- UiApplication.getUiApplication().invokeLater(new Runnable()
- {
- public void run()
- {
- Dialog.alert("Record Added Successfully");
- }
- });
- }
- else if(flag==3)
- {
- UiApplication.getUiApplication().invokeLater(new Runnable()
- {
- public void run()
- {
- Dialog.alert("Record Updated Successfully");
- }
- });
- }
- }
- catch(Exception e)
- {
- try
- {
- LoadingScreen.database.commitTransaction();
- LoadingScreen.database.close();
- }
- catch(Exception exp)
- {
- exp.printStackTrace();
- System.out.println("Exception:======"+exp.getMessage()+"\n");
- }
- e.printStackTrace();
- System.out.println("Exception:======"+e.getMessage()+"\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement