开发者

Persistence Unit SQLException No suitable driver

I have a j2ee application deployed on GlassFish. I have mysql jars in GlassFish's lib directory. I am trying to use JPA, and my persistence file is:

<persistence-unit name="teamPU"
    transaction-type="RESOURCE_LOCAL">
    <provider>
        oracle.toplink.essentials.PersistenceProvider
    </provider>
    <class>com.team.dao.Roles</class>
    <properties>
        <property name="开发者_如何学Pythontoplink.jdbc.driver"
            value="com.mysql.jdbc.Driver" />
        <property name="toplink.jdbc.url"
            value="jdbc:mysql://localhost:3306/test" />
        <property name="toplink.jdbc.user" value="root" />
        <property name="toplink.ddl-generation"
            value="create-tables" />
    </properties>
</persistence-unit>

i also have toplink-essentials* jars in lib. When I call dao.find*, it throws the No suitable driver. Don't I have all the jars where they should be?


I had this issue with a Java web app (Servlets/JSP) using JPA/toplink. It worked fine on my development system w/NetBeans deploying to Tomcat. When I deployed the web app to Tomcat on the production server, I'd get "java.sql.SQLException: No suitable driver" and I saw toplink packages in the call stack. What's interesting is that I'm also using direct JDBC in my web app and that worked fine on the production server.

The fix was to copy the appropriate jdbc driver .jar to the jre6\lib\ext folder.

It would be nice to know why it's not enough to have the jdbc .jar put into the web app .war file in the case of toplink...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜