Database in MS Access using Java...Help!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Database in MS Access using Java...Help!!

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Amsterdam
    Posts
    10

    Exclamation Database in MS Access using Java...Help!!

    I have already created an MS Access database to store a list of users with the following details:- First Name, Last Name, Address, Home Tel No, Mobile No and E-mail Add.

    Now i need all the names to be read into an array of structures and the names should be displayed when the form is loaded. When the name is highlighted, all the details of that user should apprear at the bottom of the screen.

    There are also 4 other options needed;

    Add new user - update the Access database with the relevant details and display a welcome message.

    Delete user - delete the user from the database after displaying a delete confirmation message.

    Update user - select the user name and click update button to amend the details.

    Total users - calculate the total number of users in the database and display the top 10 users according to last names in alphabetical order.

    Anyone kind enough to provide a source code for the following or have a similar program's source code?? I need some help badly...

    Thanks!!

  2. #2
    Join Date
    Aug 2003
    Posts
    313
    Here is some source code which tries to solve the Othello game using a depth first search (not realistic). There is a class called DBWriter which is probably the type of thing that you are looking for. I'm sure there are better classes out there, but this should hopefully get you started.

    Hope this helps.
    Attached Files Attached Files
    ~evlich

  3. #3
    Join Date
    Sep 2005
    Location
    Amsterdam
    Posts
    10
    Thanks evilch....but it dosen't seem to work the way i wanted it to...

    Any experts out there have a better solution??

    Pls advice.

    Thanks a million!!

  4. #4
    Join Date
    Aug 2004
    Posts
    46
    Only you know what "doesn't seem to work" means...

    Please be a little more explicit about what you're doing, what you expect to happen, and what you actually observe.

    Please post a short, concise, executable example of what you're trying to do. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.

    Post your code between [code] and [/code] tags. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please preview your post when posting code.

    Please assume that we only have the core API. We have no idea what SomeCustomClass is, and neither does our collective compiler.

    If you have an error message, post the exact, complete error along with a full stack trace, if possible. Make sure you're not swallowing any Exceptions.

    Help us help you solve your problem.

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    Here is:

    A simple one-table database application. I have modified it so it
    deals with your table. The database is MySQL, so you will have to
    change the database connection parameters.
    And it has a qouple of quirks left.... you are cordially invited to find
    them, understand them and fix them.

    PS: you may want to remove the package directive on top of the src files.
    Attached Files Attached Files
    eschew obfuscation

  6. #6
    Join Date
    Sep 2005
    Location
    Amsterdam
    Posts
    10

    Thumbs up

    Brilliant!!

    It was exactly what i was looking for.. i managed to correct the quirks and the database is working perfectly fine now!!

    Thank you so much for your help sjalle

    Hope to learn more from you experts here..

    Cheers!!
    Last edited by vanaxel; 09-07-2005 at 12:16 PM.

  7. #7
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Thats fine.

    Btw, have you tried to overwrite (one of the) primary key field(s) with a new value
    and clicked "save changes" .. hmm ?
    eschew obfuscation

  8. #8
    Join Date
    Oct 2005
    Posts
    1

    Need your help

    Hi all... I wan to know the way how to insert data from java into database Access. I need to insert into 2 table in one time...can put like this?

    String url = "jdbcdbc:library";
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String theStatement="INSERT INTO Member (MemberID, Name, UserID, Password, TelNo, Email) VALUES ('"+ jTextFieldID.getText() + "','" + jTextFieldName.getText() + "','" + jTextFieldUser.getText() + "','" + jTextFieldPass.getText() + "','" + jTextFieldTel.getText() + "','"+ jTextFieldEmail.getText() + "')";
    String theStatement2="INSERT INTO Student(RegisterNo ) VALUES ('"+ jTextFieldID.getText() + "')";
    System.out.println(theStatement);
    System.out.println(theStatement2);
    try {
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    String loc = "jdbcdbc:librarysystem";
    con = DriverManager.getConnection (loc);
    }
    catch (ClassNotFoundException cnf) {
    JOptionPane.showMessageDialog (null, "Driver not Loaded...");
    System.exit (0);
    }
    catch (SQLException sqlex) {
    JOptionPane.showMessageDialog (null, "Unable to Connect to Database...");
    System.exit (0);
    }
    setVisible (true);


    try
    {
    Class.forName(driver);
    Connection connection=DriverManager.getConnection(url);
    Statement querylibrary=connection.createStatement();
    int result = querylibrary.executeUpdate(theStatement);
    int result2 = querylibrary.executeUpdate(theStatement2);


    if ( result == 1 ){
    System.out.print( "\nOrder Placed\n" );
    JOptionPane.showMessageDialog (this, "Record has been Saved.");
    jTextFieldID.setText(null);}
    else{
    System.out.print( "\nInsertion failed\n" );
    JOptionPane.showMessageDialog (this, "Problem while Saving the Record.");}

    querylibrary.close();
    connection.close();
    }

Similar Threads

  1. Java and MS access database connection
    By borceivanovski in forum Java
    Replies: 1
    Last Post: 04-27-2005, 06:35 PM
  2. Really Cool 3 tier Java database solution
    By Russ in forum Database
    Replies: 0
    Last Post: 06-04-2002, 01:57 AM
  3. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 01:43 AM
  4. General class in java to access database using JDBC
    By Rafat balaom in forum VB Classic
    Replies: 0
    Last Post: 12-09-2001, 03:47 AM
  5. Open Access database Form from VB 6.0?
    By Demo in forum VB Classic
    Replies: 7
    Last Post: 07-25-2000, 09:10 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center