How to inherit from the main class in java

Posted by user225269 on Stack Overflow See other posts from Stack Overflow or by user225269
Published on 2010-06-03T03:39:41Z Indexed on 2010/06/03 3:44 UTC
Read the original article Hit count: 166

Filed under:
|

I have two java classes. One is NewFrame.java where the forms(buttons, textfields) are located. And the other one is Main.java where I have put the connection string for mysql:

Main.java looks like this: public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        // TODO code application logic here
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee_record", "root", "password");
        PreparedStatement statement = con.prepareStatement("select * from employee");
        ResultSet result = statement.executeQuery();

    }

}

How do I inherit from the main.java so that the declarations in it would be universally accessible to the forms in NewFrame.java? Please help. Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about mysql