GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  JDBC
Go To First  |  Previous Question  |  Next Question 
 JDBC  |  Question 134 of 135    Print  
connection pooling concept through weblogic 8.1
Hi,

I tried using connection pooling concept through weblogic 8.1 .

import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;
public class ConnectionpoolDemo {
public static void main(String[] args) {
try {
InitialContext ic=new InitialContext();
Object obj=ic.lookup("MyDsJNDI");
DataSource ds=(DataSource)obj;
Connection con=ds.getConnection();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select empno,ename from emp");
while(rs.next()){
System.out.print(rs.getString(1)+"t");
System.out.println(rs.getString(2));
}
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}

}

Output:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at ConnectionpoolDemo.main(ConnectionpoolDemo.java:8)



EXCEPTION OCCURRED AT LINE

Object obj=ic.lookup("MyDsJNDI");



  
Total Answers and Comments: 2 Last Update: May 16, 2008     Asked by: balinaidu007 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 23, 2008 05:42:22   #1  
cvshankar Member Since: December 2007   Contribution: 1    

RE: connection pooling concept through weblogic 8.1
The constant indicating the type for a ResultSet object that is scrollable and generally sensitive to changes made by others
 
Is this answer useful? Yes | No
May 15, 2008 09:31:42   #2  
ashwin1483 Member Since: May 2008   Contribution: 2    

RE: connection pooling concept through weblogic 8.1
try using this code............


import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class ConnectionPool
{
 public static void main(String args[])
 {
  try
  {
   Hashtable hs=new Hashtable();
   hs.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
   hs.put(Context.PROVIDER_URL,"t3://localhost:7001");
   Context ctx=new InitialContext(hs);
   DataSource ds=(DataSource)ctx.lookup("connectionpooling");
   Connection con=ds.getConnection();
   Statement st=con.createStatement();
   ResultSet rs=st.executeQuery("select ename,epwd from emp");
   while(rs.next())
   {
    System.out.println(rs.getString(1)+" "+rs.getString(2) );
   }
  }
  catch (Exception e)
  {
   System.out.println("error" +e);
  }
 }
}
  

 
Is this answer useful? Yes | No

 Related Questions

Answered by Jey on 2005-05-10 06:01:10: Here are the steps.  Using DriverManager: 1. Load the driver class using class.forName(driverclass) and class.forName() loads the driver class and 
Latest Answer : First we register the connection and after that we connect the database, in that we give to which database is connecting giving that  ipaddress ,port number,username and password . ...

Latest Answer :          The Connection Creation section described when connections are created. It described how several context instances can share the same connection. In this type of sharing, operations from the different context ...

Latest Answer : code for connecting the connection poolingInitalContext ic=new InitialContext();Hashtable ht=new Hashtable();ht.put("Context.INITIAL_PROVIDER",weblogic.jndi.InitialCla) //u have to set weblogic properties first and the jndi name that u r defining in //weblogic ...

The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendors driver must provide implementations of the java.sql.Connection,Statement,PreparedStatement, 
Latest Answer : As has been mentioned above, the implementations are provided by the database vendors like for example, the classes12.jar of oracle which has the implementations. ...

Create an instance of a JDBC driver or load JDBC drivers through jdbc.driversRegister a driverSpecify a databaseOpen a database connectionSubmit a queryReceive results 
Latest Answer : import java.sql.*;class Type1 { public static void main(String[] args)throws Exception {  Connection c=null;  try  {    Driver d=new Driver("sun.jdbc.odbc.JdbcOdbc");     //or  ...

There are 8 packages: java.sql.Driver, Connection,Statement, PreparedStatement, CallableStatement, ResultSet, ResultSetMetaData, DatabaseMetaData. 
Latest Answer : Packages arejava.sql and javax.sql only..Those mentioned in the previous lists are the classes & interfaces in those packages. ...

A URL string -->getConnection-->DriverManager-->Driver-->Connection-->Statement-->executeQuery-->ResultSet. 
Latest Answer : 1). Register the Driver 2) load the Driver 3)get the connection 4) create the statement 5) Execute the query 6) fetch the results with ResultSet ...

This involves two steps: (1) loading the driver and (2) making the connection. 
Latest Answer : Steps to follow establish a connection1.import required(sql) package.import java.sql.*;import javax.sql.*;javax.sql-----------------------1Data source 2Connection pooling 3Distributed transactions 5Rowsets 2.Load and register the driver(by using class.forName())Java ...

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. 
Latest Answer : it is used tom initialize the driver . ...

In establishing a connection is to have the appropriate driver connect to the DBMS. The following line of code illustrates the general idea:E.g.String url = "jdbc:odbc:Fred";Connection con = 
Latest Answer : First You can lode the driver calssee into your program.This can be achived by the useing of follwing Code.Class.forName("oracle.jdbc.driver.OracleDriver");once the driver is avilable now u can get any number of connections, by the using of DriverManager ...


 Sponsored Links

 
Related Articles

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Connection between Data Model and Data Warehouse

Connection between Data Model and Data Warehouse Data models are required in order to build data warehouses The problem is those who develop data warehouses need to be able to show results at a fast pace Data models are problematic in that they take a very long time to build Is it possible then to s
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 

HR Interview - Behavioral HR Interviews

Behavioral HR Interviews As the name implies a behavioral interview is an interview that is held by a human resources department to determine if an applicant has the behaviors that are appropriate for a job The company must know how an applicant will behave in a certain situations mosgoogle The logi
 

HR Interview - How To Prepare For Your HR Interview

How To Prepare For Your HR Interview Before you begin thinking about how you are going to dress for the interview it is important to do your research first You should learn everything you can about the company you wish to work for When you have detailed information about your employer you will conve
 

HR Interview - Telephone Interview Etiquette

Telephone Interview Etiquette When you conduct a telephone interview for a job it is important to show the proper etiquette Not only is it important it is critical is you wish to be hired by the company There are a number of things you will want to do and other things should never be done mosgoogle
 

HR Interview - How To Succeed At HR Interviews

How To Succeed At HR Interviews There are a number of things you will need to do in order to make sure you pass the interview process Your appearance is something that you will want to pay close attention to Even if you feel that your appearance shouldn t be a factor in whether or not you re highere
 

HR Interview - Do's and Dont's in a HR Interview

Do s and Dont s in a HR Interview There are a number of things that you will want to avoid during the HR interview process While some of these things are directed at the interviewer the other things are directed at the applicant If interviewers fail to follow the proper procedures throughout the int
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape