0
votes

I'm trying to connect to my existing SQL Express database, but I can't seem to figure out how to create the persistence unit in Netbeans.

Currently, when I try to create a persistence unit, I select "New Database connection". I select a Derby JAR as driver, then I have to enter the database, username and password to generate a JDBC url. The database doesn't have a username or password.
I think this is my database: .\sqlexpress;Database=MyDatabase.
But somehow whenever I click "Test Connection", it fails. I have no idea what I'm doing wrong. Am I missing something obvious in the database string?

1
Derby is for the Derby database, you can't use it to connect to Microsoft SQL Server. And if you want to use Microsoft SQL Server you need to specify the hostname (just .\sqlexpress is not a valid JDBC url for SQL Server). - Mark Rotteveel

1 Answers

1
votes

For MS SQL server use jtds driver http://jtds.sourceforge.net/. Add new driver when creating PU. If your MS SQL server is running on localhost with default port then host is localhost and port 1433. Make sure your server is running.