On Mar 22, 2006, at 5:50 PM, Jeffrey Pearson wrote:

Robert,

I forgot to include the parent package in the page which is why I was getting the error(OK. I got spoiled. IntelliJ automatically adds it). But I did still need to add the new to the line. Thanks.

Not that I would ever lure someone over to the dark side, but when you are ready for a real Java IDE, look here:
http://www.objectstyle.org/confluence/display/WOL/Home

Granted it is not IntelliJ, but it is not veXcode either.

Chuck

On Mar 22, 2006, at 4:32 PM, Robert Walker wrote:

Registry registry = Registry();

I think you want:
Registry registry = new Registry();

Then your methods don't have to be static because you will be sending messages to a new instance of a Registry object?
--
Robert Walker
[EMAIL PROTECTED]

There are 10 types of people in the world, those who count in binary, and those who don't.


On Mar 22, 2006, at 7:18 PM, Jeffrey Pearson wrote:

More of a Java question than strictly WebObjects but this exact same code works in the jp/servlet web app.

When I compile, I get:

cannot resolve symbol on line:

Registry registry = Registry();

in the Main.java file.

If I remove the static parameter from the getMySQLConnection line, I get:

com/metrohero/web/PublisherFunctions.java:22: non-static method getMySQLConnection() cannot be referenced from a static context




******************************************************************** ***
//
// Main.java: Class file for WO Component 'Main'
// Project metropolisadmin
//
// Created by jeffreypearson on 3/21/06
//

import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
import com.metrohero.common.*;

public class Main extends WOComponent {
    public String userName;
    public String password;
        public Main(WOContext context) {
        super(context);
    }

    public WOComponent validateLogin() {
if ("".equalsIgnoreCase(userName) || "".equalsIgnoreCase (password)) {
             return pageWithName("Main");
        }
        try {
            Registry registry = Registry();
                        Connection MySQLConnection = 
registry.getMySQLConnection();
            Statement stmt = MySQLConnection.createStatement();
ResultSet rset = stmt.executeQuery("SELECT userid from users where username = '" + userName + "' AND password = '" + password + "'");
                        if (rset != null) {
                                return pageWithName("Home");
                        } else {
                                return pageWithName("Main");
                        }
        } catch (SQLException SQLEx) {
            System.out.println("SQL Exception:" + SQLEx);
        }

        //return pageWithName("Home");
    }

}
*********************************************************

package com.metrohero.common;

//import java.sql.DriverManager;
import java.sql.*;

//import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Driver;




public class Registry {

    //private static OracleDataSource ds;

    public static Connection getMySQLConnection() {
        Connection MySQLConnection = null;
        try {
            // The newInstance() call is a work around for some
            // broken Java implementations
           Class.forName("com.mysql.jdbc.Driver").newInstance();
MySQLConnection = DriverManager.getConnection ("jdbc:mysql://64.81.81.18/metropolis? user=username&password=password");
        } catch (Exception ex) {
            // handle the error
        }
        return MySQLConnection;
    }

    public static void closeMySQLConnection(Connection m_conn)
    {
        try {
            if (m_conn != null) {
                m_conn.close();
            }
        }
        catch (SQLException e) {
            System.out.println("ERROR_OCCURRED");
            e.printStackTrace();
        }
    }
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/ robertwalker1%40mac.com

This email sent to [EMAIL PROTECTED]


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill% 40global-village.net

This email sent to [EMAIL PROTECTED]

--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to