in place of derby file, locate the obdj thin file in the ...

guitarchanceSoftware and s/w Development

Aug 15, 2012 (4 years and 11 months ago)

286 views


in place of derby file, locate the obdj thin file in the programfiles86/java/jdk1.7.0._01/bin/

create the module,

IT WORKS!!!!


To do: create step by step easy for me. Also show project for the creation of crud.


When adding this code:

Node node

= new AbstractNode(Children.LEAF, Lookups.singleton(c));


node.setDisplayName(c.getName());


node.setShortDescription(c.getCity());


return node;


it goes into the childFactory



First thing we need to do is create a connection to the database:

1.

S
ervices
-
> databases : right click

and add new connection

2.

Select oraclethin

a.

*** need to add the .jar file we got from dr. Hansen

3.

Keep XE, and 1521, enter your username and password, test connection

4.

Select schema and finish


You can view data in the new connection by right clicking a table to open sql mode


Now we are going to create a modular program.



Modular programming

is a software design technique that increases the extent to
which software is composed of separate, inter
changeable components
called

modules

by breaking down program functions into modules, each of which
accomplishes one function and contains everything necessary to accomplish this.
[1]


File
-
>new projects

1.

Select netbeans modules / platform application, select name and location and finish


Now we need to create a library

to hold entitie classes from the

database connection,

1.

File
-
> new project : java class library

….. name and

finish

2.

Right click new library : new
-
> other : entity class from database

3.

Select the connection and all the tables you want

4.

Name the package and finish



This will create the entity classes [examine the classes]



Notice the named queries and getter methods

for each of the items



Also examine the persistence file, name of item


Now we need to build the library to create a jar file, right click it and build
,

Go to files section, and view the new jar file, in dist folder


Now we are going to get

the jar file and create a module with it

Go to the manager, and modules, right click the modules and select :
ADD NEW LIBRARY

Select the jar file: mydocs / netbeans projects /
project name


library
/

dist / jar file


Code name org.csit.dblibrary that’s
org.
YOUR ORG. module name

Since modules need to be able to accomplish things on their own, an overall project sometimes needs
related modules, in our case, one for the database connection, and one for the eclisple link we use

Add the oracle.jar from :



C:pr
ogramfiles(86)/Java/jdk.1.7/bin/ jar file



Name it org.csit.oracle

WHAT IS ECLIPSE LINK?


Object
-
relational mapping

or ORM is
the category of products that provide
services to map objects to relational databases. The

Java Persistence
API

(JPA) is the Java speci
fication that provides a standard to ORM in Java.
JPA provides both a standard mapping and a standard runtime API and
object
-
level query language (JPQL

EclipseLink provides sophisticated and high performance object
-
relational
mapping services and complete
support for the JPA specification. JPA objects
are mapped through the package

javax.
persistence

annotations and JPA
persistence.xml and orm.xml. JPA provides a runtime API through
the

EntityManager

class in the javax.persistence package.


Add new library module from



Programfiles(86)/Netbeans/java/modules/ext/eclipselink

o

Select both eclipselink
-
2.2.0 and

javax.persistance
-
2.0



**YOU COULD DO THEM SEPARATE However this

would
create more modules to manage when you need both
anyways

o

org.csit.eclipselink

Next is to create the view module



right click the view module and add new


now we add the view file to the module




run on application startup and on explorer



name it
viewer


in design drag in a text area,
and show properties, also drag a button on it and
show the click event, have it add text to new box, after you name box output

we will test that out later


now, since we are in the view, we want to add some inter modu
le useage,
where this module will depend on the ones we created earlier

add this to bottom of constructor

EntityManager entityManager =
Persistence.createEntityManagerFactory("deleteLibraryPU").createEntityMan
ager();


Query query =
entityManager.createQuery("SELECT p FROM Personnel
p");


List<Personnel> resultList = query.getResultList();


for (Personnel c : resultList) {


outputArea.append(c.getName() + " (" + c.getRank() + ")" + "
\
n");


}



Now notic
e that there are problems
with the syntax, It doesn’t know what
some of the stuff is. Notice earlier I said
they depend on other modules, we
need to set these dependancies,

The entity library needs, both eclipse, and oracle

Viewer needs entity and the ec
lipse


Right click and fix imports!



You are able to automatically fix the imports, you don’t have to mess
with any dependencies yourself, imports are handled automatically


Notice there is still an error for query, hover over it and see that it expects
the
persistence, and it fixes it.


Set as main project and run


AND WE PULLED DATA, also have lots of features built in already,

And the click button also works!


Now we can do more.. run the other one and show some features.


Also show new project. Java

desktop app, from database, …..