You need a proper jndi.properties file on your ClassPath. It will define
the property 'java.naming.factory.initial', as well as others. These are
needed by JNDI to find your InitialContext.
tim.
> I have download a couple of MS SQL Server trial JDBC2.0 drivers including
> the free one from freetds.org.
>
> The data source I am trying to use looks like:
>
> <data-source
> class="com.evermind.sql.DriverManagerDataSource"
> name="MyDatabase"
> location="jdbc/MyDatabase"
> xa-location="jdbc/xa/MyDatabase"
> ejb-location="jdbc/MyDatabase"
> connection-driver="com.internetcds.jdbc.tds.Driver"
> username="mydbuser"
> password=""
> url="jdbc:freetds:sqlserver://mydbserver:1433/mydatabase"
> inactivity-timeout="30"
> schema="database-schemas/ms-sql.xml"
> />
>
> <data-source
> class="com.evermind.sql.DriverManagerDataSource"
> name="MYDB"
> location="jdbc/MYDBCoreDS"
> xa-location="jdbc/xa/MYDBXADS"
> ejb-location="jdbc/MYDBDS"
> connection-driver="com.inet.tds.TdsDriver"
> username="mydbuser"
> password=""
> url="jdbc:inetdae7:mydbserver:1433?database=mydatabase"
> inactivity-timeout="30"
> schema="database-schemas/ms-sql.xml"
> />
>
> I have tested out both these JNDI (ejb-location) names in the following
> code:
>
> import java.sql.*;
> import javax.naming.InitialContext;
> import javax.sql.DataSource;
> import java.util.*;
>
> class TestSQL
> {
>
> public static void main (String args[])
> {
> try
> {
> // Obtain connection
> InitialContext ctx = new InitialContext();
> DataSource ds = (DataSource) ctx.lookup("jdbc/MYDBDS");
> Connection connection = null;
>
> // Close connection - important!
> connection.close();
> }
> catch(Exception e)
> { System.out.println("Error: " + e.getMessage() ); }
> }
>
> }
>
>
> Neither one of the JNDI database names ("jdbc/MyDatabase" or "jdbc/MYDBDS")
> work. Whenever I try to execute the code for the datasource, I get an error
> as follows:
>
> 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
>
>
> Can anyone tell me what is going on? What is this problem and what can I
> do to correct the problem?
>
> Any help would be much appreciated! Thanks.
>
>
> Tom
>
>
>