Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. java.sql.SQLException: Database 'Mobsters' not found.
  2. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
  3. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
  4. at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
  5. at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
  6. at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
  7. at org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
  8. at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
  9. at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source)
  10. at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source)
  11. at java.security.AccessController.doPrivileged(Native Method)
  12. at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
  13. at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
  14. at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
  15. at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
  16. at java.sql.DriverManager.getConnection(DriverManager.java:664)
  17. at java.sql.DriverManager.getConnection(DriverManager.java:208)
  18. at com.adrian.mobsters.gui.controllers.MainController.getDBConnection(MainController.java:401)
  19. at com.adrian.mobsters.gui.controllers.MainController$2.call(MainController.java:388)
  20. at com.adrian.mobsters.gui.controllers.MainController$2.call(MainController.java:376)
  21. at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
  22. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  23. at java.lang.Thread.run(Thread.java:748)
  24. Caused by: ERROR XJ004: Database 'Mobsters' not found.
  25. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
  26. at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source)
  27. ... 22 more
  28.  
  29. create=true
  30. databaseName=Mobsters
  31. user=myuser
  32. password=mypw!
  33. shutdown=true
  34.  
  35. public void initializeDB() {
  36. Task<Void> task = new Task() {
  37. @Override
  38. protected Void call() throws Exception {
  39. Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
  40. Properties properties = loadDBProperties();
  41. // Decide on the db system directory: <userhome>/.addressbook/
  42. String userHomeDir = System.getProperty("user.home", ".");
  43. String systemDir = userHomeDir + "/.mobsters";
  44. new File(systemDir).mkdir();
  45. // Set the db system directory.
  46. System.setProperty("derby.system.home", systemDir);
  47.  
  48. getDBConnection(properties);
  49.  
  50. MobsterDBUtils.createMobsterTable(getDBConnection());
  51. return null;
  52. }
  53. };
  54.  
  55. new Thread(task).start();
  56. }
  57.  
  58. public void getDBConnection(Properties properties) {
  59. String url = "jdbc:derby:";
  60. try {
  61. connection.set(DriverManager.getConnection(url, properties));
  62. } catch (SQLException ex) {
  63. Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
  64. }
  65. }
  66.  
  67. public Properties loadDBProperties() {
  68. Properties prop = new Properties();
  69.  
  70. InputStream is = MainController.class.getResourceAsStream("/derby/DerbyConfig.properties");
  71.  
  72. try {
  73. prop.load(is);
  74. } catch (IOException ex) {
  75. Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
  76. }
  77.  
  78. return prop;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement