How it will look context.xml for this code

Joined
May 11, 2006
Messages
1
Reaction score
0
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();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,352
Latest member
SherriePet

Latest Threads

Top