cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC Connection to an external Database in NW2004s !

Former Member
0 Kudos

Hello,

using the J2EE Server in NW2004s i'm facing some troubles in an Servlet, wich should get the connection from the J2EE Server with an jndi lookup. The JDBC driver is deployed by our hosting partner via the Visual Administrator.

The next step was to create an datasource in the SAP NetWeaver Administrator ( Web Fronted ) and an alias to this datasource.

The alias is "bpitrigger".

Finally the servlet code :

public void init() throws ServletException {
		// TODO Auto-generated method stub
		log.info("Init Methode startet.");
		log.info("Get DB Connection with JNDI Lookup.");
		DataSource ds = null;
		String contextName = "jdbc/bpitrigger";
		log.debug("Suche in Context nach " + contextName);
		try{
			Context cont = new InitialContext();
			ds = (DataSource) cont.lookup(contextName);
			Connection con = ds.getConnection();
			this.stmt = con.createStatement();
			
			this.getServletContext().setAttribute("statement", stmt);

		}
		catch(Exception e){
			log.error("Error on DataSource. " + e.getMessage());
		}
		log.debug("Datasource : " + ds.toString());
	} 

The logging of the servlet is telling me, that no object with the name bpitrigger could be found.

My question is : how can i verify in the j2ee server, that the deployed jdbc driver is working and can be referenced over the jndi context with the alias ?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

JNDI Lookup ist working.