JPA Support for SQL Server 2008 using NetBeans 6.7.1

View: New views
5 Messages — Rating Filter:   Alert me  

JPA Support for SQL Server 2008 using NetBeans 6.7.1

by rsajja :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 following 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.





Re: JPA Support for SQL Server 2008 using NetBeans 6.7.1

by Arshad Noor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Do you have a JDBC driver installed for SQLServer?  NB supports
Apache Derby (JavaDB) directly, but I'm not sure if it includes
a JDBC driver for SQLServer.

Arshad Noor
StrongAuth, Inc.

rsajja wrote:

> 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 following 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.
>
>
>
>

JPA Support for SQL Server 2008 using NetBeans 6.7.1

by rsajja :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, I do have a JDBC driver installed. In fact, I am able to write a JDBC program to access SQL Server 2008 database using that driver. But am having trouble using JPA with the same driver.



I wanted to find out if anybody has used JPA with SQL Server 2008.



Thanks.




Arshad Noor wrote:
> Do you have a JDBC driver installed for SQLServer?  NB supports

> Apache Derby (JavaDB) directly, but I'm not sure if it includes

> a JDBC driver for SQLServer.

>

> Arshad Noor

> StrongAuth, Inc.

>

> rsajja wrote:

>
> > 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 following 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.

> >

> >

> >

> >
>






Re: JPA Support for SQL Server 2008 using NetBeans 6.7.1

by Arshad Noor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you can reach the SQLServer DB using the JDBC driver directly,
then there is no reason why you shouldn't be able to reach it
through the JPA Persistence layer.

Try looking on Oracle's Toplink website (they are the suppliers
of the "official" JPA library for the JDK) for a possible answer
to your question.

If you can't find anything there, try replacing the Toplink JPA
layer with Hibernate (from JBoss).  Their JPA library may have
a better chance of working with your JDBC driver.

Arshad Noor
StrongAuth, Inc.

rsajja wrote:

> Yes, I do have a JDBC driver installed. In fact, I am able to write a JDBC program to access SQL Server 2008 database using that driver. But am having trouble using JPA with the same driver.
>
>
>
> I wanted to find out if anybody has used JPA with SQL Server 2008.
>
>
>
> Thanks.
>
>
>
>
> Arshad Noor wrote:
>> Do you have a JDBC driver installed for SQLServer?  NB supports
>
>> Apache Derby (JavaDB) directly, but I'm not sure if it includes
>
>> a JDBC driver for SQLServer.
>
>
>> Arshad Noor
>
>> StrongAuth, Inc.
>
>
>> rsajja wrote:
>
>>> 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 following 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.
>
>
>
>
>
>
>
>
>

JPA Support for SQL Server 2008 using NetBeans 6.7.1

by rsajja :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.



Thanks for looking into this.