Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Please help me

Options
  • 24-08-2009 1:09pm
    #1
    Closed Accounts Posts: 32


    Ok so here's the thing. I have a database created in ms sql with stored procedures and functions, I have all my java classes created for the database. I have the database connected through java. I have to put a gui on the application so as people can actually use the application, and this is where I am stuck.

    I have all the forms created that I need. I however have no functionality behind them as I have no clue how to proceed. I am absolutly completely stuck. I have spent the morning trawling the internet for some sort of tutorial and I can find nothing. Please help me. Thanks.


Comments

  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Well, on buttons you click you want to perform an action so you implement an action listener in java.

    Have you looked at things like: http://www.netbeans.org/kb/60/java/gui-functionality.html#Exercise_2

    - May not be to do with database, but same general idea applies only input data comes from DB and data gets written back out again.


  • Closed Accounts Posts: 32 SoItsMe


    Thanks for your response Webmonkey. I have a fairly good grasp on net beans, but my problem really is figuring out how to seperate my application up into a business layer, presentation layer and data layer. Does anyone know where I could find some information on doing this?
    Thanks.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Netbeans will work with MSSQL but you'll need the JDBC driver for MSSQL which you can download here: http://short.ie/vazu8o.

    Innanutshell noob explanation:

    For your presentation layer you really should only have your windows (FrameViews, JFrames, JDialogs) and code to respond to user events like the actionListeners Webmonkey mentioned. The presentation layer should be referencing the BOL objects.

    Your Business Object Layer should contain your custom classes, not have any visual elements and certainly not reference anything in the presentation layer. This is where most of your processing should go.

    The Data Access Layer should only contain the classes that talk to the database and should have all the java.sql.* classes in there. Some people will disagree but I think its okay to have ResultSets in the BOL, especially when your learning, but not in the UI. Look at collections instead of resultsets in the UI (ArrayLists are good, Generic ArrayLists are better).


  • Registered Users Posts: 163 ✭✭stephenlane80


    Im not too familiar with Java Enterprise solutions, but here is how you would do it with C#:

    Best practice tends to use three layers as Phil and others explained, smaller applications with 2 layers is very acceptable. If i create an app i use 3:

    DataAccessLayer:

    public DataSet Employees()
    {
    \\call stored proceedure and return results as dataset
    }


    BusinessLogicLayer:

    public ArrayList Employees()
    {
    \\call Employees function from DAL and read DataSet into an arraylist,
    \\you can apply business rules to data before returning
    }

    Presentationlayer

    public void DisplayData()
    {
    \\call Employees function from business layer, and bind ArrayList to a \\datagrid, or list box or something, you could also bind the Datagrid from the \\business layer to a GUI control
    }


Advertisement