File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Beginning in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Beginning in java" Watch "Beginning in java" New topic

Beginning in java

bala kan
Ranch Hand

Joined: Aug 20, 2012
Posts: 44
Hi Guys,

I saw one mini project in which they use ms-access as back end and java as front end.. in which they used the following two lines to connect to the database

con = DriverManager.getConnection( "jdbc:odbc:lib");

can you explain me in detail why we have to use forName() and what it does

thanks in Advance
Darryl Burke

Joined: May 03, 2008
Posts: 5115

Since your question isn't in any way related to Swing / AWT / SWT, I've moved it to a more general section of the Ranch. Also, please go through the sections on "Use A Meaningful Subject Line" and "Use Code Tags" in How To Ask Questions On Java Ranch

Do you know how to find the Java API? Go through the documentation for Class#forName(...) and if you still don't understand, tell us what is confusing about it.

luck, db
There are no new questions, but there may be new answers.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

bala, I see you didn't return to all but one of the threads you started. When other members spend their time to help you, they like to know whether the help offered was useful or not, and whether your question is answered adequately.

There's a section in the page I linked to titled SayThanks <- link Please go through that one too, or maybe just go through all the sections.
Ray Thibeault

Joined: Jul 25, 2012
Posts: 3
I won't cover the general use of Class.forName(). In this case, the call to Class.forName() will cause the specified java class to be loaded and its static code to be executed. This static code will register the database driver under the name "jdbcdbc:lib" in the JDBC driver list, thus allowing you to use it to open a connection in the following line.
- R
I agree. Here's the link:
subject: Beginning in java
It's not a secret anymore!