connecting to a database

Discussion in 'Java' started by w00, Nov 25, 2006.

  1. w00

    w00 Guest

    Hello, i've installed NetBeans with the Derby Database. I've created a
    table with some content in it. Now i want to create a simple JSP file
    where i can connect to the database and select an item from a table.
    I just dont know how to do that, i couldn't find anything on the net
    either about this. So i hope someone here can help me out.
     
    w00, Nov 25, 2006
    #1
    1. Advertising

  2. w00 wrote:
    > Hello, i've installed NetBeans with the Derby Database. I've created a
    > table with some content in it. Now i want to create a simple JSP file
    > where i can connect to the database and select an item from a table.
    > I just dont know how to do that, i couldn't find anything on the net
    > either about this.


    If you are looking for examples of connecting to a
    DB from a JSP - you might be disappointed.
    I suspect most of the answers will revolve around
    a) accessing a DB (whether it is from an applet,
    application, web-app., or the command line)
    ...or..
    b) Writing JSP's.

    But then, try doing a DB access from an application,
    (with or without GUI) and I think you'll find most of the
    code can be 'copy/pasted' into a JSP.

    Andrew T.
     
    Andrew Thompson, Nov 25, 2006
    #2
    1. Advertising

  3. w00

    w00 Guest

    Andrew Thompson wrote:

    > If you are looking for examples of connecting to a
    > DB from a JSP - you might be disappointed.
    > I suspect most of the answers will revolve around
    > a) accessing a DB (whether it is from an applet,
    > application, web-app., or the command line)
    > ..or..
    > b) Writing JSP's.
    >
    > But then, try doing a DB access from an application,
    > (with or without GUI) and I think you'll find most of the
    > code can be 'copy/pasted' into a JSP.
    >
    > Andrew T.



    So you're saying that there isn't much about connecting to a Database
    with JSP files...??
    I know how to connect to a databse with php, its just calling the
    'mysql_select_db()' function. But i can't just guess what the function
    would be in Java with a Derby Database...

    There must be some resources/tutorials about this somewhere right...
     
    w00, Nov 25, 2006
    #3
  4. w00

    Mich Guest

    "w00" <> wrote in message
    news:...
    > Hello, i've installed NetBeans with the Derby Database. I've created a
    > table with some content in it. Now i want to create a simple JSP file
    > where i can connect to the database and select an item from a table.
    > I just dont know how to do that, i couldn't find anything on the net
    > either about this. So i hope someone here can help me out.



    create a class that connects to the database and then invoke the class from
    the jsp
     
    Mich, Nov 25, 2006
    #4
  5. w00

    Denz Guest

    "w00" <> wrote in message
    news:...
    > Hello, i've installed NetBeans with the Derby Database. I've created a
    > table with some content in it. Now i want to create a simple JSP file
    > where i can connect to the database and select an item from a table.
    > I just dont know how to do that, i couldn't find anything on the net
    > either about this. So i hope someone here can help me out.


    I have no idea about Derby specifically, but assuming it connects just the
    same as any other JDBC connection, you may be able to get some pointers
    from this page i put together for connecting to a MySQL database from jsp
    pages (using Tomcat as the jsp server):
    http://gus.gscit.monash.edu.au/~dmgel2/tomcat.html
     
    Denz, Nov 25, 2006
    #5
  6. w00 wrote:
    > Hello, i've installed NetBeans with the Derby Database. I've created a
    > table with some content in it. Now i want to create a simple JSP file
    > where i can connect to the database and select an item from a table.
    > I just dont know how to do that, i couldn't find anything on the net
    > either about this. So i hope someone here can help me out.
    >


    Connecting to Java DB or Derby from a JSP page requires the same code as
    from a desktop application....although that code may be handled by
    tags or other libraries.

    The following article can help you connect to a Java DB (Apache Derby)
    db from a desktop application:
    http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javadb/

    The basic ideas you want to pay attention to are these:
    * including the derby.jar or derbyclient.jar files in the app classpath
    * loading the driver
    * connecting to the db
    * executing sql statements using the jdbc classes and methods.

    The article should help considerably.

    Regards,
    John O'Conner
     
    John O'Conner, Nov 25, 2006
    #6
  7. Denz wrote:
    > "w00" <> wrote in message
    > news:...
    > > Hello, i've installed NetBeans with the Derby Database. I've created a
    > > table with some content in it. Now i want to create a simple JSP file
    > > where i can connect to the database and select an item from a table.
    > > I just dont know how to do that, i couldn't find anything on the net
    > > either about this. So i hope someone here can help me out.

    >
    > I have no idea about Derby specifically, but assuming it connects just the
    > same as any other JDBC connection, you may be able to get some pointers
    > from this page i put together for connecting to a MySQL database from jsp
    > pages (using Tomcat as the jsp server):
    > http://gus.gscit.monash.edu.au/~dmgel2/tomcat.html


    There is nothing quite like making a public statement
    in an archiveable medium to find out ..I'm wrong. ;-)

    Nice page. I especially like the styling (info. seems
    good and clear, too).

    BTW - noticed one tiny typo. just before the start of
    step 2 - 'atleast' with no space.

    Andrew T.
     
    Andrew Thompson, Nov 26, 2006
    #7
  8. w00

    Lew Guest

    Andrew Thompson wrote:
    >> But then, try doing a DB access from an application,
    >> (with or without GUI) and I think you'll find most of the
    >> code can be 'copy/pasted' into a JSP.


    w00 wrote:
    > So you're saying that there isn't much about connecting to a Database
    > with JSP files...??
    > I know how to connect to a databse with php, its just calling the
    > 'mysql_select_db()' function. But i can't just guess what the function
    > would be in Java with a Derby Database...
    >
    > There must be some resources/tutorials about this somewhere right...


    JSTL tag library has SQL tags.

    See Chapter 14 of the Sun JEE tutorial:
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html

    - Lew
     
    Lew, Dec 1, 2006
    #8
    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. Tom Wild
    Replies:
    0
    Views:
    6,738
    Tom Wild
    Aug 14, 2003
  2. Tom Wild
    Replies:
    1
    Views:
    10,980
    Kevin Swarts
    Aug 25, 2003
  3. =?Utf-8?B?ZWoxMDA4?=
    Replies:
    10
    Views:
    589
    =?Utf-8?B?VmFuaQ==?=
    Jul 2, 2004
  4. Ammar
    Replies:
    2
    Views:
    308
    Ammar
    Jul 8, 2004
  5. =?Utf-8?B?TWFrYXJhbmQgS2Vlcg==?=

    Connecting Database in thread

    =?Utf-8?B?TWFrYXJhbmQgS2Vlcg==?=, Nov 19, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    417
    =?Utf-8?B?TWFrYXJhbmQgS2Vlcg==?=
    Nov 22, 2004
Loading...

Share This Page