Java and Databases

Discussion in 'Java' started by Ryan Stewart, Feb 16, 2004.

  1. Ryan Stewart

    Ryan Stewart Guest

    Someone posted something about this a while back in one of the
    comp.lang.java groups, but I can't find it now. I want to create an object
    model backed by a database. Where should the database code go? Should I have
    a commit() method in each class, or something like that? That doesn't seem
    right. I found some info about JDO (Java Data Objects), but after about half
    an hour of browsing, it doesn't seem to be quite what I'm looking for. I may
    be wrong though.

    What it's for: Soon I intend to begin writing an application which is
    primarily for learning purposes, though some use may come of it later on. It
    will probably be a webapp using JSP, but there's a very slight possibility
    that I'll use applets as an interface instead. I'm doing this at home
    entirely on my own. I also intend to look into Struts for the first time.
    Will it help with my database code issue?

    My reason for asking: I've been involved with webapps where all the code,
    including db code, was crammed into a JSP. Talk about *ugly*. I want to
    learn the correct way to write a solid, maintainable application
    Ryan Stewart, Feb 16, 2004
    #1
    1. Advertising

  2. Ryan Stewart wrote:

    > Someone posted something about this a while back in one of the
    > comp.lang.java groups, but I can't find it now. I want to create an object
    > model backed by a database. Where should the database code go? Should I
    > have a commit() method in each class, or something like that? That doesn't
    > seem right. I found some info about JDO (Java Data Objects), but after
    > about half an hour of browsing, it doesn't seem to be quite what I'm
    > looking for. I may be wrong though.
    >
    > What it's for: Soon I intend to begin writing an application which is
    > primarily for learning purposes, though some use may come of it later on.
    > It will probably be a webapp using JSP, but there's a very slight
    > possibility that I'll use applets as an interface instead. I'm doing this
    > at home entirely on my own. I also intend to look into Struts for the
    > first time. Will it help with my database code issue?


    Not really , Struts is an MVC web framework, it has nothing to do with your
    business logic itself.

    > My reason for asking: I've been involved with webapps where all the code,
    > including db code, was crammed into a JSP. Talk about *ugly*. I want to
    > learn the correct way to write a solid, maintainable application


    Use hibernate (http://www.hibernate.org) in combination with DAO (Data Acces
    Object) classes (a class in which you do basic CRUD operations, so all DB
    code is centralised there and encapsulated from other classes).

    Combined with Hibernate, you'll barely ever need to write a single line of
    SQL, while being able to support a rich domain model, and allowing faster
    development.


    --
    Kind regards,
    Christophe Vanfleteren
    Christophe Vanfleteren, Feb 16, 2004
    #2
    1. Advertising

  3. Ryan Stewart

    Ryan Stewart Guest

    "Christophe Vanfleteren" <> wrote in message
    news:Zg5Yb.3431$-ops.be...
    > Ryan Stewart wrote:
    >
    > > Someone posted something about this a while back in one of the
    > > comp.lang.java groups, but I can't find it now. I want to create an

    object
    > > model backed by a database. Where should the database code go? Should I
    > > have a commit() method in each class, or something like that? That

    doesn't
    > > seem right. I found some info about JDO (Java Data Objects), but after
    > > about half an hour of browsing, it doesn't seem to be quite what I'm
    > > looking for. I may be wrong though.
    > >
    > > What it's for: Soon I intend to begin writing an application which is
    > > primarily for learning purposes, though some use may come of it later

    on.
    > > It will probably be a webapp using JSP, but there's a very slight
    > > possibility that I'll use applets as an interface instead. I'm doing

    this
    > > at home entirely on my own. I also intend to look into Struts for the
    > > first time. Will it help with my database code issue?

    >
    > Not really , Struts is an MVC web framework, it has nothing to do with

    your
    > business logic itself.
    >
    > > My reason for asking: I've been involved with webapps where all the

    code,
    > > including db code, was crammed into a JSP. Talk about *ugly*. I want to
    > > learn the correct way to write a solid, maintainable application

    >
    > Use hibernate (http://www.hibernate.org) in combination with DAO (Data

    Acces
    > Object) classes (a class in which you do basic CRUD operations, so all DB
    > code is centralised there and encapsulated from other classes).
    >
    > Combined with Hibernate, you'll barely ever need to write a single line of
    > SQL, while being able to support a rich domain model, and allowing faster
    > development.
    >
    >
    > --
    > Kind regards,
    > Christophe Vanfleteren


    Many thanks for the prompt reply. I think DAO is what I was looking for.
    I've had some exposure to TopLink, which Hibernate looks very similar to. I
    may go that route, or I may take a step down and get into the nitty gritty
    of database programming, just for the experience. Maybe get some experience
    with reflection as well. Other comments/suggestions still welcome!
    Ryan Stewart, Feb 16, 2004
    #3
  4. Ryan Stewart wrote:

    >
    > Many thanks for the prompt reply. I think DAO is what I was looking for.
    > I've had some exposure to TopLink, which Hibernate looks very similar to.
    > I may go that route, or I may take a step down and get into the nitty
    > gritty of database programming, just for the experience. Maybe get some
    > experience with reflection as well. Other comments/suggestions still
    > welcome!


    You are correct: if you had no JDBC experience before, it is wise to use it
    in order to get to know the basic layers (if only to get to see how tedious
    it can become :).

    But once you know the basics and need to begin a new project, I would
    recommend an ORM (Object Relational Mapper) like Hibernate or Toplink, or a
    JDO implementation. Assuming ofcourse, that your problem lends itself to an
    ORM solution (not everything does).

    You can still use a "normal" library on top of JDBC like IBatis or Spring in
    those cases, as it still is nicer to work with than raw JDBC.

    --
    Kind regards,
    Christophe Vanfleteren
    Christophe Vanfleteren, Feb 16, 2004
    #4
  5. Ryan Stewart

    Matt Parker Guest

    Ryan Stewart wrote:

    > Someone posted something about this a while back in one of the
    > comp.lang.java groups, but I can't find it now. I want to create an object
    > model backed by a database. Where should the database code go? Should I
    > have a commit() method in each class, or something like that? That doesn't
    > seem right. I found some info about JDO (Java Data Objects), but after
    > about half an hour of browsing, it doesn't seem to be quite what I'm
    > looking for. I may be wrong though.
    >
    > What it's for: Soon I intend to begin writing an application which is
    > primarily for learning purposes, though some use may come of it later on.
    > It will probably be a webapp using JSP, but there's a very slight
    > possibility that I'll use applets as an interface instead. I'm doing this
    > at home entirely on my own. I also intend to look into Struts for the
    > first time. Will it help with my database code issue?
    >
    > My reason for asking: I've been involved with webapps where all the code,
    > including db code, was crammed into a JSP. Talk about *ugly*. I want to
    > learn the correct way to write a solid, maintainable application


    I'm currently getting towards the end of writing an OpenSource web
    development toolkit, which includes a database abstraction layer. E-mail me
    off list if you want to give it a test drive. I've only got Javadocs at the
    moment for documentation though. At the very least you'll see how I've
    implemented my database pool, wrapped the objects etc.

    Matt

    --
    Not so interesting...
    http://www.mpcontracting.co.uk
    Matt Parker, Feb 16, 2004
    #5
  6. Ryan Stewart

    valds Guest

    Matt Parker <> wrote in message news:<40311a63$0$24281$>...
    > Ryan Stewart wrote:
    >
    > > Someone posted something about this a while back in one of the
    > > comp.lang.java groups, but I can't find it now. I want to create an object
    > > model backed by a database. Where should the database code go? Should I
    > > have a commit() method in each class, or something like that? That doesn't
    > > seem right. I found some info about JDO (Java Data Objects), but after
    > > about half an hour of browsing, it doesn't seem to be quite what I'm
    > > looking for. I may be wrong though.
    > >
    > > What it's for: Soon I intend to begin writing an application which is
    > > primarily for learning purposes, though some use may come of it later on.
    > > It will probably be a webapp using JSP, but there's a very slight
    > > possibility that I'll use applets as an interface instead. I'm doing this
    > > at home entirely on my own. I also intend to look into Struts for the
    > > first time. Will it help with my database code issue?
    > >
    > > My reason for asking: I've been involved with webapps where all the code,
    > > including db code, was crammed into a JSP. Talk about *ugly*. I want to
    > > learn the correct way to write a solid, maintainable application

    >
    > I'm currently getting towards the end of writing an OpenSource web
    > development toolkit, which includes a database abstraction layer. E-mail me
    > off list if you want to give it a test drive. I've only got Javadocs at the
    > moment for documentation though. At the very least you'll see how I've
    > implemented my database pool, wrapped the objects etc.


    Few weeks ago I found interesting enough ide+framework (www.worcsnet.com), guys
    used another approach - solid javascript control library for client, including
    objects like datawindow from powerbuilder, tonns of other controls and browser
    based studio IDE, that they claim, allows to create complex web apps within
    days, and apps may function and look like standart standalone client-server app


    Regards,
    Valds
    valds, Feb 26, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?Andree_Gro=DFe?=

    Re: Java & Databases

    =?ISO-8859-1?Q?Andree_Gro=DFe?=, Jun 30, 2003, in forum: Java
    Replies:
    0
    Views:
    770
    =?ISO-8859-1?Q?Andree_Gro=DFe?=
    Jun 30, 2003
  2. Polo

    Java & databases & awt

    Polo, Nov 6, 2003, in forum: Java
    Replies:
    0
    Views:
    562
  3. Ken North
    Replies:
    0
    Views:
    587
    Ken North
    Jul 14, 2005
  4. Replies:
    11
    Views:
    766
    Lee Fesperman
    Nov 23, 2006
  5. Replies:
    2
    Views:
    979
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Oct 14, 2007
Loading...

Share This Page