Thursday, 20 August 2009

Export Crystal Report to PDF by using Java Program


Here I am using some crystal report which will connect to database and fetch the data to create report.
It will expect username and password from the calling function.
Also it will expect some parameter(Name) from the calling function. Below is the code
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Date;
import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
import com.crystaldecisions.*;
import com.crystaldecisions.sdk.occa.report.data.Connections;
import com.crystaldecisions.sdk.occa.report.data.Fields;
import com.crystaldecisions.sdk.occa.report.data.IConnection;
import com.crystaldecisions.sdk.occa.report.data.ParameterField;
import com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat;
public class ReportExport {
public static void main(String[] args) {
try {
String report_name = “D://path/crystalReportName.rpt”;
String exportFileName = “D://path/outputFileName.pdf”;
ReportClientDocument clientDoc =  new ReportClientDocument();
clientDoc.open(report_name, ReportExportFormat._PDF);
//Connecting Database through crystal report
clientDoc.getDatabaseController().logon(“user_name”, “password”);
//Passing Parameter(Name) to Crystal Report
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue(“”, “Name”,”anand”);
//Writing into PDF file
ByteArrayInputStream bais = (ByteArrayInputStream) clientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
int size = bais.available();
byte[] barray = new byte[size];
FileOutputStream fos = new FileOutputStream(new File(exportFileName));
ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
int bytes = bais.read(barray, 0, size);
baos.write(barray, 0, bytes);
baos.writeTo(fos);
clientDoc.close();
bais.close();
baos.close();
fos.close();
dbConn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

Friday, 24 July 2009

Spring Framework


Spring is standard in lightweight enterprise application framework. Layered architecture, which allows you to be selective about which of its components you use there are seven modules in Spring Frame work
I>  Spring Core:
Uses IOC pattern to separate the application configuration with dependency specification from the actual application code.
IOC (Inversion of control)
  • No creation of object but describe how to create
  • Not connect direct to components
  • Mention in conf file for which service which component
  • org.springframework.beans
Bean Factory
  • org.springframework.beans.factory.BeanFactory
  • Singletone mode: Shared instance
  • Prototype Mode: each retrieval result new object
  • Take care when to create objects and when to invoke the method
Java Beans -  POJO ()
  • No creation of object but describe how to create
II>  Spring Context:
  • Context Information
  • EJB, e-mail, internalization, validation, and scheduling functionality.
III>  Spring AOP (Aspect Oriented Programming):
  • Provides transaction management services for objects
  • Logging (declaratively to the components that required logging.)
IV> Spring DAO (Data Access Object):
  • managing the exception handling
  • error messages
  • opening and closing connections
V > Spring ORM
  • Including JDO, Hibernate, and iBatis SQL Maps.
VI>  Spring Web Module
  • The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.
VII > Spring MVC framework:
  • Numerous view technologies including JSP, Velocity, Tiles

Difference between Struts and Spring


Sl. No
Struts
Spring
1
Struts is a web framework
Spring is an application
framework
2
Using MVC pattern
spring MVC is one of the
modules
3
Hard code to use applications
like hibernate, JDBC
Inbuilt hibernate, JDBC etc
4
Struts allows only JSP
Support JSPs, Velocity,
Free maker etc.,
5
Struts is heavy weight
Spring is light weight
6
Struts is tightly coupled
Spring is loosely coupled.
7
Excellent support for
Tag Library
Not that Much
8
Easy to integrate with other
client side technologies
Not Easy.

Wednesday, 18 March 2009

Example : MultiActionController in Spring


1> Controller Contains
public class testController extends MultiActionController {
public ModelAndView action_name1(HttpServletRequest          httpServletRequest,HttpServletResponse httpServletResponse) {
System.out.println(“In Action1″);
return new ModelAndView(“view1″, “date”,”date”);
}
public ModelAndView action_name2(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) {
System.out.println(“In Action 2″);
return new ModelAndView(“view2″, “date”,”date”);
}
}
2> View contains
<a href=”test.htm?action=action_name1″ >Go to Action1 </a> |
<a href=”test.htm?action=action_name2″ >Go to Action2 </a>
3> Change in Application-servlet.xml
<bean name=”/test.htm” class=”testController”>
<property name=”methodNameResolver”>
<ref bean=”paramResolver”/>
</property>
</bean>
<bean id=”paramResolver” class=”org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver”>
<property name=”paramName”><value>action</value></property>
</bean>
Simple Way:
1> Controller Contains
same as above
2> View contains
<a href=”test.htm/action_name1″ >Go to Action1 </a> |
<a href=”test.htm/action_name2″ >Go to Action2 </a>
3> Change in Application-servlet.xml
No need to add anything

Wednesday, 18 February 2009

Error : svnserve.conf:12: Option expected svnserve.conf

In svnserve.conf, you cannot have a space before you set an argument and a variable. It doesn’t find the argument. Open svnserve.conf and delete extra spaces at the beginning of any line.

Monday, 26 January 2009

Edakkal Cave Kerala

         

The name "Edakkal" translates to "a stone in between," aptly describing the formation of this intriguing site. The cave is formed by a massive boulder wedged between a fissure in the rock. The cave itself is divided into two levels. The lower chamber, measuring approximately 18 feet long, 12 feet wide, and 10 feet high, is accessible through a narrow opening of 5 x 4 feet. Opposite the entrance, a passage ascends to a small aperture in the roof, leading to the upper level. This upper chamber is vast, spanning about 96 feet in length, 22 feet in width, and 18 feet in height. Natural light filters into the cave through a large gap at the right-hand corner of the roof, where the boulder does not meet the adjacent wall.

Located just three kilometers from Ambalavayal and 25 kilometers from Kalpetta, Edakkal Caves are nestled in the Ambukuthy Mountain. Despite being referred to as caves, they are not caves in the conventional sense. Instead, they are a cleft in the rock, about 96 feet long and 22 feet wide, formed when a section of rock split away from the main body due to natural forces. The depth of the cleft and fissure is approximately 30 feet. What gives it the appearance of a cave is the enormous rock, weighing several tons, that has fallen across the cleft, creating a natural roof.

The rock walls of Edakkal are adorned with fascinating carvings that depict human figures, animals, tools, and symbols. These ancient petroglyphs, believed to belong to a highly civilized prehistoric community, have captivated archaeologists and historians, inspiring them to delve deeper into the history of Wayanad and Kerala as a whole.

Visitor Tips:

  • Trekking: The journey to Edakkal Caves involves trekking, so wear comfortable shoes and carry essentials like food and water, as there are no facilities along the way.
  • Travel Light: Minimize luggage to make the trek easier.
  • Entry Fee: The entrance ticket costs ₹15 per person, and an additional ₹25 is charged for carrying a camera.

This breathtaking site is not just a haven for nature lovers but also a treasure trove for history and archaeology enthusiasts.

         



Sunday, 25 January 2009

Soochippara Waterfall Kerala

Soochippara Waterfalls: A Hidden Gem of Nature

Nestled near Meppadi, the Soochippara Waterfalls is a stunning natural wonder, offering an enchanting experience for visitors. The waterfalls cascade from heights ranging between 100 and 300 feet, creating a mesmerizing spectacle that captivates all who visit. At the base of the falls lies a serene pool, perfect for water activities such as rafting, swimming, and bathing.

Adding to its charm, tree-top huts in the area provide breathtaking panoramic views of the Western Ghats. From here, one can also marvel at the shimmering, shallow waters of the surrounding springs, making it a perfect retreat for nature lovers and adventure enthusiasts alike.

Visitor Tips:

  • Essentials: Carry food and water to stay refreshed during your visit.
  • Trekking: The falls are accessible after a short 100-meter walk, followed by a brief trek to the bottom for a closer view of the cascading waters.

Soochippara Waterfalls is a true treasure waiting to be discovered—a harmonious blend of adventure, tranquility, and natural beauty.





Alappuzha(Alleppey)


Alappuzha (Alleppey):

The Venice of the East

Renowned for its enchanting backwaters, Alappuzha (formerly Alleppey) is one of Kerala's most sought-after destinations. A visit to Alappuzha promises unforgettable experiences, from gliding along serene waters in traditional Kettuvalloms (houseboats) to witnessing the excitement of the iconic boat races.

Alappuzha offers a variety of activities for every traveler. Picture yourself relaxing on a houseboat, enjoying the gentle sway of the waters, or indulging in fishing amidst picturesque surroundings. The region is also home to Kuttanad, famously known as the "Rice Bowl of Kerala", with its lush green paddy fields and vibrant rural life. Beyond the backwaters, Alappuzha boasts beautiful beaches, swaying palm trees, and delectable local cuisine, making it a complete package for nature lovers and cultural enthusiasts alike.

Tips for Visitors:

  • Houseboat Experience: Opt for the 22-hour houseboat trip, which covers all the must-visit spots and includes breakfast and lunch.
  • Cost: A standard houseboat accommodating up to 10 people costs around ₹3000, with pricing varying depending on the amenities and type of boat.
  • Best Time: For a truly immersive experience, plan your visit during the famous Nehru Trophy Boat Race, typically held in August.

Alappuzha’s captivating beauty and tranquil charm make it a must-visit destination, earning it the title of the "Venice of the East".







Saturday, 24 January 2009

Athirapilly waterfalls Kerala


Athirappilly Waterfalls: The Niagara of India

Located near Chalakudy in the Thrissur district of Kerala, the Athirappilly Waterfalls is a breathtaking destination, celebrated as one of the most scenic picnic spots in the region. Known as the "Niagara of India", this stunning cascade, along with its twin falls Vazhachal, is situated on the edge of the Sholayar forest ranges, just 5 kilometers apart.

Athirappilly plunges dramatically from a height of approximately 80 meters, merging with the Chalakudy River below. Surrounded by dense forests, the falls create a postcard-perfect setting that captivates every visitor.

Experience the Magic:

  • First Glimpse: As you drive toward the falls, you’ll catch your first awe-inspiring view of this natural marvel.
  • Top View: From the main entrance, a rock pathway leads you to a viewpoint offering spectacular sights of the falls from above.
  • Adventure Awaits: For the thrill-seekers, a short trek along slippery trails will take you to the base of the falls, where you can enjoy the misty spray of the cascading waters.

The entire region exudes a magical charm, offering not just the waterfalls but also lush greenery, a serene atmosphere, and stunning landscapes. Whether you seek relaxation or adventure, Athirappilly Waterfalls promises an unforgettable experience.

Tips for Visitors:

  • Best Time to Visit: The monsoon season enhances the flow of the falls, making it even more majestic.
  • What to Wear: Comfortable trekking shoes and clothes suitable for getting wet.
  • Don’t Miss: Capture the panoramic views and immerse yourself in the tranquil beauty of the Sholayar forest surroundings.

Athirappilly is more than just a waterfall—it's a mesmerizing escape into nature's grandeur!






Cherai Beach Kerala


Cherai Beach: Where the Sea Meets Serenity

Situated at the northern tip of Vypeen Island, just 26 km from Ernakulam city in Kochi, Cherai Beach is a perfect blend of natural beauty and cultural charm. This idyllic destination is uniquely framed by the sea on one side and tranquil backwaters bordered by lush coconut palms and vibrant paddy fields on the other. The backwaters, a network of lakes, lagoons, canals, and estuaries, add to the picturesque allure of Cherai.

What Makes Cherai Special?

  • Golden Sands: Stretching over 15 kilometers, Cherai Beach boasts pristine, golden sands that are clean and inviting, making it ideal for swimming, surfing, and sunbathing.
  • Night-Time Beauty: A newly revamped 400-meter stretch of the main beach features a well-lit walkway and high mast lamps, allowing visitors to enjoy the serene ambiance even after sunset.
  • Safety and Accessibility: With trained security staff on duty round-the-clock, the beach is a safe haven for visitors of all age groups.

Activities and Attractions:

  • Seashells and Dolphins: Explore the shoreline adorned with seashells of various hues and shapes, and keep an eye out for playful dolphins that occasionally leap from the waters.
  • Water Sports: Thrill-seekers can indulge in water scooter rides and speed boat adventures.
  • Chinese Fishing Nets: At the far end of the beach, the iconic Chinese fishing nets create a stunning silhouette against the backdrop of the setting sun—a sight not to be missed.
  • Family Fun: A dedicated children’s park on the beach ensures entertainment for younger visitors.

Cherai Beach’s combination of scenic beauty, rich marine life, and recreational opportunities make it a must-visit destination in Kerala, offering something for everyone—from adventure enthusiasts to those seeking tranquility.

Tips for Visitors:

  • Best Time to Visit: Early mornings or evenings to enjoy cooler weather and spectacular views.
  • Stay Options: Consider staying overnight at nearby resorts or homestays to explore the beach and backwaters at leisure.
  • Essentials: Don’t forget sunscreen, hats, and cameras to capture the unforgettable beauty of Cherai.

Cherai Beach is not just a destination; it’s an experience that captures the heart of Kerala’s coastal charm.





Friday, 9 January 2009

Java Concept differences


ListArrayListLinkedListVectorArray
1FlexibleFlexibleFlexibleFixed
2UnsynchronizedUnsynchronizedSynchronizedUnsynchronized
SetHashSetLinkedHashSetTreeSet
1UnorderedInserted orderOrdered
2UnSynchronizedUnsynchronizedUnsynchronized
MapHashMapLinkedHashMapTreeMapHashTable
1Stored in HashHashTreeHash
2UnsynchronizedUnsynchronizedSynchronizedSynchronized
3UnorderedInserted orderOrderedUnordered
4Null allowedNull allowedNull allowedNull not allowed
ItrnIteratorIteratorListEnumerator
1One by oneOne by oneMore than one
2Remove EleRemove EleCan not
3UnidirectionalBidirectional
StringStringBufferStringBuilder
1ImmutableMutableMutable
2UnsynchronizedSynchronizedUnSynchronized

# Differences of Exceptions and Errors
Sl. No
Exceptions
Errors
1Exception is an abnormal condition raised while executing the programError is a condition that doesn’t occur under normal conditions Ex: run out of memory, stack over flow.
#Differences of final, finally and finalized.
Final
Finally
Finalized
We can apply the final keyword to variables, methods and classes. If a variable is declared as final we can’t change the values. if method is declared as final we can’t override. if class is declared as final we can’t subclasseswhether an exception is raised or not finally block must executeAll objects have finalized method. It is inherited from Object class. It is used to release system resources. Giving a chance to object free their resources before destroying. It is called prior to garbage collector.
# Differences of functions
Wait()Sleep()Suspend()Notify()Notifyall()Join()
Blocked until certain condition occurs -notify()Blocked for a specified timeBlocked until further orders -resume()it is used to bring waiting thread to run able stateIt is used to bring all waiting thread to run able stateWaiting for thread to finish or die.