MS SQL Server Java Connection Source Code

Source Code

After running this code you will see the successful message as shown blow.


Click here for Detailed Tutorial


 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;

/**
*
* @author cs2it.blogspot.com
*/
public class RealEstate {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try{
final String DATABASE_URL =
"jdbc:sqlserver://localhost:1433;databaseNam=YourDatabaseName";
Connection connection =
DriverManager.getConnection(DATABASE_URL, "YourUserName", "Password");
JOptionPane.showMessageDialog(null, "Connection to database is Successful");
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);

}
}
}
Click on the download button for full source code

 Download


Comments

Popular posts from this blog

Body Mass Index (BMI) calculator with JUnitTesting in Java

Stack and Queue Implementation with JUnitTesting according to UML