Developing SQL Server based Java Apps using NetBeans IDE
This article introduces you to developing Java (or JFC) based applications with Microsoft SQL Server as the database, using NetBeans IDE. In this first article in a series, I will show you how to establish a connection from your Java programs to a Microsoft SQL Server database using JDBC.
Developing SQL Server based Java Apps using NetBeans IDE - How to establish a Microsoft SQL Server database connection using JDBC (Page 4 of 6 )
You can skip to the next section if you are using NetBeans IDE. This section is only for the Java developers who don’t make use of any IDE.
Make sure that you complete all the steps in the previous section before proceeding with this section. Once you have the correct JDBC driver installed and have configured CLASSPATH (and PATH) correctly, establishing a connection from your Java programs to your SQL Server database is pretty easy.
Regardless of whether you're trying to connect to Microsoft SQL Server, Oracle, Sybase (or any other JDBC data source), establishing a connection to any RDBMS database with Java JDBC is a simple two-step process:
Load the JDBC driver.
Establish the connection.
Let us go through the following program to connect to Microsoft SQL Server database.
You need to modify “serverjag” with your server name, which has Microsoft SQL Server installed. Similarly, you also need to modify the port (default Microsoft SQL Server port is 1433), user id and password to get connected successfully.