Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Derby classpath can't connect to database

I just installed derby and I followed the instructions from here the exact same way it told me to but replacing the paths with my paths. But for some reason why i try to create a connection to connect to create a Database and run my sql scripts to create the tables and populate them it gives me a few errors firstly is this one

ERROR 08001: No suitable driver found for jdbc:derby:SuperMarket;create=true

Then when my sql scripts run I get this error

IJ ERROR: Unable to establish connection

I dont see what I did wrong this is the line i used to set the class path

C:\> set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;.

I included the derby.jar file that was needed so I can't see the problem does anyone know what I did wrong? Also when I run

 connect 'jdbc:derby://localhost:1527/MyDB';

The server starts fine

C:\Derbs\db-derby-10.10.2.0-bin\bin>startNetworkServer
Thu Jun 26 11:56:38 PDT 2014 : Security manager installed using the Basic server
 security policy.
Thu Jun 26 11:56:39 PDT 2014 : Apache Derby Network Server - 10.10.2.0 - (158244
6) started and ready to accept connections on port 1527
like image 610
user3780970 Avatar asked Oct 31 '22 21:10

user3780970


1 Answers

There are many troubles when I start using DerbyDB. It is really painful to practice.

1. For example, I download Derby from http://db.apache.org/derby/derby_downloads.html#Latest+Official+Releases

2. Unzip to C:\tools\db-derby-10.11.1.1-bin. enter image description here


3. Press Windows key + R, type: SystemPropertiesAdvanced, set up environment variables. enter image description here
Reference: https://db.apache.org/derby/docs/10.0/manuals/getstart/gspr16.html


4. Run cmd, We should run additional command:

C:\tools\db-derby-10.11.1.1-bin\bin\NetworkServerControl.bat

and type:

C:\tools\db-derby-10.11.1.1-bin\bin\ij.bat

then press Enter, and result: enter image description here


5. We will put in-memory Derby database to D:\ directory. Folder vy1 must doesn't exit. We type command for creating new database named vy1:

connect 'jdbc:derby:D:\vy1;create=true';

Use Windows Explorer, go to directory D:\vy1, you will see new folder named vy1 just created.

then type command:

connect 'D:\vy1'


6. See SQL command to create database, table, insert, then read database like this:

enter image description here

(Open images in new web page is better for view. Note: This is my old screenshot when I use older version few months ago).

Come back to your question, focus at section 3, and commnand call NetworkServerControl.bat at section 4.

Good luck! :)

like image 53
Do Nhu Vy Avatar answered Nov 15 '22 06:11

Do Nhu Vy