How to connect hibernate to sqlserver

Source: Internet
Author: User

Mom was called by the boss recently to get sqlserver

Well, it's easy. Just change the configuration of hibernate.

Get the driver package for half a day or something

It's okay to use the SQL Server client to connect to the database. (The connection string in the upper part of other ports is added: No. Microsoft may want to get one, no)

Then it's okay to use myeclipse to connect to the ing object (this function only reduces the workload, but you have to manually change the ing)

At the end of the connection, the problem arises:

Java. lang. AbstractMethodError: com. microsoft. jdbc. base. BaseDatabaseMetaData. getJDBCMajorVersion () I

There are other cases of searching on the Internet:

Java. lang. AbstractMethodError: com. microsoft. jdbc. base. BaseDatabaseMetaData. supportsGetGeneratedKeys () Z

It is said that the SQL Server database driver provided by microsoft has a bug. (Note: There is no problem when calling the original driver of java code to connect to the database. This problem occurs when using hibernate. ---- I have never tried the non-hibernate method, to be verified.) I need to change the driver connection and use the jtds driver.

Change the configuration to OK:

Net. sourceforge. jtds. jdbc. Driver

Jdbc: jtds: sqlserver: // database IP: port; DatabaseName = xxx

Jtds http://sourceforge.net/projects/jtds/files/

By the way, the latest version of jtds may require jdk7 support.

If you use a lower version, you may need to use the older jtds.

For example, if I use jdk1.6 and only use jtds1.2 and later than 1.3, an error will be reported:

Java. lang. UnsupportedClassVersionError: net/sourceforge/jtds/jdbc/Driver: Unsupported major. minor version 51.0

If this error occurs, we can use the jtds version a little lower.

As for the online version of jdk, it is generally not easy to change the jdk version during development.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.