Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

what is super?

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I'm waiting for amazon to deliver the books... meanwhile, I have a java project to create!
Here is some code I found for a database access bean. Can someone please explain what the super() call does and why there is a method in the class with the same name as the class? Is that a requirement in a bean?
muchos thankyous,
Scottie Zman
---------------------------------------------
package sqlBeans;
import java.sql.*;
import java.io.*;
public class DbBean {
String dbURL;
String dbDriver;
private Connection dbConn;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException {
Class.forName(dbDriver);
dbConn = DriverManager.getConnection(dbURL);
return true;
}

public void close() throws SQLException{
dbConn.close();
}

public ResultSet execSQL(String strSQL) throws SQLException{
Statement stmt = dbConn.createStatement();
ResultSet rs = stmt.executeQuery(strSQL);
return (rs == null) ? null : rs;
}

public int updateSQL(String strSQL) throws SQLException{
Statement stmt = dbConn.createStatement();
int r = stmt.executeUpdate(strSQL);
return (r == 0) ? 0 : r;
}
}

[This message has been edited by scottie zman (edited August 23, 2001).]
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no good reason for the super() call to be used like that. It would be automatically called if you left it out. Even then it doesn't do much. super(arguments) calls a contructor on a parent class. In this case that class would be java.lang.Object. Here is an example of it's use:
 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the explanation and example, it helped a lot!
 
Something must be done about this. Let's start by reading this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic