Unable to connect to JNDI name- weblogic 9.2 datasource defined though
I have these parameters done in weblogic 9.2-1. Created a JNDI name
2. Have DB URL and driver ready/ class names and everything (created using JDBC create datasource).
Problem
I am using this code to test the connection-
package com.gs;
// Code to look up a datasource object for getting database connection
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class TestConnection {
public TestConnection() throws NamingException, SQLException{
Connection connection =null;
// Create the initial context. No JNDI properties are to be supplied here
Context initialContext = new InitialContext();
DataSource dataSource = null;// datasource object
// Look up the datasource using the logical name specified in the ejb-location tag in data-sources.xml
// You must always cast or narrow the object that JNDI returns to the DataSource, because the
// JNDI lookup() method returns a Java object.
dataSource = (DataSource)initialContext.lookup("GTA");
// Establishing db connection
connection = dataSource.getConnection();
System.out.println("Test Successful");
}
}
I am unable to view results as a java file. Plz help me to establish a connection with GTA JNDI name.
I don't think I need to specify jndi name in .xml files
Thanks,

