I have created my class and one constructor in the class and I now want to call my class in the main method.
How do I call the constructor then. My code looks like this
import java.sql.*; import java.io.*; import javax.swing.JOptionPane; public class MyConnection { Connection conn; public MyConnection() { //load the driver try { Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println ("Driver successfully loaded"); } catch (ClassNotFoundException c) { System.out.println ("Unable to load database driver"); } //connect to the database try { BufferedReader inKb = new BufferedReader (new InputStreamReader(System.in)); //String filename = inKb.readLine(); String filename = "c:/mydatabase.mdb"; String database = "jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ="; database += filename.trim () + ";DriverID=22;READONLY=true}"; conn = DriverManager.getConnection (database, "", ""); System.out.println ("Connection to Disease database successfully established"); } catch (Exception e) { System.out.println ("Unable to connect to the database"); } } //end connect }