I can't connect to my database vlad.mdb on my computer using DataSource
and i think i shoul create a context.xml but i dont know what to write exactly to get connection.Pls help.
public class AvocatData
{
private DataSource dataSource;
private Connection conn;
I
public AvocatData()
{}
public void init() throws SQLException
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Context lContext = new InitialContext();
//System.out.println("fgh"+lContext+"ghj");
Context envCtx=(Context)lContext.lookup("comp/avocati");
if(lContext==null)
throw new Exception("No Context");
//DataSource dataSource=(DataSource)lContext.lookup("jdbc:/avocati");
DataSource dataSource=(DataSource)envCtx.lookup("jdbc/avocati.mdb");
if(dataSource !=null)
throw new Exception("Este nula");
Connection conn = dataSource.getConnection();
/*if(conn!=null)
{AngajatDAO ad=new AngajatDAO();
ad.getAll();
}*/
}catch(Exception ex){ex.printStackTrace();
}
}
and i think i shoul create a context.xml but i dont know what to write exactly to get connection.Pls help.
public class AvocatData
{
private DataSource dataSource;
private Connection conn;
I
public AvocatData()
{}
public void init() throws SQLException
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Context lContext = new InitialContext();
//System.out.println("fgh"+lContext+"ghj");
Context envCtx=(Context)lContext.lookup("comp/avocati");
if(lContext==null)
throw new Exception("No Context");
//DataSource dataSource=(DataSource)lContext.lookup("jdbc:/avocati");
DataSource dataSource=(DataSource)envCtx.lookup("jdbc/avocati.mdb");
if(dataSource !=null)
throw new Exception("Este nula");
Connection conn = dataSource.getConnection();
/*if(conn!=null)
{AngajatDAO ad=new AngajatDAO();
ad.getAll();
}*/
}catch(Exception ex){ex.printStackTrace();
}
}