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 3 of 3

Thread: can anyone help me to fix the error in the program???

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default can anyone help me to fix the error in the program???

    import java.sql.*;
    import java.lang.*;
    import java.io.*;
    public class new
    {
    public static void main(String args[])
    {
    try
    {
    //int n=0,p=0,s;
    int SBP,DBP,CHOL,AGE,WAIST,BMI;
    DataInputStream ob=new DataInputStream(System.in);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbcdbc:ddd");
    Statement st = con.createStatement();
    String query = "SELECT CHOL,BMI,AGE,SBP,DBP,WAIST FROM hyp";
    ResultSet rs=st.executeQuery(query);

    while(rs.next())
    {
    if(((SBP>=90&&SBP<=119)&&(DBP<=60&&DBP<=79))||(CHO L<=200)||(AGE<=45)||(BMI>=18&&BMI<=25)||(WAIST>=35 ))
    {
    System.out.println("Normal");
    }
    else if(((SBP>=120&&SBP<=139)&&(DBP>=80&&DBP<=89))||(BM I>=25&&BMI<=30)||(CHOL>=200&&CHOL<=239))
    {
    System.out.println("Stage1");
    }
    else
    {
    System.out.println("Hypertension");
    }
    }
    }
    catch(Exception e)
    {
    System.out.println("error:");
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: can anyone help me to fix the error in the program???

    Please explain what the error is. If you get error messages, copy the full text and paste it here.

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

    The catch block should call the printStackTrace() method to give a full error message.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Jan 2013
    Posts
    39
    My Mood
    Relaxed
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: can anyone help me to fix the error in the program???

    The code you have never initialize the integers so you cant use them in your code.
    You should give them a value before you use them.

    And i noticed too that you called your class "new" which is a keyword and cant be used as a class name, this is probaly your first problem what stands above is your second problem.

Similar Threads

  1. Cant fix this error... Help!
    By Hypermegazord in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 1st, 2012, 01:06 PM
  2. Need Help, Not sure how to fix basic error!
    By ChicoTheMan94 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 15th, 2012, 01:41 PM
  3. Simply error; can't quite fix it.
    By JRabbit in forum Android Development
    Replies: 1
    Last Post: March 19th, 2012, 06:46 PM
  4. Intparse error. I have been trying to fix for hours.
    By TBB3 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 16th, 2011, 01:38 PM
  5. Replies: 6
    Last Post: October 5th, 2011, 07:21 AM