Results 1 to 10 of 10
  1. #1
    webbusiness23 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default New simple application using a simple database

    Hi,

    i want to learn how to do a simple application using Java and a database.

    Something like:

    1. A window which contains 2 text inputs and an "Submit" button.

    The user types let's say his name and age, and after he clicks on "Submit", the data is stored into my database.

    2. A second window which will contain one text input and the "OK" button.
    After i type a random name, i want to print or display the data for that name (name and age).

    Can you tell me where should i start?

    P.S. I do know things related to panels, adding buttons to panels, etc.
    What i don't know is how to work with databases, how to store and retrieve the data from databases.

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Read about the Java DataBase Connector (JDBC) and Structured Query Language (SQL). There's plenty more on our Databases board.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    I get the feeling you don't want to connect to an actual database (MySQL, etc...) one that you create yourself (something simple made just for the purposes of your program).

    You can make a simple database with an ArrayList, and use the methods in the Collections package for sorting, and you could write a simple binary search for lookup. If you want a little more challenge, you could do the same thing with a Hashtable, which would make for more efficient loopups.

    Once you can insert new items and get them back out, then start looking at GUI stuff.

  4. #4
    webbusiness23 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by quad64bit View Post
    I get the feeling you don't want to connect to an actual database (MySQL, etc...) one that you create yourself (something simple made just for the purposes of your program).

    You can make a simple database with an ArrayList, and use the methods in the Collections package for sorting, and you could write a simple binary search for lookup. If you want a little more challenge, you could do the same thing with a Hashtable, which would make for more efficient loopups.

    Once you can insert new items and get them back out, then start looking at GUI stuff.
    Yes, i don't want to connect to an existing database.
    I want to create one. I'm interested in database and working with it, not into ArrayList and Collections.

    And i do know the SQL language.

    What i need is a starting point.

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

  6. #6
    webbusiness23 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default

    Here's what i've done so far:

    I read and done this tutorial: netbeans.org/kb/docs/java/gui-db.html#running-outside-IDE

    At the end of it i had a 100% running application.

    I tried to run the .jar file on a different computer, but no result.

    How can i make a database Java application that will run on any computer?

  7. #7
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Why wouldn't it run on another computer? What was the console output when you ran it?

  8. #8
    webbusiness23 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by quad64bit View Post
    Why wouldn't it run on another computer? What was the console output when you ran it?

    I tried to run the project on the other computer by double clicking the .jar file.

    There was no console output. Nothing happened.

    Here is what i still don't understand: How can i create an application which will have a database embedded, which will also run on any computer?

  9. #9
    adz
    adz is offline Member
    Join Date
    Jul 2009
    Posts
    35
    Rep Power
    0

    Default

    Research SQLite; make sure to look at its implementations because there are some pitfalls you may fall into (although for a small app, some may not matter/be noticeable).

    But yeah, there are implementations of SQLite for Java although I haven't found a way to view/manage the tables/dbs yet. Maybe someone else can link a program that does this.

  10. #10
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    adz is right about SQlite -- its what ruby on rails uses for an embedded database.

    As far as console output -- there is always console output, you just may not have been looking at it. Run the jar file from the command line--
    java -jar myJar.jar

    And see what errors it prints. I suspect you used absolute paths or loopback ip for a server running locally, or something of the sort.

Similar Threads

  1. JSP simple application
    By Ms.Ranjan in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 10-04-2008, 10:08 AM
  2. Simple example Client Server Application
    By ferosh in forum Networking
    Replies: 1
    Last Post: 04-01-2007, 10:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •