• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Understanding Java API docs, word for word

 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ! I always learned how to use Java API's and read a bit about them. But now, I want to understand them completely, word for word.
I will be posting many questions that will ask questions about a word or two that I see in the API docs.
Here is the first one:
http://docs.oracle.com/javase/6/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String, java.lang.String, java.lang.String)

Attempts to establish a connection to the given database URL. The DriverManager attempts to select an appropriate driver from the set of registered JDBC drivers.


1- DB URL ? why do we have a URL to connect to a DB ? Is there any other way for a Java program (besides URL) to connect to a DB ?
2- What is the meaning of "registered drivers" ? How does one register a driver ?

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A forum isn't a good replacement for a tutorial. You should find a JDBC tutorial and that will answer these and many other questions.
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:A forum isn't a good replacement for a tutorial. You should find a JDBC tutorial and that will answer these and many other questions.


I try to look at the tutorials and google too before I seek help here. Sometimes the tutorials
do not explain everything. Half-understanding is good as not understanding.
I hope that you can still help me.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What part of the tutorials on JDBC URLs and driver management did you not understand?
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:What part of the tutorials on JDBC URLs and driver management did you not understand?


The points 1 and 2 in my post. You are answering my questions with questions;
questions that don't give hints or lead me towards an answer. What do I do now ?

Not the kind of image of a bear i had in mind:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
justin smythhe wrote:The points 1 and 2 in my post. You are answering my questions with questions;

Exactly. I'm trying to get you to ShowSomeEffort and hone your questions down into answerable ones.

What do I do now ?

Have you read through a JDBC tutorial? If so, which one?

To spot answer your questions:
1) The JDBC URL identifies the database to be connected to.
2) The driver manager does exactly what it says: manages the loaded JDBC drivers.

For more details, a book or a tutorial would be appropriate. Forums do not exist so that people can avoid reading on their own. It's here to answer specific questions that you might have after reading books and tutorials, or to help with specific code problems.

No one has time to enter in long passages that repeat what's already available elsewhere.

Not the kind of image of a bear i had in mind:

Love it! That is so me!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, have you read through the JdbcFaq?
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
justin smythhe wrote:You are answering my questions with questions;
questions that don't give hints or lead me towards an answer. What do I do now ?

You ShowSomeEffort and learn HowToAskQuestionsOnJavaRanch.

Winston
 
Faisal Fuad
Ranch Hand
Posts: 87
IBM DB2 Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol...Bear, I saw your picture in this forum before. Really Justin picked the best one. I can't stop laughing....oh God. You guys are great !!!

By the way, Justin it is good that you started reading those most boring API's but as Jayesh said, look for sample codes and try to run those by your own (use IBM-RAD or Eclipse) and see which part you can't understand. I am also learning Java everyday and this forum is an awesome place for me to motivate myself because here everyone will help you to overcome that point where you will get stuck. So no worries ok.

About JDBC, (in sort) try to see the whole picture. Suppose you wrote an Application. And your application needs to access data from a Database (called Data source). Now what you will do? First you have to locate where is your targated database-right? It can be in your local machine or in any remote server. So you need that address and any how you have to tell your app to read or write from that database. Here that URL comes, you see. It is nothing but the address where your database is located.

Ok....so you have your app and the database address. What will be the next step? Your application should understand how to reach to that database. Well, again at this point, did you realize that your App is doing so many stuff? You are writing logic in your App, writing SQL queries in your App so that it can read/write data from database..bla...bla...and finally you have the database address where you want to connect.

Now ask yourself.....out there you will find so many different types of Databases such as MySQL, DB2, JBOSS. Each database has their own dealing style with user's request. Now who will take care of this whole uncertainty? How you application will know how to talk to different types of Databases out there? How they will know what you want? You know what....there the JDBC API comes! It is saying...wait Justin.....I am here.....in your App you do your part. Just give me proper access information to your target database address. And once I will be connected with that database then you don't have to worry. I will do my part and will give you the resultset which your App is looking for. Nice ha !! And the heart of JDBC API is the "DriverManager" who is actually doing all those stuff for you. As you want to use that Manager to make your life simple, therefore you need to add that "DriverManager" (means register that Manager) in your code.

The best way to learn about these stupid boring APIs is that (at least to me), once you will understand what for you will be using those APIs at there basic level, then always look at your problem statement and ask.."Oh....I know that JDBC API does help to connect with Database. Now I need to trace the connection log in my console. Is there any way this API can help?" ....owala....this API has a method called "getLogStream" to do that task. So use that happily.

See...life is simple and beautiful ha. Good Luck Justin
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Learning the JAva API word for word is not a good way to learn java. The Java API is a reference, not a guide. Learning Java by reading the Java API is a lot like appreciating the Mona Lisa by looking at it through a microscope. Definetly can be interesting, but the beauty comes in when you look at it as a whole. SImilarly, the way you learn Java is by learning how to use it, not by rote learning of each API ever written.

 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal Fuad wrote:
....this API has a method called "getLogStream" to do that task. So use that happily.


Hey ! I really appreciate all the help that you gave me. I am going to try "getLogStream". But it is deprecated.
Do you know what can be used instead of "getLogStream" ?

Deprecated

thanks.
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayesh A Lalwani wrote:Learning the JAva API word for word is not a good way to learn java. The Java API is a reference, not a guide. Learning Java by reading the Java API is a lot like appreciating the Mona Lisa by looking at it through a microscope. Definetly can be interesting, but the beauty comes in when you look at it as a whole. SImilarly, the way you learn Java is by learning how to use it, not by rote learning of each API ever written.



I did not mean rote. I mean, i have to understand every word and sentence they use in the api tutorials.
I want to know the reasons and logic behind the words in those tutorials.
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's still pointless to go over the API word for word without understanding how to use the API first. If you don't understand how to make a database call using Java, the javadocs in java.sql are going to make zero sense to you. The same goes for every API in Java. There's a reason most books start by teaching you fundamentals concepts and code examples first, and then go into the API last. Hint: because it works.

The APIs are meant for to be a reference for someone who already knows how to program using that API.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic