I am staring a new project with swing application framework in netbeans 6.5 in that i selected newproject->java - java desktop application - basic application-> finish.
when opening the project i saw three classes about,view,app.In view class
i started doing my project in that class i take two textboxes and one button.the
textboxes names are usernamee and password.and a button name is submit.from that
class i connect a database connection to SQLServer 2005.In my code i loaded
driver successfully but not getting connection. In libraries i add sqljdbc.jar
file also.please help me

//code under the button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// getting textbox values.

String user = username.getText();
String pass = password.getText();

System.out.println("username " + user);
System.out.println("password "+pass);

try {
//connecting database

Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");

System.out.println("driver loaded........");

con = DriverManager.getConnection("jdbc:sqlserver://java04:1433;databaseName=appforum;userName=sa");

stmt = con.createStatement();
System.out.println("statement created.");
rst = stmt.executeQuery("select userName,Password from SwingsUser where UserName='" + user + "' and Password='" + pass + "'");
System.out.println("resultset created.");
if (rst.next())
db_username = rst.getString("UserName");
db_password = rst.getString("Password");
System.out.println("retrieving username,password.");


if (user.equals(db_username))
if (pass.equals(db_password))

NewJFrame appframe = new NewJFrame();

} catch (Exception e)

//entered textboxes username and password

driver loaded..... after that process is running only and structed the form

and connection is not getting plz help me