logging in ant script for running .sql - sql

I have a .sql file which contain create script for 20 tables.I am running this through ant.
the Ant Script is
<target name="CompleteDBRollCreate" >
<sql classpath="D:\lib\ojdbc14.jar" driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#12326:1521:orcl"
userid="scott" password="tiger"
src="D:\dropalltables.sql" />
</target>
but there is no logging in ant so I can't know if the SQL file was executed correctly. Can any one please suggest how to do logging into a separate localfile/on the ant console. I just want to know where I need to change the .sql file or the ant script.

There is logging in ant. Check out Running Apache Ant - Command Line:
-logfile use given file for log

-logfile will give you jdbc jdbc exceptions and all the noise around that, which can be useful, but I would also recommend spooling in the sql file as well as it looks like you are going to have multiple statements in the script. So I'd say you should use the -logfile option and also alter your script to spool any ORA errors you might encounter if you have multiple statements.
spool test.out
create table foo (testCol varchar2(2));
drop table foo;
spool off

Related

Liquibase over SSH: Unexpected error running Liquibase: <file> does not exist

We have been using Liquibase successfully for about six months. I'm moving to a new CI/CD pipeline using CircleCI and running into an error when running liquibase update over SSH.
Here's the command (after many iterations and much exploration of Liquibase documentation):
ssh $SSH_USER#$TEST_JOB_SSH_HOST "cd /var/www/html/liquibase ; liquibase --url=jdbc:$TEST_DB_URL/$TEST_DB_SCHEMA?user=$TEST_DB_USERNAME --username=$TEST_DB_USERNAME --password="\""$TEST_DB_PASSWORD"\"" --changelog-file=cl-main.xml --search-path=.,./ update --log-level 1"
The result:
However, the file does exist and can be seen here:
It was successfully executed several months ago using our old approach. Now I think Liquibase is just parsing files and somehow failing, likely because it's running from a different directory.
Here's a snippet from the changeset file:
<sqlFile dbms="mysql, mariadb"
encoding="UTF-8"
endDelimiter=";"
path="/../data/regional_integration_details-ingest_day-01.sql"
relativeToChangelogFile="true"
splitStatements="true"
stripComments="true"/>
I think the issue is the leading slash.
The command I pasted above was based on reviewing this help document: https://docs.liquibase.com/concepts/changelogs/how-liquibase-finds-files.html
I'm struggling with the proper syntax to include in the --search-path parameter -- if that's even the correct parameter -- to make this work.
The nuclear option (yet to be tested) is to update all of our changesets, removing the leading slash. I'd prefer not to go that route.
Suggestions?
Edit 1
Updating to mention that the first four changesets are parsed successfully. They have path values like ../dirname/sqlscript_00.sql. Liquibase chokes on the first script with /../dirname/sqlscript_01.sql.
Also, we have no problems running Liquibase in local development, when we cd to /var/www/html/liquibase in our Docker containers and execute the liquibase update command.
Edit 2
Having CircleCI SSH directly into the server doesn't work, as it doesn't carry the variables over with it.
Passing the commands via SSH preserves those variables.
Liquibase removed support for absolute paths in v4.x.

Liquibase - Test changeset before executing

I have a pipeline Jenkins that execute liquibase scripts. However, lots of time the pipeline failed because there are errors in the script.
I would like to test my script locally before running the pipeline. I would run the script locally to detect if there are errors (syntaxe problem, column that doesn't exist, etc), without creating an entry in the databasechangelog.
One option is to run updateSQL, which will display the sql that liquibase update WOULD run. You can take that sql and run it in any SQL query IDE of your choice to test syntax.

Bat file to run a sql query on a schedule through Task Scheduler

I am trying to run a .sql script on a schedule. I have created a batch file to run the script. The script runs fine in sql server management studio and also when I run the batch file content through cmd.
Contents of the batch file:
sqlcmd -S omfmesql -U OMESRV -P orat -i "\\pvsrv-
fsr14\data\Projects\Stat_Table_Creation_unique.sql"
The sql script is supposed to update a stat table. When I run it though cmd and refresh the stat table, the numbers are updated. But when I run this batch file through Task Scheduler, the only action that seems to be performed is running C:\Windows\SYSTEM32\cmd.exe
The task is stated to be completed successfully but the sql query is just not run.
I am not too experienced with Task Scheduler. Any help here would be very much appreciated. Thanks!
Note: I am not intending to use SQL Server Agent
If you have not done so, you need to set the location in Task Scheduler (TS). In at least some versions of TS, this can only be done when you create a basic task, not from the more general "Create Task..." option. Ensure that all the paths in the batch file are absolute or are based in this location.

Execute External commands Fitnesse/DBFit from within a Test page

I would like to execute external commands in my test from Fitnesse/DBFit from within a Test page.
For example, as part of a Unit Test:
run a remote ssh command towards host ABC and copy a file with win cp command
run a DB2 load command to import the data in the database from the file
run a stored procedure
verify results
May anyone advice regarding step 1) ?
There's been a few implementations of a CommandLineFixture - google commandlinefixture and you'll find them.

Failure to connect to derby database using ij from .bat file

I have a java application from which I need to delete and insert data into a local JDBC derby database. I'm trying to execute a SQL script that does this using the ij utility. I've written a batch file to handle this.
C:
C:\Progra~1\Sun\JavaDB\bin\ij.bat
connect 'jdbc:derby:D:\Documents and Settings\user\My Documents\mydatabase';
run "D:\Documents and Settings\user\sqlscript.sql";
disconnect;
exit;
When I run the batch file, the command prompt will execute up to line 2. The ij utility will load in the command prompt, but then the rest of the commands won't be run. I've tested each line by hand and it works fine (as does the SQL script). Is there anything I need to add to the batch file to make the last 4 lines execute? Thanks.
Put these commands in a file called 'commands.txt'
connect 'jdbc:derby:D:\Documents and Settings\user\My Documents\mydatabase';
run "D:\Documents and Settings\user\sqlscript.sql";
disconnect;
exit;
then run ij as follows from your batch file:
C:\Progra~1\Sun\JavaDB\bin\ij.bat commands.txt
You might have the add the exact path to to commands.txt if it is not in your current folder.