Results 1 to 2 of 2

Thread: Tomcat stop

  1. #1
    danyperez1989 is offline Member
    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Default Tomcat stop

    First hello its my first time in the forum, if someone can help me i really apreciated, im doing a login application with java and mysql , the issue is when i run the program and press the button automatically the tomcat server stops and i dont know why, this are my codes, thanks:
    For dbconnection
    Java Code:
    package BaseDatos;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    
    public class DBConnection 
    {
    	//Static instance of connection, only one will ever exist
    	private static Connection _connection = null;
    	
    	private DBConnection()
    	{
    		try	
    		{
    					
    			String userName = "root";
                String password = "admin";
                String url = "jdbc:mysql://127.0.0.1:3306/Leon";
               
                
                Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                _connection = DriverManager.getConnection (url, userName, password);
    		}
    		catch (ClassNotFoundException e){	
    			System.out.println(e.getMessage());
    			System.exit(0);
    		}
    		catch (SQLException e){			
    
    			System.out.println(e.getMessage());
    			System.exit(0);
    		}
    		catch (Exception e){
    			e.printStackTrace();
    		}
    	}
    	
    	//Returns single instance of connection
    	public static Connection getConnection()
    	{		
    		//If instance has not been created yet, create it
    		if( _connection == null )
    		{
    			new DBConnection();
    		}
    		
    		return _connection;
    	}
    	
    	public static void closeConnection()
    	{
    		try
    		{
    			if ( _connection != null )
    			{
    				_connection.close();
    			}
    			
    			_connection = null;
    		}
    		catch( Exception ex )
    		{
    			ex.printStackTrace();
    		}
    	}
    }
    For Login
    Java Code:
    package Login;
    
    import com.vaadin.server.VaadinRequest;
    import com.vaadin.ui.Button;
    import com.vaadin.ui.Button.ClickEvent;
    import com.vaadin.ui.ComboBox;
    import com.vaadin.ui.FormLayout;
    import com.vaadin.ui.GridLayout;
    import com.vaadin.ui.Label;
    import com.vaadin.ui.PasswordField;
    import com.vaadin.ui.TextField;
    import com.vaadin.ui.UI;
    
    
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import BaseDatos.DBConnection;
    
    
    
    /**
     * Main UI class
     */
    @SuppressWarnings("serial")
    public class LoginUI extends UI{
    	private PreparedStatement _preparedStatement = null;
    	private ResultSet _resultSet = null;
    	@Override
    	protected void init(VaadinRequest request) {
    		
    		Label usuario = new Label("user");
    		final TextField usuariot= new TextField("");
    		Label pass = new Label("Contrasea");
    		final PasswordField passp = new PasswordField();
    		Label sistema = new Label("Rol");
    		final ComboBox sistemat = new ComboBox();
    		Button button = new Button("Ingresar");
    		final FormLayout formulario =new FormLayout();
    		
    		setContent(formulario);
    		
    		GridLayout Login = new GridLayout(2, 3);
    		Login.addComponent(usuario);
    		Login.addComponent(usuariot);
    		Login.addComponent(pass);
    		Login.addComponent(passp);
    		Login.addComponent(sistema);
    		Login.addComponent(sistemat);
    		Login.addComponent(button);
    		
    		formulario.addComponent(Login);
    		
    		
    		
    		button.addClickListener(new Button.ClickListener() {
    			public void buttonClick(ClickEvent event) {
    				try{
    					String user = usuariot.getValue();
    					System.out.println(user);
    					String passw = passp.getValue();
    					System.out.println(passw);
    					String sqlQuery = "SELECT usuario FROM user " + "WHERE " + "usuario="+ user  +" AND " + "contrasena="+passw;
    					System.out.println(sqlQuery);
    					_preparedStatement = DBConnection.getConnection().prepareStatement( sqlQuery );	
    					_resultSet = _preparedStatement.executeQuery();
    					if(( _resultSet != null )){
    						formulario.addComponent(new Label(" existe"));
    					}else{
    						formulario.addComponent(new Label(passw));
    					}
    				} catch (Exception e) {
    
    					e.printStackTrace();
    				}finally{
    					
    				}
    					
    				}
    			});
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Tomcat stop

    There's nothing in there to do with Tomcat.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 3
    Last Post: 06-19-2012, 04:40 PM
  2. Replies: 0
    Last Post: 10-20-2011, 10:10 AM
  3. New to java stop need help stop
    By Skrap09 in forum New To Java
    Replies: 3
    Last Post: 09-17-2011, 12:45 PM
  4. Use stop button to stop moving (stop timers) on JPanel
    By mneskovic in forum New To Java
    Replies: 3
    Last Post: 07-23-2010, 12:50 PM
  5. Tomcat In Eclipse - Sysdeo Tomcat Plug-in
    By JavaForums in forum Eclipse
    Replies: 1
    Last Post: 02-13-2008, 10:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •