Search code examples
javasqlsql-serverjava-8netbeans-8

Invalid column name "account"


My code is executing well but after it execute on my java output it shows to the error of invalid column name account.

Here is my query String,

{
  String sql = 
  "SELECT [account]" +"[date] 
   FROM [reports].[dbo].[acc] 
   WHERE [account='"+str+"'";
}

Exception:

Exceptioncom.microsoft.sqlserver.jdbc.SQLServerException: The column name account is not valid

Solution

  • Try This:

    {
      String sql = 
      "SELECT [account]," +"[date] 
       FROM [reports].[dbo].[acc] 
       WHERE [account]='"+str+"'";
    }