Sunday, November 7, 2010

Installing XAMPP IN UBUNTU

After downloading the file give the below command

1. sudo chown root:byorn xampp-linux-1.7.3a.tar.gz

2. sudo tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt/

3. cd /opt/lampp
sudo ./lampp start

Sunday, September 12, 2010

Groovy, Blob to String

sql.eachRow "select * from table1",
{
///println it.id

String result = ""
blobTest = (oracle.sql.BLOB)it.mydoc

byte_stream_test = blobTest.getBinaryStream()
byte_stream_test.eachLine {charset->

result += charset+"\n" }
println result;


}

Saturday, September 11, 2010

Staring Oracle in Ubuntu. - Problem and work around resolution.

1) /etc/init.d/./oralcle-xe.sh start


2) error:
Copyright (c) 1991, 2005, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lexi)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
byorn@lexi:/etc/init.d$ sudo ./oracle-xe restart
Shutting down Oracle Database 10g Express Edition Instance.
Stopping Oracle Net Listener

3) Now:
sudo /etc/init.d/./oralcle-xe.sh restart

4) success:
ler(s) for this service...
The command completed successfully


Any body have any idea about this?

Friday, September 10, 2010

DB Connectivity With Groovy

import java.sql.Connection
import java.sql.DriverManager
import javax.sql.DataSource
import groovy.sql.Sql
import oracle.jdbc.driver.OracleTypes

driver = oracle.jdbc.driver.OracleDriver
Connection conn = DriverManager.getConnection(
'jdbc:oracle:thin:rcms/password@localhost:1521:xe');

/*
*
* Here we call a procedural block with a closure.
* ${Sql.INTEGER} and ${Sql.VARCHAR} are out parameters
* which are passed to the closure.
*
*/
Sql sql = new Sql(conn);

//define a closure
myclosure = {println it.cusid + " " + it.cusname }

sql.eachRow("select * from tbl_customer", myclosure);

Tuesday, July 27, 2010

SubVersion Client To Work With Ubuntu For Netbeans 9

Downloaded the rpm from Collabnet, as suggested by Netbeans 9 (Ubuntu 10.4 lts)

extracted the rpm on a folder structure like "myfolder/mysubverclient/[..extracted file..]

when in /bin folder ./svn command is given, the below error appeared.



./svn: error while loading shared libraries: libsvn_client-1.so.0: cannot open shared object file: No such file or directory


when i put all the .so libraries fro /lib to /usr/lib folder it worked.

Wednesday, June 2, 2010

Sign JARs

(1) Create a Key Store With a Validity Period.
keytool -genkey -alias alias-name -keystore keystore-name -validity 365

(2) Sign the JAR

jarsigner -keystore keystore-name -storepass keystore-password
-keypass key-password jar-file alias-name

thats its, now bundle and deploy.

Tuesday, May 18, 2010

Dynamically generating an Image and displaying it with JQuery

The JQuery Code:

$(document).ready(function() {

CUSTOM JQUERY PLUGIN
$.fn.image = function(src, f){
return this.each(function(){
var i = new Image();
i.src = src;
i.onload = f;
this.appendChild(i);
});
}

-- on button click output image generating servlet to the div.

$('#clickme_button').click(function(){

$("#the_div").image('/rcms/chequeImageServlet',function(){

});

});


The Servlet:

response.setContentType("image/jpg");
//RESOLVE CACHING ISSUES
response.setHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0);

try {
byte[] rb = null;

Cheque cheque = chequeEjb.getCheque(new Long(13));

if (cheque != null) {

rb = (byte[]) cheque.getImgFront();

cheque entity a POJO which stores images as Serializable , in DB Blob


if (rb != null && rb.length > 0) {
response.reset();

response.getOutputStream().write(rb, 0, rb.length);
response.getOutputStream().flush();


}
}
} finally {
response.getOutputStream().close();
}
}

Hats off to the below blog link:

http://letmehaveblog.blogspot.com/2006/08/simple-jquery-plugin-to-load-images.html

Saturday, May 15, 2010

JPA Cache Refresh

If you are a beginer to JSF and JPA,sometimes, you may wonder why your web page does not reflect the database table values accurately, especially when the table values were modified externally.(Manually).

This happens, because when you (by default) fetch data using JPA entity manager, the values are fetched from the Entity Cache. So basically when you update the database table externally, the Entity Cache needs to be updated as well.

To get over this issue, simply,
fetch the data like this:

e = (Employee)em.createQuery("SELECT e FROM Employee e WHERE e.id = :id")
.setHint("toplink.pessimistic-lock", "Lock")
.setParameter("id", primaryKey)
.getSingleResult();



http://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t.html

Monday, April 19, 2010

Monday, March 29, 2010

Set up a cluster (Glassfish v2.1.1) and load balancer (sjws7)

If you come accross this post by any chance, I just wanted you to know that
if you follow the below link's instructions to the dot, you will not face difficulties as its pretty straight forward.



https://glassfish.dev.java.net/javaee5/build/GlassFish_LB_Cluster.html

Monday, January 11, 2010

Adding an auto startup service in RH Linux 5

1.) Create a executable file.
vi filename.
2.) Add the below content to the file
#!/bin/sh
#chkconfig: 2345 80 05
#description: my service
echo "starting up"
3.)Place the scrip in etc/init.d/rc.d
4.)Make it executable: chmod a+x filename
5.)add the filename to the executing sequence using: chkconfig --add filename

Notes:

Bios -- > Master Boot Record -- > Kernel -- >Init.
read linux about startup

to see the PID of init:
ps -ef | grep init
In short, the init performs tasks that are outlined in /etc/inittab.


The folders in etc/init.d/rc.d
/etc/rc.d. there are a set of files rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6,
the system uses these files (and/or directories) to control the services to be started.

Note: to see all the auto initializing scripts
type : chkconfig --list


startup sequence in init with chkconfig