Results 1 to 15 of 15
  1. #1
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default Help retrieving images from Access to Netbeans 6.0

    Hello fellow programmers, i am trying to "retrieve, get" an image that is stored in my Database(Access 2010)(OLE) and into my Netbeans Project. I have seen this works quite well in SQLite using the BLOB datatype. But unfortunately i will have to use Access. My Database is connected properly and i am able to view the table with its corresponding results. When i click a record in my table(Netbeans) the data is displayed in the respective Text Fields. but the image just wont show ;'(

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Help retrieving images from Access to Netbeans 6.0

    And your code?
    We're not mind readers...and my crystal ball appears to be broken.
    Please do not ask for code as refusal often offends.

  3. #3
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default Re: Help retrieving images from Access to Netbeans 6.0

    My Connection Class(100% correct):
    Java Code:
    import java.sql.*;
    import java.io.*;
    import javax.swing.JOptionPane;
    
    public class dbclass {
    
        Connection conn;
        ResultSet queryTbl;
    
    
           public dbclass()
          {
           
             try
             {
                Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
                //JOptionPane.showMessageDialog(null, "Driver successfully loaded","Connection", JOptionPane.INFORMATION_MESSAGE);
    
             }
                 catch (ClassNotFoundException c)
                {
                  JOptionPane.showMessageDialog(null, "Unable to load database driver","Connection", JOptionPane.ERROR_MESSAGE);
    
                }
    
    
          //connect to the database
             try
             {
    
                String filename = "testDB.mdb";
                String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
                database += filename.trim () + ";DriverID=22;READONLY=false}";
                conn = DriverManager.getConnection (database, "", "");
    
               //JOptionPane.showMessageDialog(null,"Connection to database successfully established","Connection", JOptionPane.INFORMATION_MESSAGE);
    
    
             }
                 catch (Exception e)
                {
                     String err = "Unable to connect to the database" + " " + e;
                   JOptionPane.showMessageDialog(null,err,"Connection", JOptionPane.ERROR_MESSAGE);
                }
          } //end connection
    
           public void updateTbl ( String sqlStmt ) throws SQLException
        {
            Statement stmt = conn.createStatement();
            stmt.executeUpdate(sqlStmt);
            stmt.close();
        }//updateTbl
    
            ResultSet queryTbl ( String sqlStmt ) throws SQLException
        {
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(sqlStmt);
            return rs;
        }//queryTbl
    
        public String quote( String S )
        {
            return "'"+S+"'";
        }
    
    
    }
    My Code:
    Java Code:
    rivate void cmd_ltableMouseClicked(java.awt.event.MouseEvent evt) {                                        
            try{
                int row = cmd_ltable.getSelectedRow();
                String Table_click = (cmd_ltable.getModel().getValueAt(row, 0).toString());
                ResultSet rs = obj.queryTbl("select * from learnerTB where LearnerID='"+Table_click+"'");
               
               
                while(rs.next()){
                    
                    fid = rs.getString("LearnerID");
                    fname = rs.getString("LearnerName");
                    s = rs.getString("LearnerSurname");
                    c = rs.getString("LearnerContactNumber");
                    sp = rs.getString("SchooName");
                    
                        
                }
                
                
                
            }catch(Exception e){
                
                
                JOptionPane.showMessageDialog(null, e);
                
                
            }
           id.setText(fid);
           name.setText(fname);
           surname.setText(s);
           number.setText(c);
           sname.setText(sp);
           Update_table();

    I just need the code to get the image
    Last edited by Tolls; 12-11-2012 at 03:24 PM. Reason: Added code tags

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Help retrieving images from Access to Netbeans 6.0

    I knew I should have mentioned [code] tags [/code].

    Anyway, where in that code are you trying to get the image?
    Your original post implies you have code that should get the image but doesn't.
    Please do not ask for code as refusal often offends.

  5. #5
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Sorry for that, well i was improvising, the code was from ProgrammingKnowledge from youtube, since it did not work i had deleted that with the mind that it is only compatible with SQlite

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Well, it's going to be the same sort of thing.
    What column type hav eyou got the image data in in the Access table?
    Please do not ask for code as refusal often offends.

  7. #7
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default Re: Help retrieving images from Access to Netbeans 6.0

    OLE and the image i tried .gif, bitmap, jpeg

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Ah.
    Of course, Access does not have a proper LOB datatype does it.

    This is where I ask if you have to use Access?
    Please do not ask for code as refusal often offends.

  9. #9
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Ahh man! Yes i have to ;'( . This was something great if it worked, i would have topped my class :D, oh well thanks a million for the help!

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Help retrieving images from Access to Netbeans 6.0

    There are ways, from Googling, but it seems to involve extracting stuff from the stream returned, which strikes me as a bit of a faff.
    You could store the images as a file, and hold the location in the DB?
    Please do not ask for code as refusal often offends.

  11. #11
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Would you be kind enough to direct to one of those sites.

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Just google.
    I expect stackoverflow has threads on Access and OLE images.
    Please do not ask for code as refusal often offends.

  13. #13
    Aash96 is offline Member
    Join Date
    Dec 2012
    Posts
    26
    Rep Power
    0

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Thanks mate.

  14. #14
    kkohuliyadda is offline Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Dear Friend,

    If you got the answer for this problem,, I mean the correct code or the way to be correct please reply me. Because i also following the programmeknowledge the you tube tutorial and same like you i got this problem. Still i couldn't answer that problem.

    I need you here :)

    Thanks in advance.

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Help retrieving images from Access to Netbeans 6.0

    Don't use Access...
    Please do not ask for code as refusal often offends.

Similar Threads

  1. how to access images
    By javaa in forum New To Java
    Replies: 10
    Last Post: 09-02-2012, 12:12 AM
  2. Request help for retrieving data from Access
    By tunali2 in forum New To Java
    Replies: 6
    Last Post: 04-04-2011, 07:59 AM
  3. NetBeans to set images for J2ME
    By oluwaphemi in forum CLDC and MIDP
    Replies: 0
    Last Post: 07-09-2010, 08:12 PM
  4. how to store images in access database
    By sridarshan in forum JDBC
    Replies: 11
    Last Post: 06-26-2010, 02:26 AM
  5. How to display Images from MS access using JSP
    By redmaverick in forum JDBC
    Replies: 3
    Last Post: 11-30-2009, 09:28 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
  •