 <p>Check this code. Yo have to create a class with any name example conexionDB, and into the class put the next code:</p> <pre><code>import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * * @author programmerhn */ public class ConexionDB { private Connection con; /** * */ public void Conectar() { try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); con = DriverManager.getConnection("jdbc:derby://localhost:1527/accounts", "username", "password"); System.out.println("Connection successfully"); }catch( ClassNotFoundException | SQLException e) { System.out.println(e.getMessage()); } } } </code></pre>