Friday, June 22, 2012

eclipse seizure - 1

In some cases when you are trying to install a  eclipse plugin through their update manager, and you are on Linux, you may get something like:


Cannot complete the install because one or more required items could not be found. Software currently installed: Shared profile ....... etc.

It happened to me many times. What do to ?

Login as root, and install the updates you need. Big chance it may work. You may try to change the permissions for the base eclipse installation, but I didn't try this yet.


Monday, June 11, 2012

Mounting database as a file

Postgresql offers the ability to query external data. In some scenarios this can be really useful. This called SQL/MED ("SQL Management of External Data").

One of those cool scenarios is when you need to query a file inside code as if it was a database table. To do so you need to have at least postgresql-9.1.

We will use the simplest file format to demonstrate the idea.

Create a CVS file:

Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38
 
 
Create a postgresql server:
 
CREATE SERVER file_server FOREIGN DATA WRAPPER "file_fdw" ;




Now it's the time to create the table:


CREATE FOREIGN TABLE test (
year int,
make text,
model text,
length float
) SERVER file_server
OPTIONS (format 'csv', filename '/tmp/test.txt', header 'true', delimiter ',', null '');
 
CREATE FOREIGN TABLE

Let's try a select:

testdb=# SELECT * from test ;                                                      
 year |  make   | model  | length 
------+---------+--------+--------
 1997 | Ford    | E350   |   2.34
 2000 | Mercury | Cougar |   2.38
(2 rows)
 



Change a value in the file, and re-run the select. You should see the changes reflected in query results.

Additional Forgein Data Wrapper exists and they are cool. Using them, you can query 'twitter', MySql tables,
LDAP servers.
 
Additional documentation:
Foreign data wrappers


 
For those who likes this idea but don't use postgresql, here's a perl utility that may help:
DBIx::FileSystem

Related documents:
http://archive09.linux.com/feature/127055 
https://github.com/bianster/mysqlfs
http://www.nongnu.org/libsqlfs/
http://www.perlmonks.org/?node_id=397814




Sunday, April 29, 2012

JSTL, jsp-api with IVY

Many Application servers include jstl.jar in their classpath. However tomcat doesn't.
When you include it in your dependency manager, it pulls jsp-api.jar which conflicts with the one
shipped with tomcat. Therefore you need to exclude jsp-api.jar. For ivy users,


<dependency org="javax.servlet" name="jstl" rev="1.2" conf="compile->*" >
            <exclude module="jsp-api" />
</dependency>

<dependency org="javax.servlet" name="javax.servlet-api" rev="3.0.1" conf="provided->*" />






Tuesday, January 24, 2012

Back to Ant

Now with apache ivy, there's no need for maven, and I can easily rewrite Ant targets in xml without diving into extending maven. However, I still miss maven's "Convention over Configuration", and I hate reconfiguring every single war file, when using ANT+IVY combo. Gradle looked promising, but hey, when will I stop learning new build systems ? How many build system available and all of them address one single problem. If ant+ivy can do it, then they are good enough for me.

Plus, I was hit with gradle limitation, the third day I started using it and tried to extend it.

runnig task programmatically

To me, nothing is more transparent than ant and easier to customize, except those repetitive configurations.

May be it's the time for a simple antlib that saves me for writing those configuration again and again.