After creating conntinpool in weblogic
how to write the code in programe where i can use that pool
object in the programe connecting to the database
and how to debug programe withou eclipse

Answer Posted / penchala

import java.sql.*;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

class WLConnection
{


public static void main(String arg[]){
Context ctx = null;
java.util.Hashtable ht = new Hashtable();

ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");

Connection conn = null;

try {
ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource)
ctx.lookup ("jdbc/sample");
conn = ds.getConnection();


}
catch (Exception e) {
// a failure occurred

}
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is JDBC Connection? Explain steps to get Database connection in a simple java program.

830


Where is mysql jdbc driver located?

701


What do you mean by two phase commits?

747


How to retrieve warnings in jdbc?

710


Where jdbc drivermanager class is used?

687


Why hibernate is better than jdbc?

677


Is jdbc a middleware?

681


Which type of driver is unique in jdbc?

689


Which is better odbc or jdbc?

659


What is the difference between client and server database cursors?

795


What types of DataSource objects are specified in the Optional Package?

750


Which is best database for java?

716


Why can't Tomcat find my Oracle JDBC drivers in classes111.zip?

738


What is database deadlock ? How can we avoid them?

690


What does the jdbc driver interface do?

723