title: Java DB (Embedded) Connect using
body: <p>I have created Database named emb4 in Java using NetBeans IDE, with one table and I am trying to create application with embedded DB. I have created my embedded driver and I am using this code : </p>
  
  <pre><code>&gt;     /*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */ package embededbaza4;
  &gt; 
  &gt; import java.sql.Connection; import java.sql.DriverManager; import
  &gt; java.sql.ResultSet; import java.sql.Statement;
  &gt; 
  &gt; 
  &gt; /**  *  * @author Admin  */ public class EmbededBaza4 {
  &gt; 
  &gt;     
  &gt;      private static final String driver = "org.apache.derby.jdbc.EmbeddedDriver";
  &gt;      
  &gt;     /**
  &gt;      * @param args the command line arguments
  &gt;      */
  &gt;     public static void main(String[] args) {
  &gt;         // TODO code application logic here
  &gt;         
  &gt;         try
  &gt;         {
  &gt;             Class.forName(driver).newInstance();
  &gt;             Connection conn = null;
  &gt;             conn = DriverManager.getConnection("jdbc:derby:emb4;create=true");
  &gt;             
  &gt;         Statement st = conn.createStatement();
  &gt;         String sql = "SELECT * FROM TEKSTOVI";
  &gt;         ResultSet setRezultata = st.executeQuery(sql);
  &gt;         
  &gt;        while(setRezultata.next())
  &gt;        {
  &gt;          System.out.println(setRezultata.getString("txt"));
  &gt;        }
  &gt;        
  &gt;        
  &gt;         }
  &gt;         catch(Exception exc)
  &gt;         {
  &gt;             System.err.println("Unable to load the embedded driver."); 
  &gt;              exc.printStackTrace(System.err); 
  &gt;             System.exit(0); 
  &gt;         }
  &gt;     } }
  </code></pre>
  
  <p>But it won't connect to database I have created, rather it's creating a new database and there isn't a table I have created . How can I resolve this problem?</p>