But it's not a bean. I'm having the same problem trying to acquire a connection inside a JSP (Tomcat running inproc to jboss).
Is it doable at all?
Here's the code for my JSP page:
<%@ page import="javax.naming.*,java.sql.*,javax.sql.*" %>
<%
InitialContext context = new InitialContext();
Object dsObject = context.lookup("InstantDB");
%>
<html>
<body>
Hello, JBOSS!!<br />
DataSource is <%=dsObject.toString()%>. Class is <%=dsObject.getClass().getName()%><br />
Dumping references...<br />
<%
Reference ref = (Reference)dsObject;
%>
Storing <%=ref.size()%> references of class <%=ref.getClassName()%>.<br />
Narrowing...
<%
'Exception...
DataSource ds = (DataSource)javax.rmi.PortableRemoteObject.narrow(dsObject, DataSource.class);
%>
</table>
</body>
</html>
Thanks,
Rodrigo
-----Original Message-----
From: Aaron Mulder [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 18, 2000 1:09 PM
To: jBoss
Subject: Re: [jBoss-User] Datasource exception
Use the JNDI name "java:/comp/env/Hypersonic". Be sure to declare
the data source in your ejb-jar.xml file for that bean.
Aaron
On Mon, 18 Sep 2000, Sean O'Connor wrote:
> I am trying to write a "hello world" type client app that connects to
> the default Hypersonic database. The result when I try to cast to the
> DataSource is the following exception. I know it's finding
> "Hypersonic", if I change that, I'll get a naming exception.
>
> Exception: java.lang.ClassCastException: javax.naming.Reference
>
> Any ideas why? Everything looks ok to me. Here's the source.
>
> Thanks.
> Sean
>
> import java.sql.*;
> import javax.sql.*;
> import java.util.*;
> import javax.ejb.*;
> import javax.naming.*;
>
> public class DBBoss {
>
> public static void main(String[] args) {
>
> String sql = "create table test ( column1 integer )";
>
> try {
> Context ctx = new InitialContext();
>
> DataSource ds = (DataSource) ctx.lookup("java:Hypersonic");
> Connection con = ds.getConnection();
>
> Statement stmt = con.createStatement();
> stmt.execute(sql);
> stmt.close();
> con.close();
> } catch (Exception se) {
> System.out.println("Exception: " + se);
> }
> }
> }
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Problems?: [EMAIL PROTECTED]
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]
