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)