Struts problem
Hi everyone,
could anyone help me with a proble in connecting a database through struts. Im using tomcat 4.1 and Eclipse IDE. well the IDE is not relevant but ...I have created a connection class in which i Have the following code :
public class MyConnection
{
public Connection con=null;
public ResultSet rs=null;
public PreparedStatement ps=null;
private DataSource ds=null;
private DataSource GetDataSource()
throws NamingException
{
try
{
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/temp");
return ds;
}
catch(NamingException ex)
{
throw new NamingException("Naming look up Failue first time" + ex.getMessage());
}
catch(Exception ex)
{
throw new NamingException("Naming look up Failue in initialization." + ex.getMessage());
}
}
Now How do i add a <context> code into server.xml. Im connecting to a sybase database. When i careate an object of the above code in a program and call it, it gives the following error :
Error in initializing connection Naming look up Failue first time Cannot create resource instance
I just want to know what code is to be added to the server.xml of tomcat.
following is the driver name and the URL for connectivity
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
con = DriverManager.getConnection("jdbc:sybase:Tds:192.168.4.8:4100/mtslive","sa","");
pls help as soon as you can,
thanks a lot,
your answer will be a great help to me.
saroj.
Awaiting replies,
Thanks,
Saru
Bookmarks