XI dapupben, Microsoft JDBC Driver For SQL Server has been released to the maven central repository, jdbcmaven

Source: Internet
Author: User
Tags sql server driver maven central

XI dapupben, Microsoft JDBC Driver For SQL Server has been released to the maven central repository, jdbcmaven

I believe that students who develop applications through java and SQLServer have experienced the following similar problems.

The official JDBC driver provided by Microsoft is not placed in the Maven repository. If your Java application needs to access SQL Server, You have to download sqljdbc4.jar to your local device, run the following Maven command to install the driver:

mvn install:install-file -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar -Dfile=YOUR FILE DIR\sqljdbc4.jar


Then, configure the following in the POM. xml file of your Java application:

<dependency>    <groupId>com.microsoft.sqlserver</groupId>    <artifactId>sqljdbc4</artifactId>    <version>4.0</version></dependency>

Finally, execute:

mvn clean package

If you are using Eclipse for development, you may need to restart Eclipse if the compilation fails after the above steps are executed.


Perhaps it was a strong response from the masses of developers, or for any other reason. Microsoft released this driver to the Maven central repository in the last month (December, next time you want to install the SQL Server Driver, directly go to POM. in the xml file, perform the following configuration (Microsoft provides two versions (6.1.0.jre8 and 6.1.0.jre7). My current development is based on Java8, so I chose 6.1.0.jre8. For details, refer to here ):

<dependency>    <groupId>com.microsoft.sqlserver</groupId>    <artifactId>mssql-jdbc</artifactId>    <version>6.1.0.jre8</version></dependency>


The test is successful.

I hope everyone can write the code happily.

 

Refer:

Http://stackoverflow.com/questions/19537396/missing-artifact-com-microsoft-sqlserversqljdbc4jar4-0

 

Appendix:. NET calls Java Restful interface time processing 1

This problem is caused by the Date type that is more difficult to use in the Java language. Although we are using the Jada-Time framework during the development process, the service interface is exposed to the outside and maintained as Date.
When the Java interface Time Parameter type is defined as Date, we use. NET calls the Rest interface, although it seems very simple, just pass the parameter to the caller to call the interface, but the test results show that ,. the DateTime of the NET transmitter, which is stored in the database through the Java service, is not correct, and then the problem is located.
For example, there is a Java CRM Customer Information Rest service and. NET call service. The Customer information entity is as follows:

Public class Customer {public string firstName {get; set;} public string lastName {get; set;} public DateTime createTime {get; set ;}}Customer

If we create a New Customer and assign the createTime value to DateTime. Now:

 var ent = new Customer {      firstName = "jeff",      lastName = "wong",      createTime = DateTime.Now, };

The time for database insertion through the Java interface is incorrect, although it can be inserted.

There are two solutions:
1. DateTime. ToUniversalTime (). ToString ("s ")

This method is the simplest interface message for interface calling, which is roughly as follows:

var sb = new StringBuffer(1024);sb.Append("{");sb.AppendFormat(" \"firstName\": \"{0}\",", ent.firstName);sb.AppendFormat(" \"lastName\": \"{0}\",", ent.lastName);sb.AppendFormat(" \"createTime\": \"{0}\"", ent.createTime.ToUniversalTime().ToString("s"));sb.Append("}");var postData = sb.ToString(); 

 

2. Use Newtonsoft. Json

 var timeConverter = new IsoDateTimeConverter {         DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss",         DateTimeStyles = DateTimeStyles.AdjustToUniversal };var postData = JsonConvert.SerializeObject(ent, Newtonsoft.Json.Formatting.Indented, timeConverter);

Finally, I felt that some language features of Java 8 were added, such as Lambda expressions, Optional classes, Stream APIs, default methods, and method references. NET, developing Java applications is also quite easy. Of course, you can't forget the powerful development frameworks such as Spring Boot and SpringCloud. You can really write less code and who knows who to use.

 

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.