Exception in creating InitialContext.



hi
here is a class to make connectivity with Derby database. jndi name is
created for jdbc connectivity as jdbc/proformaInvoice
import com.maruti.proforma.dto.ConcreteLoginDTO;
import com.maruti.proforma.dto.LoginDTO;
import java.sql.*;
import java.util.*;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public final class Database {
private static DataSource ds=null;
private static Connection conn=null;
private static InitialContext ic=null;
private static Map <String,String> authMap=null;
private static Statement stmt=null;
private static ResultSet res=null;
/** Creates a new instance of Database */
private Database() {
}
public static void connect()
{
try
{
ic= new InitialContext(); //<----------here it gives
javax.naming.NoInitialContextException: 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

what is this exception for? what will I have to do then?
//rest is kept as to verify complete program
DataSource
ds=(DataSource)ic.lookup("jdbc/proformaInvoice");
conn=ds.getConnection();
}
catch(SQLException se){se.printStackTrace();}
catch(NamingException ne){ne.printStackTrace();}
}
public static boolean validate(LoginDTO loginDTO)
{
boolean bnFlag;
authMap=new HashMap<String,String>();
try
{
if(conn == null){System.out.println("Conn is null");}
stmt=conn.createStatement();
res=stmt.executeQuery("Select User, Password from
UserMaster");
while(res.next())
{

authMap.put(res.getString("user").toUpperCase(),res.getString("password"));
System.out.println(res.getString(1) + "
"+res.getString(2));
}
if(authMap.containsKey(loginDTO.getName()) &&
authMap.get(loginDTO.getName()).equals(loginDTO.getPassword()))
{
bnFlag=true;
}
else
{
bnFlag=true;
}
}
catch(SQLException se){bnFlag=false;}
return bnFlag;
}
public static void main(String[] args)
{
Database.connect();
Database.validate(new ConcreteLoginDTO("LEO","leo"));
}
}

.



Relevant Pages

  • Re: Camping or Merb
    ... and has heavy persistent database connectivity. ... anyway i would recommend nginx as load balancer and for serving static files and flv's, evented mongrel for backend, merb for backend, erubis for templates, and sequel fro postgresql database - supports connection pooling and persistent connections. ...
    (comp.lang.ruby)
  • Re: idiot database flamewars
    ... > I have manged to get connectivity at leased I think I do. ... next section lists ... The database will ask for a password but so will ... >>It's more of a Wine question than anything else, ...
    (Fedora)
  • Re: Java/SQL Developer for a 12 month contract opportunity in Albany, NY
    ... contract opportunity in Albany, NY. ... specifically database design, testing and implementation. ... What a surprise, connectivity involved connecting to databases. ...
    (comp.lang.java.programmer)
  • Re: Which databse?
    ... But by using a specific database connectivity layer, you lock yourself into only using that database. ... Somewhere around here I have a Delphi W32 proof of concept that makes the switch back and forth online by just clicking on a "ChangeString" button. ...
    (borland.public.delphi.non-technical)
  • Re: Advice on choosing IP PBX
    ... intelligent system that will integrate with our database, ... I wish I knew how they could get ISDN interfaces so cheap... ... line for your ADSL connectivity (unless you've got cable or leased line ... a business quality service and go with it - however you mention database ...
    (uk.telecom)