users@glassfish.java.net

Re: Glassfish, MySQL and _at_Resource

From: <glassfish_at_javadesktop.org>
Date: Mon, 09 Jun 2008 11:47:39 PDT

Hello Shalini,

My Databaseconnection seems to be fine, I get it rolling using the following ( skipping DI ):

                [i]InitialContext initialContext;
                DataSource dataSource=null;
                try {
                        initialContext = new InitialContext();
                        dataSource = (DataSource) initialContext.lookup("jdbc/__MysqlPool");[/i]


What I would like to do is to accomplish this by using Dependecy Injection:
public class JDBCSelectServlet extends javax.servlet.http.HttpServlet {
        @Resource(name="jdbc/__MysqlPool")
        private javax.sql.DataSource dataSource;

But the datasource is never set.

I Seem to be having problem with DI.
Is there something I should do, for getting DI going ?

regards, i
[Message sent by forum member 'inkimar' (inkimar)]

http://forums.java.net/jive/thread.jspa?messageID=279235