Java, JDBC, ms Sql server

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
Java

Installing Subversion? Just follow this 7 Steps

During  this week I had installed and configured Subversion and Cruise Control in my office. We all know its relatively simple to configure these but then also here in this post I am just writing the installation and configuration of Subversion into some simple steps. Hope it will be helpful to any of you in future [ Surely. for me too 😉 ].

Click here to Read Full Article

Java

TestNG 5.6 and Junit 4.4 : which framework you will choose for unit testing?

As we all know JUnit is the most famous unit testing framework. Nobody needs any type of introduction for this small and easy framework. Most of the developers are using this as their unit testing framework in their day to day development life. And can I ask one question? Do you know TestNG? a unit testing framework which is named as ‘Next Generation test ing tool’. Here is a small comparison on these two unit testing frameworks.

TestNG Version 5.6 JUnit  Version 4.4
1 Extensive annotation support 1 Supports Annotations but not that much rich as TestNG
2 Flexible test configuration in an external XML file. 2 Configuration is less and no XML file configuration at all.
3 External configuration gives more flexibility. 3 Less configuration makes it more easy and really fast to create 🙂
4 Support for data-driven testing (with @DataProvider). 4 We have to integrate with EasyMock for Mock object testing
5 Support for parameters using @Parameters 5 No such type of annotations
6 Allows distribution of tests on slave machines. 6 NA
7 Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc…). 7 Cant defeat JUnit in this matter. It has a lot of supporting tools and plugins.
8 Embeds BeanShell (scripting)  for further flexibility. 8 JUnit dont have this feature at all.
9 Default JDK functions for runtime and logging (no dependencies). 9 I dont aware of logging support in JUnit.
10 Dependent methods for application server testing. 10 NA
11 Creates a small HTML report at eash time of testing. Which will display the passed/failed tests and errors. It gives the XML output for testing also. 11 JUnit also creates the test report in XML form. But it will not create an HTML form with passed/failed testnames at each test run. But we can create a very useful JavaDoc Style report for entire JUnit testing
12 We dont need a specific name for setup and tearDown. We can make any method/ any number of methods that works on start up 12 Same in Junit also.
13 Here we can create Groups, Suites, etc and it also gives more annotations like
@After/BeforeSuite.
@After/BeforeGroup.
@After/BeforeClass.
@After/BeforeMethod
etc
13 @After/Before works in methods and @After/BeforeClass will work with classes. But no groups or suites.
14 No annotation like @Ignore. But we can ignore through XML congiurations. 14 @Ignore annotation is there for ignoring a method.
15 Dependancy of previous methods can be managed easily 15 Methods dependancy handling between each test methods is not possible easily.
16 Option to run failed tests only/ last test only in the IDE 16 We have to select and run each methods which are failed
17 No AssertThat method support 17 It gives a method AssertThat that is very much flexible for giving a Business type result message for the tests.
18 Using ‘ExpectedExceptions in @Test Annotation’ we can expect some exceptions in the test methods and thus the method will be success. 18 We can use (expected = Exception.class) in the @Test annotation

Conclusion

If you are a very busy programmer and want very little time to spend on testing the code then go for JUnit. It is giving enough support for that. But you need a good testing and more configurable options for each test cases then choose TestNG. The depeneded methods are also can make work on TestNG very easily.

Digg This
Java, javafx, jruby, ruby, Sun

Sun Tech Days : In Hyderabad

std08_web_header.jpg

Yesterday I had attended Sun Developers Conference held here in Hitex Convensional center, Hyderabad, India. It was day ONE of three days conference.  The day ONE was really interesting and informative for me. Got an overview about the new Sun techs and got chance to interact with a lot of developers working in Java.

We reached there aroung 9.30 in the morning and done with our registration formalities. The first seesion as Sun keynote bye Rich Green, Executive Vice President, Software, Sun microsystems. After that there was a Demo showcase in which SIX SUN java professionals presented some software demos. Those were in jMaki, Sun SPOTS, J2ME, Swing, JavaFX etc. There are 30 sessions total in the First day and those are from 5 different categories. Five sessions are going on the same time and the whole day is divided in to Six layers. So a delegate can select a session as per his/her taste. If a person is attentding full sessions then they can attent maximum 6 sessions in a day.

The Sessions which I had attened are

1. JEE , Glassfish and their future

2. Testing with Junit and other Testing tools

3. Rapid development with Ruby, JRuby and rails

4. Java Persistence API : Further simplifying persistence.

5. Java troubleshooting tips.

6. JEE with Spring ad Seam.

You can check the other sessions here

The first day ended with a Welcome reception – delicious Dinner and a Music Mela. 🙂 You can read more about each sessions in my next posts…