It's because jdbc is not a datasource, it's a container (or something
similar.  I have not the time to look it up).

In your server.xml/web.xml files you should have a resource that's probably
named "jdbc/myConnection".

Your code should read

dataSource2=(DataSource)ctx.lookup( "java:comp/env/jdbc/myConnection" );

This of course is a guess.  Without your config file, it's hard to tell.


Andy




----- Original Message -----
From: "shawn" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Sunday, December 22, 2002 9:04 PM
Subject: ClassCastException Conn=dataSource.getConnection();


> I am getting a java.lang.ClassCastException
>
> from Connection conn = datasource.getConnection();
> in the folowing:
>
> try {
>             Context ctx = new InitialContext();
>             if(ctx == null )
>             {throw new Exception("Boom - No Context");}
>
>
>             DataSource
> dataSource2=(DataSource)ctx.lookup("java:comp/env/jdbc/");
>             if(dataSource2 == null )
>             {throw new Exception("Boom - No dataSource");}
>
>             conn = dataSource2.getConnection();
>         }
>
> Why would that be?
>
> TIA
>
> Shawn
>
> PS the ds ="null" error I had earlier was due to not setting up my root
> context properly.  That document base threw me off.
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to