0

I am pretty new to this. I am trying to set up a local Java environment, and my attempts at connecting my database via JDBC have failed so I am also trying to create a local version of the database using existing .sql files and an .sh file:

mazefire-recreate-db.sh:

cd src/main/sql

# DROP tables
mysql --user=**** --password=**** mazefirehg < mazefire-db-schema-DROP-mysql.sql
# Recreate tables (existing and new)
mysql --user=**** --password=**** mazefirehg < mazefire-db-schema-mysql.sql
mysql --user=**** --password=**** mazefirehg < mazefire-db-schema-new-tables.sql
# Reference/existing/new data import
mysql --user=**** --password=**** mazefirehg < mazefire-db-existing-data.sql
mysql --user=**** --password=**** mazefirehg < mazefire-db-data-new-tables.sql
# ALTER scripts
mysql --user=**** --password=**** mazefirehg < dbupdate-001-alter-answers.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-002-alter-users.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-003-alter-played.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-004-alter-mazes.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-006-new-table-subscription.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-007-alter-mazes-images.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-008-alter-questions-issue-61.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-009-alter-mazes-images.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-010-alter-played-gotRightTwice.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-011-alter-mazes-images.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-012-alter-mazes-images-biology101.3.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-013-alter-played-large-fields.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-014-alter-mazes-images-biology101.4.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-015-alter-mazes-categories.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-016-update-pages.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-017-alter-played-invalid-entry.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-018-update-pages.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-019-create-userconnection.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-020-alter-user.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-021-alter-mazes-categories-MEDscience.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-022-update-pages.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-023-new-table-maze_collection-and-collection_maze.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-024-alter-mazes-categories.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-025-alter-questions-special-characters.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-026-alter-collections.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-027-alter-in_collection.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-029-alter-collection.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-030-new-table-player_collection.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-031-alter-player_collection.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-032-alter-played.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-033-update-mazes-thumbnails.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-034-update-mazes-thumbnails-may13-2015.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-035-alter-answers-special-characters.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-036-alter-questions-explain-special-characters.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-037-alter-mazes-isStretched.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-038-update-mazes-thumbnails-may30-2015.sql

mysql --user=**** --password=**** mazefirehg < dbupdate-040-update-users-data.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-039-update-latest-data-jun11-2015.sql

mysql --user=**** --password=**** mazefirehg < dbupdate-042-alter-mazes-thumbImages-size.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-041-update-mazes-thumbnails-June13-2015.sql

mysql --user=**** --password=**** mazefirehg < dbupdate-043-alter-mazes-isPack.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-044-update-mazes-isPack.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-045-update-mazes-thumbnails-June17-2015.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-046-create-trigger-for-old-new-site-integration.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-047-update-mazes-thumbnails-June24-2015.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-048-insert-and-update-mazes.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-049-insert-anatomy-and-physiology-2.10-maze-data.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-050-missing-AnP-mazes-from-pak.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-051_alter_maze_collections.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-052_remove_unused_collection_tables.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-053-update-Pages.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-054-collections-cleanup.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-055-create-user-purchased-mazes.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-056-update-maze-thumbnails-Biochem-Microbiology.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-057-create-pharmacology-collection.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-058-microbiology-collection-and-other-cleanup.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-059-collections-category-cleanup-new-biochem-collection.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-060-update-Pages.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-061-microbiology-collection-updates-copy.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-062-create_user_purchased-collections.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-063-update-maze-thumbnails-microbiology_astrobiology.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-064-update-microbiology-collection-categories-fix-for-healthcare.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-065-update-collections-verbiage.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-066-maze-thumnail-image-for-Anp2.9.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-067-change-collection-description-size.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-068-alter-played.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-069-alter-played-increase-size-of-pathtaken-and-gotwrong.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-070-alter-table-played.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-071-alter-table-answers.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-072-alter-table-played.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-073-new-table-testimonial.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-074-update-table-testimonial.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-075-alter-table-played.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-076-alter-table-played.sql
# Updates from here for teacher dashboard
mysql --user=**** --password=**** mazefirehg < dbupdate-077-alter-table-users-teachers.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-078-alter-admin-users.sql
mysql --user=**** --password=**** mazefirehg < dbupdate-079-revert-admin-column.sql

cd ../../../

Each of the sql files referenced are doing some combination of creating tables, importing data, etc. I am using IntelliJ and found I can Before Launch "Run External Tool" via the Run/Debug Configurations. You can see my Run/Debug Configurations as well as my External Tool Configurations.

I am unsure if I should be referencing other files/directories:

Program: the path to where the mazefire-recreate-db.sh file resides.
Also tried referencing "mazefire.recreate-db.bat" file.
Parameters: the actual .sh file.
Working directory: the path to where all the .sql files that create/modify/import/etc. the database reside.

The error I get for now is:

Error running 'database': Cannot run program "/Users/jayjapra/IdeaProjects/MazePilot" (in directory "/Users/jayjapra/IdeaProjects/MazePilot/src/main/sql"): error=13, Permission denied

even though I used chmod to add execute permissions so I don't believe I am referencing correctly.

halfer
  • 19,824
  • 17
  • 99
  • 186
JKJ
  • 1
  • 3

1 Answers1

0

In Program text field, specify the full path to the program you want to run (i.e.full path to the .sh file: /Users/jayjapra/IdeaProjects/MazePilot/mazefire-recreate-db.sh).

Parameters - is for, well, the parameters (if any) for your program (script), i.e. .../recreate-db.sh -arg1 -arg2 etc I suppose you have none.

Working directory the current directory from where the program(script) will be launched. See documentation for Edit tool dialog for the description of each option.

P.s. Are you sure you want to re-create the database each time you launch Tomcat and deploy the application to the server? This is what IDE will do each time you launch it, according to your setup.

Andrey
  • 15,144
  • 25
  • 91
  • 187
  • Thanks @andrey I used `/Users/jayjapra/IdeaProjects/MazePilot/` as the **working directory** and it executed the build. Unfortunately it appears the database still is not getting created. As mentioned I tried a JDBC setup but am getting a lot of errors, mainly "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure" and I don't think I am able to figure out what of the many possible problems [https://stackoverflow.com/questions/2983248/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-communications-link-fai] – JKJ Sep 05 '17 at 13:27
  • Make sure you specify correct host and port and that the remote database is running and is configured to accept connections on that port. Write to https://intellij-support.jetbrains.com/hc/en-us/requests/new if connection problem remains to check the parameters you enter in database connection settings. – Andrey Sep 05 '17 at 14:50
  • My host is via aws and my port is default 3306 and I am able to remotely connect with those settings via MySQL Workbench as well as the IntelliJ Database Tool window. Even though those work, I get the "communication error" when running the build with the settings above. Should I post a different question for this since it has to do with JDBC and not the script? – JKJ Sep 05 '17 at 21:07