Derby classpath can't connect to database

孤者浪人 提交于 2019-12-07 06:44:56

问题


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

回答1:


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.


3. Press Windows key + R, type: SystemPropertiesAdvanced, set up environment variables.


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:


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:

(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! :)



来源:https://stackoverflow.com/questions/24440222/derby-classpath-cant-connect-to-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!