Search This Blog

Sunday, 10 March 2013

Weblogic JDBC Interview Questions


1.JNDI?

   Java Naming and Directory Interface.

   It is an API for accessing different naming and directory services uniformly.
   A naming service associates names with objects and finds objects based on their given names.

2.DATA SOURCE?

   provides a way for jdbc client to obtain a database connection from a connection pool.

3.CONNECTION POOL?

   It is a group of ready-to-use database connections associated with a datasource.

4.DIFFERENCE BETWEEN XA AND NONXA DRIVER TYPES?
 
  An XA transaction, in the most general terms, is a "global transaction" that may span multiple resources.
  A non-XA transaction always involves just one resource.

  An XA transaction involves a coordinating transaction manager, with one or more databases (or other resources, like JMS) all involved in a single global transaction.
  Non-XA transactions have no transaction coordinator, and a single resource is doing all its transaction work itself (this is sometimes called local transactions).

5.DIFFERENCE BETWEEN DATASOURCE AND MULTIDATASOURCE?

  Datasource provides a way for jdbc client to obtain a database connection from a connection pool.
  Multidata source is group of data sources that you can set up according to either a fail over or load balancing algorithm.

6.EXPLAIN DIFFERENT TYPES OF DRIVERS?

  There are 4 types of drivers.
 
  Type 1 Drivers: It is a JDBC - ODBC bridge.usually runs on windows and requires ODBC driver to be installed in client machine.

  Type 2 Drivers:  Requires native driver to be already installed on the client machine. Driver converts JDBC calls to native API calls of database.

  Type 3 Drives: Network server can apply several techniques to boost performance of connection pooling,load management,caching.

  Type 4 Drivers: All java driver Implementations that donot require client side configerartion.

7.STEPS FOR CREATING DATA SOURCE AND CONNECTION POOL IN CONSOLE?
 
  1.click on services
    click on jdbc
    click on datasources
  2.click on lock and edit
    click on new
  3.Provide jdbc datasource properties
    Name,Jndi name,Database type,Driver type
  4.Select one phase commit in "Transaction options"
  5.Create connectionpool in connection properties
    Database name,Hostname,port number,Database username,Password.
  6.Test cofigeration
    Message will display as "connection test succeeded"
  7.Select targets
    Finish and activate changes.


8.WLST SCRIPT FOR CREATING DATASOURCE AND CONNECTION POOL?


  from java.util import *
from javax.management import *
import javax.management.Attribute

print 'Starting the script .... '

connect('system','weblogic','t3://localhost:7001')

# Check if dizzyworldDS data source already exists
try:
cd('/JDBCSystemResources/dizzyworldDS')
print 'The dizzyworldDS data source already exists.'
exit()
except WLSTException:
pass


print 'Changing to edit mode...'


edit()
startEdit()

# creating JDBC resources

jdbcSR = create('dizzyworldDS','JDBCSystemResource')
theJDBCResource = jdbcSR.getJDBCResource()

connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()
connectionPoolParams.setInitialCapacity(5)
connectionPoolParams.setMaxCapacity(15)
connectionPoolParams.setCapacityIncrement(5)
connectionPoolParams.setTestTableName('SYSTABLES')
connectionPoolParams.setLoginDelaySeconds(1)

dsParams = theJDBCResource.getJDBCDataSourceParams()
dsParams.addJNDIName("dizzyworldDS")
theJDBCResource.setName("dizzyworldDS")

driverParams = theJDBCResource.getJDBCDriverParams()
driverParams.setUrl('jdbc:pointbase:server://localhost:9092/HRDATABASE')
driverParams.setDriverName('com.pointbase.jdbc.jdbcUniversalDriver')
driverProperties = driverParams.getProperties()

proper = driverProperties.createProperty('user')
proper.setName('user')
proper.setValue('PBPUBLIC')

proper1 = driverProperties.createProperty('databaseName')
proper1.setName('databaseName')
proper1.setValue('jdbc:pointbase:server://localhost:9092/HRDATABASE')

driverParams.setPassword('PBPUBLIC')

# targeting the resources to the Managed Server called dizzy1

cd('/')
tgtServer = getMBean("/Servers/dizzy1")
tgtServer.setJavaCompiler("javac")
tgtServer.setListenAddress("localhost")
tgtServer.setListenPort(7003)
tgtServer.setInstrumentStackTraceEnabled(1)


jdbcSR.addTarget(tgtServer)


save()
activate()
disconnect()

print 'End of script, exiting WLST...'
exit()


9.HOW TO RESET A CONNECTION POOL? PURPOSE OF RESETING CONNECTION POOL?

  1.click on services in admin console
  2.click on jdbc
  3.click on datasources
  4.select the datasource and click on control
  5.now click on reset

  The connection pool goes out of resource is very common issue we usually face across all types of applications.
  As there are plenty of reasons for the same like application is not closing the connections, concurrent user access of DB resources etc.
  When WebLogic Server starts, connections from the connection pools are opened and are available to all clients.
  When a client closes a connection from a connection pool, the connection is returned to the pool and becomes available for other clients;
  the connection itself is not closed. There is little cost to opening and closing pool connections.

10.HOW TO TEST A CONNECTION POOL?
   
  1. click on services
     click on jdbc
     click on datasources
  2. click on lock and edit
     click on new
  3. Provide jdbc datasource properties
  4. Create connectionpool in connection properties
   
  5. click on Test cofigeration
     Message will display as "connection test succeeded"
 

11.CONNECTION POOL PROPERTIES?

   The connection pool properties are Initial size,maximum capacity, capacity increment,login delay,database name,host name,port number,database username,password etc.

12.EXPLAIN ABOUT TWO TIER AND MULTI TIER ARCHITECTURES?

   TWO-TIER ARCHITECTURE: In two tier java application communicates directly with the DBMS.
                          A JDBC driver is needed that can communicate directly with the DBMS.

   MULTI-TIER ARCHITECTURE: In multi tier commands are sent to a middle tier of serviceswhich then sends the commands.
                            DBMS process the commands and sends the results back to middle tier,which then sends them to client.

13.EXPLAIN MULTI DATA SOURCE ALGORITHMS?

   FAIL OVER : connection requets are sent to the first data source in the list.If the request fails, The request is sent to the next data source in the list.

               The process repeated until a valid connection is obtained.or until the end of the list is reached,in which case an exception is thrown.

   LOAD BALANCING : Multi data source distributes connection requests evenlyto its member datasources.Multi data sources that use the load balancing algorithm
             
                    also fail over to the next connection pool in the list if a connection request fails.



                       



























 



 

Saturday, 2 March 2013

Weblogic deployment FAQs


          DEPLOYMENT

1.       Different ways ,modes,types to deploy an application?
          Different ways:
·        console mode of deployment
·        java command line deployment
·        wlst deployment
·        python deployment
·        antscript deployment


Deploying modes:
1.staging modes
2.No stage  mode
3. External stage mode
Types of deployment:
1.side by side deployment
2.Two phase deployment
3.Deployment using plan

2.Deployment steps for console mode?
1. click on lock & edit
2.click on deployments
3.click on install
4.select location
5.choose targeting style
6.select  deployment targets
7.select security roles and policies and modes
8.activate changes

3. Deployment steps for java command line deployment?
 1.set the class path to execute java commands - setDomainEnv.cmd
2.execute java command for deployment – java weblogic.Deployer
Java weblogic.Deployer  –adminurl  t3://localhost:7001   –username  weblogic  –password  weblogic       –name  benefits  –source  path\benefits.war  –targets ms1,ms2  –deploy
4. steps for deploying an application using wlst?
1.invoke / connect to wlst-offline – wlst.cmd
2.connect to online- connect(‘weblogic’,’weblogic’,’t3://localhost:7001’)
3.edit ( )
4.startEdit ( )
5.execute - deploy (‘appname’,’path/app.war’,targets=’ms1,ms2’)
6.activate( )
7.disconnect( )

5.steps for deploying  an application using ant script?
1.create   build.xml file
2.write  script in it.
3.execute command  ant  deploy {if we save the file name as build.xml}
Ant  –f  filename.xml {if the file name is created with filename.xml}
6.Auto Deployment?
1.copy the application in to Autodeployment folder,which is present in c:bea/user_projects/domains/domain1/servers/admin/autodeloyment
2.Now Run the admin server .
3. The application automatically deployed in admin server.
7.Different modes of deployment
Staging mode:  The admin server copies the deployment unit files to the staging directories of target servers and they are deployed using the local copy.
This mode is useful when deploying  small or moderate size applications.
This is default staging mode for managed servers .
No stage mode:   the deployment units are deployed using the same physical copy  which must accessible by the admin server and target servers
This mode is useful when deploying large  applications to multiple targets
This is default staging mode for adminservers.
External stage: we must copy the deployments units manually to the correct staging directories  before deployment.
We will use this mode for deployments when we want to manually control the distribution of deployment files to target servers.
8. Side by side deployment  ?
Use the weblogic server to redeploy a new version of a production application without interrupting the availability of application to new client requests.
This way the new client get connected to the new version of the application and the previous version  of the application is till in use bythe older clients and gets retired after the client disconnects.
9.How to clear weblogic cache?
Steps :
1.shut down the server.
2.delete the contents of the folder:
c\bea\user_projects\domains\domain1\servers\server_name\tmp\wl_user
3.Restart the server.
10.what happens if we don’t  clear the cache?
If we are redeploying an application or deploying a new version of same application, weblogic  server look up in the above directory.if there are older objects persists that will be conflict with new code objects.
11. Difference between .jar .war and .ear files?
.jar:  java archive files intended to hold generic libraries of java classes ,Resources,Auxillary  files etc.
        Used in J2ee for packaging EJB’s  & client side java applications.
.war : web archive files intended to contain complete web applications.
           Specially for web applications made from servlets , jsp’s supporting classes.
  .ear : Enterprise archive files intended to contain complete enterprise applications.
            Contains all of the components     that make up a particular  J2EE application.



12.what is two phase deployment?
There are two states in two phase deployment
They are 
1.prepare state
2.active state
Deployment first prepares the application across all the target servers and then activates the application in a separate phase.
If  deployment of an application fails in either of the two phases then the cluster deployment is failed.
13.      What are deployment descriptors? 
   It is a configuration file for web application or EJB application which is to be deployed to web or EJB container.

Deployment descriptors describes the deployment settings of an application or module or component.

It contains meta data describing the contents and structure of the enterprise beans, and runtime transaction and security information for EJB container.

It directs a deployment tool to deploy a module or application with specific container options and describes specific configuration requirements that a deployer must resolve.

14.Deployment process in current organization?

1.Developers develop the code,check into svn (sub version number)
2.Build team build the code using Hudson tool.
3.War,Ear files will be generated after the build.
4.we will stage these files from windows machine to unix machine using winscp tool.
5.once staging is complete we will clear weblogic servers cache .
6.next we will trigger the deployment using wlst script.
7.deployment will complete automatically ,we will get mail alert for success or failure status.
8. if in case of deployment failures ,we will check log files and fix issues.

15.Deployment issues?

1.       Code issues
2.       Out of memory issues
3.       Connection pool issues
4.       Clear cache issues
5.       Library class path issues
6.       Applications are not deployed