Skip to main content

Where is com.sun.appserv.DataSource ?

3 replies [Last post]
nicolasbolbol
Offline
Joined: 2007-05-11
Points: 0

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 ?

Thanks in advance for your help.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jr158900
Offline
Joined: 2005-04-13
Points: 0
Jan Luehe

glassfish@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@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Scott Oaks

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@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@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net