aspose file tools*
The moose likes JDBC and the fly likes driver manager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "driver manager" Watch "driver manager" New topic
Author

driver manager

ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic

t

[edited to use a meaningful subject line - was "how is this"]
[ October 18, 2006: Message edited by: Jeanne Boyarsky ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

Originally posted by ravindra patil:
having top level class is meaningless

Why is it meaningless?


but in jdbc DriverManager is static class so why this is sattic

It is static so you can call it without having to create an object.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
Originally posted by ravindra patil:
having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic

t

[edited to use a meaningful subject line - was "how is this"]

[ October 18, 2006: Message edited by: Jeanne Boyarsky ]




oh......jeanne you don't require class object if class's method is static if your method is static then though your class is static you want object of it ,if you really know the answer then give it otherwise don't
what is the perpose behind having it as a static
most of the java book mention that having top leval class is meaningless
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10201
    
166

if you really know the answer then give it otherwise don't


Ravindra, everyone here tries to help others voluntarily. Please be nice to everyone, whenever you are posting in the forums.

Also, what Jeanne has mentioned in her answer is correct. We dont see anything wrong in what she has mentioned.

[Jaikiran: Edited message, since there was a mistake in addressing Jeanne]
[ October 19, 2006: Message edited by: Jaikiran Pai ]

[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10201
    
166

most of the java book mention that having top leval class is meaningless


I havent read this before. Any reference?
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
Originally posted by ravindra patil:
[QB]having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic



[edited to use a meaningful subject line - was "how is this"]

Mr Pai
just visit this Url
http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html t

then give me comment
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10201
    
166

From the link that you mentioned:

A top-level class is by definition already top-level, so there is no point in declaring it static; it is an error to do so. The compiler will detect and report this error.


And here's the javadoc of DriverManager:

DriverManager

Where did you find that the DriverManager class itself is declared as static? Only the methods of that class have been declared as static.
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
Originally posted by ravindra patil:
having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic

t

[edited to use a meaningful subject line - was "how is this"]

[ October 18, 2006: Message edited by: Jeanne Boyarsky ]


man, just read JDBC section of Professional java server progreamming 1.3 edition by wrox publication and 'read it carefully'

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

From your link, "Each top-level class corresponds to its own java file sporting the same name as the class name.". This is the most common type of class. It is certainly not meaningless. The link goes on to say "A top-level class is by definition already top-level, so there is no point in declaring it static; it is an error to do so." I think this is what we are discussing.

The DriverManager class follows a pattern called a "utility class." This is where all the methods are static.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

Jaikiran: Just want to mention that I am female.

Ravindra:
if you really know the answer then give it otherwise don't

Sometimes people (especially the moderators here) ask questions to help you elaborate your question. The alternative is everyone remaining silent because they don't understand the question and then you don't get any help.

Note that the rolleyes icon is often construed as being upset with someone. That's probably not what you wanted to portray in a technical forum. Just mentioning this so you are away of the perception of this icon. (Smilies are disabled in this forum anyway, so you may want to ease up on their use here.)
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
Originally posted by ravindra patil:
having top level class is meaningless but in jdbc DriverManager is static class so why this is sattic

t

[edited to use a meaningful subject line - was "how is this"]

[ October 18, 2006: Message edited by: Jeanne Boyarsky ]



Jeanne i am sorry




from where are you i ask this question because interviewer asked me that question i answered top less class is never static but when i was reading professional java server programmming 1.3 edition by wrox publication it is clearly nentioned that DriverManager is staic class but document on static on java world shows that having top level class as static is error and compiler gives error

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10201
    
166

Originally posted by Jeanne Boyarsky:
Jaikiran: Just want to mention that I am female.



Sorry Jeanne, i was unaware.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

professional java server programmming 1.3 edition by wrox publication it is clearly nentioned that DriverManager is staic class

Ravindra: Sometimes people/books make mistakes or are misleading. Since you are finding web articles and people (in this forum) who are stating top level classes cannot be static, I think the book meant that DriverManager contains static methods, not that it is a static class.

Jaikiran: It's not big deal. I just wanted to mention it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: driver manager