Posted By:
sankar_subramani
Posted On:
Thursday, February 14, 2002 07:37 AM
Hai.. i am new to weblogic.I am trying to create connection pool to oracle database. I am using weblogic6.1,oralce thin driver. As per weblogic specification i created connection pool to oracle database. those item given bellow connectionpoolname: MyJDBCConnection. Url: jdbc:oracle:thin:@oracleservername:1521:isoweb DriverClassname: oracle.jdbc.driver.OracleDriver in property i given username and password I also created DataSource those details are follow DataSourceName:testDataSource JndiName:testDataSource PoolName:MyJDBCConnection Row
More>>
Hai..
i am new to weblogic.I am trying to
create connection pool to oracle
database. I am using
weblogic6.1,oralce thin driver.
As per weblogic specification i created
connection pool to oracle
database. those item given bellow
connectionpoolname: MyJDBCConnection.
Url: jdbc:oracle:thin:@oracleservername:1521:isoweb
DriverClassname: oracle.jdbc.driver.OracleDriver
in property i given username and password
I also created DataSource those details
are follow
DataSourceName:testDataSource
JndiName:testDataSource
PoolName:MyJDBCConnection
Row Prefetch Enabled: false
Stream Chunk Size:256
I write one java program to get connection..
import java.sql.*;
import javax.naming.*;
import java.util.*;
import java.io.*;
import javax.sql.*;
public class DbConnection
{
public void getConnection()
{
System.out.println("Line 2");
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
//ht.put(Context.INITIAL_CONTEXT_FACTORY,weblogic.jndi.WLInitialContextFactory.class.getName());
ht.put(Context.PROVIDER_URL,"t3://15.70.169.155:7001");
System.out.println("Line 3");
try {
System.out.println("Line 4");
ctx = new InitialContext(ht);
System.out.println("Line 5");
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("testDataSource");
System.out.println("Line 6");
java.sql.Connection conn = ds.getConnection();
System.out.println("Line 7");
// You can now use the conn object to create
// a Statement object to execute
// SQL statements and process result sets:
Statement stmt = conn.createStatement();
stmt.execute("select * from test");
ResultSet rs = stmt.getResultSet();
// Do not forget to close the statement and connection objects
// when you are finished:
stmt.close();
conn.close();
}
catch (NamingException e) {
e.printStackTrace();
System.out.println(e.getExplanation());
}
catch(SQLException e)
{
System.out.println("Sql Exception :"+e);
}
finally {
try {ctx.close();}
catch (Exception e) {
// a failure occurred
}
}
}
public static void main(String[] args)
{
System.out.println("Line 1");
DbConnection dbcon = new DbConnection();
dbcon.getConnection();
System.out.println("Hello World!");
}
}
Now if i try to run this program i am
getting
javax.naming.NameNotFoundException.
Pls give me suggestions..That will
usefull for me
<<Less