Connecting to database in sqlserver using Context

Please HELP,

I have this my database is vladHotel made in sqlserver 2005.I have de jdbc drivers for that but i can't connect .My server name is "Vlad"

import javax.sql.DataSource;

import java.io.IOException;

import java.sql.Connection;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import java.sql.SQLException;

import javax.naming.*;

import java.rmi.RemoteException;

import java.rmi.Remote;

import com.microsoft.sqlserver.jdbc.*;

publicclass AvocatData

{

private SQLServerConnectionPoolDataSource dataSource;

private Connection conn;

public AvocatData()

{}

publicvoid init()throws SQLException

{

try{

Context lContext =new InitialContext();

dataSource=(SQLServerConnectionPoolDataSource)lContext. lookup("java:comp/env/jdbc/vladHotel");

conn=dataSource.getConnection();

}catch(Exception ex){ex.printStackTrace();

}

}

}

and give this error:

javax.naming.NoInitialContextException:Need to specify class name in enviroment or system property,or as an applet paramater,or in an application resource file:java.naming.factory.initial

[2291 byte] By [Vlad25a] at [2007-10-2 22:02:31]
# 1

You have to mention the env properties.

something like :

Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");

props.put(Context.PROVIDER_URL, "url here");

Context lContext = new InitialContext(props);

OR like

Hashtable ht = new Hashtable();

ht.put(Context.INITIAL_CONTEXT_FACTORY, "blah");

ht.put(Context.PROVIDER_URL, "blah blah");

Context lContext = new InitialContext(ht);

GayathriMania at 2007-7-14 1:18:59 > top of Java-index,Core,Core APIs...
# 2
What is INITIAL_CONTEXT_FACTORY for sqlserver? The one you show is for Weblogic.Thankskienlua
kienlua_thienthaia at 2007-7-14 1:18:59 > top of Java-index,Core,Core APIs...