0

I am working towards creating a database template project in eclipse that contains all our SQL script files required for database deployment.

Keeping this in view, i have created a sample Java project in eclipse and added the SQL Development --> SQL files to the project. These SQL files contains a script for creating tables in the database. Now, I tried to clean and build the project to check if there are any build errors but i could not be able to clean and build the project(That contains SQL files) in eclipse.

Can you please let me know what needs to be done in order to clean and build the project (That contains SQL files) ? Also please suggest if a database template project can be created in eclipse?

Note: When i try to build the project it should validate the project to check if there are any errors in the SQL script files. Here i am using PostgreSQL database . Please suggest on what needs to be done

6
  • Which plug-ins do you have installed for SQL, SQL Development Tools? Commented Dec 27, 2017 at 14:04
  • I have using the PostgreSQL for my SQL development Commented Dec 28, 2017 at 4:28
  • I have using the PostgreSQL database for my SQL development. Will be creating a database project that contains SQL files for creating tables, Views, Functions etc... For this i am using a JAR file 'postgresql-42.1.4.jar'. Please suggest on how to create a database project, clean and build the project and validate errors in eclipse Commented Dec 28, 2017 at 4:35
  • I am using Dbeaver Plugin for my development purpose. First i tried using the Java and Database Development Perspective but could not find auto completion(Intellisense) feature for PostgreSQL commands. So Installed the Dbeaver plugin but i could not be able to clean and build the project in order to check for errors in any of the SQL file Commented Dec 28, 2017 at 4:39
  • Make sure you use the SQL Editor (right-click + Open With > ...), which supports autocomplete (Ctrl+Space). Commented Dec 28, 2017 at 10:27

1 Answer 1

0

DBeaver does not have the functionality you're looking for. While it is an Eclipse plugin, it does not function like a traditional Java project where you can clean/build the source files.

The tool mentioned in this answer might be able to help you: https://stackoverflow.com/a/13209943

Point it to your Eclipse workspace directory that contains your script files, e.g.:

$ find ~/eclipse-workspace/General/Scripts/ -name '*.sql' | xargs pgsanity

Edit:

You can set up Eclipse to use pgsanity to "build" your script files and check them for syntax errors (if you're on Linux). I'm using Ubuntu with Eclipse Oxygen and this is how I set it up:

Install pgsanity (via https://github.com/markdrago/pgsanity)

sudo apt-get install libecpg-dev 
sudo apt-get python-pip
sudo pip-install pgsanity

Configure Eclipse

From the menu go to Project -> Properties, select Builders from the left-hand menu and click "New...". Select Program as the builder type and click OK.

Create a new builder with the following options.

Name: pgsanity (or choose your own)
Location: /usr/local/bin/pgsanity
Working directory: ${workspace_loc:${project_path}/Scripts}
Arguments: ${build_files:f}

${workspace_loc:${project_path}/Scripts} will return the absolute path to the Scripts folder in your current project. If you're using the default DBeaver project configuration, you should have a scripts folder.

${build_files:f} returns the set of files that make up this build, which is the files changed or added since the last build.

Eclipse Edit Configuration Window

Build Project

Go to Project -> Build Project. Any syntax errors will be shown in the console. If no errors are shown, no files were selected for build or no files had syntax errors.

enter image description here

Sign up to request clarification or add additional context in comments.

9 Comments

I am using Windows OS... Does pgsanity support windows OS? f so, Please suggest the steps that need to be followed to install the pgsanity.
I can be able to install the pgsanity on my machine that has windows Operating System but when i try to build the project, it got stuck at 28% for about an hour with no progress further . It is showing the message "Building all .....Launching delegate". Can you please let me know what needs to be done in order to fix this?
Sounds like a configuration error. When you edit your build configuration, did you replace "usr/local/bin/pgsanity" with the Windows-style path? E.g. "C:/Program Files/..."? Can you run pgsanity from the command line outside of Eclipse to verify it's working?
Yeah i have replaced the location with that of the path present in my machine only... We need to provide the path of the pgsanity.exe file. right??? if so i have provided the exact path where the pgsanity.exe is resided
Yes. Can you run pgsanity for the command line with a .sql file as the input, e.g. C:\path\to\pgsanity.exe script1.sql ? Verifying it's working is step one. If that works, please provide a screenshot of your "Edit Configuration" window and provide your project directory structure.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.