title: Store and view images in JAVA database - Netbeans
body: <p>I am creating a simple photo catalogue using JAVA and Netbeans. I have the basic Swing layout all OK and I can store and retrieve text/number etc from/to the database, delta records etc etc. This is all Fine.</p>
  
  <p>I am really not sure how to go about storing the images and viewing them in the jFrame.</p>
  
  <p>I want to store the images as a file path I think (as opposed to BLOB) as I have read this is better?</p>
  
  <p>I am using getText and setText to display the database entries on the form at present and this is all fine. Like below:</p>
  
  <pre><code>String location = rs.getString("Location");
  
  textLocation.setText(location);
  </code></pre>
  
  <p>I am using the JavaDB derby database connection.</p>
  
  <p>I have searched for a tutorial but have not had much luck. There are tutees fro images etc but not really how to store/retrieve them from a database.</p>
  
  <p>If anyone can point me in the right direction or to a good tutorial covering this that would be grand.</p>
  
  <p><strong>* UPDATE *</strong></p>
  
  <p>Thanks for the help. I thought I would just share what ended up working.</p>
  
  <p>Set path to location of images folder:</p>
  
  <pre><code>private static final String PATH = "/images/";
  </code></pre>
  
  <p>Assign string</p>
  
  <pre><code>String image = rs.getString("ImageURL");
  </code></pre>
  
  <p>Add image to label</p>
  
  <pre><code>image_label.setIcon(new javax.swing.ImageIcon(getClass().getResource(PATH + image)));
  </code></pre>
  
  <p>Thanks again.</p>