2

After 5 hours of trying and not finding any solution to my problem, maybe you guys can help me. I´ve been trying to add a database connection to my eclipse JPA-project, but the window in Eclipse won´t let me pass on:

enter image description here

I am using Eclipse Link 2.5.2 and JPA 2.1 with the newest Eclipse Neon release, my Database is an MSSQL-Server 2012. I have implemented a JDBC connection, which works just fine (to make sure the Server-Ports are open and the connection-URL etc. is correct).

If i want to add a new connection with new->other->Connection Profiles->Connection Profile in my JPA-Project. Eclipse lets me choose the Connection Profile Type where I select SQL Server, then I define a new Driver with New Driver Definition, where I take Microsoft SQL Server 2012 JDBC Driver, add the sqljdbc4.jar (which is located in my lib folder and added to the build path). Lastly I add the connection URL and the other preferences. After I click OK, I cannot move on from there because the buttons are disabled. Did anyone experienced the same problem or knows a solution for this? Thanks in advance!

Jérôme
  • 1,254
  • 2
  • 20
  • 25
Miazl
  • 31
  • 1
  • 3

2 Answers2

7

Do not use "Microsoft SQL Server ..." driver (there seems to be a bug here in Eclipse, as I tested the same procedure w/ MySQL & it worked just fine), so instead use "Generic JDBC Driver"

  1. Type in name (& optional description)

  2. Edit driver definition (Click on triangle icon)

    • 2.1 Jar List tab - Add in path to the driver jar file
    • 2.2 Properties tab -

      • 2.2.1 - Connection URL : jdbc:sqlserver://localhost:50147 (MS Sql Server does not necessarily use the default port 1443 & allocates a listening port dynamically - see How to Identify port number of SQL server (#2) for how to determine which port is being used)
      • 2.2.2 - Database name : "Your database name"
      • 2.2.3 - Driver class : com.microsoft.sqlserver.jdbc.SQLServerDriver
      • 2.2.4 - UserID : "myuserid"
      • 2.2.5 - Password :

After this the "Test Connection" button is active & can be clicked & returns "Ping succeeded!".

I also had to do the below 3 things for MS Sql Server : (My windows authentication login i.e. domain\login did not work)

  1. In SQL Server Configuration Manager - Enable ALL TCP/IP protocols for

    • 1.1 SQL Native Client Configuration / Client Protocols, and,
    • 1.2 SQL Server Network Configuration / Protocols for SQLEXPRESS (Apparently TCP/IP was disable by default for my MS Sql Server)
  2. In MS Sqlserver Mgmt Studio, in Object Explorer

    • 1.1 Under Security - Create a new login "myuserid" (password : ) & assign appropriate default db, etc. to it
    • 1.2 Under "Your database name" - Create a new user "myuserid" & assign this user to the login "myuserid" above
  3. In MS Sqlserver Mgmt Studio, in Object Explorer Under "Your datatbase name", rt. click, "Properties" | "Permissions" | "View Server Permissions" | "Security" | "Server Authentication" - select "SQL Server and Windows Authentication Mode". Restart the SQL Server.

Press the "Test Connection" button & it'll say "Ping Succeeded!" This can also be done in Eclipse's Database perspective (for create a new connection) as the same setup windows are used there as well.

4

The JPA has a problem with the connection of the driver that you are using, but it works very well with the JBDC 2008 driver, I recommend you to use it and try it.

enter image description here

Then you can quietly make the respective settings for your connection to the database you want.

Kobi
  • 2,494
  • 15
  • 30
Leonardo Tomalo
  • 103
  • 2
  • 6