Professional Documents
Culture Documents
Updated - Unit 5
Updated - Unit 5
D R . R . R A M A L A KS H M I
D R . K . M U R U G E S WA R I
M R . M . K . N AG A R A J A N
M R S . A . M .G U R U S I G A A M A N I
Course description
CO 1.Understand the objet oriented concepts using java Java still has its importance and popularity in the
software industry, in spite of recent development of
several high level languages. It has an excellent support
CO2 Apply fundamental programming concepts of Java of high-level as well as low-level functionality, which
to develop stand alone applications makes it suitable for many applications. This course
provides students with a comprehensive study of the
Java programming language. Instead of Classroom
CO 3. Solve Real World Problem through reusable and lectures, practical classes stress the strengths of Java,
error free code. which provide the students with the means of writing
efficient, maintainable, and portable code. A course
with mini project is one of the great learning
CO 4. Design and develop distributed applications. opportunities to develop students in various aspects.
This course will also help the students during their
placement sittings, as most of the companies test
CO 5. Implement window based applications using proficiency in programming using Java.
event handling mechanisms
Unit 1
– Streams – Byte streams and Character streams – Reading and Writing Console
– Reading and Writing Files - abstract classes and methods - final methods and
classes
Lesson 4. JDBC
Lesson 4. JDBC
All the previously mentioned workers run together on a solitary machine simultaneously.
Subsequently, one machine may run Multiple workers and Clients together.
Customer and worker measures convey over the organization to trade information in type of
solicitation and reaction.
Clients and Servers are extraordinarily distinguished on a solitary machine by remarkable Port
Numbers.
Extraordinary Port Number is appointed by OS.
Interaction can ask wanted port number from OS, or OS will allocate next accessible port
number to a cycle.
Port number is a two bytes unsigned number going from 0-65535.
At the point when you bring somebody over telephone and start discussion, you follow
convention.
First you welcome and say "Hi", then, at that point you tell your name "I'm Vijay", then, at that
point you ask with whom you need to talk "May I converse with Tisha?".
In like manner when discussion is over you say "Bye" and other would react "Have a Good Day".
This is Protocol
Applications Layer:
Contains client custom and undeniable level application conventions like HTTP,FTP,SMTP, Telnet
and so on
Transport Layer:
Contains TCP or UDP conventions, liable for making information bundles and send or get across
Network.
Your custom application will impart to this layer.
Network Layer:
Contains IP convention that utilizations steering data to choose course of information bundle to
send it to the objective.
Link Layer :
Converts information into signals.
UDP(User Datagram Protocol):It is a show that sends self-ruling heaps of data(called datagrams)
beginning with one PC then onto the following with NO confirmation about appearance.
Example applications:
Clock server
Ping
socket is an association between two hosts. It can perform seven essential tasks:
Associate with a distant machine
Send information
Get information
Close an association
Tie to a port
Tune in for approaching information
Acknowledge associations from far off machines on the bound port
When an association has been set up, a more significant level convention guarantees, which is
subject to which port you are utilizing.
TCP/IP saves the lower 1024 ports for explicit conventions. A large number of these will appear
to be recognizable to you on the off chance that you have invested any energy riding the
Internet.
Port number 21 is for FTP; 23 is for TELNET; 25 is for email; 80 is for HTTP; 110 is for netnews
and some more.
It is dependent upon every convention to decide how a customer ought to collaborate with the
port.
Techniques
InetAddress getInetAddress( ) - Returns the InetAddress related with the Socket object. It returns invalid if the
attachment isn't associated.
int getPort( ) - Returns the far off port to which the conjuring Socket object is associated. It returns 0 if the attachment
isn't associated.
int getLocalPort( ) - Returns the neighborhood port to which the summoning Socket object is bound. It returns {1 if the
attachment isn't bound.
A worker program makes a specic sort of attachment that is utilized to tune in for customer
demands (Server Socket), For the situation of an association demand, the program makes
another Socket through which it will trade information with the customer utilizing input and
output streams.
.
© Kalasalingam academy of research and education 42
Creating Client Program
The URL gives a sensibly intellible structure to extraordinarily distinguish or address data on the
Internet.
URLs are omnipresent; each program utilizes them to recognize data on the Web.
Inside Java's organization class library, the URL class gives a basic, brief API to get to data across
the Internet utilizing URLs.
Java's URL class has a few constructors; each can toss a MalformedURLException.
One ordinarily utilized structure indicates the URL with a string that is indistinguishable from
what you see showed in a program.
. 46
© Kalasalingam academy of research and education
URL Class
The following two types of the constructor permit you to separation the URL into its segment
parts:
URL(String protocolName, String hostName, int port, String way) tosses MalformedURLException
URL Connection is a broadly useful class for getting to the qualities of a distant asset.
When you make an association with a distant worker, you can utilize URL Connection to review
the properties of the far off object before really shipping it locally. These ascribes are uncovered
by the HTTP convention particular.
Topic 2
Protocol stack
Topic 3
TCP/IP & UDP Protocols
Topic 4
Working with Java
Topic 5
Lesson 4. JDBC
Class ServerSocket makes a TCP worker and hangs tight for Client demand.
ServerSocket ss=new ServerSocket(4444);
socket client=ss.accept();
server will undoubtedly port number 4444.
server is hanging tight for customer demand by calling technique ss.accept().
.
© Kalasalingam academy of research and education 71
DatagramSocket
The first makes a Datagram Socket bound to any unused port on the nearby PC.
The second makes a Datagram Socket bound to the port indicated by port.
The third develops a Datagram Socket bound to the predetermined port and Inet Address.
The fourth develops a Datagram Socket bound to the predetermined Socket Address.
DatagramSocket characterizes Two most significant strategies are send() and get() , which are
displayed here:
void send(DatagramPacket bundle) tosses IOException
void receive(DatagramPacket bundle) tosses IOException
The send() strategy sends bundle to the port indicated by parcel.
The get() strategy trusts that a bundle will be gotten from the port indicated by parcel and
returns the outcome.
The main constructor indicates a support that will get information and the size of a bundle. It is
utilized for getting information over a DatagramSocket.
The subsequent structure permits you to determine a balance into the cradle at which
information will be put away.
The third structure indicates an objective location and port , which are utilized by a
DatagramSocket to figure out where the information in the parcel will be sent.
The fourth structure sends parcels starting at the predetermined balance into the information.
With UDP you simply send parcels of information (datagrams) to some IP address on the
organization. You have no assurance that the information will show up. You likewise have no
assurance about the request which UDP bundles show up in at the recipient. This implies that
UDP has less convention overhead (no stream honesty checking) than TCP.
UDP is fitting for information moves where it doesn't make any difference if a parcel is lost on
the move. For example, envision an exchange of a live TV-signal over the web.
The byte support (the byte exhibit) is the information that will be sent in the UDP datagram. The
length of the above support, 65508 bytes, is the greatest measure of information you can send
in a solitary UDP bundle. The length given to the DatagramPacket constructor is the length of the
information in the cradle to send. All information in the support after that measure of
information is disregarded.
.
© Kalasalingam academy of research and education 79
Sending and Receiving Data via a
DatagramSocket(Cond..)
Topic 2
Sockets
Topic 3
Creation of UDP Server & Client
Topic 4
Echo Server
Topic 5
Lesson 4. JDBC
.
© Kalasalingam academy of research and education 89
Database
Data independence
Applications not dependant on how information put away or got to.
Applications can have various perspectives on information
Change stockpiling/recovery methodology without evolving applications.
Data dependency
Change away or recovery procedure powers program change. .
Database language
-Host languages
◦ Used to get to information base
◦ Can utilize significant level dialects Java,C,C++,Visual Basic, COBOL,PL/I, Pascal
-Database sublanguage(DSL)
◦ Indicates of data set articles and activities
◦ Blend of Data definition language(DDL) and Data Manipulation
Language(DML)
In the above table, “Employee” is the table name, “EMP_NAME”, “ADDRESS” and “SALARY” are
the column names. The combination of data of multiple columns forms a row e.g “Ahsduibf”,
“DELHI”, and “150000”.
A distributed information base is a data set in which stockpiling gadgets are not all appended to
a typical handling unit like the CPU, constrained by a circulated data set administration
framework. It very well might be put away in numerous PCs, situated in a similar actual area; or
might be scattered over an organization of interconnected PCs.
Cons
-Intricacy
- Economics
- Security
- Difficult to look after trustworthiness
A relational database is a data set that has an assortment of tables of information things, which
is all officially depicted and coordinated by the social model.
Created tables
- Rows called records(tuples)
- Columns are fields(attributes)
First field typically essential key
- Unique for each record
- Primary key can be more than one field.
- Cannot permit invalid qualities
Topic 2
SQL Tables
Topic 3
Distributed Database
Topic 4
Relational Database
Lesson 4. JDBC
Benefit
Simple to utilize
Permit simple availability to all information base upheld by the ODBC Driver.
Hindrance
Moderate execution time
Reliant upon ODBC Driver.
Utilizations Java Native Interface(JNI)
.
© Kalasalingam academy of research and education 107
JDBC 4.0 API
java.sql
javax.sql
java.sql bundle - This bundle incorporate classes and interface to perform practically all JDBC
activity, for example, making and executing SQL Queries.
java.sql.Connection - makes an association with specic data set
java.sql.CallableStatement - Execute put away methods
java.sql.Driver - make an occurrence of a driver with the DriverManager.
java.sql.DriverManager - This class oversees data set drivers.
java.sql.PreparedStatement - Used to make and execute defined question.
java.sql.ResultSet - It is an interface that give techniques to get to the outcome column by-line.
java.sql.Statement - This interface is utilized to execute SQL explanations.
The following 5 steps are the basic steps involve in connecting a Java
application with Database using JDBC.
Register the Driver
Create a Connection
Create SQL Statement
Execute SQL Statement
Closing the connection
Register the Driver
Class.forName() is used to load the driver class explicitly.
Example to register with JDBC-ODBC Driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Topic 2
JDBC Structure
Topic 3
Drivers
Topic 4
JDBC 4.0 API
Topic 5
JDBC Connection
Fourth Lesson Summary
Understand about Java Database connectivity, its structure, JDBC
& ODBC Drivers, Steps to connect to a Database, JDBC Application
Programming Interface, Example Program for JDBC Connection
Lesson 4. JDBC
In the realm of Teradata, every nation has one national bank and its own installment door related with it. They all are
associated with one another using tree geography. On the off chance that a client is attempting to move assets from
country to then the assets need to move through all transitional banks connecting and .
Tree geography is organized like a tree, where it's anything but a root hub, middle hubs and leaves. Root hub is the head
hub of the construction, and the leaves are the last hubs, which has no further youngster hubs. This construction is
organized in a various leveled structure, every hub can have quite a few the kid nodes.
Let's say there are central banks in the Teradata world and every one of them are exceptionally numbered between .
Root bank will be addressed by . All edges are bidirectional in nature, i.e., an assets can stream toward any path. It is
ensured that there will be by and large one way between each pair of banks. There will be connections which will be
utilized to interface the banks.
Topic 2
Case Study 2:UDP Server
Topic 3
Case Study 3:JDBC Connection