How to Connect SQL Server with Java

Hello Friends, Here is the article to give simple code to connecting SQL Server Database with Java Application.Here i am using eclipse IDE. i am connecting java with SQL Server database using JDBC driver. Let’s see all important steps.

1.First Download jdbc driver. write in google search box “jdbc driver for SQL Server”. Download suitable driver Microsoft site and extract.

2.Open your favorite IDE, i am using eclipse.right click on project.scroll down to Properties.click “Add External JARs”.select the jar file that you downloaded.

3.Write below codes.

4.the above code explanation. server name “localhost”,port number “1433” user name “sa” password “1234”. Database name “Adam”, Table Name “HR.EMPLOYEES” . first_name and last_name are columns. In the codes i am using try and catch. if any exception occurs then it handle by catch block.

Happy Coding…Thanks.

Post Author: adama