Hi Big Ben, Microsoft Microsoft JDBC Driver for SQL Server published to MAVEN central warehouse

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

I believe that the students who develop applications through Java and SQL Server have experienced the following similar problems.

The JDBC official driver provided by Microsoft is not placed in the MAVEN repository, so if your Java application needs to access SQL Server, you have to download Sqljdbc4.jar to local, and then install the driver each time through the following MAVEN command:

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 your Java application's Pom.xml file:

<Dependency>    <groupId>Com.microsoft.sqlserver</groupId>    <Artifactid>Sqljdbc4</Artifactid>    <version>4.0</version></Dependency>

Finally re-executed:

MVN Clean Package

If you are using Eclipse for development, after the above steps are executed, you may also need to restart eclipse if the compilation does not pass.


Perhaps it is the strong voice of the vast majority of developers, or other reasons, Microsoft this month (this November) released this driver to the MAVEN central warehouse, next time you want to install SQL Server driver, Directly in the Pom.xml file to configure the following (Microsoft provides two versions (6.1.0.jre8 and 6.1.0.jre7) driver, I am currently developing based on JAVA8, so choose 6.1.0.jre8 This version, can refer to here):

<Dependency>    <groupId>Com.microsoft.sqlserver</groupId>    <Artifactid>Mssql-jdbc</Artifactid>    <version>6.1.0.jre8</version></Dependency>


Currently pro-Test passed.

I hope everyone can happily write code.

Reference:

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

Report:. NET call Java RESTful interface time processing a

  This problem is caused by a more difficult date type in the Java language, although we used the framework of jada-time in the development process, but exposed the service interface externally, or kept it as date.
When the Java interface time parameter type is defined as date, we pass. NET call to the rest interface, although it seems to be very simple, the parameter-to-call interface can be, but the test results found that. Net-descendant datetime, after the Java service saved in the database is not correct, and later only to locate the problem.
For example, there is a Java CRM Customer information Rest service. NET Call service, the client Information entity customer is as follows:

     Public class Customer    {        publicstringgetset;}          Public string Get Set ; }          Public Get Set ; }    }
Customer

If we are directly new to a customer and assign Createtime to DateTime.Now:

var New Customer {      "Jeff",      "Wong"  ,      = DateTime.Now,};

The time to insert the database through the Java interface is not correct, although it can be inserted.

There are two types of solutions:
1, Datetime.touniversaltime (). ToString ("s")

This way is the most simple splicing interface message for the interface call, roughly the following:

varSB =NewStringBuffer (1024x768); 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 ("}");varPostData = sb. ToString ();

2. Using Newtonsoft.json

var New isodatetimeconverter {         "yyyy '-' mm '-' dd ' T ' HH ': ' mm ': ' ss',         = datetimestyles.adjusttouniversal}; var postdata = Jsonconvert.serializeobject (ent, Newtonsoft.Json.Formatting.Indented, timeconverter);

Finally, Java8 some language features, such as lambda expression, optional class, Stream API, default method, method reference, and so on, compared to. NET, the development of Java applications is also relatively cool, of course, can not forget the spring Boot, Springcloud these powerful development frameworks, you can really write a lot less code, who knows who.

Hi Big Ben, Microsoft Microsoft JDBC Driver for SQL Server published to MAVEN central warehouse

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.