users@glassfish.java.net

Re: Creating a JNDI for MySQL ?

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Oct 2007 15:23:19 PDT

Hi Marina,

Lost you there.

In JBoss I use mysql-ds.xml ( deployed in the server/deploy) and persistence.xml file that is in my '/META-INF/'.

My class gets injected .... at least in JBoss with the correct Manager.

this is my WS:
Stateless()
@WebService()
public class ProjectManagerWs {

    @PersistenceContext(unitName = "company")
    private EntityManager em;
    @WebMethod
    public String version() {
        return "ProjectManager version 0.1";
    }
    @WebMethod
    public Object[] getProjects() {
        Query q = em.createNamedQuery("Project.findAllProjects");
        List projects = q.getResultList();
        return projects.toArray();
    }
}

Do you suggest that I change my restype in my resource.xml:
it is like this now:
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
        res-type="javax.sql.DataSource">

And Datasource seems wrong to me.
could probably use that in some way .... just don't know how.

The EntityManager gives me access to persist and merge and soforth:
So that I can run the following code:
[b]Query q = em.createNamedQuery("Project.findAllProjects");[/b]

Any more suggestions ?

thanks a bunch, i
[Message sent by forum member 'inkimar' (inkimar)]

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