users@glassfish.java.net

Re: Where is com.sun.appserv.DataSource ?

From: Scott Oaks <Scott.Oaks_at_Sun.COM>
Date: Sat, 12 May 2007 20:55:42 -0400

But unless you really need to write non-portable code, the correct class
to cast to is javax.sql.DataSource. It's not clear to me from reading
that tutorial page why they would recommend the appserver-specific class
-- the one exception being if you needed to get a non-transaction
connection from a transaction-defined data source. But since that code
wouldn't be portable, it would be far better to recommend always using
javax.sql.DataSource, and if you need a non-transactional connection,
define a non-transaction data source.

-SCott

On Fri, 2007-05-11 at 21:41, Jan Luehe wrote:
> glassfish_at_javadesktop.org wrote On 05/11/07 14:39,:
>
> >Hello,
> >
> >I just read this tutorial https://glassfish.dev.java.net/javaee5/docs/DG/beamj.html#beams and created a JDBC connection pool for my MySQL database.
> >
> >Now I want to use to my JDBC connection pool with this code :
> >
> >InitialContext ctx = new InitialContext();
> >com.sun.appserv.DataSource ds = (com.sun.appserv.DataSource)
> > ctx.lookup("jdbc/MyBase");
> >Connection con = ds.getConnection();
> >Connection drivercon = ds.getConnection(con);
> >// Do db operations.
> >con.close();
> >
> >The problem is that I don't have the class com.sun.appserv.DataSource in my class path and can't find the jar file where this class is located (I already try to import all jar in the glassfish lib directory). Where is this class ?
> >
> >
>
> This is not really my area of expertise, but it looks like
> com.sun.appserv.DataSource was changed
> to com.sun.appserv.jdbc.DataSource (see
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4917147:
> "com.sun.appserv.DataSource should be com.sun.appserv.jdbc.DataSource"),
> which is included in appserv-ext.jar,
> but the tutorial was never updated.
>
> If so, can you file a bug against docs?
>
>
> Jan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>