Results 1 to 4 of 4

Thread: Database Help

  1. #1
    simtology is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Smile Database Help

    Hi.Don't know if anyone can help me but I have a project involving databases.My problem is I'm trying to create buttons that will allow the user to delete,insert and update data into the various fields in the database.They have to be able to see the rows during and after editing.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    This could possibly be solved by a mix of database code and a Swing GUI cpde (if a desk-top app), but I think that you'll need to provide a lot more detail here on just what your requirements are and what you've got so far.

  3. #3
    simtology is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Default Database help

    thanks a l ot for replying so soon. My project is sort of a DVD rental application that will allow users to rent or purchase movies. I have seperate screens one for the users and one for an administrator.All the administrator does is udate,delete,add new movies from databases that I have created.
    Heres most of the code
    [code]

  4. #4
    simtology is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Smile Database help

    thanks a l ot for replying so soon. My project is sort of a DVD rental application that will allow users to rent or purchase movies. I have seperate screens one for the users and one for an administrator.All the administrator does is udate,delete,add new movies from databases that I have created.
    Heres most of the code.Im using netbeans 6.5 so I will omit some generated code,Frames,buttons etc.

    Login Screen
    Java Code:
    package supadvd;
    
    
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    
    
    public class MainMenu extends javax.swing.JFrame {
    
      
        public MainMenu() {
            initComponents();
        }
    
       String ID[] = new String[999];
    
     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
         int row = 0;
         String password = jPasswordField1.getText();
    
       Connection conn = null;
    try {
    
                // Step 1: Load the JDBC driver.
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    
                // Step 2: Establish the connection to the database.
               // String url = "jdbc:odbc:contact_mgr";
    
                 String url = "jdbc:odbc:;Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\movies.mdb";
                conn = DriverManager.getConnection(url,"user1","password");
    
    
        
    
          
            } catch (Exception e) 
                jLabel9.setText("CONNECTION FAILED");
                System.err.println("Got an exception! ");
                System.err.println(e.getMessage());
            }
         try
         {
    
            Statement stmt = conn.createStatement(); 
            ResultSet rs = stmt.executeQuery("SELECT * FROM Client");
    
    
    
            for(int j = 0;j < 50;j++)
            {
             while (rs.next())
             {
              ID[row] = rs.getString("StudentId");
    
    
    
                
             if(password.equalsIgnoreCase(ID[row]))
              {
           
               ClientSelection next;
               next = new ClientSelection ();
               next.setVisible(true);
               this.hide();
            }
              
             else
             if(password.equals("oldboys"))
             {
                 Administrator follow;
                 follow = new Administrator ();
                 follow.setVisible(true);
                 this.hide();
    
             }
         
             else
             {
                  jLabel9.setText("Wrong Password");
              }
             }
    
               stmt.close();
               conn.close();
             }
             
    
            }catch(Exception e) {
                System.err.println();
            }
    Now my problem is I want the administrator to be able to delete,update,insert new data into the database from my program I dont know if you can help me.I would really appreciate it if you could though.
    Last edited by Fubarable; 08-18-2009 at 06:45 PM. Reason: code tags fixed

Similar Threads

  1. What database shall i use?
    By etherkye in forum JDBC
    Replies: 13
    Last Post: 06-26-2009, 06:03 PM
  2. database
    By kswiss in forum AWT / Swing
    Replies: 0
    Last Post: 03-26-2009, 11:51 AM
  3. help with database
    By fahien_akim in forum NetBeans
    Replies: 0
    Last Post: 03-07-2009, 01:44 PM
  4. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  5. Database in a PDA
    By percivalwcy in forum JDBC
    Replies: 2
    Last Post: 08-08-2007, 03: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
  •