Archive for August, 2011 The TCP/IP connection to the host localhost, port 1433 has failed

Problem: The TCP/IP connection to the host localhost, port 1433 has failed

Solution: Multiple Issues i had while trying to connect to SQL Server


sqljdbc4.jar class library provides support for JDBC 4.0. It includes all of the features of the sqljdbc.jar as well as the new JDBC 4.0 methods.

sqljdbc4.jar class library requires a Java Runtime Environment (JRE) of version 6.0 or later. Using sqljdbc4.jar on JRE 1.4 or 5.0 will throw an exception.

Use sqljdbc4.jar when your application must run on JRE 6.0, even if your application does not use JDBC 4.0 features.

sqljdbc.jar class library provides support for JDBC 3.0.

sqljdbc.jar class library requires a Java Runtime Environment (JRE) of version 5.0. Using sqljdbc.jar on JRE 6.0 will throw an exception when connecting to a database.

The JDBC Driver does not support JRE 1.4. You must upgrade JRE 1.4 to JRE 5.0 or later when using the JDBC Driver0. In some cases, you might need to recompile your application because it might not be compatible with JDK 5.0 or later. For more information, see the documentation on Sun Microsystems Web site.
sqljdbc4 can  be downloaded from
2. Add one of the above jars to your classpath
3. Copy sqljdbc_auth.dll from the enu\auth\x86 folder of jdbc to C:\Windows\System32
3. Check the SQL Server port on which it is running from SQL Server Management Studio ->Management -> SQL Server Logs > Current


Spring RESTful Webservice + JSON

1. In the Controller

@RequestMapping(method={RequestMethod.GET,RequestMethod.OPTIONS, RequestMethod.POST} ,value=”/product”,headers = “Accept=application/json”)
public ResponseEntity<ProductBO> getProducts(@RequestParam(“id”) String id, @RequestParam(“type”) String type) {

ProductBO prodBO = new ProductBO();
prodBO = service.getProducts(id,type);

HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add(“Access-Control-Allow-Origin”, “*”);
responseHeaders.add(“Access-Control-Allow-Methods”, “GET, OPTIONS, POST”);
responseHeaders.add(“Access-Control-Allow-Headers”, “Content-Type”);
responseHeaders.add(“Access-Control-Max-Age”, “86400”);

return new ResponseEntity<ProductBO>(prodBO, responseHeaders, HttpStatus.OK);

2. web.xml





3. rest-servlet.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”;

<context:component-scan base-package=”com.spring.controller” />

<bean class=”org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping”/>
<bean class=”org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter”>
<property name=”messageConverters”>
<!– Support JSON –>
<bean class=”org.springframework.http.converter.json.MappingJacksonHttpMessageConverter”/>

<bean id=”productView”>
<constructor-arg ref=”jaxbMarshaller” />

<!– JAXB2 marshaller. Automagically turns beans into xml –>
<bean id=”jaxbMarshaller”>
<property name=”classesToBeBound”>

Leave a comment