I'm still working on getting my head around this type of design. I might have been a little further along a few years ago in PHP, but some of it has slipped. I know what i have so far can be cleaned up, so by all means point out those mistakes as well.

What I need to do is create a Close() function. I need to close "connection" that resides inside Connect(). I'm thinking that needs defined within database() but I'm not 100% sure. The idea behind what I'm doing is I wasnt to register the driver, make a connection, and be able to return multiple query results using database() before using database.close()

Any help and pointers is much appreciated with this little self teaching exercise of mine.

Code Java:
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
 
public class Main {
 
    public static void main(String[] argv) {
        database db = new database();
        if (db.registerDriver("oracle.jdbc.driver.OracleDriver") == true) {
            System.out.println("Driver Registered");
            if (db.Connect("jdbc:oracle:thin:@host:port:alias", "user", "pass") == true) {
                System.out.println("Connection made");
            }
        }
 
    }
}
 
class database {
 
    public boolean registerDriver(String sDriver) {
        try {
            Class.forName(sDriver);
            return true;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return false;
        }
    }
 
    public boolean Connect(String sHost, String sUser, String sPass) {
        Connection connection = null;
        try {
            connection = DriverManager.getConnection(sHost, sUser, sPass);
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
        //Check Connection
        if (connection != null) {
            return true;
        } else {
            return false;
        }
    }
 
}