Hi,

Iīm trying to connect to a mysql db using DataSource but it's not working.
The message is:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or in an application resource file: java.naming.factory.initial

Does anyone knows how to specify class name in environment?
Or how can I fix it? Do I need to change Eclipse conf?
I have an apache server 9.0

My code:
public class ValidateKey {
	public int GetKey(String valor) {
		int result;
		Context initContext;
		Connection connection = null;
		Statement statement = null;
		ResultSet rs = null;
		String query = "SELECT * FROM users WHERE email='"+valor+"'";
		try {
			initContext = new InitialContext();
                        //HERE is where the message appears
			DataSource ds = (DataSource) initContext.lookup("java:/comp/env/jdbc/DBTest");
			connection = ds.getConnection();
			statement = connection.createStatement();

My context.xml is:
	<Resource
		auth="Container"
		driverClassName="com.mysql.jdbc.Driver"
		type="javax.sql.DataSource"
		url="jdbc:mysql://localhost:3306/test"
		maxActive="20" maxIdle="10" maxWait="10000"
		name="jdbc/DBTest"
		username="user_test"
		password="test_user"
		/>
My web.xml:
         <resource-ref>
		<description>TestDB</description>
		<res-ref-name>jdbc/DBTest</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>

Thanks in advanced.