OOP translation needed
For the below Object Oriented statements:
<% 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.
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.
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?
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.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)