Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Tuesday, April 15, 2008

Java/J2EE Project Name proposal.

Choices of names proposed:

  1. William Wallace
  2. Great Alexander
  3. Gladiator
  4. Big Boss
  5. Ashoka (Why not Indian Names?)
  6. Sivaji

I like to choose any one from the list. I would be happy if you could pick up one name and vote it!
Or I can go about choosing one name to separate dev/build release cycles.

So, for whom this name?

I have planned to evaluate Light Weight J2EE Architecture. I am planning to re-engineer SAB with LW J2EE. Or, I am planning to build a biggest sample application that will cover all application life cycle scenarios. I have sent a re-engineering architecture proposal to some of my friends. They wanted me to think about a new one to start from scratch.

I might work on coming up with a new application architecture that will cover

  • Complex persistence scenarios
  • Complex Integration Scenarios
  • Commonly used architectural patterns
  • Light Weight J2EE Components trade off over Heave weight Components to satisfy Non-functional requirements.
  • A complete product development life cycle (including development guide, source control, various testing process, build maintenance, releases, patch releases, bug tracking, etc)
  • Comparing and contrasting different stacks of J2EE/Generic Enterprise application.
Let me work on it for some times.

Wednesday, April 02, 2008

Java: Collest bug, ever seen!

Recently, I was a fixing a bug (which was introduced by me!). The bug is very silly, you may never catch it!

Issue is, a there is a java bean factory class with factory methods. In one of the factory method, a recursive call was there (which was not supposed to be), it was causing a stack overflow exception.

The factory method is supposed to be like this,

(I am providing a sample code, not actual code)

public Employee newEmployeeImpl()
{
return (Employee)new EmployeeImpl();
}

Instead of this, the code was mistakenly written as,

public Employee newEmployeeImpl()
{
return (Employee)newEmployeeImpl(); //there is no space in between new and EmployeeImpl!
}

It was accidentally typed without leaving a space between new and EmployeeImpl class. It is syntactically correct. So, the compiler didnt crip for the expression. But, at runtime, it goes as a recursive call!

So, the newEmployeeImpl() factory is getting called at infinite number of times and results in Stack Overflow Exception...

I laughed out to myself when I found this issue!

Thursday, March 27, 2008

I am a J2EE Architect! – Says Sun Microsystems.

Now, it is mid-night 12:33 AM. A windy night and rain is pouring heavily outside. Weather is so cool, and my heart is too. Though I am feeling like running outside and shout louder in the rain…, I can not do that now. Because, I am 24, and yet, the time is mid night 12.

The much awaited result is out..! I have been waiting for this result, since last 3 to 4 weeks. My Architect exam result. Why I am so excited about this is, I am only 23.7 years old – too young to have Architect Certified! :-)

Out of all my learnings till date, I consider this exam is pretty worth. The perspective of looking at software systems has changed, after looking them through the architect view. I don’t see software as a program or piece of code; I see software is assembled of components and constructs. They are like bricks and stones that give the infrastructure (I am more or less has become as a mechanic!)

I will cherish this great moment till life long. Let me recall, what I have done, lost, tried and given up to get this Architect Exam.

The Exam has 3 parts. In Part-I, we need to answer for multiple-choice questions. In Part-II, we need to workout a J2EE based architectural solution, for the problem given by Sun Microsystems. In Part-III, questions will be asked from our Part-II solution. Part-III is an essay type exam. We need to answer their questions in paragraphs.

Sun Certified Enterprise Architect – Part I

Date : 25th Sept 2007

I have already published a post about this Part I exam, here: http://manivannan57.blogspot.com/2007_09_01_archive.html

Sun Certified Enterprise Architect – Part II (Assignment)

Date: 28th Feb 2008

Here is the stage, you host your skills! I registered for the part II – Assignment exam. I received the assignment, and started reading the requirements about a week. I understood what the requirements were, but did not find even a single clue about how to derive solution

I started reading advises from saloon forum http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&f=26 at my free times. Needless to say, more we listen to people’s advice, the more we get confused. So, I gave up reading the forum, as it had ‘N’ number of views, arguments, advises, approaches and etc. (But, one should really read through the forum, just to see how different people mind can think to derive a solution for a given single problem! :-) )

I was helpless to bring solution and to verify my solution is correct. Because, I have not met any real world architects so far. Also, I had a fear that, they can misguide me to give a Design Solution instead of the required Architectural solution. Because, most of the techies do not distinguish a ‘Design’ and an ‘Architecture’. (And there are cases, where people have failed in the exam, as they submitted a design kind of solution rather than the architectural solution).

I’ve decided to keep my architectural solution very simple and straight-forward. I have strongly decided not to use any Framework (that is not a part of J2EE) in my solution. I did so.

The difficult part in my assignment, which I feel is, session handling decision. I needed to give a session handling solution for JSP and Swing based clients. First, I have decided an approach. I went out for coffee and cam back, and then changed the approach. I went out, looked at the children playing in the street, cam back then, and changed the approach. Likewise, it got changed many times, that I cannot even remember.

I was very strong in one thing – the examiner should be able to understand my architectural solution without any difficulties. Keeping that in mind, I put lot of details in supporting documents. I explained the approach over several pages; also, clarified the reason why I opted that approach over others.

Also, I have presented a Traceability Matrix for Functional and Non Functional requirements. That might be impressive. But, that is dangerous too. If I forget to add any requirement in the Matrix, then he will catch me. I spent lot of time to make sure that all the requirements are addressed in the Matrix table.

That’s all.

One early morning I submitted the assignment to Sun.

Sun Certified Enterprise Architect – Part III (Theory Exam)

This exam was an interesting one. We need to write the answers as paragraphs. No! we cant fill the paragraphs with some legacy stories; the answer we provide here will have to match with the architectural solution submitted for Part-II. So, I reloaded all the assignment requirements and my solution into my memory, before taking up this exam.

All of the questions were about Non Functional requirements. That’s, about performance scalability and the kind of stuffs. I gave only valid points to fill up the paragraph. I repeated most of the lines from my Part-II supporting documents. Because, it should match right.

Finally

Part II & Part III Score: 88% (Pass)

Part I Score: 95% (Pass)

Overall Grade: Pass

That’s it!

I am so excited to get passed in this exam. I am happy that I have passed in the top most level of J2EE exam, in this young age. Many people advised me that one should have minimum 6 to 8 years of experience in designing and architecting software applications to give such exams. But, me poor guy has only 2 and half years. But, I have endless passions to do.

This is the last level of the exam. So, I have decided to not to take any more certification exams in the future.

Friday, February 01, 2008

Jargons of Java Releases!

It's nice to have such question! Also, nice to explain such things. There are so many jargons with Java releases, which confuse people. My friend has asked a fundo question. He is a too very fundo..!! I am hereby posting the mail, hoping it would be useful.

----------------------Forwarded Message------------
Date: Thu, 31 Jan 2008 09:54:20 -0800 (PST)
From: Manivannan yahoo.com
Subject: Re: one small basic doubt]
To: ravishankar.dhamodharan

Hi Ravi,

How do you? Long, since heard from you.
Nice doubt Ravi! I often came across people having this doubt in common. Please find my comments below.

JDK/J2SDK – JDK is a SDK for Java. After standardizing Java as a ‘technology’ JDK was re-branded to J2SDK. Yes, they are same (alias).

Java/J2SE – Earlier Java release went like Java1.1, Java1.3 and etc. Later up on, Java releases are standardized as J2SE. So, J2SE1.5 or Java 1.5 or J2SE5.0 or Tiger – they refer to same thing – ‘A version of Java release’. Also, Sun used to give pet names to Java releases like Tiger (Java1.5) and Mustang (Java1.6) and Dolphin (Java1.7 – coming soon).

Ravi, If I am not wrong, JDK is obsolete name, and Sun will no more use the name ‘JDK’.So, you can download J2SDK’s instead of JDK.Doesn’t matter, it’s an alias name for JDK.

If you don’t bother, I am blogging this mail, hoping it would be useful!

-Mani

------- Original Message --------
Subject: one small basic doubt
Date: Wed, 30 Jan 2008 13:55:24 +0530
From:ravishankar.dhamodharan
To:Manivannan yahoo.com


Mani,
Is j2se1.4 is the java 2 standard edition is one and the same as the jdk1.4 java development kit and the j2sdk1.4 is the java 2 software development kit. Am I right.
My understanding is j2se1.4 and jdk1.4 is the same and the j2sdk1.4 is different.
The following which depicts the same I think.

Mani when I tried to download the jdk1.4 for Linux it takes me to download the j2sdk1.4. I don’t want j2sdk to be installed in the machine , I want only jdk. Where to download , in sun site it takes me like that.
Thanks,
Ravi.

Thursday, November 01, 2007

Maximus - The Gladiator. (NOT A MOVIE REVIEW)




Maximus:

I have chosen this name (Maximus) for the next release of my pet project.. , to be more frank, mini product. Yes, it has grown as a product, with all such composite eligibilities. Personally, I would like to call it as a platform, not a project or product. Because, it is ‘programmable’ rather than ‘usable’.

People usually consider birds, trees, and pet animals for naming their company/product/children. I like choosing brave names. A fighter or War hero or brave man ever lived. I chose ‘Archer’ as the name for the first release. Now, I am half the way to release next version. I was looking for a name, and hardly satisfied. I chose ‘Ajax’, which is a brave king name, but dropped the idea later, as it may conflict with the existing ‘Ajax’ language.

And, I am satisfied with ‘Maximus’ – Gladiator hero. Gladiator means, a continuous fighter; a fighter who fights for survival. It makes lots of sense to me personally. So, I chose this name ‘Maximus’.

This second drop may happen before Jan-2008. Currently, I am trying to complete business logic coding. Once it is done, I will refactor the whole code against various standards.

Then, I’ll expose the whole project platform as a service, so that it can constitute to SOA.

I am not sure how much time I can spend on this project daily. I have millions of other works going ahead in parallel. I will be the single and only developer in this Maximus release. I don’t find people joining in and I am not going to ask anybody to join, anymore :-)

I have spent so much of time on this SAB (Stock Analysis Base). It has helped me than the level of my expectation. I don’t know anything about stocks or investment earlier. I am techie; hardcore techie; if I had been into investment earlier, then this might be a killer combination. :-)

I enjoy architecting SAB! My first architecture assignment! :-)

-- Manivannan.P(@) gmail.com, SAB Architecture.



Wednesday, October 10, 2007

6 years after....

Few weeks back I went to my college, where I was 'educated'. There was going a faculty training program, sponsored by ISTE. They were looking for a guy to give a presentation on Networking & Webservices in J2ME and also to talk about J2EE in general. I agreed to speak, only because the audience would not be students; because I know, what the student’s mentality would be. The audience was mainly lecturers, few professors, and some M.E students from various colleges.

I reached Erode at morning 5.30. By 6'o clock, there was car to pick me up. I was dropped in Guest House, served breakfast and told that there would be a pick up to the venue at morning 8.30. A car dropped me in front of IT-Park! Some unknown fear and unknown silence started waving in heart. Because, that was the feeling I always had, when I was there 2 years back. History repeats itself!

I met few of my lecturers and professors whom I knew or who remembered me. Lots of people left the campus; hence most of the faces were quite new to me.

The venue was ITP - Seminar Hall 2. After briefing my self introduction, I just started the session….

“Java is yet another cancer (after Linux), it starts spreading everywhere today; Java runs in computer, laptop, big fat servers, my mobile, Tv, Smart Cards, Mars Rovar...and etc”

I gradually landed in J2ME. And discussed the architecture of J2ME and explained how stuffs are programmed in J2ME, with lots of sample snippets. After discussing various networking connections in J2ME, we went into SOA, and Web Services.

I don’t like to listen continuously and also don’t like to speak continuously in front of others; so I broke the session in every 20 minutes. I think it went around 3 hours. Later, we had a Q&A session on J2EE. Really, very curious people they are, they asked lots of interesting questions. I encountered lots of questions on EJB3.0, WEB 2.0, OR Mapping, J2EE Design Patterns scenarios – it is really a healthy situation that those people had spent time to know latest stuffs.

I extended the time to separately discuss J2EE architecture and what components to use at what situations. And also, discussed some architectural design patterns, like Middleware Oriented Architecture, SOA and etc.

After noon, I showed some demos, by loading the J2ME applications into my mobile and running some GUI, Networking applications in my mobile. They felt happy to see the theory was working!


I didn’t go and meet any students. I met some second year students, a month back. They were plain, without having any idea of what to do. But, I told them they would have very bright future than anyone else. Because, opportunities are hell a lot today, you can find another one as soon as you miss one. Getting a job won’t matter any more; But getting a job in your dream company, with fat pay, and interested technology will be tough, unless you work hard – this is what nowadays I say to whomever I meet.

In the evening, a car arrived to IT-Park for pick up. I was picked and the car started running towards Erode. I was filled up with lots of old memories on the way. I first stepped into the college by Aug 10th 2001; On that day, I was clueless, shy, and filled up with lots of questions about everything. I had only a blind confidence towards future. To be frank, I never thought I would live a life, that I am living today. 6 years gone now! I am happy with whatever I have done till today, and whatever the position I am in today.

I am no more connected to this college; but, I can’t deny the memories of those days, that often put me in an unknown silence.

Thursday, September 27, 2007

The Architect Dream :-)

In the recent days I became crazy about architecture; better design; better code; As a chain effect,I decided to take up J2EE Architect exam. Sun itself recommends (not mandates) that the candidate should have minimum of 6 to 8 years Java/J2EE experience to appear for this exam. Last Saturday, I decided to take up this exam. I am not sure how dare I was, at the point of time, to take such decision. I booked the exam within 6 days.

My background is: I know EJB concepts/UML/Networking layouts/Server architecture basics. But, this skill is really poor to take up such an exam. I was left with no clue. Sometimes, some strange things happen right! I got a mad curiosity towards architecture and started reading books so fast. I've never read a book that fast in my lifetime, and never had such a capability to understand/interpret/memorize the stuffs. But, it happened. Within 4 days I grabbed the confidence to pass the exam. In the last two days, I went through lots of mock exams, short notes.

I have myself created many Thumb rules for my understanding, from various sources of books, and sites.

Exam questions were really simple and I was able to score more.My score is 95%, missing two questions, on the whole. (good number, isnt it? ;-) )

I don't remember exactly why I choose this exam; I probably would have thought putting a full-stop to the certification hierarchy, because this certification is the highest level of Sun's Java Certification hierarchy. But one thing is for sue -- I like Sun's java exams. They are very good learning aids for Java/J2EE. The syllabus for every exam is designed with great care that the candidate should know the hardcore stuffs in the specific technology.

Refer the exam objectives here:

http://www.sun.com/training/catalog/courses/CX-310-051.xml

Thursday, September 06, 2007

Framework ?


Software people should often hear this term ‘Framework’. What is it all about? The picture you see looks like an exploded building. But, you see the steel skeleton standing alone right? That’s Framework. That is some thing that supports the building architecture and gives a structural support.

I am thinking of writing a framework for my pet project. Especially for database persistence and queries. It might simplify coding complexity and speedup writing of code. Because, frameworks can provide basic structural support for projects. Also, it can help to eliminate boilerplate code found here and there in projects. When I imagined, how the coding style could change if I develop a framework, it turned me excited.

Few lines about Framework:

1. Usually, at the beginning of projects, Architects do some basic works -- one of them is building a Framework.
2. A Framework will offer basic structural support and services. For example, accessing a database is a common scenario in any project. We end up writing database access calls every where in project; every where we need to handle transaction, synchronization and etc. This plate of code can be moved into Framework and can be accessed from any part of the projects. Like wise, a Framework can have basic and structural functionalities for a project. Change/upgradation in code/functionalities can be done in one place, that’s in the Framework level, and dont need to change every part of the project.

A cool example,
Suppose, if you want to insert some values into database, you write painful code like this,

-------------------------------------------
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection(connectionURLThin, userID, userPassword);
PreparedStatement preparedStatement = con.prepareStatement("insert into emp(?,?,?,?)");
preparedStatement.setInt(1, 100);
preparedStatement.setString(2, "mani");
preparedStatement.setDate(3, new Date());
preparedStatement.setDouble(4, new Double(46000.50));
preparedStatement.executeUpdate();
con.commit();
preparedStatement.close();
con.close();
-------------------------------------------

Ssshh! Take a break and come back :-) Just think what will happen if one need to repeat this code everywhere? That’s something called 'boilerplate'.

Rather, this can be abstracted/wrapped into a Framework, like

-------------------------------------------
MyDatabaseFramework.persistValues(100, "mani", new Date(),
new Double(46000.5)); // this single line code will insert, commit & save your head.
-------------------------------------------

That’s what Framework is, and that’s something, I am planning to write. Now Framework can be abbreviated into single word, "COOL" -- isn't?

Monday, September 03, 2007

Art of designing it.

I am planning to add a new module to my pet project. This is the proposed class diagram design for the new module. Nowadays I am becoming very crazy about better design and better architecture. I spent a lot of time on these diagrams, to get it better and better. First, I drew this diagram in one shot with few classes. Within few minutes, I thought that the design was bad, so I crushed the paper and thrown out. Like wise, three papers went to the dust bin and finally, I got something better on the paper. This is a reusable, modular, pattern oriented design. I thought of drawing other diagrams also. But, this is my personal project and why I should take much pain! :-)

I might start coding slowly. I am expecting a developer gang to join for the code development. Let's see again how it goes. I dont have plan or schedule for release, because this is absolutely my personal project, based on personal interest, and a base for personal learning :-)


(Click on the image to enlarge it)

Tuesday, May 22, 2007

Best of ever written, in 4 years :-)



Programs as poems:

If you look at some body’s code, you will see it as a poem, not merely a software program. That’s how they write it. Impressed by those cool programmers, I tend to follow lots and lots of code tricks and style in whatever I write. Recently, I was developing a java based application for my personal use. If you are interested to listen, I could continue telling the best I have don’t in it,

  1. No use of Class level (or global) variables. (Because they confuse programmers to trace the parts, where they are initialized & modified.)
  2. No hard-coding. (Because, tough to change later)
  3. No bad smells in code. (no big methods, no big expressions, no big conditions, no complex loops)
  4. Standard, naming conventions (I use some times underscore too, in java. why dont you ask 'why'? )
  5. Exception handling – (Anti pattern imitated)
  6. Large scale of reusable code. (Seriously)
  7. Use of Design Patterns – (that’s a sign of great future)
  8. Proper (styled) Java doc comments, (you will be impressed if you see it.)
  9. Code refactoring, using tools.(one should really do)
  10. Code inspection, using tools. (rare tools)

I couldn’t post the code here; I would post the code somewhere & give the link here.

Tuesday, January 02, 2007

SCBCD (EJB 3.0) The Exam!

I was thinking of taking J2EE/EJB certifications. But, luckily, Sun offered latest EJB exam for free of cost, as it is Beta version. So, was glad, and registered for the Beta exam. But, I didn’t know that the exam was going to bring me ache.

Thousand or more times, I thought of dropping the exam plan later! Since, there are no books into market yet, there are no proper docs, there are no guides, there are many such ‘no’s…

At last (taking it as a big challenge!), today, I sat for the exam. The exam duration was about 5:15 Hrs. I’ve never taken such a long-lasting exam in my life before. I was eager in first hour… then, was boring… then, loosing focus… then…. seriously I vexed at the 5th Hour!

My eyes were paining like anything when I came out of the exam center. I felt dead-tired, and
wherever I looked around, it was ejb, ejb and ejb... nothing else.

The exam was not tough actually. It needs strong understanding of concepts, and a serious preparation. There were damn good questions at which I was stuck, and yanking. How come one can expect some one to study the programming stuffs on a new-year day? But, I studied until the last moment, (seriously.. I was two hours late to the exam hall! :-) )

Result? It will come after some 6 to 8 weeks!

So, I think I’ve done my side well. God, now it’s your turn! ;-)

Thursday, September 28, 2006

Tip #3: Difference: Jvm, JRE, JDK, J2SDK, HotSpot...

JVM, JRE, JDK, J2SDK, HotSpot... : These terms are often parts of Java programmers communication. But, it seems.. all such terms sound to mean a same thing – no, they just seem, not really. Let’s discuss and distinguish the terms in detail.

JVM- Otherwise called as 'Java virtual machine' that actually takes the .class file as input, interprets it and executes it. JVM is platform dependent. The java.exe, found in your J2SDK/bin folder is called as JVM!

JRE - JRE includes a JVM and standard libraries (which are imported by default during execution). Note, JRE doesn't include other tools like jdb, javac, javap and etc. It includes only the jvm (java.exe) and default packages. JVM can be thought as a proper subset of JRE.

JDK - JDK is a box in which everything is put together. JDK includes JRE as well as other necessary tools and libraries. You have JRE, JVM and all the standard & extended libraries.

Important differences:

1. The important difference between JRE and JDK is that, Java License allows any one to re-distribute the JRE along with his product. But, it is illegal to re-distribute the JDK with your product!

2. JDK and J2SDK exactly refer to a same thing. But, what is difference? The term ‘JDK’ is just re-branded (re-named) to ‘J2SDK’ to bring a Standard (guts?) to Java. Seriously! :-)

The following simple formulas can help you to understand easily what were said above:

JVM = java.exe
JRE = JVM + Standard Libraries – Other java tools like jdb, javac.
JDK = JRE + Other java tools + all core libraries and packages.
J2SDK = rename (JDK)

Exercise:

The term ‘HotSpot’ is left unexplained. If you are curious to know, Pl, spare some minutes to find out yourself and post the answer as comment.
Or, let me post the answer in next tip.

Sunday, September 24, 2006

Tip #2: How to access the private variables outside the class in java?

Is that possible?

Yes, it is. Have you ever heard of ‘Java Reflection API’?. If no, then this brief intro can help. Java Reflection API: has set of classes and methods to access the runtime behavior and memory foot print of classes and objects”

Using the reflection API, you can access (any) instance member variable of an object. Yet, you can do a lot more with that.

Don't you thing this is a loop hole in Java? Breaking the integrity of Oops?

Not in that way. This API actually meant for helping people tracing the memory foot print and for developing applications like ‘Java Debugger’, ‘Java Profiler’, ‘Java Application Monitor’ and the likes. Usually, other applications programmers are advised not to use this API unnecessarily.

The following simple example demonstrates how to access the private variable of an object outside the class (using Reflection API):

(This example is referred from javareference.com)

java.lang.reflect.*;

class Example {

private int x = 10; // means not available to outside the class
public int y = 10; // accessible from anywhere.

}

public class ReflectionDemo

{
public static void main(String[] args) throws Exception {

Example e = new Example();
Class ref = e.getClass(); //will return ‘Example’ – right?
Field f = ref.getDeclaredField("x"); // watch here! :)
f.setAccessible(true); // Now the ‘x’ is accessible!
Object obj = f.get(e);
int val=((Integer) obj).intValue();
System.out.println("Private var X is = " + val);

}
}


That’s it!

If you want to know more about Reflection API, spend some minutes at Sun sites/ Tutorial.

Answer for Tip #1

Here comes the answer for the question asked in last tip (Tip #1 Java Memory Issues) : To run the program successfully, you have to increase the memory by using JVM command line options –Xmx and –Xms, like

$java –Xms20m –Xmx120m Memory

The -Xms20m options instructs the JVM to set the initial heap size to be 20 MB and the –Xmx120m options instructs the JVM to set the Maximum heap size to be 120 MB. (If this doesn’t work for your machine, you can try changing the numbers).

Sunday, September 10, 2006

Tip #1: Java Memory issues.

Hmm. I am going to write some tech bits frequently, which might help others. So, let’s start the first one.

Memory issue:

The most critical problem, most of us might be experiencing is memory leak. Your JVM may brainlessly spit out “OutofMemoryException”, then say “bye” and exit. It’s because your heap memory ( heap -the memory used for storing objects used in the program) might have become full.

So, in order to fix this issue, you have to increase heap space size using the JVM command line arguments –Xms (Initial Heap size) and –Xmx (Maximum Heap size)

Exercise: (If you wish!)

1. Just compile and run the below code. Watch curiously what happens. Then, use the tip presented above and fix the issue.I may get a chocolate for you if you get it running :-)

class memory {

public static void main (String args [] ) throws Exception {

int[] a = new int[18000000] ; // Watch here! :-)
System.out.println("Code is running");
}

}

Note:I will post the ans when I post next Tip. :-)

Saturday, September 09, 2006

Java/JDBC Questions

I have prepared set of questions for Java/J2EE (may be helpful to test one's knowledge). Here, first comes the questions from JDBC.

I don't have time to type the answers here:-) Pl, find yourself by reading books or googling or by asking someone who had lost his life in java.

If unable to find answers anywhere, you can directly mail ( or scold) me via: manivannan.p (at) gmail.com

JDBC – Questions: Manivannan.P (at) gmail.com, 14th Aug, 2006.

[For Beginner/Advanced/A bit experts]


1. What are all the available types of JDBC drivers? Give example for each type.
2. Which one of the available drivers is better?
3. Give sample scenarios where you would choose each one.
4. Write a sample JDBC code to connect to any database.
5. What do you understand by Class.forName(“drivername”).newInstance() ? (give alternative syntax for this)
6. What is a Statement and a PreparedStatement?
7. What is the difference between Statement and PreparedStatement. Which one is advisable to use?
8. How will you execute a DML statement using JDBC?
9. How will you traverse the ResultSet?
10. What exception will you probably get when you have no data in Resultset?
11. How will you print Meta data of Resultset like column count, column names and etc.
12. How will you execute a stored procedure using JDBC?
13. How will you pass parameters to stored procedure using JDBC?
14. Can you give example code for using IN, OUT and INOUT parameters stored procedure using JDBC?
15. How will you capture the return value of a function using JDBC?
16. How will you print the warning message, error code, status generated by the database (while using JDBC)?
17. How will you catch/escalate the exception generated by the database?
18. How will you manage the concurrency while using JDBC? (Just write down a sample code)
19. Give example for managing transaction using JTA.
20. How will you make the Resultset become scrollable by back and forth?
20.a) Can you move the Resultset to a particular row absolutely or relatively?
21.b) Can you give an example for inserting/updating/deleting a specified row on ResultSet?
21. How will you apply concurrency for Resultset?
22. How will you refresh the Resultset, without repeating the code?
23. How will you send sql statements in bulk? [Batchupdates]
23.a) How will you capture & analyze the return value of BtachUpdate?
23.b) What is the limitation of BatchUpdate ?
23.c) What is the difference in using Stored procedure and BatchUpdate
24. Can you explain what is connection pooling & how it is implemented? [provide sample code for connection pooling and a client that uses it]
25. What are all the parameters you need to pass while configuring connection pooling?
26. Do you know about two-phase and three-phase commit, can you explain it?
27. How will you handle blob, clob fields using JDBC?
28. Can you write code for storing and retrieving an image file/ text file using JDBC? [hint: using blob and clob]
29. Can you tell any noticeable differences between JDBC1.0, JDBC2.0, JDBC3.0 APIs?


Disclaimer: The questions [or answers] presented here are purely based on my perspective alone. There may be number of alternative answers.

Monday, July 03, 2006

Links, have to be blogged.

1.Good examples for JMS, found here: http://darwingrok.physics.ox.ac.uk:8080/source/xref/JBoss/jboss-all/messaging/src/docs/jms-examples/

2.A wonderful article on JDBC is here: http://java.sun.com/developer/Books/JDBCTutorial/index.html

After reading this, you have to be able to answer for the ques, "what’s the difference between PreparedStatement and Statement? " :)


3.Very good/advanced examples for Oracle+JDBC are waiting here: http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.html
(I haven’t yet looked at them deeply; but they sound as good future references!)

Don’t miss JBOSS’s Wiki stuffs; there people wrote everything what you call as ‘secrets’!.

Hmmm… few more links, I really forgot!

Saturday, July 01, 2006

JNDI Stuffs | EJB Stuffs

Today, I was modifying some EJB JDNI context of my application. , , were the stuffs, kindling my brain today afternoon. I was looking keen at DataSource (javax.sql.DataSource) and its deployment descriptor options. Good design.

It was really great to read the article "Advanced JDBC", at Sun's site. My God!, the article was dated 1999; people are always curious to learn and do things faster!


I am planning to sign-off all Ejb-Stuffs by this week end! I will post some interesting tips, links and articles here tomorrow.

Friday, June 02, 2006

How do I register a project & upload at sf.net?



Hey, Successfully done! I have uploaded my sample project at http://j2ee-examples.sourceforge.net ....

Yeah, Here is the snap shot of my putty. Thanks to Hari, who helped me to get out of the mess!














And this is scp uploading screen-shot



















As I promised, this is the FAQ I present from my experience:

------------------------------------

How do I register a project at sf.net?

First register for a user account. Then, go to ‘My Projects’ column and follow the new project link. It will guide throughout registering a project. After the registration, you have to wait for approval more than 2 weeks. Approval will not be emailed, you have to go and check.

I followed the instructions and successfully uploaded the project using CVS into sf.net. (I mean projectname.cvs.sourceforge.net). But, it is not available for download for other users. What went wrong?

Same sweet first! I was also such an ignorant last week. CVS is for you and for managing your versions. Sf.net doesn’t allow the CVS folder’s or files for download. For uploading projects (which can be downloadable), you can use ‘scp’ or ‘sftp’ (about which we are going to discuss later).

So, how do I upload?

In case of windows, first download putt.exe and scp.exe (use Google). Then, launch the scp like from the command prompt like,

scp -r . username@shell.sourceforge.net:/home/groups/P/PR/PROJECTNAME/htdocs

The command says, “Hey scp, recursively (-r) copy all the files present in current directory (.) to shell.sourceforge.net server, under the directory /home/groups/P/PR/PROJECTNAME/htdocs”

Note: you have to replace the ‘P’ (in the destination directory path) by the first letter of your project name and ‘PR’ by the first two letters of your project name.

htdocs directory is where the htmls files are kept. (like your web root directory). The allocated quota is 5 MB. In the same hierarchy you have cgi-bin directory where you can put your php or cgi scripts.

Then, how do I login and see every thing?

Use either putty or ssh on windows. The host name is shell.sourceforge.net, the port is 22. You have your login and password right? Then, what else! Enjoy.
I can just tell you where you should not try to login. Projectname.cvs.sourceforge.net – This is not for ssh-ing. Only for CVS repository access.

Last time, when I logged in to sf.net, it was successful. Same thing I try now… but the putty is closed saying “connection problem”... but the network is fine …sf.net is ‘Ping’ able from my host …. What went wrong?

(OR)

My ssh gives some strage errors like

‘ssh_exchange_identification: Connection closed by remote host’

Do you want to see more ?

$ ssh -v username@shell.sourceforge.net
OpenSSH_3.5p1, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Rhosts Authentication disabled, originating port will not be trusted. debug1: ssh_connect: needpriv 0 debug1: Connecting to channel-e.sourceforge.net [66.35.250.209] port 22.
debug1: Connection established. debug1: identity file /home/csea/.ssh/identity type -1
debug1: identity file /home/mani/.ssh/id_rsa type -1
debug1: identity file /home/mani/.ssh/id_dsa type -1 ssh_exchange_identification: Connection closed by remote host
debug1: Calling cleanup 0x80674d0(0x0)

Now, tell me what went wrong?

Don’t worry. You are not the culprit. Sf.net might have blocked the access. I also got the same error message.
I tried logging after 1 or 2 days. Then, it worked fine. I guess, the access list would have released the lock. Not sure…

All the best!






Thursday, March 23, 2006

My articles published.

My article was approved for publishing at javareference.com. I would like to thank Raghul, who spent time to review and publish.

[1] Object eligibility factors for Garbage Collection in Java. http://www.javareference.com/articles/viewarticle.jsp?id=736
[2] Gearing up the JSP Performance. http://www.javareference.com/articles/viewarticle.jsp?id=613

Friday, December 16, 2005

java -XX:+PrintGCDetails -verbose:gc hello

I am trying out all the possible command line options with javac, java, jdb, javap and other interesting tools.
It seems really interesting to unleash some thing, that we rarely use, or never use!

Here is the list of some cool links:


http://java.sun.com/docs/hotspot/gc1.4.2/

http://www.petefreitag.com/articles/gctuning/

http://java.sun.com/developer/technicalArticles/Programming/GCPortal/