www.webdeveloper.com
Results 1 to 4 of 4

Thread: OOP translation needed

  1. #1
    Join Date
    Nov 2002
    Posts
    333

    OOP translation needed

    For the below Object Oriented statements:

    Code:
    <% Connection connection = DriverManager.getConnection("jdbc:odbc:data", "", "");
    Statement statement = connection.createStatement();
    ResultSet resultset= statement.executeQuery("select * from mytable"); %>

    Connection is the class name and connection is the creation of a new object?
    DriverManager is another class with getConnection as a method
    where getConnection has 3 arguments? This is all part of the sql class library?

    Please clarify this so I can understand the OOP syntax and meaning.

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    1. Connection is the name of the class, connection is the name of the variable which will hold an instance of that class.

    2. DriverManager is a class and getConnection is a static method within this class.

    3. getConnection takes three parameters; a DSN, a username, and a password.

    4. ResultSet stores a collection of returned records from an SQL query.

    Regards.

  3. #3
    Join Date
    Nov 2002
    Posts
    333
    Thanks,

    How would I know or did you know that getConnection is a static method? Is this something I can find out myself in the future for other methods and if so how?

  4. #4
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Two ways.

    1. Cheat (Look at the Javadoc for the class)
    2. Note the fact it's referenced directly off the class rather than an object (an instance of the class).

    BTW, doing the JDBC driver stuff is a very confusing process for a newby to understand because there is so much static stuff involved with it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles