Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error: Column "Budget" not found..I have checked in my sql, it has a budget column

Java
private void pick_highest_value_here_and_display( ArrayList<Double> value,int b,int k) throws Exception {
    // TODO Auto-generated method stub
    double aa[]=value.stream().mapToDouble(v -> v.doubleValue()).toArray();
    double highest=Double.MIN_VALUE;
    double secHighest=Double.MIN_VALUE;
    int highestIndex=0;
   int secIndex=0;
 
for(int i=0;i<aa.length;i++)
   {
   	if(aa[i]>highest)
   	{
                secHighest=highest;
   		highest=aa[i];
   		highestIndex=i;
   		
   	}
}


System.out.println("The highest value is "+highest+"");
    System.out.println("It is found at index "+highestIndex+"");
    String sql ="Select Budget and  Day from menu where ID =?";
    DatabaseConnection db = new DatabaseConnection();
    Connection  conn =db.getConnection();
    PreparedStatement  ps = conn.prepareStatement(sql);
  
    ps.setInt(1, highestIndex);
    ResultSet rs = ps.executeQuery();
    if (rs.next()) 
    { 
     int ba=rs.getInt("Budget");
     int aaa=rs.getInt("Day"); 
     System.out.println("The budget categorizes in sql is"+ba);
     System.out.println("Day in sql is"+aaa);
}
Posted
Comments
Michael_Davies 16-Aug-15 2:21am    
You may have checked but may we see the table schema?

Also, you are using the keyword "and" in your select which may be performing a binary AND, try:

Select Budget, Day from menu where ID =?
wseng 16-Aug-15 2:26am    
thanks, it solved :)

1 solution

When you select multiple columns from a database you separate the columns with a comma. So instead of
C#
String sql ="Select Budget and  Day from menu where ID =?";

try
C#
String sql ="Select Budget, Day from menu where ID =?";
 
Share this answer
 
Comments
wseng 16-Aug-15 2:26am    
Thanks :)
Wendelius 16-Aug-15 3:08am    
You're welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900