<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://bamcgill.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://bamcgill.github.io/" rel="alternate" type="text/html" /><updated>2026-05-18T20:47:01+00:00</updated><id>https://bamcgill.github.io/feed.xml</id><title type="html">Barry McGillin</title><subtitle>Oracle Database Tools — SQLcl, SQL Developer, ORDS, and more.</subtitle><author><name>Barry McGillin</name></author><entry><title type="html">Long Running Tasks in SQLcl</title><link href="https://bamcgill.github.io/2024/03/long-running-tasks-in-sqlcl/" rel="alternate" type="text/html" title="Long Running Tasks in SQLcl" /><published>2024-03-19T00:00:00+00:00</published><updated>2026-05-18T00:00:00+00:00</updated><id>https://bamcgill.github.io/2024/03/long-running-tasks-in-sqlcl</id><content type="html" xml:base="https://bamcgill.github.io/2024/03/long-running-tasks-in-sqlcl/"><![CDATA[<p>SQLcl 24.1 introduced a way to run tasks in parallel. Any command that makes sense to run in the background — a long-running query, a Liquibase changeset generation, a data export — can now be kicked off without blocking your session.</p>

<p>Three commands work together to make this happen: <code class="language-plaintext highlighter-rouge">background</code>, <code class="language-plaintext highlighter-rouge">jobs</code>, and <code class="language-plaintext highlighter-rouge">wait4</code>.</p>

<h2 id="the-commands">The commands</h2>

<p><strong><code class="language-plaintext highlighter-rouge">background</code></strong> (or <code class="language-plaintext highlighter-rouge">bg</code>) takes any SQLcl or SQL*Plus command and runs it as a background task. You can name the task and optionally wait for another task to complete before it starts.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SQL&gt; help background syntax
 background|bg [-wait4|-w4 &lt;wait4&gt;] [-taskname|-tn &lt;taskname&gt;] &lt;commandspec&gt;
</code></pre></div></div>

<p><strong><code class="language-plaintext highlighter-rouge">jobs</code></strong> lists and manages background tasks — check status, view logs, or clean up finished work.</p>

<p><strong><code class="language-plaintext highlighter-rouge">wait4</code></strong> pauses execution until a specific task (or list of tasks) completes, or waits for a given number of milliseconds. Useful for scripting dependencies between tasks.</p>

<h2 id="running-a-command-in-the-background">Running a command in the background</h2>

<p>Take a Liquibase changeset generation as an example. Normally you’d run it in the foreground:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SQL&gt; liquibase generate-db-object -object-name employees -object-type table -sql
--Starting Liquibase at 2024-03-19T23:10:47 (version 4.26.0)
Changelog created and written out to file employees_table.xml
Operation completed successfully.
</code></pre></div></div>

<p>That blocks your session until it finishes. With <code class="language-plaintext highlighter-rouge">background</code>, you can fire it off and keep working:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SQL&gt; background -taskname lb-employees liquibase generate-db-object -object-name employees -object-type table -sql
Started task with id: 2

SQL&gt; jobs
 2: [ Running ] lb-employees (/Users/bamcgill/.sqlcl/jobslogs/lbemployees.log)
</code></pre></div></div>

<p>The task runs in the background. Check on it with <code class="language-plaintext highlighter-rouge">jobs</code>, and pull the output with <code class="language-plaintext highlighter-rouge">jobs logs</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SQL&gt; jobs logs -id 2
--Starting Liquibase at 2024-03-19T23:21:09 (version 4.26.0)
Changelog created and written out to file employees_table.xml
Operation completed successfully.

SQL&gt; jobs
 2: [ Finished ] lb-employees (/Users/bamcgill/.sqlcl/jobslogs/lbemployees.log)
</code></pre></div></div>

<p>The output is identical to running the command in the foreground — it’s just not blocking you while it works.</p>

<h2 id="where-this-matters">Where this matters</h2>

<p>The obvious use case is kicking off several independent tasks at once — generate changesets for multiple schemas, run exports in parallel, or execute long-running reports while you continue working in the same session.</p>

<p>Combined with <code class="language-plaintext highlighter-rouge">wait4</code>, you can script task dependencies: start task A and task B in parallel, then <code class="language-plaintext highlighter-rouge">wait4</code> both before starting task C. That’s a simple but effective orchestration pattern without leaving the command line.</p>

<p><a href="https://www.oracle.com/database/sqldeveloper/technologies/sqlcl/download/">Download the latest SQLcl from oracle.com</a> and give it a try.</p>]]></content><author><name>Barry McGillin</name></author><category term="SQLcl" /><category term="Oracle" /><category term="Database Tools" /><category term="Liquibase" /><summary type="html"><![CDATA[SQLcl 24.1 introduced background task execution — run any command in parallel, name it, track it, and wait for it to finish.]]></summary></entry><entry><title type="html">git bash completion</title><link href="https://bamcgill.github.io/2019/10/git-bash-completion/" rel="alternate" type="text/html" title="git bash completion" /><published>2019-10-11T15:15:00+00:00</published><updated>2019-10-11T15:15:47+00:00</updated><id>https://bamcgill.github.io/2019/10/git-bash-completion</id><content type="html" xml:base="https://bamcgill.github.io/2019/10/git-bash-completion/"><![CDATA[<p>Try this in bash</p>

<p><code class="language-plaintext highlighter-rouge">git p</code></p>

<p>You get a file names p or a list of them.  Thats not much good, but there is a great bash completion library which you can source in your .bashrc to give you valid completion targets</p>

<p><code class="language-plaintext highlighter-rouge">$git p  
pull  
push  
$git p</code></p>

<p>Pull this <a href="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash">file</a> and source it in your .bashrc</p>

<p><code class="language-plaintext highlighter-rouge">$wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash  
$echo . $PWD/git-completion.bash &gt;&gt; ~/.bashrc</code></p>

<p>Open up a new terminal window and enjoy.</p>]]></content><author><name>Barry McGillin</name></author><summary type="html"><![CDATA[Try this in bash git p You get a file names p or a list of them.  Thats not much good, but there is a great bash completion library which you can source in your .bashrc to give you valid completion targets $git p pull push $git p Pull this file and source it in your .bashrc $wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash $echo . $PWD/git-completion.bash &gt;&gt; ~/.bashrc Open up a new terminal window and enjoy.]]></summary></entry><entry><title type="html">Migrating Subversion to Git with LFS</title><link href="https://bamcgill.github.io/2018/08/migrating-subversion-to-git-with-lfs/" rel="alternate" type="text/html" title="Migrating Subversion to Git with LFS" /><published>2018-08-03T18:36:00+00:00</published><updated>2019-10-11T15:21:23+00:00</updated><id>https://bamcgill.github.io/2018/08/migrating-subversion-to-git-with-lfs</id><content type="html" xml:base="https://bamcgill.github.io/2018/08/migrating-subversion-to-git-with-lfs/"><![CDATA[<p>When a project has been on the go for a while theres going to be all sorts of stuff in there from jars to zips and everything in between.  We went though this a while ago and wanting to keep all the history, we needed a way to prune the history of all the big files and weird things we were not going to move to git.</p>

<p>Now we knew we had some large files, namely binary files like jars which were build dependencies before we moved to artifactory for a lot of it.  So, before we start we need to make sure that git is installed, and git-lfs.  Git-lfs should be on the path so git can find it and you’ll need to make sure git svn can run.  You’ll need perl and  to run cpan (Comprehensive Perl Archive Network) to install the SVN::Core modules.</p>

<h2 id="initialisation">Initialisation</h2>

<p>As a test to start, make sure git and git lfs are on the path and that git svn runs.</p>

<p>bamcgill@bamcgill-mac[~]</p>

<ul>
  <li>$ git –version</li>
</ul>

<p>git version 2.15.2 (Apple Git-101.1)</p>

<p>bamcgill@bamcgill-mac[~]</p>

<ul>
  <li>$ git lfs version</li>
</ul>

<p>git-lfs/2.3.4 (GitHub; darwin amd64; go 1.9.1)</p>

<p>bamcgill@bamcgill-mac[~]</p>

<ul>
  <li>$ git svn</li>
</ul>

<p>git-svn - bidirectional operations between a single Subversion tree and git</p>

<p>usage: git svn  [options] [arguments]</p>

<h2 id="clone-empty-git-repository">Clone Empty GIT Repository</h2>

<p>Before the migration, we should create an empty repository for importing the subversion repository into.  Then we can clone it to start the migration</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone git@gitlab.yourcompany.com:group-name/gitrepo.git
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<h2 id="clone-the-subversion-repository-into-the-empty-git-repository">Clone the subversion repository into the empty git repository</h2>

<p>Before we do the clone, we need to build a file of the authors on the svn</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" &lt;"$2"&gt;"}' | sort -u &gt; authors.txt
</code></pre></div></div>

<p>Now we need to edit that file which has a format like this</p>

<p>bamcgill = bamcgill</p>

<p>to a format like this</p>

<p>bamcgill = Barry McGillin</p>

<p>This file is then used to map the users in subversion to the new decorated users in git.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git svn clone https://server.company.com/svn/project/trunk gitrepo --authors-file=authors.txt &gt; loglog 2&gt;&amp;1
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<p>We push the output into a log file because it takes ages and you can scroll back and see where the actual clone is.  This pulls the entire history from revision 1 to HEAD and drops it into the git repository</p>

<h2 id="clean-up-the-git-repository-metadata">Clean up the GIT Repository Metadata</h2>

<p>Now, we use a really handy utility: BFG: Removes large or troublesome blobs like git-filter-branch does. For this exercise we run the utility twice. Once to strip blobs larger than 1M</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>java -jar bfg-1.13.0.jar --strip-blobs-bigger-than 1M git-repo
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Now fix the changes into the repository.
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd git-repo &amp;&amp; git reflog expire --expire=now --all &amp;&amp; git gc --prune=now --aggressive &amp;&amp; cd -
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<p>Now for the second run of the BFG, we want to convert a bunch of things like binary files to Large File Storage</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>java -jar bfg-1.13.0.jar --convert-to-git-lfs "*.{rar,dll,zip,war,gz,jar,tar,opar,dmp,serial,exe,mde,gif,msg,oxd_db,dylib,so}" --no-blob-protection git-repo
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>And fix that into the repository too.
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd sql-developer &amp;&amp; git reflog expire --expire=now --all &amp;&amp; git gc --prune=now --aggressive &amp;&amp; cd -
</code></pre></div></div>

<h2 id="install-and-configure-git-lfs">Install and Configure GIT LFS</h2>

<p>Create an file called .lfsconfig which has your preconfigured LFS server</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$cp lfsconfig git/.lfsconfig 
$cat .lfsconfig
[lfs]
 url = https://artifactory.yourcorp.com/api/lfs/git-lfs
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
</code></pre></div></div>

<p>Now, you need to install lfs into the repository.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd git-repo &amp;&amp; git lfs install
</code></pre></div></div>

<p>and then track all the binary and large files you want</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git lfs track *.{rar,dll,zip,war,gz,jar,tar,opar,dmp,serial,exe,mde,gif,msg,oxd_db,dylib,so}
</code></pre></div></div>

<h2 id="commit-and-push">Commit and Push</h2>

<p>Next we need to add the files we just edited AND the base directory of the git repository as all the binary files will be swapped out to LFS on push</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git add .lfsconfig .gitattributes &amp;&amp; git add .
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git commit -m "initial commit to git" &amp;&amp; git push origin master
</code></pre></div></div>

<p>Depending on the security setting of your artifactory repository you may be prompted for a username and password for pushing the binary files to LFS and then the references and files will be pushed to your remote git repository</p>

<h2 id="summary">Summary</h2>

<p>It took us a couple of goes to get this right so we put it in a file to rerun when it died (it will til you get all the large file extensions listed)<br />
Heres the contents of that script you can grab and use for your migration.<br />
Have fun.</p>

<p>git clone git@gitlab.yourcompany.com:group-dev/git-repo.git &amp;&amp; \</p>

<p>git svn clone https://svn.yourcompany.com/svn/project/trunk git-repo –authors-file=authors.txt &gt; loglog 2&gt;&amp;1 &amp;&amp; \</p>

<p>java -jar bfg-1.13.0.jar –strip-blobs-bigger-than 1M git-repo &amp;&amp; \</p>

<p>cd git-repo &amp;&amp; git reflog expire –expire=now –all &amp;&amp; git gc –prune=now –aggressive &amp;&amp; cd - &amp;&amp; \</p>

<p>java -jar bfg-1.13.0.jar –convert-to-git-lfs “*.{rar,dll,zip,war,gz,jar,tar,opar,dmp,serial,exe,mde,gif,msg,oxd_db,dylib,so}” –no-blob-protection git-repo &amp;&amp; \</p>

<p>cd git-repo &amp;&amp; git reflog expire –expire=now –all &amp;&amp; git gc –prune=now –aggressive &amp;&amp; cd - &amp;&amp; \</p>

<p>cp lfsconfig git-repo/.lfsconfig &amp;&amp; \</p>

<p>cd git-repo &amp;&amp; \</p>

<p>git lfs install &amp;&amp; \</p>

<p>git lfs track *.{rar,dll,zip,war,gz,jar,tar,opar,dmp,serial,exe,mde,gif,msg,oxd_db,dylib,so} &amp;&amp; \</p>

<p>git add .lfsconfig .gitattributes &amp;&amp; \</p>

<p>git add . &amp;&amp; \</p>

<p>git commit -m “initial commit to git” &amp;&amp; \</p>

<p>git push origin master</p>]]></content><author><name>Barry McGillin</name></author><category term="bfg" /><category term="git" /><category term="subversion" /><category term="Migration" /><category term="lfs" /><category term="gitlab" /><category term="svn" /><summary type="html"><![CDATA[When a project has been on the go for a while theres going to be all sorts of stuff in there from jars to zips and everything in between.  We went though this a while ago and wanting to keep all the history, we needed a way to prune the history of all the big files and weird things we were not going to move to git. Now we knew we had some large files, namely binary files like jars which were build dependencies before we moved to artifactory for a lot of it.  So, before we start we need to make sure that git is installed, and git-lfs.  Git-lfs should be on the path so git can find it and you’ll need to make sure git svn can run.  You’ll need perl and  to run cpan (Comprehensive Perl Archive Network) to install the SVN::Core modules.]]></summary></entry><entry><title type="html">Git installing on windows, ‘Nix and applications</title><link href="https://bamcgill.github.io/2018/06/git-installing-on-windows-nix-and/" rel="alternate" type="text/html" title="Git installing on windows, ‘Nix and applications" /><published>2018-06-11T16:02:00+00:00</published><updated>2018-06-11T16:02:20+00:00</updated><id>https://bamcgill.github.io/2018/06/git-installing-on-windows-nix-and</id><content type="html" xml:base="https://bamcgill.github.io/2018/06/git-installing-on-windows-nix-and/"><![CDATA[<h1 id="getting-git-installed-in-lots-of-places-for-a-team-can-be-a-irksome-part-of-your-team-is-running-windows-maybe-withcygwin-others-with-various-flavours-on-unix-and-osx-layered-on-top-of-that-are-the-applications-that-we-use-with-git-services-embedded-in-them-this-should-serve-as-a-sample-page-to-show-where-we-can-get-access-to-theclients-and-how-we-set-them-up-for-ssh-which-is-our-default">Getting Git installed in lots of places for a team can be a irksome.  Part of your team is running windows, maybe with Cygwin, others with various flavours on unix and osx.  Layered on top of that are the applications that we use with git services embedded in them.  This should serve as a sample page to show where we can get access to the clients and how we set them up for ssh which is our default.</h1>

<h1 id="installing-git">Installing git</h1>

<h1 id="overview-of-install-athttpsgit-scmcombookenv2getting-started-installing-git-theres-lots-of-different-versions-but-boiled-up-to-basics-are-these-below">Overview of install at <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">https://git-scm.com/book/en/v2/Getting-Started-Installing-Git</a>.  Theres lots of different versions, but boiled up to basics are these below.</h1>

<h2 id="unix">Unix</h2>

<h1 id="--sudo-yum-install-git-all---sudo-dnf-install-git-all-rh---sudo-apt-install-git-all-debian">- sudo yum install git-all - sudo dnf install git-all (RH) - sudo apt install git-all (debian)</h1>

<h2 id="windows">windows</h2>

<h1 id="--download-and-installhttpsgitforwindowsorg">- download and install <a href="https://gitforwindows.org/">https://gitforwindows.org/</a></h1>

<h2 id="mac">mac</h2>

<h1 id="1-brew-install-git-2-or-download-and-install-fromhttpgit-scmcomdownloadmac">1. brew install git 2. or download and install from <a href="http://git-scm.com/download/mac">http://git-scm.com/download/mac</a></h1>

<h1 id="connections-to-github">Connections to GitHub</h1>

<p>We are specifically only looking at SSH connections so, heres some ways to get your keys sorted</p>

<h1 id="--generate-an-ssh-key---add-the-public-key-to-orahub---clone-your-repository">- generate an ssh key - add the public key to Orahub - Clone your repository</h1>

<h2 id="ssh-key-generation">SSH Key Generation</h2>

<h3 id="unix-1">Unix</h3>

<h1 id="ssh-keygen--t-rsa">ssh-keygen -t rsa</h1>

<h3 id="windows-1">Windows</h3>

<h1 id="use-putty-gen--this-is-installed-as-part-of-the-putty-installation-available-herehttpwwwchiarkgreenendorguksgtathamputtydownloadhtml">Use Putty-gen . This is installed as part of the putty installation available here: <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html</a></h1>

<h2 id="add-your-keys-to-github-or-your-enterprise-git-repo">Add your keys to GitHub or your Enterprise Git Repo</h2>

<p>In order to do this, its pretty specific.  You need to go to the your user settings page and click on ssh keys,  There, you can paste in your public key.  This will then let you clone your repositories with SSH as below.</p>

<h2 id="clone-repository-to-local-repository">Clone Repository to local Repository</h2>

<h3 id="unix-terminal--cygwin">unix terminal / cygwin</h3>

<h1 id="git-clone-gitorahuboraclecorpcomrestofyourrepogit-destination">git clone git@orahub.oraclecorp.com/restofyourrepo.git destination</h1>

<h3 id="tortoisegit">tortoisegit</h3>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCrNAqxJ5rxsJ3VvepkahxjBZvXI9w0qM0SZzrTg-Iy0L6DqrW3WUq6a2mV9K7I20-nHdykosKv5rV9cXb6q28FvtnXZGfkG5X5pD44ropS3iXHYKGVc3QVQ5P32tFgnF8k-Mi0XDNutQ/s1600/Capture3.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCrNAqxJ5rxsJ3VvepkahxjBZvXI9w0qM0SZzrTg-Iy0L6DqrW3WUq6a2mV9K7I20-nHdykosKv5rV9cXb6q28FvtnXZGfkG5X5pD44ropS3iXHYKGVc3QVQ5P32tFgnF8k-Mi0XDNutQ/s320/Capture3.png" alt="" /></a></p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7p-zBuhIJiYx3BpOpjXnvt8pwv3_0_MbeRKNQI3zsuSG7jGQ_Ql0N1wgUqtnzZ0YT-36WjN48Rik4EPJYLlDCc9HwxqRk__JdvWaihmSGA5dTuaeYnHwRrckwV_M3PPRDG-1vVf-QDKU/s1600/Capture4.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7p-zBuhIJiYx3BpOpjXnvt8pwv3_0_MbeRKNQI3zsuSG7jGQ_Ql0N1wgUqtnzZ0YT-36WjN48Rik4EPJYLlDCc9HwxqRk__JdvWaihmSGA5dTuaeYnHwRrckwV_M3PPRDG-1vVf-QDKU/s320/Capture4.png" alt="" /></a></p>

<h3 id="sqldeveloper">sqldeveloper</h3>

<h1 id="team-connect-to-git-view-files">team → Connect to git view → files</h1>

<h3 id="eclipse">eclipse</h3>

<h1 id="window-perspective-open-perspective-git-repositories-click-clone-git-repository">window → perspective → open perspective → git repositories click clone git repository</h1>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd5_lm9Uh7Php3SjJD7xFBQ-gHvM0hudQFkfRR5kDA84X3Sll9vGLADeBIoFJIBbTwYFS98gQh6jXJV8iCN2UUajtox-N9ZVXjK6QizC-VVdI8Byy7xoALYLN96PBdRmgk4-1lw9AcO14/s1600/Capture9.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd5_lm9Uh7Php3SjJD7xFBQ-gHvM0hudQFkfRR5kDA84X3Sll9vGLADeBIoFJIBbTwYFS98gQh6jXJV8iCN2UUajtox-N9ZVXjK6QizC-VVdI8Byy7xoALYLN96PBdRmgk4-1lw9AcO14/s320/Capture9.png" alt="" /></a></p>

<h3 id="github-desktop">github desktop</h3>

<h1 id="download-it-fromhttpsdesktopgithubcom">Download it from <a href="https://desktop.github.com/">https://desktop.github.com/</a></h1>]]></content><author><name>Barry McGillin</name></author><category term="git" /><category term="git desktop" /><category term="tortoisegit" /><category term="Eclipse" /><category term="windows" /><category term="unix" /><category term="osx." /><summary type="html"><![CDATA[Getting Git installed in lots of places for a team can be a irksome.  Part of your team is running windows, maybe with Cygwin, others with various flavours on unix and osx.  Layered on top of that are the applications that we use with git services embedded in them.  This should serve as a sample page to show where we can get access to the clients and how we set them up for ssh which is our default.]]></summary></entry><entry><title type="html">Making Git cmd line fancy - ish :)</title><link href="https://bamcgill.github.io/2018/04/making-git-cmd-line-fancy-ish/" rel="alternate" type="text/html" title="Making Git cmd line fancy - ish :)" /><published>2018-04-27T17:44:00+00:00</published><updated>2018-04-27T17:44:06+00:00</updated><id>https://bamcgill.github.io/2018/04/making-git-cmd-line-fancy-ish</id><content type="html" xml:base="https://bamcgill.github.io/2018/04/making-git-cmd-line-fancy-ish/"><![CDATA[<p>So, we’re having a great time with git, fighting over how branches should work and what policy is best in our environment, which I suppose I’ll talk about in another post, but for today, I wanted to share a little bit of usefulness.</p>

<p>Most of our repositories have several branches for various releases and its often confusing and terse to 1. remember where you are and 2, run git branch to see.</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTDBmqdpkJw3c4lzG72-ZD9SP9M_sw8zLl3I7Jr_u3hRVQ2TTTsactgquoePWojgegt9RE6v9KQsrrGWxI6v4AxfjhgZSu8VbsJuRT2gTG6JB64X5ovVTYrT-90ADzwePyUtjvDNQx10U/s1600/Screen+Shot+2018-04-27+at+18.18.30.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTDBmqdpkJw3c4lzG72-ZD9SP9M_sw8zLl3I7Jr_u3hRVQ2TTTsactgquoePWojgegt9RE6v9KQsrrGWxI6v4AxfjhgZSu8VbsJuRT2gTG6JB64X5ovVTYrT-90ADzwePyUtjvDNQx10U/s640/Screen+Shot+2018-04-27+at+18.18.30.png" alt="" /></a></p>

<p>This for example, I have changed to my repository in GitHub, but unless you know that you’re in a repository you couldn’t be sure.  Long story short, lets say we’ve had one or two boo-boos along the way.</p>

<p>Now, imported projects in eclipse will have the branch of the code you’re working on so today, we’re going to bring it to the terminal.  Cut the following and put it in your .bashrc or .bash_profile and see your repository and branch pop out on the prompt.  Now,  I have decorated the prompt with some colours, which you might want to change.  (search for bash unix colors for details)</p>

<p>parse_git_branch() {</p>

<table>
  <tbody>
    <tr>
      <td>git branch 2&gt; /dev/null</td>
      <td>sed -e ‘/^[^*]/d’ -e ‘s/* (.*)/[\1]/’</td>
    </tr>
  </tbody>
</table>

<p>}</p>

<p>parse_git_repo() {</p>

<table>
  <tbody>
    <tr>
      <td>git rev-parse –show-toplevel 2&gt; /dev/null</td>
      <td>xargs basename</td>
      <td>sed ‘s/(.*)/[\1]/’</td>
    </tr>
  </tbody>
</table>

<p>}</p>

<p>export PS1=”[\033[91m]\u[\033[30m]@[\033[34m]\h[[\033[36m]\w[\033[30m]] \</p>

<p>\n\r[\033[31m]$(parse_git_repo)[\033[00m]-[\033[33m]$(parse_git_branch)[\033[00m] $ “</p>

<p>What you get from all this, the next time you start a terminal is this (without my adornments).</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYwGUpeEJ-SmnD6WL_G32DH2bgMfHP39BX413mAxNtmsr66cl-JbXDH89wb04rpWyFKGeIT78TUPNHPAfuNLa3TAP2eJWJkrlXhkgZ5ASakBjOnoHb3RtjLucFy_VYFH1sOPKZVg-VDAA/s1600/Screen+Shot+2018-04-27+at+18.29.10.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYwGUpeEJ-SmnD6WL_G32DH2bgMfHP39BX413mAxNtmsr66cl-JbXDH89wb04rpWyFKGeIT78TUPNHPAfuNLa3TAP2eJWJkrlXhkgZ5ASakBjOnoHb3RtjLucFy_VYFH1sOPKZVg-VDAA/s640/Screen+Shot+2018-04-27+at+18.29.10.png" alt="" /></a></p>

<p>So, as soon as you enter a repository, the prompt now tells you which repository and which branch you are on too, in this case I have branch called flatten which I used for the previous post.</p>

<p>Finally, if you dont want the colour, strip the escape codes and while your PS1 export will look more sane, it’ll lack a certain bedazzling…</p>

<p>export PS1=”\u@\h[\w] \n\r$(parse_git_repo)-$(parse_git_branch) $ “</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlklrURrt8lTEMw4ySN-QfPMOdMFo2l3r8w23VRfUtiPEn7om95vuensflnpusmdaUJ5JYItJNHNgZtX1Myr5tTNikH-Nmu3YMriKW9fTo0TqJ6VM9YWuDuVtB3Gr6v0mkjsYc2d0uAWg/s1600/Screen+Shot+2018-04-27+at+18.42.13.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlklrURrt8lTEMw4ySN-QfPMOdMFo2l3r8w23VRfUtiPEn7om95vuensflnpusmdaUJ5JYItJNHNgZtX1Myr5tTNikH-Nmu3YMriKW9fTo0TqJ6VM9YWuDuVtB3Gr6v0mkjsYc2d0uAWg/s640/Screen+Shot+2018-04-27+at+18.42.13.png" alt="" /></a></p>

<p>Have fun!</p>]]></content><author><name>Barry McGillin</name></author><category term="open source" /><category term="git" /><category term="oracle" /><category term="bash" /><summary type="html"><![CDATA[So, we’re having a great time with git, fighting over how branches should work and what policy is best in our environment, which I suppose I’ll talk about in another post, but for today, I wanted to share a little bit of usefulness. Most of our repositories have several branches for various releases and its often confusing and terse to 1. remember where you are and 2, run git branch to see.]]></summary></entry><entry><title type="html">Maven Duplicated Versions consolidated with flatten</title><link href="https://bamcgill.github.io/2018/04/maven-duplicated-versions-consolidated/" rel="alternate" type="text/html" title="Maven Duplicated Versions consolidated with flatten" /><published>2018-04-25T20:58:00+00:00</published><updated>2018-04-25T20:58:24+00:00</updated><id>https://bamcgill.github.io/2018/04/maven-duplicated-versions-consolidated</id><content type="html" xml:base="https://bamcgill.github.io/2018/04/maven-duplicated-versions-consolidated/"><![CDATA[<p>We had the situation lately where we have a bunch of modules in a project and a common parent.  Now when we go to update the project version we need to update the parent version in EVERY pom.</p>

<p>Lets take a look at a simple project</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj4N6UmZ8F8rkEMz2oDkJRMZFxNPNljT2eVLeA7lML79XCV1PIzdwFmg_6HbkP1uoZE_sZlUL1dxw6gqo47Wa8BZjn7jT6iAUk7C2WZcLrGOYcb2ztZsC3OXBBZiC-XamHj6Mpd-AAcv4/s1600/Screen+Shot+2018-04-25+at+19.41.06.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj4N6UmZ8F8rkEMz2oDkJRMZFxNPNljT2eVLeA7lML79XCV1PIzdwFmg_6HbkP1uoZE_sZlUL1dxw6gqo47Wa8BZjn7jT6iAUk7C2WZcLrGOYcb2ztZsC3OXBBZiC-XamHj6Mpd-AAcv4/s320/Screen+Shot+2018-04-25+at+19.41.06.png" alt="" /></a></p>

<p>This project has three simple modules which have a common parent</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:  &lt;project&gt;  
3:      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;  
4:      &lt;packaging&gt;pom&lt;/packaging&gt;  
5:      &lt;name&gt;Three Stooges&lt;/name&gt;  
6:      &lt;groupId&gt;oracle.blogger&lt;/groupId&gt;  
7:      &lt;artifactId&gt;stooges&lt;/artifactId&gt;  
8:      &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;  
9:      &lt;properties&gt;  
10:          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;  
11:      &lt;/properties&gt;  
12:      &lt;modules&gt;  
13:          &lt;module&gt;larry&lt;/module&gt;  
14:          &lt;module&gt;curley&lt;/module&gt;  
15:          &lt;module&gt;moe&lt;/module&gt;  
16:      &lt;/modules&gt;  
17:  &lt;/project&gt;
</code></pre></div></div>

<p>Each module inherits from the parent including the version.  Lets take a look at Larrys module.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:  &lt;project&gt;  
3:      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;  
4:      &lt;packaging&gt;jar&lt;/packaging&gt;  
5:      &lt;name&gt;Larry&lt;/name&gt;  
6:      &lt;artifactId&gt;larry&lt;/artifactId&gt;  
7:      &lt;parent&gt;  
8:          &lt;groupId&gt;oracle.blogger&lt;/groupId&gt;  
9:          &lt;artifactId&gt;stooges&lt;/artifactId&gt;  
10:          &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;  
11:      &lt;/parent&gt;  
12:  &lt;/project&gt;
</code></pre></div></div>

<p>In our larger project, we had over 20 of these to change at once when we branched for release</p>

<p>Instead, we introduced a revision property in the parent pom, which was then used to be the version in all the pom’s. Here’s the modified parent pom with the revision in place.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:  &lt;project&gt;  
3:       &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;  
4:       &lt;packaging&gt;pom&lt;/packaging&gt;  
5:       &lt;name&gt;Three Stooges&lt;/name&gt;  
6:       &lt;groupId&gt;oracle.blogger&lt;/groupId&gt;  
7:       &lt;artifactId&gt;stooges&lt;/artifactId&gt;  
8:       &lt;version&gt;${revision}&lt;/version&gt;  
9:       &lt;properties&gt;  
10:            &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;  
11:            &lt;flatten.version&gt;1.0.1&lt;/flatten.version&gt;  
12:            &lt;!-- Build Revision --&gt;  
13:            &lt;revision&gt;1.0.1-SNAPSHOT&lt;/revision&gt;  
14:       &lt;/properties&gt;  
15:       &lt;modules&gt;  
16:            &lt;module&gt;larry&lt;/module&gt;  
17:            &lt;module&gt;curley&lt;/module&gt;  
18:            &lt;module&gt;moe&lt;/module&gt;  
19:       &lt;/modules&gt;
</code></pre></div></div>

<p>and in each of the children, that change propagates like this.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:  &lt;project&gt;  
2:       &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;  
3:       &lt;packaging&gt;jar&lt;/packaging&gt;  
4:       &lt;name&gt;Larry&lt;/name&gt;  
5:       &lt;artifactId&gt;larry&lt;/artifactId&gt;  
6:       &lt;parent&gt;  
7:            &lt;groupId&gt;oracle.blogger&lt;/groupId&gt;  
8:            &lt;artifactId&gt;stooges&lt;/artifactId&gt;  
9:            &lt;version&gt;${revision}&lt;/version&gt;  
10:       &lt;/parent&gt;  
11:  &lt;/project&gt;
</code></pre></div></div>

<p>Now, for most things, this all works and we can see that in the build.</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQxnfumR89yCLXG1zWGaRGdu9eRM9IKTKZ7bFqtHQteBikJ7IRGCCKHVMtPHqsrYdCPYsJtQvSRMVF_vyCgtcBFZfI_D2UEmWvILZ68uI9vsy1hkiZJ-RN61TmOxttx038xe7yf-9_t4s/s1600/Screen+Shot+2018-04-25+at+20.12.11.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQxnfumR89yCLXG1zWGaRGdu9eRM9IKTKZ7bFqtHQteBikJ7IRGCCKHVMtPHqsrYdCPYsJtQvSRMVF_vyCgtcBFZfI_D2UEmWvILZ68uI9vsy1hkiZJ-RN61TmOxttx038xe7yf-9_t4s/s400/Screen+Shot+2018-04-25+at+20.12.11.png" alt="" /></a></p>

<p>But, when we deploy these builds to artifactory, we need to flatten the poms with the versions so that they can be used for versioning.  We can use the <a href="https://www.mojohaus.org/flatten-maven-plugin/">Maven Flatten Plugin</a> from <a href="https://www.mojohaus.org/">mojoHaus</a> to help with this. What this does to the pom is:</p>

<ul>
  <li>Build specific elements are removed</li>
  <li>Development specific elements are removed by default</li>
  <li>It only contains elements required for users of your artifact</li>
  <li>Its variables are resolved</li>
  <li>Its parent relationship is resolved, flattened and removed</li>
  <li>Its build time driven profiles <strong>can</strong> be evaluated so their impact gets embedded</li>
  <li>JDK or OS driven profiles still remain allowing dynamic dependencies if needed</li>
</ul>

<p>Add it to your parent pom pluginManagement section.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:       &lt;build&gt;  
2:            &lt;pluginManagement&gt;  
3:                 &lt;plugins&gt;  
4:                      &lt;plugin&gt;  
5:                           &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;  
6:                           &lt;artifactId&gt;flatten-maven-plugin&lt;/artifactId&gt;  
7:                           &lt;version&gt;${flatten.version}&lt;/version&gt;  
8:                           &lt;configuration&gt;  
9:                                &lt;updatePomFile&gt;true&lt;/updatePomFile&gt;  
10:                           &lt;/configuration&gt;  
11:                           &lt;executions&gt;  
12:                                &lt;execution&gt;  
13:                                     &lt;id&gt;flatten&lt;/id&gt;  
14:                                     &lt;phase&gt;process-resources&lt;/phase&gt;  
15:                                     &lt;goals&gt;  
16:                                          &lt;goal&gt;flatten&lt;/goal&gt;  
17:                                     &lt;/goals&gt;  
18:                                &lt;/execution&gt;  
19:                                &lt;execution&gt;  
20:                                     &lt;id&gt;flatten.clean&lt;/id&gt;  
21:                                     &lt;phase&gt;clean&lt;/phase&gt;  
22:                                     &lt;goals&gt;  
23:                                          &lt;goal&gt;clean&lt;/goal&gt;  
24:                                     &lt;/goals&gt;  
25:                                &lt;/execution&gt;  
26:                           &lt;/executions&gt;  
27:                      &lt;/plugin&gt;  
28:                      &lt;plugin&gt;  
29:                           &lt;groupId&gt;org.eclipse.m2e&lt;/groupId&gt;  
30:                           &lt;artifactId&gt;lifecycle-mapping&lt;/artifactId&gt;  
31:                           &lt;version&gt;${lifecycle-mapping.version}&lt;/version&gt;  
32:                           &lt;configuration&gt;  
33:                                &lt;lifecycleMappingMetadata&gt;  
34:                                     &lt;pluginExecutions&gt;  
35:                                          &lt;pluginExecution&gt;  
36:                                               &lt;pluginExecutionFilter&gt;  
37:                                                    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;  
38:                                                    &lt;artifactId&gt;flatten-maven-plugin&lt;/artifactId&gt;  
39:                                                    &lt;versionRange&gt;[0,)&lt;/versionRange&gt;  
40:                                                    &lt;goals&gt;  
41:                                                         &lt;goal&gt;flatten&lt;/goal&gt;  
42:                                                    &lt;/goals&gt;  
43:                                               &lt;/pluginExecutionFilter&gt;  
44:                                               &lt;action&gt;  
45:                                                    &lt;ignore&gt;&lt;/ignore&gt;  
46:                                               &lt;/action&gt;  
47:                                          &lt;/pluginExecution&gt;  
48:                                     &lt;/pluginExecutions&gt;  
49:                                &lt;/lifecycleMappingMetadata&gt;  
50:                           &lt;/configuration&gt;  
51:                      &lt;/plugin&gt;  
52:                 &lt;/plugins&gt;  
53:            &lt;/pluginManagement&gt;  
54:            &lt;plugins&gt;  
55:                 &lt;plugin&gt;  
56:                      &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;  
57:                      &lt;artifactId&gt;flatten-maven-plugin&lt;/artifactId&gt;  
58:                 &lt;/plugin&gt;  
59:            &lt;/plugins&gt;  
60:       &lt;/build&gt;
</code></pre></div></div>

<p>This will run as part of the build like this</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXh5kAh3WP4xxWzKS4qmKAgW1xMqBDULlhJUmFhHVqSAvv6toAKxLae9sIpPgnJHPaNWonpuupc2DMpwmgUjef72NewG_5la3UxpdRAvG7gxs9hi26k2YDSgI0mnZd6ik5Wl7IkDmgZE0/s1600/Screen+Shot+2018-04-25+at+20.32.31.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXh5kAh3WP4xxWzKS4qmKAgW1xMqBDULlhJUmFhHVqSAvv6toAKxLae9sIpPgnJHPaNWonpuupc2DMpwmgUjef72NewG_5la3UxpdRAvG7gxs9hi26k2YDSgI0mnZd6ik5Wl7IkDmgZE0/s400/Screen+Shot+2018-04-25+at+20.32.31.png" alt="" /></a></p>

<p>and will produce a flattened pom for you</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhXIWJ5eghSwsESEn-rfWvT3JlSnBQ49_Ge2N9F8LrtAzl-pNOd6sVAajtOnR6sowKwkh2zquUMq9UukiR2cmxpdWLMsbzaNgBiBq1mbubL7y6tvALHDyBd1srVrPBtvmOVnROFYKseE/s1600/Screen+Shot+2018-04-25+at+20.34.35.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHhXIWJ5eghSwsESEn-rfWvT3JlSnBQ49_Ge2N9F8LrtAzl-pNOd6sVAajtOnR6sowKwkh2zquUMq9UukiR2cmxpdWLMsbzaNgBiBq1mbubL7y6tvALHDyBd1srVrPBtvmOVnROFYKseE/s400/Screen+Shot+2018-04-25+at+20.34.35.png" alt="" /></a></p>

<p>without all the variables and so on as detailed above.</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSl9Mg0R3EImOXwHOArQOkEHcVmr_eTfCjToAPBC9mh_7VZ2atgwMxpccgzHfiurQuUkB0QcdxmOHXdbUXcXww65-GdQNYYbGaQJqzxe2wvlJVUb5dNai9lGk2EehzVhYi7ZqYLnzJCOc/s1600/Screen+Shot+2018-04-25+at+20.35.57.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSl9Mg0R3EImOXwHOArQOkEHcVmr_eTfCjToAPBC9mh_7VZ2atgwMxpccgzHfiurQuUkB0QcdxmOHXdbUXcXww65-GdQNYYbGaQJqzxe2wvlJVUb5dNai9lGk2EehzVhYi7ZqYLnzJCOc/s400/Screen+Shot+2018-04-25+at+20.35.57.png" alt="" /></a></p>

<p>mvn clean will remove all created files afterwards to leave your original pom.xml.  The pull request in the repo looked like this before merge.</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs6YwJ9ruJEqpt02AapsSLine-NdEJVzHhnLIK047yHKJJ_kztIoxgHcW2p5DtXT6gvTvkhM1SaEp6nsEDuz8J3xinNdHY8SqDs_ZpdDVwmtXV3bu8qK_mUjRzfFo6YJSu3R1q6WlydUQ/s1600/Screen+Shot+2018-04-25+at+20.49.45.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs6YwJ9ruJEqpt02AapsSLine-NdEJVzHhnLIK047yHKJJ_kztIoxgHcW2p5DtXT6gvTvkhM1SaEp6nsEDuz8J3xinNdHY8SqDs_ZpdDVwmtXV3bu8qK_mUjRzfFo6YJSu3R1q6WlydUQ/s400/Screen+Shot+2018-04-25+at+20.49.45.png" alt="" /></a></p>]]></content><author><name>Barry McGillin</name></author><category term="flatten" /><category term="maven" /><category term="module" /><category term="version" /><category term="revision" /><summary type="html"><![CDATA[We had the situation lately where we have a bunch of modules in a project and a common parent.  Now when we go to update the project version we need to update the parent version in EVERY pom. Lets take a look at a simple project]]></summary></entry><entry><title type="html">Run your SQL script from java NOW</title><link href="https://bamcgill.github.io/2018/04/run-your-sql-script-from-java-now/" rel="alternate" type="text/html" title="Run your SQL script from java NOW" /><published>2018-04-13T21:18:00+00:00</published><updated>2018-04-13T21:18:44+00:00</updated><id>https://bamcgill.github.io/2018/04/run-your-sql-script-from-java-now</id><content type="html" xml:base="https://bamcgill.github.io/2018/04/run-your-sql-script-from-java-now/"><![CDATA[<p>Run them with the code we use for Oracle SQL Developer, SQLcl and REST Data Services.<br />
We’ve just released some of the code that underpins these tools in an attempt to help  others run SQL, PLSQL and SQL*Plus scripts confidently and repeatably from java.</p>

<p>From Github, look for the repository <a href="https://github.com/oracle/dbtools-commons">dbtools-commons</a>. Look at my <a href="http://barrymcgillin.blogspot.co.uk/2018/04/sqlcl-code-aka-dbtools-common-is-now.html">previous post</a> to build it.</p>

<p>The code below is one simple example to run sql code with the common jars we ship with sqlcl and sqldeveloper.</p>

<p>Further down, I stuck in a pom file you can use to build with maven.</p>

<h2 id="demo-using-script-executor-to-run-sql">Demo using Script executor to run SQL</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:  import java.io.BufferedOutputStream;  
2:  import java.io.ByteArrayOutputStream;  
3:  import java.io.UnsupportedEncodingException;  
4:  import java.sql.Connection;  
5:  import java.sql.DriverManager;  
6:  import java.sql.SQLException;  
7:  import oracle.dbtools.db.ResultSetFormatter;  
8:  import oracle.dbtools.raptor.newscriptrunner.ScriptExecutor;  
9:  import oracle.dbtools.raptor.newscriptrunner.ScriptRunnerContext;  
10:  /**  
11:   * @author bamcgill  
12:   */  
13:  public class DemoScriptRunner {  
14:    /**  
15:     * @param args  
16:     * @throws ClassNotFoundException  
17:     * @throws SQLException  
18:     * @throws UnsupportedEncodingException  
19:     */  
20:    public static void main(String[] args) throws ClassNotFoundException, SQLException, UnsupportedEncodingException {  
21:      Class.forName("oracle.jdbc.driver.OracleDriver");  
22:      Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/ORCL", "barry", "oracle");  
23:      ScriptRunnerContext ctx = new ScriptRunnerContext();  
24:      ctx.setBaseConnection(conn);  
25:      ScriptExecutor executor = new ScriptExecutor(conn);  
26:      ByteArrayOutputStream bout = new ByteArrayOutputStream();  
27:      BufferedOutputStream bs = new BufferedOutputStream(bout);  
28:      executor.setOut(bs);  
29:      executor.setScriptRunnerContext(ctx);  
30:      executor.setStmt("select * from all_objects where rownum &lt; 10 ");  
31:      ResultSetFormatter.setMaxRows(Integer.MAX_VALUE);  
32:      executor.run();  
33:      String results = bout.toString("UTF8");  
34:      System.out.println(results);  
35:    }
</code></pre></div></div>

<h2 id="pom-file-to-build-code">Pom File to build Code</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
2:      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;  
3:      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;  
4:      &lt;groupId&gt;oracle.dbtools&lt;/groupId&gt;  
5:      &lt;artifactId&gt;demo-common&lt;/artifactId&gt;  
6:      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;  
7:      &lt;packaging&gt;jar&lt;/packaging&gt;  
8:      &lt;name&gt;demo-common&lt;/name&gt;  
9:      &lt;url&gt;http://maven.apache.org&lt;/url&gt;  
10:      &lt;properties&gt;  
11:          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;  
12:      &lt;/properties&gt;  
13:      &lt;dependencies&gt;  
14:          &lt;dependency&gt;  
15:              &lt;groupId&gt;junit&lt;/groupId&gt;  
16:              &lt;artifactId&gt;junit&lt;/artifactId&gt;  
17:              &lt;version&gt;3.8.1&lt;/version&gt;  
18:              &lt;scope&gt;test&lt;/scope&gt;  
19:          &lt;/dependency&gt;  
20:          &lt;dependency&gt;  
21:              &lt;groupId&gt;oracle.dbtools&lt;/groupId&gt;  
22:              &lt;artifactId&gt;dbtools-common&lt;/artifactId&gt;  
23:              &lt;version&gt;LATEST&lt;/version&gt;  
24:          &lt;/dependency&gt;  
25:          &lt;dependency&gt;  
26:              &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
27:              &lt;artifactId&gt;orai18n&lt;/artifactId&gt;  
28:              &lt;version&gt;12.2.0.1&lt;/version&gt;  
29:          &lt;/dependency&gt;  
30:          &lt;dependency&gt;  
31:              &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
32:              &lt;artifactId&gt;orai18n-mapping&lt;/artifactId&gt;  
33:              &lt;version&gt;12.2.0.1&lt;/version&gt;  
34:          &lt;/dependency&gt;  
35:      &lt;/dependencies&gt;  
36:  &lt;/project&gt;
</code></pre></div></div>]]></content><author><name>Barry McGillin</name></author><category term="Java" /><category term="dbtools-common" /><category term="open source" /><category term="oracle" /><category term="maven" /><category term="Database Tools" /><summary type="html"><![CDATA[Run them with the code we use for Oracle SQL Developer, SQLcl and REST Data Services. We’ve just released some of the code that underpins these tools in an attempt to help  others run SQL, PLSQL and SQL*Plus scripts confidently and repeatably from java. From Github, look for the repository dbtools-commons. Look at my previous post to build it. The code below is one simple example to run sql code with the common jars we ship with sqlcl and sqldeveloper. Further down, I stuck in a pom file you can use to build with maven.]]></summary></entry><entry><title type="html">SQLCL 18.1.1 Release installing jars to local maven repository</title><link href="https://bamcgill.github.io/2018/04/sqlcl-1811-release-installing-jars-to/" rel="alternate" type="text/html" title="SQLCL 18.1.1 Release installing jars to local maven repository" /><published>2018-04-13T11:28:00+00:00</published><updated>2018-04-13T11:28:39+00:00</updated><id>https://bamcgill.github.io/2018/04/sqlcl-1811-release-installing-jars-to</id><content type="html" xml:base="https://bamcgill.github.io/2018/04/sqlcl-1811-release-installing-jars-to/"><![CDATA[<p>Here we are again releasing Oracle SQLcl. We released Oracle SQLDeveloper SQLcl 18.1.1 yesterday with only one significant change.</p>

<p>Why? Well, we haven’t changed the SQLcl code in this release but we’ve made it easier for you to use the libraries we ship with it.  We’ve added a <a href="https://maven.apache.org/guides/introduction/introduction-to-the-pom.html">pom.xml</a> into the lib directory.  On a day to day use of SQLcl, this will not affect your use of SQLcl, however, it will allow you to install the libraries we ship with SQLcl into your local <a href="https://maven.apache.org/guides/introduction/introduction-to-repositories.html">maven repository</a>.</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9Y1m6aWu4dH-qkqhj-0nFrxAPBwjhYOCHINvLtN8OsvQRiY26ukBwdbPziOjvDo2Iz5YRa00kHYoZJS9yKmL7bAo_OOjnKHng_GGn3BKshnvtc-mxRmrEGH06Pl35Fdc4VLZfysIVve0/s1600/Screen+Shot+2018-04-13+at+10.15.58.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9Y1m6aWu4dH-qkqhj-0nFrxAPBwjhYOCHINvLtN8OsvQRiY26ukBwdbPziOjvDo2Iz5YRa00kHYoZJS9yKmL7bAo_OOjnKHng_GGn3BKshnvtc-mxRmrEGH06Pl35Fdc4VLZfysIVve0/s400/Screen+Shot+2018-04-13+at+10.15.58.png" alt="" /></a></p>

<p>How does that work?  Well, you need to have <a href="http://maven.apache.org/download.cgi">maven</a> installed in order to run the install.  You can check you have it like this.</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdkRpMuaXDXwiL_IkfDeYcDX_Azi7Ky7U-Lfv745XD5jWFumAheiY_Ina_qI-7fBv1FMI2DEbKy8NL19VeHXakE6QBq_4Wk197glOCA0rg_-e_v3I5PCYfg4CeIHX8U1r8PQ2kpRm2kOw/s1600/Screen+Shot+2018-04-13+at+10.20.02.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdkRpMuaXDXwiL_IkfDeYcDX_Azi7Ky7U-Lfv745XD5jWFumAheiY_Ina_qI-7fBv1FMI2DEbKy8NL19VeHXakE6QBq_4Wk197glOCA0rg_-e_v3I5PCYfg4CeIHX8U1r8PQ2kpRm2kOw/s400/Screen+Shot+2018-04-13+at+10.20.02.png" alt="" /></a></p>

<p>With confirmed you can run the install by invoking the command ‘mvn validate’ in the sqlcl/lib directory.</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheYopcx8_vWfBKogkNfM5Eg3tWyeKjKf0WHcAc_85sR_l6crEYbSkWexAFYK2TfLy9Q6rqA7QWiLDLy6JnaYO3fxiXYvKvq0dyy8pv-zqKKCD043QZPDg2HTWVvUu3PTHmcEFKO-G-dnc/s1600/Screen+Shot+2018-04-13+at+11.24.57.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheYopcx8_vWfBKogkNfM5Eg3tWyeKjKf0WHcAc_85sR_l6crEYbSkWexAFYK2TfLy9Q6rqA7QWiLDLy6JnaYO3fxiXYvKvq0dyy8pv-zqKKCD043QZPDg2HTWVvUu3PTHmcEFKO-G-dnc/s400/Screen+Shot+2018-04-13+at+11.24.57.png" alt="" /></a></p>

<p>which will take each jar and install it into your local maven repository.  By default, this will be ~/.m2</p>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgula69JepYAW1TALrcPSN7g1PziVKsUnxi5xsAaXb0Og_LN3P6a3PoijvWk92PQXdQCocyDKjk12BAPnV4KXfBe74B04skswiQjXjbPUKRCMR2zRWV1AAyelorK-9FuAdd8OtECdzS7P8/s1600/Screen+Shot+2018-04-13+at+11.48.05.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgula69JepYAW1TALrcPSN7g1PziVKsUnxi5xsAaXb0Og_LN3P6a3PoijvWk92PQXdQCocyDKjk12BAPnV4KXfBe74B04skswiQjXjbPUKRCMR2zRWV1AAyelorK-9FuAdd8OtECdzS7P8/s400/Screen+Shot+2018-04-13+at+11.48.05.png" alt="" /></a></p>

<p>While a lot of these jars are available in maven.oracle.com and maven.org, there are several that aren’t.  We’re working on getting our production jars published externally.  The ones we dont have published publicly yet are:</p>

<p>low-level-api.jar                  ojdbc8.jar</p>

<p>dbtools-common.jar                 oraclepki.jar</p>

<p>dbtools-http.jar                   orai18n-mapping.jar</p>

<p>dbtools-net.jar                    orai18n-utility.jar</p>

<p>dbtools-sqlcl.jar                  orai18n.jar</p>

<p>orajsoda.jar                       httpcore.jar</p>

<p>osdt_cert.jar                      osdt_core.jar</p>

<p>ucp.jar.                           jdbcrest.jar</p>

<p>xdb6.jar                           xmlparserv2-sans-jaxp-services.jar</p>

<p>if you want to add these to your project, take the following dependency management and prune it for your needs.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1:      &lt;dependencyManagement&gt;  
2:          &lt;dependencies&gt;  
3:              &lt;dependency&gt;  
4:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
5:                  &lt;artifactId&gt;ojdbc8&lt;/artifactId&gt;  
6:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
7:              &lt;/dependency&gt;  
8:              &lt;dependency&gt;  
9:                  &lt;groupId&gt;oracle.soda&lt;/groupId&gt;  
10:                  &lt;artifactId&gt;orajsoda&lt;/artifactId&gt;  
11:                  &lt;version&gt;12.2.0.1.0&lt;/version&gt;  
12:              &lt;/dependency&gt;  
18:              &lt;dependency&gt;  
19:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
20:                  &lt;artifactId&gt;xdb6&lt;/artifactId&gt;  
21:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
22:              &lt;/dependency&gt;  
23:              &lt;dependency&gt;  
24:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
25:                  &lt;artifactId&gt;xmlparserv2-sans-jaxp-services&lt;/artifactId&gt;  
26:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
27:              &lt;/dependency&gt;  
28:              &lt;dependency&gt;  
49:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
50:                  &lt;artifactId&gt;orai18n&lt;/artifactId&gt;  
51:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
52:              &lt;/dependency&gt;  
53:              &lt;dependency&gt;  
54:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
55:                  &lt;artifactId&gt;orai18n-collation&lt;/artifactId&gt;  
56:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
57:              &lt;/dependency&gt;  
58:              &lt;dependency&gt;  
59:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
60:                  &lt;artifactId&gt;orai18n-mapping&lt;/artifactId&gt;  
61:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
62:              &lt;/dependency&gt;  
68:              &lt;dependency&gt;  
69:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
70:                  &lt;artifactId&gt;orai18n-utility&lt;/artifactId&gt;  
71:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
72:              &lt;/dependency&gt;  
710:              &lt;dependency&gt;  
111:                  &lt;groupId&gt;oracle.dbtools&lt;/groupId&gt;  
112:                  &lt;artifactId&gt;dbtools-common&lt;/artifactId&gt;  
113:                  &lt;version&gt;18.1.1&lt;/version&gt;  
114:              &lt;/dependency&gt;  
115:              &lt;dependency&gt;  
116:                  &lt;groupId&gt;oracle.dbtools&lt;/groupId&gt;  
117:                  &lt;artifactId&gt;dbtools-http&lt;/artifactId&gt;  
118:                  &lt;version&gt;18.1.1&lt;/version&gt;  
119:              &lt;/dependency&gt;  
120:              &lt;dependency&gt;  
121:                  &lt;groupId&gt;oracle.dbtools&lt;/groupId&gt;  
122:                  &lt;artifactId&gt;dbtools-sqlcl&lt;/artifactId&gt;  
123:                  &lt;version&gt;18.1.1&lt;/version&gt;  
124:              &lt;/dependency&gt;  
125:              &lt;dependency&gt;  
126:                  &lt;groupId&gt;oracle.dbtools&lt;/groupId&gt;  
127:                  &lt;artifactId&gt;jdbcrest&lt;/artifactId&gt;  
128:                  &lt;version&gt;18.1.1&lt;/version&gt;  
129:              &lt;/dependency&gt;  
130:              &lt;dependency&gt;  
131:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
132:                  &lt;artifactId&gt;osdt_cert&lt;/artifactId&gt;  
133:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
134:              &lt;/dependency&gt;  
135:              &lt;dependency&gt;  
136:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
137:                  &lt;artifactId&gt;osdt_core&lt;/artifactId&gt;  
138:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
139:              &lt;/dependency&gt;  
140:              &lt;dependency&gt;  
141:                  &lt;groupId&gt;com.oracle.jdbc&lt;/groupId&gt;  
142:                  &lt;artifactId&gt;oraclepki&lt;/artifactId&gt;  
143:                  &lt;version&gt;12.2.0.1&lt;/version&gt;  
144:              &lt;/dependency&gt;  
160:              &lt;dependency&gt;  
161:                  &lt;groupId&gt;oracle.cloudstorage&lt;/groupId&gt;  
162:                  &lt;artifactId&gt;low-level-api&lt;/artifactId&gt;  
163:                  &lt;version&gt;13.0.0&lt;/version&gt;  
164:              &lt;/dependency&gt;  
170:          &lt;/dependencies&gt;  
171:      &lt;/dependencyManagement&gt;
</code></pre></div></div>

<p>Stay tuned, you’ll have a project you can use this on soon!</p>]]></content><author><name>Barry McGillin</name></author><category term="open source" /><category term="oracle" /><category term="maven" /><category term="GitHub" /><category term="SQLDEVELOPER" /><category term="Database Tools" /><category term="dbtools" /><category term="sqlcl" /><summary type="html"><![CDATA[Here we are again releasing Oracle SQLcl. We released Oracle SQLDeveloper SQLcl 18.1.1 yesterday with only one significant change. Why? Well, we haven’t changed the SQLcl code in this release but we’ve made it easier for you to use the libraries we ship with it.  We’ve added a pom.xml into the lib directory.  On a day to day use of SQLcl, this will not affect your use of SQLcl, however, it will allow you to install the libraries we ship with SQLcl into your local maven repository.]]></summary></entry><entry><title type="html">Docker Oracle and local installs</title><link href="https://bamcgill.github.io/2018/03/docker-oracle-and-local-installs/" rel="alternate" type="text/html" title="Docker Oracle and local installs" /><published>2018-03-14T21:17:00+00:00</published><updated>2018-03-14T21:17:16+00:00</updated><id>https://bamcgill.github.io/2018/03/docker-oracle-and-local-installs</id><content type="html" xml:base="https://bamcgill.github.io/2018/03/docker-oracle-and-local-installs/"><![CDATA[<p>So you want Docker and to install and Oracle Database locally.  So did I and while I have <a href="https://www.virtualbox.org/">VirtualBox</a> and the <a href="https://gist.github.com/cdivilly/8082bece0ad8f819a6b4a3630699ed46">Oracle Developer Day VM</a>, I wanted to setup docker and the Oracle Database<br />
Well <a href="https://twitter.com/cdivilly">Colm Divilly (@cdivilly)</a> has cleared it up for me.  His <a href="https://gist.github.com/cdivilly/8082bece0ad8f819a6b4a3630699ed46">Gist</a> on on Github had me up and running. Very little work on my part here, following Colm’s detailed instructions, (barring time for downloads) I had docker up on mac in about 30 mins. </p>

<p>Take a look…..</p>

<h2 id="download-database-binaries-from-oracle-technology-network">Download Database Binaries from Oracle Technology Network</h2>

<p>Download the linux x86-64 ZIP archive from <a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html">here</a>.</p>

<h2 id="check-out-the-oracle-docker-images-from-github">Check out the Oracle Docker Images from Github</h2>

<p>There’s a few ways to do this using an SVN or GIT client, but I just go to the project’s <a href="https://github.com/oracle/docker-images">home page</a>, and click the button on the right hand side labeled ‘Clone or Download’ and then click ‘Download Zip’.</p>

<p>Next unzip this archive of the project that you just downloaded, for example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/work/docker
unzip ~/Downloads/docker-images-master.zip
</code></pre></div></div>

<h2 id="move-the-database-binaries-to-the-correct-location">Move the Database Binaries to the correct location</h2>

<p>To build the Docker image, you’ll use a script named <code class="language-plaintext highlighter-rouge">buildDockerImage.sh</code>, for this script to work the Oracle Database binaries need to be placed in the correct location, for example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/work/docker/docker-images-master/OracleDatabase/
mv ~/Downloads/linuxx64_12201_database.zip ./12.2.0.1
</code></pre></div></div>

<p>This places the ZIP archive containing the Oracle Database binaries in the expected <code class="language-plaintext highlighter-rouge">12.2.0.1</code> sub-folder</p>

<h2 id="configure-the-proxy-if-necessary">Configure the Proxy if necessary</h2>

<p>If you’re behind a proxy, you’ll need to ensure the <code class="language-plaintext highlighter-rouge">http_proxy</code> and <code class="language-plaintext highlighter-rouge">https_proxy</code> environment variables are set, so the proxy configuration can be propagated to the created Docker Container. If this is not done correctly then <code class="language-plaintext highlighter-rouge">yum</code> will not be able to reach any repositories.</p>

<p>For example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>export http_proxy=http://someproxy.corpdomain.com:80
export https_proxy=http://someproxy.corpdomain.com:80
</code></pre></div></div>

<h2 id="build-the-docker-image">Build the Docker Image</h2>

<p>To build the Docker image use the <code class="language-plaintext highlighter-rouge">buildDockerImage.sh</code> script, it’s usage is described in the <a href="https://github.com/oracle/docker-images/blob/master/OracleDatabase/README.md">README</a>. First let’s ensure the script is executable:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/work/docker/docker-images-master/OracleDatabase/
chmod +x ./buildDockerImage.sh
</code></pre></div></div>

<p>Next invoke the script to build the image, to build a 12.2.0.1 enterprise edition image:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/work/docker/docker-images-master/OracleDatabase/
./buildDockerImage.sh -v 12.2.0.1 -e
</code></pre></div></div>

<p>Go get a coffee, this step takes a while, for me it took about 16 minutes.</p>

<h2 id="run-the-docker-image">Run the Docker Image</h2>

<p>When it comes to running the Docker Image, you have several choices to make, read the <a href="https://github.com/oracle/docker-images/tree/master/OracleDatabase#running-oracle-database-in-a-docker-container">docs</a> for more detail on this. I’m only going to change a few things:</p>

<ul>
  <li>set the name of the PDB created to <code class="language-plaintext highlighter-rouge">ORCL</code></li>
  <li>Store the database data on the host machine, this enables me to blow away the docker container at any time and re-create it without losing any data. In effect I’m separating the database ‘engine’ (the docker container) from the database storage (the volume on the host where the database storage is persisted).</li>
  <li>Configure the Database to use Extended Data Types (increase max VARCHAR2 to 32767 bytes).</li>
</ul>

<h3 id="prepare-the-storage-volume">Prepare the storage volume</h3>

<p>I created a folder within my home folder:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/work/docker
mkdir oradata
</code></pre></div></div>

<p>Note the documentation states this folder must be owned by an operating system user named <code class="language-plaintext highlighter-rouge">oracle</code>. On my Mac OS host, I found I didn’t need to create an <code class="language-plaintext highlighter-rouge">oracle</code> user or give it ownership of this folder.</p>

<h3 id="extended-data-types">Extended Data Types</h3>

<p>In 12.1 and later VARCHAR2 fields can be configured to hold up to 32K bytes. However this feature is off by default, so we need to do some scripting to reconfigure the database to use extended data types. We want these scripts to run after the database is first setup, so we’ll mount a volume as part of the <code class="language-plaintext highlighter-rouge">docker run</code> command which will cause those scripts to be executed.</p>

<p>The script needed is attached to this gist, so first ensure you have downloaded this script into a folder. The easiest way to do this is to click the ‘Download ZIP’ button at the top right of this page and then unzip the downloaded archive into a folder, for example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/work/docker
mkdir db_setup_scripts
cd db_setup_scripts
unzip -j ~/Downloads/8082bece*.zip
</code></pre></div></div>

<ul>
  <li>We use the <code class="language-plaintext highlighter-rouge">-j</code> option to tell unzip not to bother recreating the directory structure of the archive</li>
</ul>

<p>We want to make sure any shell scripts are executable in the docker container, and remove unecessary files:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/work/docker/db_setup_scripts
chmod +x *.sh
rm *.md
</code></pre></div></div>

<h3 id="run-the-container">Run the container</h3>

<p>Now we are all prepared, we can tell Docker to run the image, we’ll give the container a name as well:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker run --name oracle -p 1521:1521 -e ORACLE_PDB=ORCL \
           -v ~/work/docker/oradata:/opt/oracle/oradata \
           -v ~/work/docker/db_setup_scripts:/opt/oracle/scripts/setup \
           oracle/database:12.2.0.1-ee
</code></pre></div></div>

<ul>
  <li>The <code class="language-plaintext highlighter-rouge">-name</code> argument names the container</li>
  <li>The <code class="language-plaintext highlighter-rouge">-e</code> arguments passed an environment variable that renames the created PDB to <code class="language-plaintext highlighter-rouge">ORCL</code> (the default is <code class="language-plaintext highlighter-rouge">ORCLPDB1</code>)</li>
  <li>The first <code class="language-plaintext highlighter-rouge">-v</code> argument mounts the folder to store the database data</li>
  <li>The second <code class="language-plaintext highlighter-rouge">-v</code> argument mounts the folder containing the scripts to convert the database to use extended data types</li>
</ul>

<p>Time for another coffee, creating the initial database takes time. After a while the database will have been created, and the script to enable extended data types will have been executed</p>

<h2 id="managing-the-container">Managing the Container</h2>

<p>Once the initial setup of the database has completed, I like to stop the container and then start it again to leave it running in the background. To do this, in another terminal do the following:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker stop oracle
docker start oracle
</code></pre></div></div>

<p>or simply:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker restart oracle
</code></pre></div></div>

<h3 id="deleting-the-container">Deleting the Container</h3>

<p>If you ever need to get rid of the container, then the following will remove the container, you can recreate it again using docker run:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker stop oracle
docker rm oracle
</code></pre></div></div>

<h2 id="connecting-to-the-database">Connecting to the Database</h2>

<p>You can use the <code class="language-plaintext highlighter-rouge">sqlplus</code> as described in the <a href="https://github.com/oracle/docker-images/tree/master/OracleDatabase#running-oracle-database-in-a-docker-container">docker images documentation</a> but it’s a bit hard to use because it can only read from the filesystem within the container. Much better to use it’s more modern relative, <a href="http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html">SQLcl</a>, which will run anywhere you can run Java, and doesn’t require an Oracle Client install, so it’s super easy to get working, and especially handy for Mac users.</p>

<p>Since we have port forwarded the container’s 1521 port to our host’s 1521 port, we can use <code class="language-plaintext highlighter-rouge">sqlcl</code> to connect to the database as follows:</p>

<h3 id="connect-to-the-cdb">Connect to the CDB</h3>

<p>To Connect to the CDB, just do the following:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sql system

SQLcl: Release 4.2.0.16.043.0306 RC on Fri Sep 08 18:10:52 2017

Copyright (c) 1982, 2017, Oracle.  All rights reserved.

Password? (**********?) ******
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL&gt;
</code></pre></div></div>

<h3 id="connect-to-the-pdb">Connect to the PDB</h3>

<p>To connect to the PDB, just do the following:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sql system@//localhost:1521/orcl

SQLcl: Release 4.2.0.16.043.0306 RC on Fri Sep 08 18:12:29 2017

Copyright (c) 1982, 2017, Oracle.  All rights reserved.

Password? (**********?) ******
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL&gt;
</code></pre></div></div>]]></content><author><name>Barry McGillin</name></author><category term="macosx" /><category term="oracle" /><category term="Docker" /><category term="dbtools" /><summary type="html"><![CDATA[So you want Docker and to install and Oracle Database locally.  So did I and while I have VirtualBox and the Oracle Developer Day VM, I wanted to setup docker and the Oracle Database Well Colm Divilly (@cdivilly) has cleared it up for me.  His Gist on on Github had me up and running. Very little work on my part here, following Colm’s detailed instructions, (barring time for downloads) I had docker up on mac in about 30 mins.  Take a look…..]]></summary></entry><entry><title type="html">Oracle REST JDBC Driver and SQLcl</title><link href="https://bamcgill.github.io/2017/09/oracle-rest-jdbc-driver-and-sqlcl/" rel="alternate" type="text/html" title="Oracle REST JDBC Driver and SQLcl" /><published>2017-09-07T14:09:00+00:00</published><updated>2017-09-07T14:09:59+00:00</updated><id>https://bamcgill.github.io/2017/09/oracle-rest-jdbc-driver-and-sqlcl</id><content type="html" xml:base="https://bamcgill.github.io/2017/09/oracle-rest-jdbc-driver-and-sqlcl/"><![CDATA[<p>Oracle just released its first REST JDBC driver on OTN, in conjunction with the 17.3.0 Oracle REST Data Services Beta release.</p>

<p><a href="http://dermotoneill.blogspot.co.uk/2017/09/getting-started-with-rest-enabled-sql.html">Dermot posted this morning</a> about how to setup ORDS and Enable REST SQL Statements. The JDBC driver connects to this service and allows you to connect your JDBC based program to a REST services.</p>

<p>As an example of this working with a standard application we can download the driver and drop it into Oracle SQLcl and connect to a service out of the box.</p>

<ul>
  <li>Firstly download <a href="http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html">SQLcl from OTN</a></li>
</ul>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifr-KyWp6Tcf3wLhiTs0boAHDhlf3ZtNnLwFmY1_9jsdWPnonKMx-pa4WHuIiwfMi3EDnR4Pzq_F-os-rL5xK7QdmraPJmwGepzqhNc2VpJFcP2uE2T-eM9ydt-WEA9b7vzUENHg2OVRY/s1600/Screen+Shot+2017-09-07+at+11.52.29.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifr-KyWp6Tcf3wLhiTs0boAHDhlf3ZtNnLwFmY1_9jsdWPnonKMx-pa4WHuIiwfMi3EDnR4Pzq_F-os-rL5xK7QdmraPJmwGepzqhNc2VpJFcP2uE2T-eM9ydt-WEA9b7vzUENHg2OVRY/s640/Screen+Shot+2017-09-07+at+11.52.29.png" alt="" /></a></p>

<ul>
  <li>Unzip the sqlcl-17.2.0.184.1230-no-jre.zip</li>
</ul>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVi65afTHrEkTHHj4XzcWx9JmsShjGIuzRE1Vbe3vH2vEXaQ3nfR9CB6oSUQZbJ8nsg8nemXO0_xKpwsKTEbGDsAibIuKriJtu9HQnkKpL38jiT_CsXKMjhvngqJdNv_kO3zX3awLTMlg/s1600/Screen+Shot+2017-09-07+at+12.00.38.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVi65afTHrEkTHHj4XzcWx9JmsShjGIuzRE1Vbe3vH2vEXaQ3nfR9CB6oSUQZbJ8nsg8nemXO0_xKpwsKTEbGDsAibIuKriJtu9HQnkKpL38jiT_CsXKMjhvngqJdNv_kO3zX3awLTMlg/s640/Screen+Shot+2017-09-07+at+12.00.38.png" alt="" /></a></p>

<ul>
  <li>Download the <a href="http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/ords-beta-173-3873522.html">JDBC Beta Driver from OTN</a></li>
</ul>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwm2ICpP9UcCcicood606hMiOh90ECi-FsLGKW2RgXNp6yWmRM9aYtKF8iSlmgic9ZKAfF1cZGmmVGsndYWYPW0sf8s21CnHi6HZuyC0PqEJ7lDWlnR_v5atNo7RAHakO4jG6w31CgKxk/s1600/Screen+Shot+2017-09-07+at+11.39.59.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwm2ICpP9UcCcicood606hMiOh90ECi-FsLGKW2RgXNp6yWmRM9aYtKF8iSlmgic9ZKAfF1cZGmmVGsndYWYPW0sf8s21CnHi6HZuyC0PqEJ7lDWlnR_v5atNo7RAHakO4jG6w31CgKxk/s640/Screen+Shot+2017-09-07+at+11.39.59.png" alt="" /></a></p>

<ul>
  <li>and drop it into the SQLcl lib directory</li>
</ul>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJZIV80gyNWODNnbgu_GbxSR0Fo3JuV_ywqsR50nUfjBiwNHjoMEKL7QdkKwi4uRtJELGgLUWEefsgtbr5Zt-dJqFAdShQvMH9WtQKM-W1fde7ja4yiA417wHB-cMDBv4qbUQTJO4XbPQ/s1600/Screen+Shot+2017-09-07+at+15.00.43.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJZIV80gyNWODNnbgu_GbxSR0Fo3JuV_ywqsR50nUfjBiwNHjoMEKL7QdkKwi4uRtJELGgLUWEefsgtbr5Zt-dJqFAdShQvMH9WtQKM-W1fde7ja4yiA417wHB-cMDBv4qbUQTJO4XbPQ/s640/Screen+Shot+2017-09-07+at+15.00.43.png" alt="" /></a></p>

<ul>
  <li>Lastly start sqlcl with your appropriate URL, in my case is demo/demo@http:///ords//</li>
</ul>

<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLeWwWRqfHhtvNpzQaPFKb25CDeHWqRhlQyRL3IeK757VAF7ruSEwcMMFSjmIq-srNQf15XRWkXIn-Rbpx5ZzncAR3EsQJhB8M48cHc1e6y_J72xOZ02QZZxEiqx2cTJWZoG1AMK1i_UI/s1600/Screen+Shot+2017-09-07+at+12.35.54.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLeWwWRqfHhtvNpzQaPFKb25CDeHWqRhlQyRL3IeK757VAF7ruSEwcMMFSjmIq-srNQf15XRWkXIn-Rbpx5ZzncAR3EsQJhB8M48cHc1e6y_J72xOZ02QZZxEiqx2cTJWZoG1AMK1i_UI/s640/Screen+Shot+2017-09-07+at+12.35.54.png" alt="" /></a></p>]]></content><author><name>Barry McGillin</name></author><category term="REST" /><category term="jdbc" /><category term="sqlcl" /><category term="ORDS" /><summary type="html"><![CDATA[Oracle just released its first REST JDBC driver on OTN, in conjunction with the 17.3.0 Oracle REST Data Services Beta release. Dermot posted this morning about how to setup ORDS and Enable REST SQL Statements. The JDBC driver connects to this service and allows you to connect your JDBC based program to a REST services. As an example of this working with a standard application we can download the driver and drop it into Oracle SQLcl and connect to a service out of the box.]]></summary></entry></feed>