I found this article and it realy helped me with me Oracle trees:
select name, slave_id, supervisor_id
from corporate_slaves
connect by prior slave_id = supervisor_id
start with slave_id in (select slave_id
from corporate_slaves
where supervisor_id is null);
NAME SLAVE_ID SUPERVISOR_ID
-------------------- ---------- -------------
Big Boss Man 1
VP Marketing 2 1
VP Sales 3 1
Joe Sales Guy 4 3
Bill Sales Assistant 5 4
VP Engineering 6 1
Jane Nerd 7 6
Bob Nerd 8 6
8 rows selected.
Thanks and enjoy!
Situation: Some Bank has an old legacy ABS (Automatic bank system).
Bank wants to:
1. notify old legacy CRM system about client’s account changes (Publish operation).
2. check PIN codes of client cards (Request/Response operation) - in synchronious mode.
ABS is implemented in very old private technologies with StoredProcedures calls. So, I can connect to this system via database only.
Which ways of Java/.Net (ESB) application integration with old/legacy database system do you know?
Write/Publish operation
Any vendor’s databse server:
1. Scan tables for new entries - too low speed.
2. Trigger (if they’re supported) which handles SQL updates and inserts and writes event information to some table. And application listener should be checking this table for events.
Reading operation
1. Just write result into tables of ABS - dangerous.
2. …
How to notify legacy database system about responses in synchronious mode??? How to implement Write/Read in synchronious mode???
Log4J
The file log4j.properties should be located in \WEB-INF\classes folder of WAR archive.
Java Logging
But logging.properties must live in the same directory.
1. Don’t use RPM package, because it contains only server. Or download agent RPM seperately.
2. If you try to install from
# tar zxvf hyperic-hq-installer-3.0.2-xxx.tgz
# ./hyperic-hq-installer/setup.sh
Execution of HQ setup not allowed as the root user.
Please log in as a different user and re-run
.../hyperic-hq-installer/installer-3.2.5/bin/hq-setup.sh
you will get a lot of problems like checking you privileges and rights. The installer will recommend you to login under non-root user, and then it will show many other erros and etc.
Just open file …/hyperic-hq-installer/installer-3.2.5/bin/hq-setup.sh and comment these lines:
if [ "$USER" = "root" -o "$UID" = "0" -o "$EUID" = "0" ]; then
echo ""
echo "Execution of HQ setup not allowed as the root user."
echo "Please log in as a different user and re-run $0"
echo ""
exit 1;
fi
And then you will be able to setup hyperic as you wish.
Here is an example of convertion integer or byte into hex format:
private static String getHexDump(byte[] bytes) {
final StringBuffer sb = new StringBuffer();
for(byte b : bytes){
sb.append(Integer.toHexString(((int)b & 0xff))).append(" ");
}
return sb.toString();
}
Sometimes in my servers farm the “502 Proxy Error” error occures (”The proxy server received an invalid response from an upstream server.”), and I decided to find out where and why it hepends. After scanning the Internet and manuals of Apache Load Balancer I supposed that my Glassfish servers closed TCP connection after timeout and every first client of proxy would get the error. The solution is to set:
ProxyPass http://buggyappserver:7001/foo/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
after ProxyPass parameters. And Apache server will reconnect to Glassfish every time, but this veriant should be slower…
Enjoy!
Today, I have to write Java utility for resizing JPEG images for my photo gallary. It wasn’t so easy, because to resize is really stupid task. But what about smoothing of result images. They used to become absolutely unsuitable for posting to my web-site.
I found solution and glad to open a source code:
private void resizeImage(String filename, String newfilename)
throws InterruptedException, ImageFormatException, IOException
{
LOG.info("Resizing file : " + filename);
// load image from file
Image image = Toolkit.getDefaultToolkit().getImage(filename);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
// get real size
int imageWidth = image.getWidth(null);
int imageHeight = image.getHeight(null);
double imageRatio = (double)imageWidth / (double)imageHeight;
// determine - vertical or horizontal
if(imageHeight > imageWidth) {
// vertical
imageHeight = biggerPart;
imageWidth = (int)(imageHeight * imageRatio);
} else {
// horizontal
imageWidth = biggerPart;
imageHeight = (int)(imageWidth / imageRatio);
}
LOG.info("New height = " + imageHeight + " and width = " + imageWidth);
// draw original image to new image object and
// scale it to the new size on-the-fly
BufferedImage newImage = new BufferedImage(imageWidth,
imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = newImage.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics2D.drawImage(image, 0, 0, imageWidth, imageHeight, null);
// Soften
float softenFactor = 0.09f;
float[] softenArray = {0, softenFactor, 0, softenFactor, 1-(softenFactor*4), softenFactor, 0, softenFactor, 0};
Kernel kernel = new Kernel(3, 3, softenArray);
ConvolveOp cOp = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
newImage = cOp.filter(newImage, null);
// save new image to OUTFILE
BufferedOutputStream out = new BufferedOutputStream(new
FileOutputStream(newfilename));
try {
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(newImage);
quality = Math.max(0, Math.min(quality, 100));
param.setQuality((float)quality / 100.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(newImage);
}finally {
out.close();
}
LOG.info("Resized file : " + filename + " to " + newfilename);
}
Enjoy!
This command will show you the summarized size of the current folder and it’s subfolders:
du -hs
Enjoy!
This command flushes and updates local DNS cache wihtout rebooting machine:
# ipconfig /flushdns
Enjoy!
If you use a scheme-based Spring configuration file in Mule server like this one:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<beans>
....
</beans>
you will get an error:
org.xml.sax.SAXParseException: Document root element “beans”, must match DOCTYPE root “null”.
It is required to use a DOCTYPE header of XML and DTD-based definition:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
...
</beans>
Enjoy!