Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. package dbutil;
  2. import java.sql.*;
  3.  
  4. public class DBConnect {
  5. Connection conn = null;
  6. public DBConnect() throws Exception {
  7. Class.forName("oracle.jdbc.OracleDriver");
  8. Connection conn =
  9. DriverManager.getConnection("jdbc:oracle:thin:
  10. @localhost:1521:XE","system","9424705385");
  11.  
  12. }
  13. public void queryExecuter(String sql) throws Exception
  14. {
  15. //for insert, update and Delete DML
  16. Statement stat = conn.createStatement();
  17. stat.execute(sql);
  18. stat.close();
  19. conn.close();
  20. }
  21.  
  22. public ResultSet queryReturner(String sql) throws Exception
  23. { //select statement
  24. Statement stat = conn.createStatement();
  25. ResultSet rs = stat.executeQuery(sql);
  26. return rs;
  27. }
  28. }
  29.  
  30. package dbutil;
  31. import java.sql.*;
  32.  
  33. public class RegisterUser {
  34.  
  35. public void insertUser
  36. (String email,String pass,String name,String mobile)
  37. throws Exception
  38. {
  39. String sql = "insert into webreg
  40. value('"+email+"','"+pass+"','"+name+"','"+mobile+"')";
  41. DBConnect x = new DBConnect();
  42. x.queryExecuter(sql); //line showing error
  43. }
  44. public ResultSet getAllUser() throws Exception
  45.  
  46. {
  47. DBConnect x = new DBConnect();
  48. ResultSet rs = x.queryReturner("select * from webreg"); //line
  49. showing error
  50. return rs;
  51.  
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement