Thursday, January 25, 2007

difference between a primary key and a unique key

Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only.

SOURCE : www.referjava.com

What is a join and List different types of joins

Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table. Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.


SOURCE : www.referjava.com

What is the Referential Integrity

Referential integrity refers to the consistency that must be maintained between primary and foreign keys, i.e. every foreign key value must have a corresponding primary key value.


SOURCE : www.referjava.com

difference between DELETE TABLE and TRUNCATE TABLE commands

Posted: Sat Jan 13, 2007 6:30 am Post subject: difference between DELETE TABLE and TRUNCATE TABLE commands

--------------------------------------------------------------------------------

DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.


SOURCE : www.referjava.com

query that will display ...

create a query that will display the total no.of employees and, of that total, the no.of employees hired in 1995,1996,1997, and 1998. create appropriate column headings.

select Count(*) as NumberOfEmployees,

EmployeesHiredIn1995_1996_1997_1998 =

(select count(*) from employees

where hiredate like '%1995%'

or hiredate like '%1996%'

or hiredate like '%1997%'

or hiredate like '%1998%')

from employees


SOURCE : www.referjava.com

Is Oracle is a Multidimensional database? If yes How?

Yes, Oracle is a Multidimensional database, as it provides much faster response time for analytical queries.Data in a multi-dimensional database is stored as business people views it, allowing them to slice and dice the data to answer business questions

this statement is supported by the prescence of cube and rollup operators in oracle 9i which indicates that it is a multidimensional dbs.

SOURCE : www.referjava.com

difference between varchar and varchar2

varchar means fixed length char, supported by MSSQL server 2000

varchar2 means variable length char, supported by Oracle.

SOURCE : www.referjava.com

Difference between oracle8i and oracle9i

The biggest difference between Oracle8i and Oracle9i is that Oracle9i lets You resize the SGA memory areas dynamically i.e., the Database Buffer Cache DB_CACHE_SIZE or the SHARED_POOL_SIZE, etc., can be resized when the database is up and running. The same is not possible with Oracle8i. You can get more information from OTN.


SOURCE : www.referjava.com

diff bet'n "NULL in C" and "NULL in Oracle

Null in C is Nothing or Void which can be compared with normal operators but inoracle Null can't be compared with normal operators like '=' or greater than or smallerthan.so be careful in using this feature of oracle because it can lead to several problems as like if u compared a password with oracle internal password and a user supplies a nullin password ur comparison may false like if INPUT_PASSWORD<>ORIGINAL_PASSWORD then raise_application_error(-20225,'"Incorrect Password");

NULL in SQL in an unknown value. It neither zero nor any valid value. It cannot be mapulated, but it can only be compared.



SOURCE : www.referjava.com

diffrence between and constraints and triggers

Constraints are used to maintain the integrity and atomicity of database .in other words it can be said they are used to prevent invalid data entry . the main 5 constraints are
NOT NULL,PRIMARY KEY,FOREIGN KEY,UNIQUE KEY and CHECK

Triggers are bascically stored procedures which automaticallly fired when any insert,update or delete is issued on table.

SOURCE : www.referjava.com

diff bet'n JNDI lookup(), list(), listBindings() & search

lookup() attempts to find the specified object in the given context. I.e., it looks for a single, specific object and either finds it in the current context or it fails.

list() attempts to return an enumeration of all of the NameClassPair's of all of the objects in the current context. I.e., it's a listing of all of the objects in the current context but only returns the object's name and the name of the class to which the object belongs.

listBindings() attempts to return an enumeration of the Binding's of all of the objects in the current context. I.e., it's a listing of all of the objects in the current context with the object's name, its class name, and a reference to the object itself.

search() attempts to return an enumeration of all of the objects matching a given set of search criteria. It can search across multiple contexts (or not). It can return whatever attributes of the objects that you desire. Etc. It's by far the most complex and powerful of these options but is also the most expensive.


SOURCE : www.referjava.com

what is JNDI and purpose of JNDI

The Java Naming and Directory Interface (JNDI) provides naming and directory functionality. It provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes. Using JNDI, a J2EE application can store and retrieve any type of named Java object.
Because JNDI is independent of any specific implementation, applications can use JNDI to access multiple naming and directory services, including existing naming and directory services such as LDAP, NDS, DNS, and NIS. This allows J2EE applications to coexist with legacy applications and systems.

SOURCE : www.referjava.com

What is EJB ?

Enterprise Java Bean

The three types of EJBs are: (1) session beans perform processing, (2) entity beans represent data, which can be a row or a table in a database, and (3) message driven beans are generated to process Java Messaging Service (JMS) messages.

SOURCE : www.referjava.com

How EJB Invocation happens?

Retrieve Home Object reference from Naming Service via JNDI. Return Home Object reference to the client. Create me a new EJB Object through Home Object interface. Create EJB Object from the Ejb Object. Return EJB Object reference to the client. Invoke business method using EJB Object reference. Delegate request to Bean (Enterprise Bean).


SOURCE : www.referjava.com

Can you control when passivation occurs?

The developer, according to the specification, cannot directly control when passivation occurs. Although for Stateful Session Beans, the container cannot passivate an instance that is inside a transaction. So using transactions can be a a strategy to control passivation. The ejbPassivate() method is called during passivation, so the developer has control over what to do during this exercise and can implement the require optimized logic. Some EJB containers, such as BEA WebLogic, provide the ability to tune the container to minimize passivation calls. Taken from the WebLogic 6.0 DTD -”The passivation-strategy can be either “default” or “transaction”. With the default setting the container will attempt to keep a working set of beans in the cache. With the “transaction” setting, the container will passivate the bean after every transaction (or method call for a non-transactional invocation).


SOURCE : www.referjava.com

Brief description about local interfaces?

EJB was originally designed around remote invocation using the Java Remote Method Invocation (RMI) mechanism, and later extended to support to standard CORBA transport for these calls using RMI/IIOP. This design allowed for maximum flexibility in developing applications without consideration for the deployment scenario, and was a strong feature in support of a goal of component reuse in J2EE.

Many developers are using EJBs locally -- that is, some or all of their EJB calls are between beans in a single container.

With this feedback in mind, the EJB 2.0 expert group has created a local interface mechanism. The local interface may be defined for a bean during development, to allow streamlined calls to the bean if a caller is in the same container. This does not involve the overhead involved with RMI like marshalling etc. This facility will thus improve the performance of applications in which co-location is planned.

Local interfaces also provide the foundation for container-managed relationships among entity beans with container-managed persistence.


SOURCE : www.referjava.com

difference between MessageDrivenBeans & Stateless Session

In several ways, the dynamic creation and allocation of message-driven bean instances mimics the behavior of stateless session EJB instances, which exist only for the duration of a particular method call. However, message-driven beans are different from stateless session EJBs (and other types of EJBs) in several significant ways:

Message-driven beans process multiple JMS messages asynchronously, rather than processing a serialized sequence of method calls.

Message-driven beans have no home or remote interface, and therefore cannot be directly accessed by internal or external clients. Clients interact with message-driven beans only indirectly, by sending a message to a JMS Queue or Topic.

Note: Only the container directly interacts with a message-driven bean by creating bean instances and passing JMS messages to those instances as necessary.

The Container maintains the entire lifecycle of a message-driven bean; instances cannot be created or removed as a result of client requests or other API calls.

SOURCE : www.referjava.com

Definition for AJAX

AJAX (Asynchronous JavaScript and XML) is a web development technique for creating interactive web based applications that can asynchronously interchange data between server and client.

SOURCE : www.referjava.com

What will Class.forName do while loading drivers?

It is used to create an instance of a driver and register it with the
DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.

SOURCE : www.referjava.com

How can you create JDBC statements and what are they?

A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. It takes an instance of an active connection to create a Statement object. In the following example, we use our Connection object con to create the Statement object.

SOURCE : www.referjava.com

What are the different types of Statements?

Regular statement (use createStatement method), prepared statement (use prepareStatement method) and callable statement (use prepareCall).

SOURCE : www.referjava.com

What does setAutoCommit do?

When a connection is created, it is in auto-commit mode. This means that each individual SQL statement is treated as a transaction and will be automatically committed right after it is executed. The way to allow two or more statements to be grouped into a transaction is to disable auto-commit mode:

con.setAutoCommit(false);.


SOURCE : www.referjava.com

How do you call a stored procedure from JDBC?

The first step is to create a CallableStatement object. As with Statement an and PreparedStatement objects, this is done with an open
Connection object. A CallableStatement object contains a call to a stored procedure.

CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();


SOURCE : www.referjava.com