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("jdbc:odbc: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:");
}
}
}
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.
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.