I am developing query browser in java where I want to restrict users from manipulating data. So am using executeQuery as I searched many question and all are answered that executeQuery is used to select and does not allow data manipulation as this on link.
Its working just fine with MySql but when its comes to Oracle am getting the error
ORA 00900: invalid SQL statement
but the real problem is, in database its updating the record. I am getting the same error for update, delete, insert and drop but all commands manipulating the data in database.
Now I have the option to check whether my query string start with data manipulation keywords but I am trying to avoid that checking and its working absolutely fine in MySql but not getting what is the issue with Oracle.
Below is the code sample
Connection conn = null;
Statement stmt = null;
ResultSet query_set = null;
try {
String query = "insert into users values(1,'name')";
Class.forName ("oracleDriver"); //Oracle driver as our database is Oracle.
conn = DriverManager.getConnection("oracleDbUrl", "dbUsername", "dbchecksum"); //login credentials to the database
stmt = conn.createStatement();
query_set = stmt.executeQuery(query);
} catch(Exception e) {
e.printStackTrace();
}
Kindly suggest how can I restrict users from data manipulation without applying checks on query string and the reason behind this behavior of Oracle.