get paid to paste

Not working

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

class LoginDemo extends JFrame
{
	JButton SUBMIT,ADD;
	JPanel panel;
	JLabel label1,label2;
	final JTextField text1;
	final JPasswordField text2;
	final JTextField text3;
	static String value1;
	static String value2;
	
	LoginDemo() 
	{
		label1 = new JLabel();
		label1.setText("UserName:");
		text1 = new JTextField(15);
		label2 = new JLabel();
		label2.setText("Password:");
		text2 = new JPasswordField(15);
		text3 = new JTextField(1500);
		SUBMIT=new JButton("Login");
		ADD=new JButton("Create Account");
		panel=new JPanel(new GridLayout(3,2));
		panel.add(label1);
		panel.add(text1);
		panel.add(label2);
		panel.add(text2);
		panel.add(SUBMIT);
		panel.add(ADD);
		panel.add(text3);
		
		add(panel,BorderLayout.CENTER);
		value1 = null;
		value2 = null;
		
		SUBMIT.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent ae) 
			{
				value1=text1.getText();
				value2=text2.getText();
				text3.setText("got values");
				Connection con = null;
				//String url = "jdbc:mysql://localhost/UsersDB";
				//String driver = "com.mysql.jdbc.Driver";
				//String user = "root";
				//String pass = "";
				String user1="";
				String pass1="";
				text3.setText("database info ready");
				
				try
				{
					text3.setText("try start");
					
					Class.forName("com.mysql.jdbc.Driver");
					//Class.forName(driver);
					
					text3.setText("driver in place");

					con = DriverManager.getConnection("jdbc:mysql://localhost:3306/UsersDB",  "root", "");
					//con = DriverManager.getConnection(url, user, pass);
					
					text3.setText("connection in place");
					
					Statement st = con.createStatement();
					
					text3.setText("settling up statement");
					
					ResultSet res = st.executeQuery("SELECT * FROM login3 where username='"+value1+"' && password='"+value2+"'");
					
					text3.setText("query sent");
					
					while (res.next())
					{
						user1 = res.getString("username");
						pass1 = res.getString("password");
						text3.setText("looping");
					}
					
					if (value1.equals(user1) && value2.equals(pass1) && value1.equals("Admin"))
					{
						AdminMenu window = new AdminMenu();
					    window.setVisible(true);
					    dispose();
					}
					else if (value1.equals(user1) && value2.equals(pass1) && !(value1.equals("")) && !(value2.equals("")))
					{
						Menu window = new Menu();
					    window.setVisible(true);
					    dispose();
					}
					else if (value1.equals("") && value2.equals(""))
					{
						JOptionPane.showMessageDialog(null,"Username or password cannot be empty","Error",JOptionPane.ERROR_MESSAGE);
					}
					else
					{
						JOptionPane.showMessageDialog(null,"Incorrect username or password","Error",JOptionPane.ERROR_MESSAGE);
					}
				}
				catch(Exception e)
				{
					System.out.println(e.getMessage());
				}
			}
		});
		
		ADD.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent ae)
			{
				CreateAccount account=new CreateAccount();
				account.setVisible(true);
			}
		});
		
		setTitle("Login");
		setSize(200,130);
		setLocationRelativeTo(null);	
	}

	public static String getLoginName() 
	{
		return value1;
	}
	
	public static String getPassword() 
	{
		return value2;
	}
}

Pasted: Mar 31, 2013, 8:37:15 am
Views: 8