Please try
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String name=jTextField1.getText();
String password=jTextField2.getText();
jLabel3.setText(name+" "+password);
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://DBASE\\SQLEXPRESS;DatabaseName=StackHolder", "sa", "dbase");
Statement statement = conn.createStatement();
PreparedStatement prep = conn.prepareStatement("INSERT INTO Users(name, pass) VALUES(?, ?)");
prep.setString(1, name);
prep.setString(2, password);
prep.executeUpdate();
ResultSet resultSet = statement.executeQuery("SELECT name FROM Users");
while(resultSet.next()){
System.out.println("name: " + resultSet.getString("name"));
}
conn.close();
}
catch (Exception ex) {
System.out.println(ex);
}
}