1

I am developing a java desktop application with Java Embedded DB integrated into the NetBeans 7.2 IDE The database was created using the IDE and it is separate from the front end for now. Now I want to connect the database to the front end. When I try, it gives me a server not found error. below are codes snippets.

 static final String host   = "jdbc:derby:Wa_Poly";
 static final String uName  = "chief";
 static final String uPass  = "12345";    

the code for the connection is :

    /* Connecting to the database */
    Connection  con = DriverManager.getConnection(host, uName, uPass);
    Statement stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,  
    ResultSet.CONCUR_UPDATABLE);
    String sql = "SELECT * FROM APP.ALUMNUS";
    ResultSet rs = stmt2.executeQuery(sql); 
    populateIndex(rs, Scrollable);

this is the error given:

Jul 17, 2014 2:40:40 PM SearchEngine.SearchDB searchDatabase
SEVERE: null
java.sql.SQLException: Database 'Wa_Poly' not found.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at SearchEngine.Index.buildIndex(Index.java:118)
at SearchEngine.SearchDB.searchDatabase(SearchDB.java:96)
at wa_poly.MyJFrame.<init>(MyJFrame.java:47)
at wa_poly.MyJFrame$5.run(MyJFrame.java:292)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

Caused by: java.sql.SQLException: Database 'Wa_Poly' not found.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown 

Source) ... 32 more

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at SearchEngine.SearchDB.searchDatabase(SearchDB.java:105)
at wa_poly.MyJFrame.<init>(MyJFrame.java:47)
at wa_poly.MyJFrame$5.run(MyJFrame.java:292)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)

any idea to solve the problem is welcomed.

CodeAngel
  • 569
  • 1
  • 11
  • 31

1 Answers1

1

this is not enough :

jdbc:derby:Wa_Poly

for a embedded connection must be something like

jdbc:derby:C:/Dokumente und Einstellungen/Administrator/.netbeans-derby/Wa_Poly

look at my answer here
embedded Derby

EDIT

Right click Services -> JavaDB -> create database

look where your database folder is.

enter image description here

Community
  • 1
  • 1
moskito-x
  • 11,832
  • 5
  • 47
  • 60
  • thanks for the reply. I ave checked the netbeans in this location 'C:\Users\Faisal\.netbeans-derby'. But the database is not found. Also the URL for the database as seen from the properties window is 'jdbc:derby:Wa_Poly;;create=true'. Looks like the database is missing.Any suggestion. – CodeAngel Jul 18 '14 at 01:58
  • Followed the edited suggestions but still get the error. Looks like netbeans creates the database at a different location. but not in the .NetBeans folder – CodeAngel Jul 18 '14 at 03:53
  • @CodeAngel : Create with Netbeans a new Database . How to, look above. And search with your System search for that file. – moskito-x Jul 18 '14 at 11:52
  • Was not able to fix the problem. To get around it , I used the java.sql.DriverManager.getConnection() method to create a database. Then used the absolute path to the database and the Java DB(Embedded) driver in the IDE to connect to the database. – CodeAngel Jul 28 '14 at 11:25
  • @CodeAngel : so can you please accept my answer , because it works for all my databases. – moskito-x Jul 28 '14 at 11:47