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");
Questions by balinaidu007 answers by balinaidu007
Showing Answers 1 - 2 of 2 Answers
Related Answered Questions
Related Open Questions
Connection pooling concept through weblogic 8.1
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");
Profile Answers by balinaidu007 Questions by balinaidu007
Questions by balinaidu007 answers by balinaidu007
Related Answered Questions
Related Open Questions