ruds said:
I have changed the java [sic] file which is used by my application and
contains the code for database connection.
As well as the context.xml,web.xml,etc.. specified in the tomcat [sic] 6
docs.
I going wrong smwhere but where i [sic] dont know...
Could you share the details of these changes with us?
Ok.Here are the details:
In the installdir/conf/server.xml file following additions have been
made:-
Under GlobalNamingResources I have added the line,
<Resource name="jdbc/MyDSN" auth="Container"
type="javax.sql.DataSource" description="Sample Database"/>
In the installdir/webapps/myapp/META-INF/context.xml I have added,
<Resource name="jdbc/MyDSN" auth="Container"
type="javax.sql.DataSource" username="" password=""
driverClassName="sun.java.jdbc.JdbcOdbcDriver" url="JdbcOdbcDriver"
maxActive="20" maxIdle="4"/>
In the Java file i have wriiten the following code,
import java.sql.*;
public static Connection connect() throws java.sql.SQLException
{
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
envCtx.lookup("jdbc/MyDSN");
}