Ankur Srivastava

Ranch Hand
+ Follow
since May 11, 2004
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ankur Srivastava

Forgot to mention that the best approach would be to go for an already available ORM tool like Hibernate. You would now write your code which is very much database independent, it is based on your configuration and settings that at run time hibernate will generate the database dependent code(queries).

This is very much similar to the second approach I had mentioned earlier but then here you do not have to write the code to access the different databases as that is provided by hiberante and is pretty much transparent to the code we would be writing.

I got htis idea while going through a Similar Topic. You might be also intereseted in visiting it!!

- Ankur
The first approach which I can think of is using DAO factory. So there will be a DAO factory and implementation of DAO's for different databases. But with this approach you need to ship the code (at least the class files) for three different implementation of dao's.

The other way could be to implement your API as JDBC is implemented i.e. you write interfaces then provide the implementation to the interfaces for each database and put these implementation in seperate jar files. Now depending on the database you would be using distribute the respective jar file with your application.

I would personally go for the second approach

I hope this helps.

- Ankur

Another aspect is that middle tier is more scalble than scaling the database. Say your demand increases from 100 concurrent clients to 500 concurrent clients on the web, you can add another middle tier server to scale your application. But if you have lot of your code going through the Database stored proc then your Database server will become a bottle-neck.



I am a java apps programmer and have not worked much on the DB side, but i thought if we do db clustering we can address the issue mentioned above or is it that the stored prcodures will not scale well in clustered environment or I should ask should we use stored procs in clustered db environment??

Thank you in advance
- Ankur
Can you give some scenarios where MBeans will be helpfull?

Thanks in advance.

- Ankur
15 years ago
Hi All,

I earlier had an understanding that when we create an object, the object is created on a heap and the reference we create, which points to the object is on the stack.

But recently I read something like: the reference we create does not directly point to the object in the heap, but it points to another memory location on the stack which has the reference to the object on heap.

I am a bit confused So please help !!

Thanks in advance

- Ankur
15 years ago
Hi, Ms.Jacquie Barker the one thing I am seriously looking for in a Java book is Java Memory Managment. I have read a few books on java and none of them talks about memory management in Java in detail. Does your book has enough details on this topic.

Thanks
Ankur
15 years ago
Hi Jim,

Can you please elaborate this point:

"A top-level protected class would be confusing and unnecessary at best."

Thanks
Ankur
15 years ago
Hi Phani,

Probably the code below will help you to get my point:

I have written a server class

package server;
class Server {

public static void main(String[] args) {
System.out.println("In server main!!");
}
}

Now i jar this, and put the server.jar in classpath of the other class MyServer and the MyServer class is in the same package

package server;
public class MyServer {

public static void main(String[] args) {
System.out.println("In My server main!!");
Server.main(args);
}
}

So you can see I can invoke the main method of Server class and this is something I want to restrict. I hope this will make my point more clear.
Though i know that this is not of much use but still it just came as a thought to me
- Ankur
15 years ago
Thank you Jim and Ernest!!

As I had mentioned in my mail that there is no specific requirement where I needed a private class but I just wanted to know why the java specification does not allow to have private and protected access to outer classes, the server class which I have talked about in my previous posts just came out of my mind as I was writing the post . I hope it was not very stupid of me.

And Jim can you now please elaborate on this point:
And a top-level protected class would be confusing and unnecessary at best.

- Ankur
15 years ago
Thank you Jim!!

But my point is exactly this:
If a class is top-level, and private, then no other class could access it

My requirement is, I am writing a server class and I don't want it to be accessed by any other class. I have a main method in the server class which will instantiate it and call the start method on it.

Is it that making the outer class as private will cause problems in loading the class itself.

- Ankur
15 years ago
I don't think that it will be much useful but yes when we are writing a server etc and we don't want any other class to access the server class we can make it private. Isn't it??

My reason for asking the question was not that I am writing a server and class I wanted to make it private, I just wanted to know why the Java specification does not allow to have package and private access modfiers for the outer classes.
15 years ago
Hi All,

Just wanted to know
Why can't we use private, and protected modifiers when declaring top-level classes?
I might want my class to be a standalone application with a main method and in such a case why can't I make my class as private.

I have been working on Java for a almost 2 years now and I don't know why did this stuck my mind now

Thanks in advance

- Ankur
15 years ago
Then just see if you are using this constructor for creation of socket Socket(InetAddress host, int port, boolean stream) with stream set to false in which case it will create a DatagramSocket. It has been deprecated in 1.4 but just wanted to check if that is the case beacuse your problem seems because of use of UDP protocol only.
15 years ago
Ya I completely agree with Cheng that without the context we can not preform the operation but yes one way which I think of is to first perform a search query which gives you the user with the user id by using the query of the kind ou=*,user=xyz and then depending on the result retrieve the ou information and form the dn.

I hope this helps you.
15 years ago
You firs need to find out the structure of your ldap schema. You have to find out where in the hierarchy is the user information stored. Generally it is like this:

[base-dn],ou=dep1,user=xyz

So if this is the case then for getting the user authenticated the relative dn would be ou=dep1,user=xyz.

ou stands for organizational unit.
15 years ago