Hello there and thanks in advance for any reply, I'm creating a restful web service and I would like to know:
How to execute a "table exporting query" from eclipse
the query works, it backs up the file, the only problem is it's not being executed for some reason from eclipse
Important to add, I'm using oracle's database express.
in sqlplus: $exp USERID=hr/password TABLES=(hr.students) FILE=exp_tab.dmp
from cmd: sqlplus /as sysdba $exp USERID=hr/password TABLES=(hr.students) FILE=exp_tab.dmp
The method, where I attempted to execute such query is combined with anotherinsert query
My objective is to backup the table (to a file on a local drive) after every insert
note: Yes, I know I can create a trigger for that.
public static boolean insertUser(int id, String name, String gender, int grade) throws SQLException, Exception { boolean insertStatus = false; Connection dbConn = null; try { try { dbConn = DBConnection.createConnection(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } Statement stmt_backup = dbConn.createStatement(); Statement stmt = dbConn.createStatement(); String query = "INSERT into students(id, name, gender, grade) " + "values('"+id+"',"+"'"+name+"','"+gender+"','"+grade+"')"; String query_backup = "$exp USERID=hr/password TABLES=(hr.students) FILE=exp_tab.dmp"; stmt_backup.executeQuery(query_backup); stmt_backup.close(); //System.out.println(query); int records = stmt.executeUpdate(query); //System.out.println(records); //When record is successfully inserted if (records > 0) { insertStatus = true; } } catch (SQLException sqle) { //sqle.printStackTrace(); throw sqle; } catch (Exception e) { //e.printStackTrace(); // TODO Auto-generated catch block if (dbConn != null) { dbConn.close(); } throw e; } finally { if (dbConn != null) { dbConn.close(); } } return insertStatus; } PS: I've tried doing that with one statement , and got the same result. Also I tried replacing executeQuery(query_backup); with executeUpdate(Query_backup);