Skip to Content
0
Former Member
Jul 17, 2008 at 06:35 AM

Using JDBC to connect to MS SQL DB from a J2EE Application

134 Views

Hi,

I am trying to connect from my J2EE application to a MS SQL Server Database via JDBC.

I am not able to successfully connect, and am getting the following error:

"Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial"

The following code is used to get the connection:

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/" + dataSourceName);

conn = ds.getConnection();

The exact same code is working fine within a Web DynPro project, so I don't think there is an issue with JDBC setup on the J2EE Web Server. Do you have any idea as to why I am unable to connect when using a J2EE Application instead?Am I missing something critical?

Thanks in advance,

Michael