Advertisement
Guest User

Untitled

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