Monday, February 8, 2010

Building TOra with Oracle support on Ubuntu

I'm doing some Oracle development, so I wanted to use the TOra db browser for convenience.

TOra is Free Software. There is a license conflict between TOra and the license that Oracle use on their client libraries. As a result TOra is not distributed with Oracle support: if you want to use TOra with Oracle, you must download the separate components, TOra source and Oracle client, and build TOra yourself.

This process is documented on the web, notably at pythian blog. However the instructions are for Ubuntu 9.04, and I'm using 9.10, so I thought there is an opportunity to document my experience as well.

So, on Ubuntu 9.10, I have installed Oracle XE (a resource-limited 10G installation), into it's default directory: /usr/lib/oracle/xe/

I'm also assuming that you, like me, have the three Oracle packages oracle-instantclient-basic-10.2.0.4-1.i386.rpm oracle-instantclient-devel-10.2.0.4-1.i386.rpm oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm installed in their default location: /usr/lib/oracle/10.2.0.4/client/

NOTE: I chose the '10.x' client packages - I'm not sure if this makes a difference.

It seems that the Ubuntu source for TOra have migrated to git, so when I tried to pull down the source using apt-get source I didn't have any joy. So I cloned the TOra git repository and attempted to modify the debian/rules file to include the relevant Oracle libraries. This wasn't possible - there were no configure rules in there...

So instead I configure using 'cmake'.
First I need to configure: ORACLE_HOME and LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client/lib
export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client/

I also need to install the old libstdc++5 which is available from the Debian repository: http://packages.debian.org/lenny/i386/libstdc++5/download

Then a command line to configure build:

 fakeroot cmake -DORACLE_PATH_LIB=/usr/lib/oracle/10.2.0.4/client/lib -DORACLE_LIBRARY_CLNTSH=/usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so.10.1 -DORACLE_LIBRARY_OCCI=/usr/lib/oracle/10.2.0.4/client/lib/libocci.so.10.1 -DORACLE_INCLUDES=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/rdbms/public

NOTE: I'm calling in the INCLUDES from the XE install.
...and another to build:

make

And you should know what to do from here...

Saturday, January 23, 2010

FormFu, DBIC, model_config and resultset.

I have found myself back in Catalyst development work. This wouldn't be such a bad think if I hadn't just spent a whole day trying to fix up a form to edit a 'many_to_many' relationship which is stored in my Schema.

I've been following this post which says it should be about as simple as it sounds. i.e. not as simple as Rails, but definitely doable with finite effort. So, FormFu syntax not withstanding, I following these instructions but ended up with some peculiar error talking about 'result_source'. I tried playing with 'nested_name', 'model_config' etc... I began to think about building my Select in the controller.

Finally, I discovered my error: I had not configured Controller::HTML::FormFu which is shown nicely in this post:

http://lists.scsys.co.uk/pipermail/html-formfu/2009-March/001932.html

That is a day of my life gone, but at least I will be able to rise from sleep tomorrow knowing that I can move onto doing some new development.

UPDATE: One additional comment to the post above from 2009-March. I found that I needed to use the many_to_many relationship as the nested_name, not the has_many as stated.

Friday, January 8, 2010

Skype on a Ubuntu HP Mini 1000

I have been playing with Ubuntu 9.10 on a HP Mini for a while - on and off.

I have a request to get Skype working. I struggled with this for a bit, but I couldn't get it to work with the duplex sound card: when I pluged a microphone in, the speakers stopped working for example.

Something changed - it could have been an kernel update - anyway, I can now use Skype with minimal effort - including the web-cam.

The vital thing I had to do was disable the checkbox (options->audio settings or something):

'Allow Skype to automatically adjust my mixer levels'

Then, I could twiddle the 'pulse audio' options (right click on the volume icon) to increase the microphone input level. It seemed that one problem was Skype wouldn't let me increase the microphone input level while I was letting it 'automatically adjust my mixer levels'.

Wednesday, December 16, 2009

Fedora, sqlplus: error while loading shared libraries

My sqlplus stopped working one day with the error:

sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

this is a classic shared object where the shared object cannot be found.

I don't know how it happened, but my sqlplus install had become detached. The solution is simple as root: search for the .so file in your file system. You can do this using your expert knowledge, or find:

find /usr -name 'libsqlplus.so'

Once you have this location, stick the folder which contains this library (i.e. /usr/lib/oracle/11.2/client/lib/) in a file for linker to find:

/etc/ld.so.conf.d/oracle.conf

The linker is call 'ld' and on Fedora 11 uses /etc/ld... for it's configuration files. The final step is to re-configure the dynamic linker run time bindings which is done with:

ldconfig

Building a self contained Jar with Maven on Netbeans

Sometimes I need to build a Jar for distribution. A typically ideal type of Jar is one which can be executed from the command line:

java -jar ./myApp.jar

I have in the past used One-Jar which works nicely for this purpose, but now I'm using Maven as standard, this should be able to do this for me. And do it without IDE dependent plugins.

Today I'm going to build a jar with Eclipse. The project which I'm building is dependent on another local Maven project, and they both are dependent on locally and repository managed Jars.

Once all the dependencies are in the Maven Classpath Container, it is a matter of editing the pom.xml file which dictates the build process.

to this I added a plugin - in the section of the node:

  <artifactid>maven-assembly-plugin</artifactid>
  <configuration>
    <descriptorRefs>
      <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
    <archive>
      <manifest>
        <mainClass>net.crisppacket.myApp</mainClass>
      </manifest>
    </archive>
  </configuration>

so now, issuing (from the command line):

mvn assembly:assembly

will create a Jar for you. I got this far with the assistance of the excellent KSB's Maven Notes.

Now, in Netbeans, you can add a Custom Goal. Right click on the project you want to build, select 'Custom->Goals...' and then in the Goal field type:

assembly:assembly

OK. Now you can select this Goal (using the same mouse navigation) and it will build you a Jar. Hopefully.

Thursday, December 10, 2009

reserved words in MVC

There is no other words to express my disappointment with object relational mapping framworks than: woeful

I have played with three MVC frameworks (Catalyst/perl, rails/ruby, grails/groovy) and by one metric, Rails is pittyful. That metric is narrow but significant (in my opinion) and is described below.

The object-relational mapping frameworks in question are:

Catalyst/DBIC
Rails/ActiveRecord
Grails/Hibernate

My issue is that all these frameworks have implicit 'reserved words'. These typically throw an obscure error if you use in your Models because they collide with either framework or DB reserved words.


Let me draw up a table:

Framework
# reserved words
notes
DBIC
0 + db dependent
DB reserved words are not permitted.
Hibernate
0 + db dependent
DB reserved words are not permitted.
ActiveRecord
7 + db dependent
based on Reserved words in Rails blog post from 2007

So, there is an important uncertainty here: DB reserved words.

Irrespective of db reserved words, the frameworks differed on DB reserved words - so your models aren't portable across DBs. Am I alone in feeling this is a real lost opportunity for relational mapping frameworks?

I have still not seen a reason why these 'reserved words' restrictions exist
All (?) decent DBs will (I think) allow you arbetary table names with by quoting db names...
From an architecture perspective, having reserved words for something which is supposed by be abstract is just perverse.

I await the end of 'reserved words'.

UPDATE: This post is poorly researched. I discovered an additional resource in a blog post by Daniel Butler. However, my experience still points to Catalyst being an good choice of MVC framework when dealing with large legacy databases.

Sunday, December 6, 2009

postgresql search_path with ruby on rails

I studied (amongh other things) electrical engineering at Univsrity. One of the lectures said that you only need one forumal to master the subject: V=IR. However, the lecture warned, you have to know that forumla inside out.

Indeed, you could argue that V=IR is a simplification of Maxwells law, so V=IR not only covers you for EE, but a large chunk of physics (astro, plasma for example) as well.

Some times, I think MVC frameworks are similar.

Anyways... .I'm finding myself using Rails today. I've used it before with some success but didn't like the way it wanted to dominate the DB. My current thinking is that this approach is alright unless you want to integrate a legacy DB.

I'm integrating a legacy DB. It's in PostgreSQL and it uses schema namespaces. Namespaces are really worth the effort. They look great if you use PgAdminIII.

I struggled for a hour or so with my namespaces and then I discovered that I could include a search_path in ./config/database.yml. Now everything is working well again.