Oracle JDBC SQL命令未正确结束

Oracle JDBC SQL命令未正确结束,oracle,jdbc,Oracle,Jdbc,下面是我的jdbc查询: Connection con = DB_Connection.get_dbConnectionSingleTime("TESTA2", "ao3652", "reset123", "Oracle"); String premium = "Premiums"; String query = "SELECT * FROM ELP_COUNTRY,ELP_COUNTRY_Tax where"+ "ELP_COUNTRY.COUNTRY_ID=Elp_Coun

下面是我的jdbc查询:

Connection con = DB_Connection.get_dbConnectionSingleTime("TESTA2", "ao3652", "reset123", "Oracle");
    String premium = "Premiums";
    String query = "SELECT * FROM ELP_COUNTRY,ELP_COUNTRY_Tax where"+
 "ELP_COUNTRY.COUNTRY_ID=Elp_Country_Tax.Country_Id"+  
 "and ELP_COUNTRY.DESCRIPTION=? and GETENGLISHDESCFROMLISTITEM(ELP_COUNTRY_TAX.TAX_TYPE_ID)=?"+
 "and ELP_COUNTRY_TAX.DEALER_ID is  null order by ELP_COUNTRY_TAX.Effective_Date DESC";
    //-----------------------------------------------------------------------------^
    try(PreparedStatement pst = con.prepareStatement(query)){
        pst.setString(1, Country);// Set the input
        pst.setString(2, premium);
        ResultSet rs = pst.executeQuery();
        rs = pst.getResultSet();
        while(rs.next())
        {
            System.out.println(rs.next());
        }
    }
上面的代码是通过JDBC抛出的sql命令没有正确结束

下面是我的sql查询,运行良好

SELECT *FROM ELP_COUNTRY,ELP_COUNTRY_Tax where 
 ELP_COUNTRY.COUNTRY_ID=Elp_Country_Tax.Country_Id  
 and ELP_COUNTRY.DESCRIPTION='Brasil' and GETENGLISHDESCFROMLISTITEM(ELP_COUNTRY_TAX.TAX_TYPE_ID)='Premiums'
 and ELP_COUNTRY_TAX.DEALER_ID is  null order by ELP_COUNTRY_TAX.Effective_Date DESC 

那么,有人能建议我在jdbc查询中需要做的一些更正吗?

在每个字符串的末尾追加空格:

"SELECT * FROM ELP_COUNTRY,ELP_COUNTRY_Tax where"+
 "ELP_COUNTRY.COUNTRY_ID=Elp_Country_Tax.Country_Id"+  
 "and ELP_COUNTRY.DESCRIPTION=? and GETENGLISHDESCFROMLISTITEM(ELP_COUNTRY_TAX.TAX_TYPE_ID)=?"+
 "and ELP_COUNTRY_TAX.DEALER_ID is  null order by ELP_COUNTRY_TAX.Effective_Date DESC"
例如:

 " .......  where"+
 "ELP_COUNTRY ......."
给出以下字符串:

" ...... whereELP_COUNTRY....."

这是:

 ....... X_TYPE_ID)=?"+
 "and ELP_COU ..........
结果:

....... X_TYPE_ID)=?and ELP_COU ..........

如果在
之后插入空格,其中

 " .......  where "+
 "ELP_COUNTRY ......."
您将得到正确的SQL语句:

 " ...... where ELP_COUNTRY....."