Posts Tagged ‘library’

SSH with Java

July 8th, 2009

Recently I needed to do some server manipulation over the SSH-2 protocol from a Java client program. There are quite a few choices of SSH libraries for Java out there. Usually I prefer BSD license whenever possible, so I thought I’ll give Ganymed SSH-2 for Java a try. It turned out to be pretty simple to use. Here’s a short example of how to connect to the server using the private key and execute some command.

iBatis and Stored Oracle procedures/functions

September 1st, 2008

This one took me a while to get it right the first time. I won’t go into details of configuring iBatis datasources and such, and will go straight to putting some queries in the sqlMap file. Just let me note that I’m using iBatis 2.3 for these examples. I’ll start off with a procedure call.

<procedure id="getUserRoles" parameterMap="myParamMap">
    { call SCHEMA.GET_USERS_ROLES(?, ?) }
</procedure>

This one is pretty self-explanatory, just defining a procedure to be called. Notice the questionmarks in the SQL, don’t put the usual #variable# style annotation here. Also instead of parameterClass I use parameterMap here, which means I’ll have to define a parameter map for this query or it won’t work.

Using maven

May 8th, 2008

Maven is an awesome build tool for JAVA, but it has some long parameter names that I don’t like to remember, so I put my often used tasks of maven in batch files.

install.bat

mvn install:install-file -Dfile=%1 -DgroupId=%2 -DartifactId=%3 -Dversion=%4 -Dpackaging=pom -DgeneratePom=true

This installs the specified .jar file in the local repository located in

C:\Documents and Settings\*User*\.m2\repository

where *User* is your username. Four arguments are required: jar_file, group, artifact and version.

new.bat

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=%1 -DartifactId=%2

I use this one to create new projects for stand-alone java programs. Two arguments required: group and artifact.

webnew.bat