| What are the types of JDBC Driver Models and explain them?
There are two types of JDBC Driver Models and they are:
a) Two tier model and
b) Three tier model
Two tier model: In this model, Java applications interact directly
with the database. A JDBC driver is required to communicate with the particular
database management system that is being accessed. SQL statements are sent
to the database and the results are given to user. This model is referred
to as client/server configuration where user is the client and the machine
that has the database is called as the server.
Three tier model: A middle tier is introduced in this model.
The functions of this model are:
a) Collection of SQL statements from the client and handing it over
to the database,
b) Receiving results from database to the client and
c) Maintaining control over accessing and updating of the above.
What are the steps involved for making a connection with a database
or how do you connect to a database?
a) Loading the driver : To load the driver, Class. forName() method
is used. Class. forName(”sun. jdbc. odbc. JdbcOdbcDriver”); When the driver
is loaded, it registers itself with the java. sql. DriverManager class
as an available database driver.
b) Making a connection with database: To open a connection to a given
database, DriverManager. getConnection() method is used. Connection con
= DriverManager. getConnection (”jdbc:odbc:somedb”, “user”, “password”);
c) Executing SQL statements : To execute a SQL query, java. sql. statements
class is used. createStatement() method of Connection to obtain a new Statement
object. Statement stmt = con. createStatement(); A query that returns data
can be executed using the executeQuery() method of Statement. This method
executes the statement and returns a java. sql. ResultSet that encapsulates
the retrieved data: ResultSet rs = stmt. executeQuery(”SELECT * FROM some
table”);
d) Process the results : ResultSet returns one row at a time. Next()
method of ResultSet object can be called to move to the next row. The getString()
and getObject() methods are used for retrieving column values: while(rs.
next()) { String event = rs. getString(”event”); Object count = (Integer)
rs. getObject(”count”);
What type of driver did you use in project?
JDBC-ODBC Bridge driver (is a driver that uses native(C language) libraries
and makes calls to an existing ODBC driver to access a database engine).
What are the types of statements in JDBC?
Statement: to be used createStatement() method for executing single
SQL statement PreparedStatement — To be used preparedStatement() method
for executing same SQL statement over and over. CallableStatement — To
be used prepareCall() method for multiple SQL statements over and over.
What is servlet?
Servlets are modules that extend request/response-oriented servers,
such as java-enabled web servers. For example, a servlet might be responsible
for taking data in an HTML order-entry form and applying the business logic
used to update a company’s order database.
What is the difference between an applet and a servlet?
a) Servlets are to servers what applets are to browsers.
b) Applets must have graphical user interfaces whereas servlets have
no graphical user interfaces.
What is the difference between doPost and doGet methods?
a) doGet() method is used to get information, while doPost() method
is used for posting information.
b) doGet() requests can’t send large amount of information and is limited
to 240-255 characters. However, doPost()requests passes all of its data,
of unlimited length.
c) A doGet() request is appended to the request URL in a query string
and this allows the exchange is visible to the client, whereas a doPost()
request passes directly over the socket connection as part of its HTTP
request body and the exchange are invisible to the client.
What are the different servers available for developing and deploying
Servlets?
a) Java Web Server
b) JRun
c) Apache Server
d) Netscape Information Server
d) Web Logic
Is it possible to communicate from an applet to servlet and how many
ways and how?
Yes, there are three ways to communicate from an applet to servlet and
they are:
a) HTTP Communication(Text-based and object-based)
b) Socket Communication
c) RMI Communication
Why should we go for interservlet communication?
Servlets running together in the same server communicate with each other
in several ways. The three major reasons to use interservlet communication
are:
a) Direct servlet manipulation - allows to gain access to the other
currently loaded servlets and perform certain tasks (through the ServletContext
object)
b) Servlet reuse - allows the servlet to reuse the public methods of
another servlet.
c) Servlet collaboration - requires to communicate with each other
by sharing specific information (through method invocation)
Is it possible to call servlet with parameters in the URL?
Yes. You can call a servlet with parameters in the syntax as (?Param1
= xxx || m2 = yyy).
What is the difference between TCP/IP and UDP?
TCP/IP is a two-way communication between the client and the server
and it is a reliable and there is a confirmation regarding reaching the
message to the destination. It is like a phone call. UDP is a one-way communication
only between the client and the server and it is not a reliable and there
is no confirmation regarding reaching the message to the destination. It
is like a postal mail.
What is Domain Naming Service(DNS)?
It is very difficult to remember a set of numbers(IP address) to connect
to the Internet. The Domain Naming Service(DNS) is used to overcome this
problem. It maps one particular IP address to a string of characters. For
example, www. mascom. com implies com is the domain name reserved for US
commercial sites, moscom is the name of the company and www is the name
of the specific computer, which is mascom’s server.
Do you have a Java Problem?
Ask It in The Java
Forum
Java Books
Java
Certification, Programming, JavaBean and Object Oriented Reference Books
Return to : Java
Programming Hints and Tips
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
All product names are trademarks of their respective
companies.
The site www.erpgreat.com is not affiliated with or endorsed
by any company listed at this site.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
The content on this site may not be reproduced
or redistributed without the express written permission of
www.erpgreat.com or the content authors.
|