Praveen Sharma

Ranch Hand
+ Follow
since Jul 31, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Praveen Sharma

Winston,
Sorry if my duplicate post offended the audience.

In simple terms this is what I am trying to do:
1. Read a file (Type of file is irrelevant)
2. Store the file data in data base.

I wanted suggestion on how should I structure my code. Me being from the web applications background, I have always used directory structures as defined by the model-view-controller pattern. And I am little unsure of how a java stand alone project should be organized?
6 years ago
I am some one from the MVC background and have not actually developed stand alone applications. For the first time now I am in between a stand alone java app development whose high level logic is as follows:

1. Read a CVS file
2. Process the data in three stages (I have stored the data in 3 temporary DB tables)
3. Apply business rules and finally write the data to the main DB table

I went ahead with the same app directory structure as MVC apps:
action - Read file action, loadIntoTemp1Table action, loadIntoTemp2TblAction, loadIntoTemp3Action, WritetoMainTblAction
service - similar to action class, I have 4 service interfaces and implementations
dao - 4 dao implementation classes

For the service and dao layers I created interfaces and then provided implementation for these interfaces. If I have to do it simply I can do it 3/4 java classes.
I want some suggestions if this logical design of my application is correct or not?
6 years ago
I am some one from the MVC background and have not actually developed stand alone applications. For the first time now I am in between a stand alone java app development whose high level logic is as follows:

1. Read a CVS file
2. Process the data in three stages (I have stored the data in 3 temporary DB tables)
3. Apply business rules and finally write the data to the main DB table

I went ahead with the same app directory structure as MVC apps:
action - Read file action, loadIntoTemp1Table action, loadIntoTemp2TblAction, loadIntoTemp3Action, WritetoMainTblAction
service - similar to action class, I have 4 service interfaces and implementations
dao - 4 dao implementation classes

For the service and dao layers I created interfaces and then provided implementation for these interfaces. If I have to do it simply I can do it 3/4 java classes.
I want some suggestions if this logical design of my application is correct or not?
6 years ago
Thanks Paul. In terms of simplicity which one would be better out of SAX and STAX ? I am keeping DOM out of question because DOM will need more memory compared to SAX/STAX.
6 years ago
My Java application receives a XML string from another application (TIBCO app). In my Java app I need to read, modify and send back the modified XML string to the application (TIBCO). The input XML string looks something like this:



Please suggest an efficient parser which can help me achieve this. Please note, I will have to send back the XML in the exact format,i.e, with namespace declaration and namespace prefixes. The choice of parser would be one which consumes less memory and is fast. Also, at this point of time the XML content is not very big but might increase in future hence memory usage is a consideration.

P.S: Please ignore any syntax errors in the XML as I have typed it and not copy pasted from the app.
6 years ago
Hibernate quickly
Java persistence with hibernate (for concepts)
I started learning hibernate and I must admit it is fun. At this moment I am learning the concepts and have covered quite a bit like mapping, transactions, locking etc. Apart from concepts I would like to try out examples so that I learn better.

Could some one guide me some learning resource which helps me learn hibernate by example.

P.S: I am reading Hibernate in Action. It has code snippets but not full fledged examples which I can try on my own.
I was asked this question in a recent interview which I could not answer so was hoping to get some answers. I might not have got the question correctly maybe because I lack the understanding of the concepts like - database cluster, multiple JVM synchronization, load balancing. I will try my best to recall the question. Here it is:

1. There are two instances of an application (let's say A1 & A2) running on two different JVMs and two instances of a similar database (D1 & D2).
2. The application instances will try to insert a record in a DB instance. What I mean is that A1 will insert in D1 and A2 will insert in D2.
3. A server load balancer decides which of these app instances will run at a given time and this load balancer is a typical server load balancer not under our control.

Problem : At a given time only on of these application instances should be allowed to do a insert in a corresponding DB. This is required to avoid both the app instances to run at the same time and insert the same record in its database instances. How to achieve this ?

Wrong answers I gave:
1. Synchronize the code (Not possible because the app are running on different JVMs)
2. Try some database lock (Not possible because these two database instances can't talk to each other)

Hope I have explained the problem clearly. I have also attached an ugly looking architecture image. Thanks in advance for all replies.
6 years ago
Thanks a lot Ulf. This will be quite a read.
Came across a problem which I could not answer , so I was hoping that I get some replies which might help me gain some knowledge.

Scenarios:
The data access layer (DAO layer) has two connection objects lets say: connection1 and connection2. These two connection objects need to update two different databases.

Problem:
Apply transactions so that these two update operations work as an atomic operations. There is no restriction on were we can apply the transaction.
1) Finding it tough to think

2) I know of Cloneable and Serializable. These give information to the JVM to treat the classes (marked with the marker interface) in a certain way. But the interviewer was more interested in some real time example where I can use marker interface.
6 years ago
Recently I attended an interview and could not answer these two questions satisfactorily:

1. The access level in the overriding method can't be more restrictive than the overridden method's. Why ?
2. A real time example of marker interface?

I would be glad if someone could answer these so that I can build my knowledge.
6 years ago
Thanks K. Tsang. I have reading and practising design problems these days with the hope I will be able to solve some real world problems soon . What I am targeting now (as per Jimmy's suggestion) is to find out my areas were I can improve upon.
Thanks Jimmy. I agree. Learning from knowledgeable people and gaining experience has no substitute. But the only drawback here is that you will have to live on the mercy of others by asking them to help you. I was looking for some self study / self learning kind of stuff to get me going.