ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories >> Software >> Java-Related >> Java-J2EE >> Core-Java
 
 


 

Back to Questions Page
 
Question
What is the purpose of setAutoCommit() ?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   Google
I also faced this Question!!   © ALL Interview .com
Answer
If AutoCommit is off, then any update or insert operation
perforned on database will not be reflected just after the 
query is executed.Though the operation has been 
successfully completed.
 We will have to commit the transaction manually, to view 
the incurred changes.
  This also keeps user on the safer side, if some 
undesirable row has been inserted,updated or deleted in the 
database then it can be rollback.

While if the AutoCommit is on any update,insert or delete 
are at once reflected onto the database.
 
0
Shahnawaz Sheikh
 
 
Question
What are the steps to do connection pooling in weblogic?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   TCS
I also faced this Question!!   © ALL Interview .com
Answer
We can implement connection pooling in weblogic as follows.
1. OPen weblogic console.on the top right hand side corner 
of the window click on services tab.
2.Expand it and select JDBC.
3.Create a connection pool
4.Create a DataSource.
5.Create a JNDI.

In the programs make use of the following code to get the 
connection from ConnectionPool

Context ic=null;
DataSource ds;
Connection con=null;
Hashtable ht=new Hashtable();
ht.put
(Context.INITIAL_CONTEXT_FACTORY,"Weblogic.jndi.WLInitialCon
textFactory");
ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
ic=new InitialContext(ht);
ds=(DataSource)ic.lookup("jndi name given in weblogic");
con=ds.getConnection();
 
0
Gajendra
 
 
Question
Difference between local and global transaction ?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   iFlex
I also faced this Question!!   © ALL Interview .com
Answer
Here is the defination and example in case of spring:

Local Vs Global Transaction:

Local transactions are transactions associated with a
particalar data source (means they are resource-specific).
the most common example would be a transaction associated
with a JDBC connection. While Global Transactions provide
the ability to work with multiple transactional resources
(typically relational databases and message queues).

Example of Local transaction :

<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

DataSourceTransactionManager : takes the datasource as one
of its properties.

even HibarnateTransactionManager  takes sessionfactory which
in turn uses datasource as a property or it also takes
datasource as one of the property.


Example of Global transaction : 

If we use JTA in a J2EE container, as in the
'dataAccessContext-jta.xml' file from the same sample
application, we use a container DataSource, obtained via
JNDI, in conjunction with Spring's
JtaTransactionManager. The JtaTransactionManager doesn't
need to know about the DataSource, or any
other specific resources, as it will use the container's
global transaction management infrastructure.


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/jpetstore"/>
<bean id="txManager"
class="org.springframework.transaction.jta.JtaTransactionManager"
/>
<!-- other <bean/> definitions here -->
</beans>
 
0
Prakash Sah
 
 
 
Question
What are the two major components of JDBC?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   Mind-Tree , CMC
I also faced this Question!!   © ALL Interview .com
Answer
1.Driver Manager 
2.Connection
 
0
Priyanka
 
 
Answer
The two major components of JDBC are
1.Driver
2.DriverManager
 
0
Gajendra
[Techmatics]
 
 
Answer
1.connection pool 
2.Data source
 
0
Geetanjali
[Techmatics]
 
 
Answer
JDBC Driver  and  JDBC  API 

JDBC DRIVER  is  different  for  each  db , API  is  same 
for  all the  DB . API  is  the  one  Application 
programmers  can  use and  which  will communicate  to the 
underlaying  Db  through Driver
 
0
Sukesh
[Techmatics]
 
 
Question
What is the protocol is used in type4 driver?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   CMC
I also faced this Question!!   © ALL Interview .com
Answer
native protocol
 
0
Sandhya
 
 
Answer
type 4 uses thin protocol of specified vendor say oracle is
jdbc:oracle:thin:@systemname:1521:oracleservicename
 
0
Raja
[Techmatics]
 
 
Question
What is thin driver and thick driver. why it is called so?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   Logisoft
I also faced this Question!!   © ALL Interview .com
Answer
Both these drivers are used to connect your java program to
database(oracle).

Thin drivers (comes under type 4 drivers)  are completely
written in java.You can connect to oracle without oracle
client installed on ur pc.
Thick drivers(comes under type 1 or i think 2,3 also)are not
 written completely in java.You need oracle client(like odbc
driver,jdbc-odbc bridge drivers etc)for communication
between java program and oracle.

As thin driver's implementation is smaller as compared to
thick drivers,so they are are called as such i think.
 
0
Harmandeep Singh
 
 
Question
What are batch updates. in jdbc
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   Corent-Technology
I also faced this Question!!   © ALL Interview .com
Answer
Batch updates is a facility given by the JDBC to the 
application developers to submit a set of SQL update 
statements as batch to the database.

st.addBatch("Update statement1");
st.addBatch("Update statement2");
st.addBatch("Update statement3");

int updated[]=st.executeBatch();// This methods throws 
BatchUpdateException and SQLException
 
0
Gajendra
 
 
Answer
Batch Update provide the functionality of executing a group 
of sql statement at single timing.

Steps:

1.set autocommit as false for connection .
       connectionObject.setAutoCommit(false);
2.create sql statement and add to statement object.
       statementObj.addBatch("sql1");
       statementObj.addBatch("sql2");
       statementObj.addBatch("sql3");
3.execute the batch of statement using executeBatch().
      statementObj.executebatch();
4. commit the connection.
            connectionObj.commit();
 
0
Vijayakumar Chinnasamy
[Techmatics]
 
 
Question
What are the parameters used in Connection pooling?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   IBM
I also faced this Question!!   © ALL Interview .com
Answer
Parameters used in Connection Pooling are:-
Min Pool Size,
Max Pool Size,
Connection Lifetime ,
Connection Timeout,
Incr Pool Size ,
Decr Pool Size ,
 
0
Ashwani
 
 
Question
In real time project which driver did u use? What is the
main functionality of the Prepared Statement?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   Photon
I also faced this Question!!   © ALL Interview .com
Answer
In real time project,We can use type-4 driver.This is fully 
java based driver.Prepared statement:This is pre-compiled 
sql query.
 
0
Dsr
 
 
Question
What are the types of statement? explain
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   SysBiz
I also faced this Question!!   © ALL Interview .com
Answer
There are three types of statements
1.statement
2.preparted statement
3.callable statement.

1.statement:like as sql query.
2.prepared statement:pre-compiled sql query.
3.callable statement-to call the stored procedure.
 
0
Dsr
 
 
Question
How to call a Stored Procedure from JDBC?
Rank Answer Posted By  
 Question Submitted By :: Gopalraop
This Interview Question Asked @   Satyam
I also faced this Question!!   © ALL Interview .com
Answer
We can use CallableStatement interface to call a stored 
procedure.Use the following steps.

1. crate the escape syntax like
String sql="{call procname(?,?,?);
2.CallableStatement cst=con.prepareCall(sql);
3.Set the inparameters using setXXX methods like
cst.setInt(1,10);
cst.setString(2,"abc");
4.Register the out parameter
cst.registerOutParameter(1,Types.Float);
5.Submit the statement using
cst.execute();
6. We can get the data from stored procedure using getXXX 
methods
 
0
Gajendra
 
 
Answer
use callableStatment
 
0
Vikneswarank
[Techmatics]
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com