Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: EMBEDDED derby/javaDB connection problem

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    10
    My Mood
    Confused
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default EMBEDDED derby/javaDB connection problem

    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.


  2. #2

    Default Re: EMBEDDED derby/javaDB connection problem

    The root directory doesn't load, find the location on the Database, eg C:\Users\xxx.netbeans-derby\dataBaseName copy it and paste it as the database Java DB(Embedded) name. Your new JDBC URL: is now jdbc:derby:C:\Users\xxx.netbeans-derby\dataBaseName Test the connection and the path should connect.

  3. #3
    Junior Member
    Join Date
    Feb 2019
    Location
    middletown
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: EMBEDDED derby/javaDB connection problem

    I create database and table as your instruction in video tutorial and its work successfully..... but when I run the program its says table already exits...... what should I do?

Similar Threads

  1. Embedded Derby & SE GUI (Netbeans 7.4)
    By Chaotic in forum JDBC & Databases
    Replies: 9
    Last Post: September 7th, 2014, 02:15 PM
  2. problem in Derby embedded database connection
    By brother in forum JDBC & Databases
    Replies: 6
    Last Post: December 24th, 2012, 02:17 PM
  3. where is my JavaDB/Derby?
    By chronoz13 in forum JDBC & Databases
    Replies: 3
    Last Post: December 9th, 2012, 09:00 PM
  4. Replies: 0
    Last Post: April 3rd, 2011, 10:58 AM
  5. Help with JavaDB embedded
    By jstn455 in forum JDBC & Databases
    Replies: 2
    Last Post: March 17th, 2011, 03:27 PM

Tags for this Thread