Advertisement
Guest User

Untitled

a guest
Dec 16th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. @Override
  2. public Connection connect(String url, Properties info) throws SQLException {
  3. try {
  4. if (!acceptsURL(url)) {
  5. return null;
  6. }
  7. } catch (SQLException e) {
  8. throw new SQLException();
  9. }
  10. String username = info.getProperty("username", null);
  11. String password = info.getProperty("password", null);
  12. try {
  13. if (!canLogIn(username, password)) {
  14. // return null;
  15. }
  16. } catch (Exception e) {
  17. }
  18. if (!App.checkForExistence(info.get("path"))) {
  19. throw new SQLException();
  20. }
  21. File appDir = new File(info.get("path").toString());
  22. try {
  23. String writerType = url.substring(url.indexOf(':') + 1, url.lastIndexOf(':'));
  24. if (!appDir.exists()) {
  25. appDir.mkdirs();
  26. }
  27. return new eg.edu.alexu.csd.oop.DBMS.plugins.jdbc.Connection(appDir.getPath(),
  28. BackEndWriterFactory
  29. .getBackEndWriter(writerType.substring(0, writerType.length() - 2))); // the
  30. // url
  31. // is
  32. // on
  33. // the
  34. // form
  35. // ***db
  36. } catch (Exception e) {
  37. throw new SQLException();
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement