Win a copy of Head First Go this week in the Go forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Cannot use JPA in dynamic web project in eclipse oxygen  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a dynamic web project in eclipse and i tried to add JPA to the project. Here are my steps to add JPA:

(1) I right click on my project, then click properties, then i searched "Project Facets" and selected the JPA checkbox and then clicked "Further configuration required"
(2) On the "Modify Faceted Project" modal, I clicked "Add connection..."
(3) On the "New Connection Profile" modal, I clicked "SQL Server", then clicked "Next"
(4) I chose "Microsoft SQL Server 2008 JDBC Driver" and set port number to 3306 and username to root and password to root
(5) Then I clicked "Test Connection", then i got this error:

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 3306 has failed. Error: "The driver received an unexpected pre-login response. Verify the connection properties and check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. This driver can be used only with SQL Server 2000 or later.". ClientConnectionId:5b776a70-6b5d-47eb-b995-19311ebda537

I check that I was able to connect to my local SQL database using MySQLWorkbench with the same username and password.

Can anyone help me please?
 
Master Rancher
Posts: 1162
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never tried to add jpa in such a manor, I always use maven to import the dependencies.
Since you connected with workbench I guess you allready checked if your  database was running?
What version of sql server are you using?
An other reasson could be wrong port, is the standardport tcp for sql not 1433, 3306 is for mysql, so if you haven't changed it yourself to 3306 that might cause the error.
Yet an other reasson could be that tcp is not eabled or that you used escaped backslahes instead of frontslashes in your connectionstring.
 
Saloon Keeper
Posts: 20511
115
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a JPA issue. everything you talked about has to do with the Eclipse IDE. I think that the connection is being attempted by the Eclipse Database Explorer plugin, but I don't let Eclipse do all my thinking for me, so I haven't used those options.

You need to make sure that you are attempting to connect to the correct database host, whether that's localhost or some other machine on the network. You need the exact same parameters that you were using for the MySQL Workbench, which is hostname, database userid, password, and port number. The JDBC URL contains most of that information, although userid and password can also be set as external parameters (and should be, actually).

You need to do this in two places. One is for the developer functions in the Eclipse IDE, such as the Database Explorer. The other place it has to be set correctly is in the application, because when the application is installed on a production server, Eclipse will not be available there. For a webapp server, in fact, the recommended procedure is to use a database connection pool, which is part of the webapp server configuration. JPA can then use that pool. For standalone apps, you can obtain a connection via the DriverManager, among other possibilities.

In any event, the necessary connection data is the same regardless of whether you're talking to the IDE, a webapp server, or a standalone application.
 
Daniel Demesmaecker
Master Rancher
Posts: 1162
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could be wrong, since I have no experience with sql servers, but you say you managed to connect with mysql workbench.
Couldn't be the problem that in your app you're trying to connect to a sql server while you actually using mysql?
It seems weird to me that you could use mysql workbench to connect to a sql server
 
Tim Holloway
Saloon Keeper
Posts: 20511
115
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:I could be wrong, since I have no experience with sql servers, but you say you managed to connect with mysql workbench.
Couldn't be the problem that in your app you're trying to connect to a sql server while you actually using mysql?
It seems weird to me that you could use mysql workbench to connect to a sql server



It's a good question, but actually MySQL Workbench also advertises itself as a DBMS porting tool. Since it's using JDBC, which works on not only MySQL, but SQL Server, PostgreSQL, Oracle, etc., etc., etc. it's possible to work with just about any JDBC-compatible database.

A "gotcha" for SQL server is that the JDBC port isn't turned on by default (not since the SQL Slammer disaster, anyway).

But one VERY good point is that SQL Server's standard port is 1433. It's MySQL that prefers 3306.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!