Connect to the Derby file database

I want to work with a file database using apache derby. I was wondering if anyone could figure out how to connect and create this database using netbeans as an IDE. I went through the derby guides trying to figure it out, but all I got was the Derby JDBC Database Connection Embedded Connection, which I was told is a non-file based approach, and in any case the connection does not seem to work . any help would be much appreciated

+5
source share
4 answers

When you download NetBeans 7.1.2, the "Everything" package you get with it the Glassfish application server. After installing w / glassfish in the IDE, you should select the Services tab> Deploy Databases and you should see Java DB. R. Click on Java DB and select "Start Server". Then R. Press again and select "Create Database". Enter your username, username and password. BTW I usually use APP for the user and password, because in this way it also becomes the default scheme, and I do not need to change anything for the production environment.

Java DB . R. connect. , " ". , APP, , , . R. "", " ", ui, . , . ide - Execute, DDL . db, script .sql , db .

dbinit.sql script, .

create table usertable (
    username varchar(128) NOT NULL CONSTRAINT USER_PK PRIMARY KEY ,
    password varchar(128) NOT NULL,
    email varchar(128) NOT NULL,
    firstname varchar(128) NOT NULL,
    lastname varchar(128) NOT NULL
);

create table grouptable(
    username varchar(128) NOT NULL,
    groupid  varchar(128) NOT NULL,
    CONSTRAINT GROUP_PK PRIMARY KEY(username, groupid),
    CONSTRAINT USER_FK FOREIGN KEY(username) REFERENCES usertable(username)
        ON DELETE CASCADE ON UPDATE RESTRICT
);

insert into usertable(username,password,firstname,lastname) 
    values ('admin', '21232f297a57a5a743894a0e4a801fc3','','');
insert into grouptable(username,groupid) values ('admin', 'USER');
insert into grouptable(username,groupid) values ('admin', 'ADMIN');

, , , R. , , . script, .

enter image description here

, !:)

+1

, URL- jdbc : jdbc:derby:foo;create=true, foo . , . jdbc:derby:/home/me/foo;create=true.

, URL-, ;create=true.

, . System.setProperty("derby.system.homeSystem.setProp", "/home/bar/whatever");. , , , . , URL- , .

+4

, , , derby.jar. , " ", , netbeans, .

wireshark/tcpdump/nmap , .

Derby , , , ar/w, .

  • : mkdir -p $HOME/opt/derby cd ~/opt/derby.
  • db.apache.org $HOME/opt/derby/
  • : ln -s pwd/version pwd/latest.
  • : ln -s pwd/latest pwd
  • Netbeans .

netbeans:

  • Ant "ASF-Derby-Emb.": → Ant - > .
  • /home/ [loginid]/opt/derby/default/lib/derby.jar , , derbytools.jar.
  • , .
  • javadoc /home/ [loginid]/opt/derby/default/javadocs

, ASF-Derby-Emb, "dist".

JavaDB.

  • "": "" > "" .
  • JavaDB JavaDB, .
  • JavaDB "", .
  • JavaDB: $HOME/opt/derby/default.
  • , , , /.
  • "", JavaDB.

, , . , URL: jdbc: derby:// .

, .

  • JavaDB " " , , .
  • : JavaDB .

:

  • , , ..
  • sql sql, .. .
  • : Service- > jdbc: derby://??? , , sql.

, (2) , , . sql- .sql, , sql .

(3) script.

. . , - , , netbeans, .

+2

Derby, Derby

. startNetworkServer.bat bin. , № 1527.

java-:

DriverName = org.apache.derby.jdbc.ClientDriver

ConnectionString = jdbc: derby://localhost: 1527/schema_name; create = true

, , .

run ij.bat located inside the bin directory. then on the command line:

connect 'specify connection url here

and you can run sql queries like oracle prompt.

If you want to start the derby server on a different port, run the following command in cmd:

startnetworkserver.bat -p 1234

0
source

All Articles