Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package eg.edu.alexu.csd.oop.JDBC.Connection;
  2.  
  3. import eg.edu.alexu.csd.oop.DBMSAdaptar;
  4. import eg.edu.alexu.csd.oop.JDBC.Statement.DBStatement;
  5. import eg.edu.alexu.csd.oop.JDBC.Statement.DBStatementAdapter;
  6.  
  7. import java.sql.SQLException;
  8. import java.sql.Statement;
  9.  
  10. public class DBConnectionAdapter extends DBConnection{
  11.  
  12. DBMSAdaptar adaptar;
  13. private String path;
  14. DBStatement statement;
  15. DBConnectionAdapter connectionAdapter = null;
  16. public DBConnectionAdapter getInstance(){
  17. return connectionAdapter;
  18. }
  19.  
  20. public DBConnectionAdapter(String path){
  21. adaptar = new DBMSAdaptar();
  22. try {
  23. adaptar.createDatabase("Create Database "+path.trim()) ;
  24. connectionAdapter = this;
  25. } catch (SQLException e) {
  26. e.printStackTrace();
  27. }
  28. }
  29.  
  30. public Statement createStatement() throws SQLException {
  31. if(connectionAdapter==null)throw new SQLException();
  32. if(statement==null){
  33. statement = new DBStatementAdapter(this.adaptar,this);
  34. return statement;}
  35. else{
  36. return statement;
  37. }
  38. }
  39.  
  40. public void close() throws SQLException {
  41. adaptar = null ;
  42. statement = null ;
  43. connectionAdapter = null ;
  44. }
  45. }//DB con = new DB("SA")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement