Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. insert into emp(name) values('test') <--- Works in SQL Plus
  2. insert into emp values('test2') <--- Works in SQL Plus
  3. insert into emp values(test2) <--- "ORA-00984: column not allowed here" in SQL Plus
  4.  
  5. package jagranerp.myapplication;
  6. import java.sql.Connection;
  7. import java.sql.DriverManager;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.sql.Statement;
  11.  
  12. import android.util.Log;
  13.  
  14. public class TestOracleJDBC {
  15. private Connection conn;
  16. private Statement stmt;
  17. public TestOracleJDBC() throws ClassNotFoundException {
  18. try {
  19.  
  20. Class.forName("oracle.jdbc.driver.OracleDriver");
  21. String url = "jdbc:oracle:thin:@192.168.1.111:1521/db1";
  22. this.conn = DriverManager.getConnection(url,"utk","utkarsh");
  23. this.conn.setAutoCommit(false);
  24. this.stmt = this.conn.createStatement();
  25.  
  26. } catch(SQLException e) {
  27. Log.d("tag", e.getMessage());
  28. }
  29. }
  30.  
  31.  
  32. public ResultSet getResult() throws SQLException {
  33. String s="insert into emp values ('test')";
  34. ResultSet res=stmt.executeQuery(s);
  35.  
  36. while(res.next()){
  37. System.out.println(res.getString(1));
  38. }return null;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement