Hi,
I'm creating a distributable desktop application to view an EMBEDDED Derby/JavaDB.
I need to create a connection to an EMBEDDED JavaDB database - I created it initially in Netbeans 7.4. The ONLY tutorial about EMBEDDED Derby/JavaDB is this one Embedded Derby Database In JAVA Application - Tutorial - YouTube. There are no others!
All I want to know is how to code for an EMBEDDED Derby/JavaDB - as you can see below I've actually copy and pasted the database into the classpath. The coding for the connection (which is not good) is this:
package digitalcatalogue; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; public class ConnectDB { public static final String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver"; public static final String JDBC_URL = "jdbc:derby:sitw;create=true"; public static void main(String[] args) throws ClassNotFoundException SQLException{ Class.forname("org.apache.derby.jdbc.EmbeddedDriver"); Properties p = new Properties(); p.setProperty("user","DCproject"); p.setProperty("password", "DCproject"); p.setProperty("create","true"); Connection conn = DriverManager.getConnection("jdbc:derby:classpath:sitw", p); System.out.println("Table created successfully."); } }
I'm new at Java but please no suggestions unless they are rock solid because otherwise I'll just go round in circles.
I've read the Derby developers guide from Apache and noticed that there doesn't need to be any JPA file because an EMBEDDED Derby/JavaDB has its own persistence.
Best regards and thanks for all help provided.