on 07-17-2008 7:35 AM
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
Hi,
Have you specified the JNDI Name as follows in ejb-xml
<ejb-jar>
...
<enterprise-beans>
...
<entity>
...
<resource-ref>
<res-ref-name>jdbc/ejavaPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
...
</enterprise-beans>
...
</ejb-jar>
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.