Connecting to various DBs by using ant’s sql command.

January 19, 2010 Leave a comment

As you see from my previous blog, I set up oracle client to connect to the remote DB server to do the debug. If you just deal with one DB server, this should be fine, what if you need to test against various DB servers, like mysql, postgres, oracle and sqlserver, which is our riftsaw project need to be tested against, so instead of installing all of these clients, I am using the Apache Ant’s sql command.

I added a command to show all of tables in the db, below is the build.xml that I used.


<target name="db.show.tables"
depends="log.properties, copy.ojdbc"
description="show tables in db">
<sql driver="${driver}"
url="${connection.url}"
userid="${username}"
password="${password}"
onerror="continue"
print="true">
${show.table.sql}
<classpath>
<fileset dir="drivers">
<include name="*.jar"/>
</fileset>
</classpath>
</sql>
</target>

Different database vendor has its own syntax for showing tables, as I defined below.


<condition property="show.table.sql" value="show tables;">
<equals arg1="${database}" arg2="mysql" />
</condition>

<condition property="show.table.sql" value="select table_name from information_schema.tables where table_schema='public' and table_type='BASE TABLE';">
<equals arg1="${database}" arg2="postgres" />
</condition>

<condition property="show.table.sql" value="select table_name from tabs;">
<equals arg1="${database}" arg2="oracle" />
</condition>

<condition property="show.table.sql" value="select name from riftsaw..sysobjects where xtype = 'U';">
<equals arg1="${database}" arg2="sqlserver" />
</condition>

By using this approach, you don’t need to install those db clients, which could save you a lot of time.

Categories: Database

Using Oracle Instant and Sqlplus in Fedora

January 15, 2010 Leave a comment

In case you are working against Oracle database, and don’t want to install the whole Oracle DB mess, just want to use the sqlplus to connect to an existing db. Then see this post.

I installed oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm and oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.i386.rpm in my box. (Fedora 10)

Once you connect it successfully. simply run:

select table_name from tabs;

to show the tables from your connected database.

Categories: Database

Hightlights from BPMN2.0

January 7, 2010 Leave a comment

Rick Geneva has put a set of “hightlights from BPMN2.0” blog entries, very great tutorial on BPMN2.0.

  1. Highlights from BPMN 2.0: Activity Types
  2. Highlights from BPMN 2.0: Artifact Shapes
  3. Highlights from BPMN 2.0: Event Gateways
  4. Highlights from BPMN 2.0: Non-Interrupting Events
  5. Highlights from BPMN 2.0: New Event Types

I believe we will see more to come in this series.

Categories: BPMN

Install VirtualBox and Chrome beta in Fedora 10

December 12, 2009 Leave a comment

Just installed the VirtualBox in my Fedora 10 box by following this blog entry. It works great. If you live in China, you know you have to use MS’s Internet Explore in some cases, like online bank. So it would be neat that having a virtual box, and having a Windoows installed. Noticed that google roll out the linux version of Chrome, althought it is just beat version, tried it, seems good.

Categories: Fedora

JPA implementation patterns

December 6, 2009 Leave a comment

Found a very good series on JPA implementation patterns, it was written by Vincent Partington.

Categories: JPA

open source projects should really use Git

December 6, 2009 1 comment

I am starting to work on one task in ODE, titled cleanup JPA impl (https://issues.apache.org/jira/browse/ODE-704), basically it is a quite large refactoring on DAO layer of ODE project. Because I am not a ODE committer, It is not an easy job to get this task done.

After talked with Rafal Rusin on the ode IRC channel, he suggested that I create a git project in github, which clones the ode git repo, and then put my jpa refactoring experiment branch in github, once my code has finished, and passed all the tests, they can merge my branch into the ode trunk.

I’ve heard of Git for a while, but didn’t get a chance to use it, as currently I am still using the Subversion as SCM repository. One thing that I learnt from history is that try to avoid using branch in SVN or CVS as much as possible, it is really a headache for merging branch back to trunk, so this is very inconvenient for you to try some new feature, or some experiment codes.

Create a project at Github is very easy, if you have problems, GitHub’s help is your friend. I have to say that Github did an awesome job on project hosting, it makes you very easy to browse your code, the diff message between version etc.

Watching the Linus’ Git talk on Google Tech conf, very interesting, totally agreed that one pain with centralized repository like CVS or SVN, is that you need to get the commit access for your contribution (I am not saying a small fix, or patch, I meant some large task, or feature etc, which would require multiple patches, and might take one or two weeks), like the case that I am hitting now. Alternatively, if you are hosting code repository by using Git, I can clone it from the url, and pull the changes into my local workspace to make it up-to-date, and then push it into some other repository, once I’ve finished my task, I will send you my code repository, and then you can take a look at those code to decide if you want to accept my code or not. In this case, I don’t need to have a commit permission in advance. Also merge in Git is very easy, it makes collaboration really easy.

So, I would strongly recommend that every open source project should embrace the Git as scm tool, lets forget about Subversion, CVS. Lets embrace the branch. 😉

couple resources that could help you get started with Git.
1. Git website
2. GitHub webiste
3. Learn Git website (Strongly recommend for learning)

Categories: Git

Good presentation about XMPP and Web.

December 4, 2009 Leave a comment

Jack Moffitt talked a presentation about XMPP and real time web, it is published at InfoQ, don’t miss it if you are trying to work with XMPP and Web, it is very hands-on, and technical oriented.

Categories: OpenSource, Others

JBoss AS5 MC articles and presentations.

November 16, 2009 Leave a comment

Ales has written a series of JBoss Microcontainer, which is the core of JBoss AS 5, articles at DZone.

  1. component models
  2. Advanced Dependency Injection and IoC
  3. the Virtual File System
  4. ClassLoading Layer

Also, in the youtube, we’ve got the four presentations from Scott Stark and Ales at JavaOne.

  1. JBoss AS5 Deployment Environment
  2. JBoss AS5 Component Mixture Patterns
  3. JBoss AS5 Classloading and OSGI
  4. JBoss Microcontainer Optimization

If you want to know more about JBoss Microcontainer, you wouldn’t miss the user guide, and its homepage.

Happy learning. 😉

Categories: Java, JBoss, Microcontainer

Create Database and user in Postgres and Mysql.

October 29, 2009 Leave a comment

Since I worked in SOA area, haven’t touched the database for couple years, although in some projects, I need to test against various database (Mysql, Postgres, Oracle etc), but it is very basic stuff, like create database, users etc.

This post basically is a memo for me, I need to work with various DBs from time to time, and think it is best to record it in my blog, instead of looking into the manual again. ;-). Also, you could see this is a follow-up post for my previous postgres installation blog.

1. Postgres

1) connect Postgres

psql -h localhost -U postgres

2) add user

create user jeff with password ‘jeff’

3) create database

create database jeffdb

4) grant db to user

grant all privileges on database jeffdb to jeff

Log out with “\q” command

Log in jeffdb through user jeff:

psql -d jeffdb -U jeff

2. Mysql

1) connect mysql

mysql -u root -p ‘urpassword’

2) create database

create database jeffdb

3) allow user jeff to connect to the server from localhost using the password jeff

grant usage on *.* to jeff@localhost identified by ‘jeff’;

4)grant all privileges on the jeffdb database to this user

grant all privileges on jeffdb.* to jeff@localhost ;

Log out and log in through jeff user.

mysql -u jeff -p’jeff’ jeffdb

[Reference]
1. How to add postgres user and create db
2. Create mysql database and set privileges into a user

Categories: Database, Postgresql

Openfire + jwchat + Tomcat = Realtime collaboration

October 22, 2009 Leave a comment

If you are building a web application, you might need customers use IM client to get to you easily, and can communicate with you on real time. Then I would recommend the Openfire (IM server) + jwchat (web IM) to build your real time collaboration. All of these two are open source. Openfire also has its enterprise edition.

Following are two links about how to setup these two. (both of them are written in Chinese).

1. 构建 基于openfire + jwchat 的 WEB IM
2. Openfire+jwchat linux 下安装记录

I am using the Openfire 3.6.4. But the steps are the same as before.

Update (Oct-24-2009), if you want to build your own web IM to communicate with Jabber server, then you’d better check out the JSJAC library. One common issue due to the XMLHttpRequest is that is unable to get resource across the domain. Good news is that you could either use the Apache mod_proxy or url rewrite to do so, or you deploy a JHB servlet like what jwchat war did.

Categories: Chinese, Identity