Hobione's Weblog

Living & Breathing in Web 2.0 Era

Oracle 11g on Windows 7 professional (32 bits)

I have downloaded two zip files for Oracle 11g release 2 from Oracle site as follows.

Unzipped ’em and ran setup.exe from \win32_11gr2_database_1of2\database\setup.exe and got zillion of file not found errors as follows.

–> \application\em.ear, \bin\db2gc\, \config\system-application.xml\

–> Template General_Purpose.dbc does not exist

–> Oracle Database Configuration Assistant failed

Anyway, after fiddling with some times, I found out that the two zip files I have downloaded, needed to combine together to solve file not found errors. So I copied win32_11gR2_database_2of2\database to win32_11gR2_database_1of2\database to merge two database directories and here is the login page for Oracle 11g r2 after a successful install.

A video that I found to show step by step but it does not say to combine two zip files if you download the the software from web.

January 20, 2011 Posted by | Databases: Oracle,MySql | 2 Comments

HSSFWorkbook object write it to Excel, send it as an attachment

public static void loadDailyDataToExcel(ResultSet rs, Statement st, Connection connection, Properties properties) {

 try {
 HSSFWorkbook workBook = new HSSFWorkbook();
 HSSFSheet sheet = workBook.createSheet("Excel Sheet");
 HSSFRow rowhead = sheet.createRow((short) 0);
 rowhead.createCell((short) 0).setCellValue("RESPONSE DATE");
 rowhead.createCell((short) 1).setCellValue("SERVICE ID");
 rowhead.createCell((short) 2).setCellValue("Q");
 rowhead.createCell((short) 3).setCellValue("T");
 rowhead.createCell((short) 4).setCellValue("V");
 rowhead.createCell((short) 5).setCellValue("CUSTOMER");
 rowhead.createCell((short) 6).setCellValue("OVERALL");
 rowhead.createCell((short) 7).setCellValue("COMMENTS");
 rowhead.createCell((short) 8).setCellValue("CONTACT");
 rowhead.createCell((short) 9).setCellValue("CONTACT INFO");

 int index = 1;
 Format formatter = new SimpleDateFormat("MM/dd/yy");

 while (rs.next()) {

 HSSFRow row = sheet.createRow((short) index);
 row.createCell((short) 0).setCellValue(formatter.format(rs.getDate(1)));
 row.createCell((short) 1).setCellValue(rs.getString(2));
 row.createCell((short) 2).setCellValue(rs.getString(3));
 row.createCell((short) 3).setCellValue(rs.getString(4));
 row.createCell((short) 4).setCellValue(rs.getString(5));
 row.createCell((short) 5).setCellValue(rs.getString(6));
 row.createCell((short) 6).setCellValue(rs.getString(7));
 String comments = rs.getString(8);
 if (comments != null) {
 row.createCell((short) 7).setCellValue(comments);
 String contact = rs.getString(9);
 if (contact != null) {
 row.createCell((short) 8).setCellValue(contact);
 String contactInfo = rs.getString(10);
 if (contactInfo != null) {
 row.createCell((short) 9).setCellValue(contactInfo);

 if (index > 1) {
 String fileName = "SurveyResponsesDailyReport-TestServices.xls";
 String to = properties.getProperty("survey.emailToDailyReport3aTest"); //from property file
 String subject = "Customer Survey 'Please Contact' Daily Summary - Test Services";
 String body = "Daily Survey Report for Test Services in Microsoft excel format.\n\n";
 emailNotification = new EmailNotification();
 emailNotification.sendEmailWithAttachment(to, subject, body, fileName, workBook, index);

 try {
 String hobiOneDirectoryPath = properties.getProperty("survey.hobiOneDirectoryPath"); // c:\\temp\\hobi\\
 FileOutputStream fileOut = new FileOutputStream(hobiOneDirectoryPath+"SurveyResponsesDailyReport-TestServices.xls");
 System.out.println("SurveyResponsesDailyReport-TestServices.xls was copied to "+ hobiOneDirectoryPath);

 } catch (FileNotFoundException fnfe) {
 emailNotification = new EmailNotification();
 emailNotification.sendEmail(emailToSystemAdmin, "Survey error from : ExportSurveyResponsesTestServicesToExcel.jar", "Environment: " + serverName + " : " + fnfe);

 System.out.println("Oops, FileNotFoundException caught. " + fnfe);
 } catch (Exception e) {
 emailNotification = new EmailNotification();
 emailNotification.sendEmail(emailToSystemAdmin, "Survey error from : ExportSurveyResponsesTestServicesToExcel.jar", "Print Stack Trace " + e);
 } finally {
 try {
 if (rs != null) {
 if (st != null) {
 if (connection != null) {
 } catch (SQLException sx) {
 }//close method


public void sendEmailWithAttachment(String recipients, String subject, String body,String attachmentFileName, HSSFWorkbook hssWorkBook, int totalRows) {

 properties = new Properties();
 properties.put("mail.smtp.host", host);
 properties.put("mail.smtp.port", port);

 if (recipients.equals("") || subject.equals("") || body.equals("") || attachmentFileName.equals("") || hssWorkBook.getBytes().length < 0 ) {
 System.out.println("Usage: sendEmailAttachemt() method parameter might be missing, you may check for the /test/local/surveyToExcel-test.properties for any recent changes");
 Session session = Session.getInstance(properties, null);
 try {
 // create a message
 MimeMessage msg = new MimeMessage(session);
 DataSource ds = null;
 msg.setFrom(new InternetAddress(from));

 ArrayList recipientsArray = new ArrayList();
 StringTokenizer stringTokenizer = new StringTokenizer(recipients, ",");

 while (stringTokenizer.hasMoreTokens()) {
 int sizeTo = recipientsArray.size();
 InternetAddress[] addressTo = new InternetAddress[sizeTo];
 for (int i = 0; i < sizeTo; i++) {
 addressTo[i] = new InternetAddress(recipientsArray.get(i).toString());
 msg.setRecipients(Message.RecipientType.TO, addressTo);

 // Parse a comma-separated list of email addresses. Be strict.
//            msg.setRecipients(Message.RecipientType.CC,
//                    InternetAddress.parse(<a href="mailto:test@aa.test">test@aa.test</a>, true));


 // create and fill the first message part
 MimeBodyPart mimeBodyPart1 = new MimeBodyPart();

 // create the second message part
 MimeBodyPart mimeBodyPart2 = new MimeBodyPart();

 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 byte[] bytes = baos.toByteArray();
 ds = new ByteArrayDataSource(bytes, "application/excel");
 }catch (IOException ioe ){
 this.sendEmail("hobione@hobione.com", "Survey excel file send error", "ByteArrayOutputStream: " + ioe);
 DataHandler dh = new DataHandler(ds);
 mimeBodyPart2.setHeader("Content-Disposition", "attachment;filename="+attachmentFileName+".xls");
 // create the Multipart and add its parts to it
 Multipart multiPart = new MimeMultipart();

 // add the Multipart to the message

 // set the Date: header
 msg.setSentDate(new Date());

 // send the message
 System.out.println("Report emailed successfully to: " + recipients +" Total rows count:" + totalRows);

 }catch (MessagingException mex) {
 Exception ex = null;
 if ((ex = mex.getNextException()) != null) {
 this.sendEmail("hobione@hobion.com", "Survey excel file send error", "Print Stack Trace: " + ex);

January 12, 2011 Posted by | Java | 3 Comments

2010 in blog review

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Wow.

Crunchy numbers

Featured image

The Louvre Museum has 8.5 million visitors per year. This blog was viewed about 93,000 times in 2010. If it were an exhibit at The Louvre Museum, it would take 4 days for that many people to see it.


In 2010, there were 4 new posts, growing the total archive of this blog to 69 posts. There were 17 pictures uploaded, taking up a total of 738kb. That’s about a picture per month.

The busiest day of the year was May 6th with 411 views. The most popular post that day was jQuery-ThickBox (Launch thickbox onload instead of onclick).

Where did they come from?

The top referring sites in 2010 were sitepoint.com, coderanch.com, google.co.in, google.com, and draptik.wordpress.com.

Some visitors came searching, mostly for tb_show, com.sun:tools:jar:1.4.2, thickbox onload, java.lang.classnotfoundexception: org.springframework.web.context.contextloaderlistener, and facesmessage.

Attractions in 2010

These are the posts and pages that got the most views in 2010.


jQuery-ThickBox (Launch thickbox onload instead of onclick) December 2007


RichFaces Tabs: switch dynamically April 2008


Missing com.sun:tools:jar:1.4.2 March 2009


dataTable and radio button in JSF May 2009


JSF: f:selectItem vs. javax.faces.model.SelectItem May 2009
1 comment

January 7, 2011 Posted by | 1 | Leave a comment