If you open a console (java -jar orionconsole.jar ) you will see that your
jdbc connections are in fact can be found in JNDI at jdbc/myEJBDS and not
java:comp/env/jdbc/myEJBDS.

You are getting casting  exception because in your datasources.xml you
defined DataSource as com.evermind.sql.ConnectionDataSource and not
interbase.interclient.DataSource. These two classes are siblings. Java
doesn't support casting between siblings.


This code should be better as it will work with any databases and any
datasource classes.
try
{
  context = new InitialContext();
  javax.sql.DataSource ds = (javax.sql.DataSource )
context.lookup("jdbc/myEJBDS");
}
catch(NamingException ne)
{
}

Boris



----- Original Message -----
From: "Kevin Duffey" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Sunday, November 26, 2000 1:40 AM
Subject: Can't find DataSource at java:comp/env/jdbc/NameOfDataSourceDS..??


> Hi all,
>
> Strange things abrew. I have my Interbase datasource set up as list below.
I
> thought the way inside of an EJB to find a DataSource would be:
>
> Context context = null;
>
> try
> {
>   context = new InitialContext();
>   interbase.interclient.DataSource ds = (interbase.interclient.Datasource)
> context.lookup("java:comp/env/jdbc/myEJBDS");
> }
> catch(NamingException ne)
> {
> }
>
>
> However, through various trial and errors, I found the only way I can get
it
> is if I do:
>
> Object o = context.lookup("jdbc/myEJBDS");
>
> If I try to typecast it to an interclient datasource, I get a class cast
> exception. I am at a loss as to why if this is J2EE standard programming,
I
> have to be database specific or vendor specific at any point, and why is
it
> not finding it in java:comp/env?
>
> Thanks for any help.
>
>
>
> <data-source class="com.evermind.sql.ConnectionDataSource"
>                   inactivity-timeout="120"
>                   location="jdbc/SelectScreenDS"
>                   name="My Data-source"
>                   xa-location="jdbc/xa/MyXADS"
>                   ejb-location="jdbc/MyEJBDS"
>                   url="jdbc:interbase://localhost/c:/database/mydb"
>                   connection-driver="interbase.interclient.Driver"
>                   username="sysdba"
>                   password="masterkey"
>                   />
>


Reply via email to