• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Understanding Java API docs, word for word

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, have you read through the JdbcFaq?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 88
IBM DB2 Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic