Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

JDBC Connection to an external Database in NW2004s !

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 ?

Former Member
Not what you were looking for? View more on this topic or Ask a question