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 8 of 8

Thread: a tool to distribute netbeans java application with java database

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default a tool to distribute netbeans java application with java database

    I developped a java application using netbeans but I have a problem with the distribution of my application after building I find a jar file but when I execute it with the netbeans IDE cloesed the database is not working !!! I there any tool that gives a jar file onsidering my database!!


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: a tool to distribute netbeans java application with java database

    Here's a first stab at a resource for you, but it may give you other ideas. We may be able to give you specific advice if you post the error message.

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: a tool to distribute netbeans java application with java database

    I tried to follow this tutorial many times but my problem is that the database connection is not established when te IDE is closed! I have to do it manually from netbeans. but the jar file is created and it runs but without the foncionalities related to the database. I am using derby driver like it is clear in the picture Sans titre.jpg
    Thank you

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: a tool to distribute netbeans java application with java database

    The graphic is near impossible to read. Not your fault but a good idea not done well.

    Again, it's difficult to help without seeing the code that loads/connects the database and the actual error message. Post error messages from the console that occur when the deployed .jar file is run.

    Just guessing, I suspect your source code points to the database using its location on your hard drive, specifying either a relative or full path name. That likely is failing in the .jar file, because the file isn't located where the source code is looking. I haven't done it with a database for a while, but with graphics the desired object in the .jar file is loaded as a resource using getClass().getResource(). I suspect you need to do similarly for the database file.

    Search for advice deploying a java app with a database file.

  5. #5
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: a tool to distribute netbeans java application with java database

    Thank you very much for your answer
    this is the code of the connection try {
    String url = "jdbc:derby://localhost:1527/";
    String dbName = "Data_base";
    String driver = "org.apache.derby.jdbc.ClientDriver";
    String userName = "jebali";
    String password = "Mypassowrd";

    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url + dbName, userName, password);

    System.out.println("Connected to the database");
    } catch (Exception e) {
    System.out.println("erreur");
    e.printStackTrace();

    // System.out.println("exception"+e.getClass());

    }
    When building I don't have error messages and I get my jar but when i execute it when netbeans is closed the database connection is not established so all the tasks depending on the database are not done.

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: a tool to distribute netbeans java application with java database

    Oh yeah, the server piece.

    I'm not familiar with the Netbeans jdbc plugin (or whatever it's called), but I'll assume the database server services are being started/managed by Netbeans as needed when you run this app in Netbeans. How does your app start or ensure the readiness of the necessary database server services on another client?

  7. #7
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: a tool to distribute netbeans java application with java database

    In deed It is the only way that I found is to start manually the database server!
    even in netbeans tutorial it is the only described way
    https://netbeans.org/kb/docs/ide/java-db.html#starting
    Thank you!!

  8. #8
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: a tool to distribute netbeans java application with java database

    I uesed this code in order to start the server

    NetworkServerControl server = new NetworkServerControl();
    server.start (null);

    And this code in order to connect the database

    String url = "jdbc:derby://localhost:1527/";

    String dbName = "Data_base";
    String driver = "org.apache.derby.jdbc.ClientDriver";
    String userName = "jebali";
    String password = "barbara";

    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url+dbName , userName, password);

    System.out.println("Connected to the database");

    but the problem that the connexion is not established and this is the error
    run:

    java.sql.SQLNonTransientConnectionException: La connexion a été refusée car la base de données Data_base n'a pas été trouvée.
    at org.apache.derby.client.am.SQLExceptionFactory40.g etSQLException(Unknown Source)
    at org.apache.derby.client.am.SqlException.getSQLExce ption(Unknown Source)
    at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager .java:579)
    at java.sql.DriverManager.getConnection(DriverManager .java:221)
    at OBSME.OBSME.main(OBSME.java:2353)
    Caused by: org.apache.derby.client.am.DisconnectException: La connexion a été refusée car la base de données Data_base n'a pas été trouvée.
    at org.apache.derby.client.net.NetConnectionReply.par seRDBNFNRM(Unknown Source)
    at org.apache.derby.client.net.NetConnectionReply.par seAccessRdbError(Unknown Source)
    at org.apache.derby.client.net.NetConnectionReply.par seACCRDBreply(Unknown Source)
    at org.apache.derby.client.net.NetConnectionReply.rea dAccessDatabase(Unknown Source)
    at org.apache.derby.client.net.NetConnection.readSecu rityCheckAndAccessRdb(Unknown Source)
    at org.apache.derby.client.net.NetConnection.flowSecu rityCheckAndAccessRdb(Unknown Source)
    at org.apache.derby.client.net.NetConnection.flowUSRI DPWDconnect(Unknown Source)
    at org.apache.derby.client.net.NetConnection.flowConn ect(Unknown Source)
    at org.apache.derby.client.net.NetConnection.<init>(U nknown Source)
    at org.apache.derby.client.net.NetConnection40.<init> (Unknown Source)
    at org.apache.derby.client.net.ClientJDBCObjectFactor yImpl40.newNetConnection(Unknown Source)
    ... 4 more
    erreur1
    java.lang.NullPointerException
    at OBSME.OBSME.<init>(OBSME.java:128)
    at OBSME.OBSME$31.run(OBSME.java:2365)
    C:\Program Files\Java\jdk1.7.0_04\bin;C:\Windows\Sun\Java\bin ;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\Sys tem32\Wbem;C:\Windows\System32\WindowsPowerShell\v 1.0\;C:\Program Files\Windows Live\Shared;C:\Program Files\Java\jdk1.7.0_04\bin;C:\Program Files\VDownloader;C:\Program Files\MiKTeX 2.9\miktex\bin\;C:\Program Files\Apache Software Foundation\apache-maven-3.0.4\bin;.
    at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:701)
    at java.awt.EventQueue.access$000(EventQueue.java:102 )
    at java.awt.EventQueue$3.run(EventQueue.java:662)
    at java.awt.EventQueue$3.run(EventQueue.java:660)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 671)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:244)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:147)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:139)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:97)
    BUILD SUCCESSFUL (total time: 10 minutes 4 seconds)

Similar Threads

  1. Replies: 0
    Last Post: April 5th, 2013, 10:20 AM
  2. Replies: 1
    Last Post: December 21st, 2012, 10:35 AM
  3. Java Application which will distribute mails from an exchange server
    By Rednaxela in forum Java Theory & Questions
    Replies: 3
    Last Post: January 9th, 2012, 10:20 PM
  4. Replies: 0
    Last Post: December 3rd, 2009, 04:43 PM