Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: need help in exception handling

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry need help in exception handling

    I m designing a demo for my real application i m just testing what happen when event occur
    here's my code when i press button the catch block run

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    String str=jTextField1.getText();
    String oldpass=new String(jPasswordField1.getPassword());
    String newpass1=new String(jPasswordField2.getPassword());
    String newpass2=new String(jPasswordField3.getPassword());
    if(oldpass.equals("") && newpass1.equals("") && newpass2.equals("")){
    JOptionPane.showMessageDialog(null,"Pls Enter the Username and password");
    }
    else
    {

    try
    {
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/ims","root","root");
    String s="select * from admin where Admin_pw=123";
    Statement st=con.createStatement();
    ResultSet rs=st.executeQuery(s);


    while(rs.next())
    {

    String y=rs.getString("Admin_id");


    JOptionPane.showMessageDialog(rootPane, y);
    }}
    catch(Exception e)
    {
    JOptionPane.showMessageDialog(null,ERROR);
    }
    }
    Last edited by gauravdudeja; April 8th, 2013 at 05:55 AM. Reason: format again


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: need help in exception handling

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    What problem are you having?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 4
    Last Post: February 20th, 2013, 10:01 AM
  2. Which of the subclasses of IOException are more probably to be thrown?
    By Kate123 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 16th, 2013, 07:25 AM
  3. Replies: 1
    Last Post: February 6th, 2013, 11:21 AM
  4. Exception Thrown
    By Frame in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 29th, 2011, 11:14 PM
  5. caught or declare might be thrown error
    By IDK12 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 28th, 2011, 01:55 PM

Tags for this Thread