开发者

JPA Support for SQL Server 2008 using NetBeans 6.7.1

开发者 https://www.devze.com 2022-12-07 23:40 出处:网络
I am able to create a simple JPA Java application from NetBeans using Apache Derby database. But when I try to do the same with SQL Server 2008, I keep getting the followi开发者_C百科ng error:

I am able to create a simple JPA Java application from NetBeans using Apache Derby database. But when I try to do the same with SQL Server 2008, I keep getting the followi开发者_C百科ng error:

SEVERE: Application class sample.DBTestApp failed to launch javax.persistence.PersistenceException: No Persistence provider for EntityManager named RS6910SQLEXPRESS:3027;databaseName=TestPU: The following providers: oracle.toplink.essentials.PersistenceProvider oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider Returned null to createEntityManagerFactory.

    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
    at sample.DBTestAppView.initComponents(DBTestAppView.java:285)
    at sample.DBTestAppiew.<init>(DBTestAppiew.java:36)
    at sample.DBTestApp.startup(DBTestApp.java:19)

Appreciate your help looking into this.


The problem seems to be with the generated PersistenceUnit name for SQL Server database with an instance name. The generated name was wrong as it was having backslashes and after modifying this to one simple word like "TestPU" instead of the generated "RS6910\SQLEXPRESS:3027;databaseName=TestPU" one, then everything started working.

I think this might be a bug with the NetBeans code generation for SQL Server databases with an instance name.

But as we now know a workaround, we can try to follow this. Just rename the generated persistence unit name in all of your files and things should start working.

0

精彩评论

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