Six Possible solutions for JDBC – SQL Server Connection problem

 Here in this post I am writing about some possible solutions of JDBC – MS SQL server connection problem. During my work I had faced this problem and tried a little hard to findout the solution. In our project when we tried to connect to MSSQL Server, through its default port 1433 it thrown an exception as follows. Hope this will be helpful to you.

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: “Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.”.

  1. Enable SQL Server Network Configuration
    • For this, go to Start Menu => Microsoft SQL Server 2008 => Configuration Tools => SQL Server Configuration Manager
    • Go to SQL Server Network Configuration => Protocols for [Instance Name] => TCP/IP
    • Instance name is the one in which you have created your database. By default it will be SQLEXPRESS
    • Make it enable (if disabled)
  2. Check the port on which SQL server is running
    • For this, go to Start Menu => Microsoft SQL Server 2008 => Configuration Tools => SQL Server Configuration Manager
    • Go to SQL Server Network Configuration => Protocols for [Instance Name] => TCP/IP
    • Instance name is the one in which you have created your database. By default it will be SQLEXPRESS
    • Right click on that and Go to Properties => IP Addresses tab => IP All section
    • There you will find TCP Dynamic Ports property and we have to consider that port number instead of default port 1433
  3. If you still facing the issue then please check Registry
    • Go to Start Menu => run => regedit
    • Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.[Instance Name]\MSSQLServer\SuperSocketNetLib\Tcp\IPAll and check the value of key TcpDynamicPorts. we have to consider that port number instead of default port 1433
Advertisements

HSQLDB: a lightweighted relational database

hsqldb.gif

HSQLDB is a relational database engine written 100% in Java , with a JDBC driver. This supports a subset of ANSI-92 SQL. It is best known for its small size, ability to execute completely in memory and its speed. It offers a small (about 100k), fast database engine which offers both in memory and disk based tables. Embedded and server modes are available. Additionally, it includes tools such as a minimal web server, in-memory query and management tools (can be run as applets or servlets, too) and a number of demonstration examples.This is currently being used as a database and persistence engine in many Open Source Software projects and even in commercial projects and products! It is free under the Modified BSD License.

HSQLDB home : here
Features of hsqldb : here
Known problems with hsqldb: here

Technorati Tags : HSQLDB,

The new attractive features of JDBC 4.0

Java SE 6.0 is expected to be released in October 06. An important part of the new version of Java is the new JDBC 4.0 API. JDBC 4.0 brings several changes to JDBC, but its top priority is making things easier for developers.

Interesting developments in JDBC 4.0 are:

1. No need to explicitly load JDBC drivers using Class.forName() to register a JDBC driver. The DriverManager class takes care of this automatically.
2. Java SE Service Provider mechanism as another means to specify database drivers
3. Specify SQL queries using Annotations
4. Bundled database based on Apache Derby
5. SQL 2003 support, including support for XML as a native database data type
6. Improved exception handling with new exception classes
7. A new DataSet interface. When used in a connected mode, the DataSet functions in a manner similar to ResultSet. A disconnected DataSet functions in a manner similar to a CachedRowSet. You can navigate, modify and delete records in a DataSet.

Technorati tags: JDBC, java