Upload
prathap-kumar
View
104
Download
0
Embed Size (px)
Citation preview
Database
Database is a permanent location to store our application data. it holds the data in tabular format. in general we will do normalization to store the data.
what is normalization?decomposition of schema into sub schemas is called normalization. in normalization primary
and foreign key plays main role. we make relation between parent and child tables using Primary and Foreign Key's.
Primary Key - this we use on parent table field, it won't allow duplicates and NULL values to insert.Foreign Key - this we use in child table field. it references to parent table.
simple example in the form of Tables. my parent Table is Emp and child table id Dept.
Emp tableNo (Primary Key) First Name Last Name Sal1 Abc Xyz 100002 Abc1 Xyz1 200003 Abc Xyz2 30000
in the above table if we try to insert the same number in the "No" field, it raise primary key violation exception.in the above table if we try to insert "NULL" in the "No" field, is raise "NULL values not allowed" exception.
Dept TableNO (Primary Key) Name Type Emp No(Foreign Key
References Emp Table "No" field)
1 A1 A1 12 B1 B1 13 A1 A1 24 A1 A1 3
one parent may have 0 or many child's. if we observe "Emp No" field has duplicate values.foreign key always references to primary key, without primary key there is no foreign key.
SQL ?it is a query language to do CRUD operations on Tables. CRUD stands for Create, Read,
Update and Delete. the following are the queries we use to do CRUD operations.
Select *from EMP - it fetches all the records from Table.Select *from EMP where No=1 - it fetches records based on condition, with the "No" field values equals to "1".Insert into EMP values() - it inserts the data in Table. like we have queries to Update and delete the records in table.
Procedure in Database?is used to execute multiple SQL statement in a single request. in procedure we write
multiple queries. if we execute the procedure, internally it process all the queries.
DB AdapterThe purpose of DB adapter to execute SQL commands and procedures. In general we need
to write some java code to execute SQL commands. But on behalf Adapter doing that task. Just we need to provide some configuration like JNDI name of connection pool and need to provide SQL operation what we want to do.
while working on DB Adapter we have to focus on following steps Creation of Data Source Configure Data Source in DB Adapter and Update DB Adapter Using DB Adapter in Application.
Creation of Data Sourcewe need to create Data Source in web logic console. login into web logic console using
credentials(http://localhost:7001/console).
click on Service -> Data Sources -> New -> Generic Data Source
enter the following properties
Name : we should provide the name, but it should be your choiceJNDI Name : we should provide the name, but it should be your choice, the following is the format we have to maintain, it is not Mandatory, but it is a specification we should follow.
jdbc/name on your choice
Note : if we provide name as "SOADataSource", it is good to provide JNDI name as "jdbc/SOADataSource"
Database Type : Select the Database from the list and then click "Next"
in this screen select Database Driver and Click on Next.
we have two different types of Database drivers, XA and non-XA. this i will explain later while explaining about transaction management.
in this screen, just Click on Next
In this screen we need to provide Database details like Database Name, Host Name, Port, Database User Name, Password, and Confirm Password and then Click on Next
the above details related to my Database.
In this screen click on "Test Configuration" - it validates our configuration, if everything went well it shows success message.
in this server select the server to deploy data source and click on finish
Configure Data Source in DB Adapter and Update DB Adapter
DB Adapter in ApplicationDB adapter application in server
Data Source Created in server
Why we need to configure Data Source in DB Adapter?if we are using DB adapter in our application, when we run our application, DB Adapter in
our application communicates to DB Adapter available in server, DB Adapter avilable in server communicates to data source to get the connection. using that connection we can communicate to Database.
following are the steps to configure Data Source in DB Adapter...
Login into web logic console -> Deployments
Then click on DbAdapter available in list
Then Select Configuration -> Outbound Connection Pools -> New
select javax.resource.cci.ConnectionFactory and click on "Next"
provide then JNDI name and click on "Finish", name is mandatory, but it should follow the bellow specification, it is not mandatory to maintain like this, but we should follow, eis/DB/some nameeg: eis/DB/SOADataSource2
then it navigates the following screen...then extract the javax.resource.cci.ConnectionFactory, we found JNDI name what we created in previous step
then click on JNDI name, we will navigate to following screen, the default value in XA Data Source id empty, we should provide the data source JNDI name what we created in first step.
then click on "save".
Once Again click on deployments - > select DbAdapter Check Box ->Click on "Update", it navigates to following page.
select the option "Redeploy this application using the following deployment files", then click on "Next", in next Screen click on "Finish".
Using DB Adapter in Applicationwe need to drag and drop into external reference or exposed service area in composite.
while working with DB polling option we drag and drop in Exposed services area, in remaining scenarios we place in external reference area.
Open JDeveloper IDE and create project (for creating project in Jdeveloper, please follow the document " Creating Project in JDeveloper.docx"), Drag and drop the Database Adapter from service Adapters location.