在java类中执行查询时出错

在java类中执行查询时出错,java,sql,Java,Sql,hi am不执行以下查询。它在sql developer中运行良好,但在我的java类中不起作用 query = new StringBuilder().append("select SUBSTR(attrib,2) as DEF,DECODE(parent_id,null,null,'C'||parent_id) as xyz,'C'||attribute_id as lmn,decode(parent_id,null,'C'||(to_char(attribute_id)),'C'|

hi am不执行以下查询。它在sql developer中运行良好,但在我的java类中不起作用

    query = new StringBuilder().append("select SUBSTR(attrib,2) as DEF,DECODE(parent_id,null,null,'C'||parent_id) as xyz,'C'||attribute_id as lmn,decode(parent_id,null,'C'||(to_char(attribute_id)),'C'||parent_id||'/'||'C'||attribute_id) as abc from (select ATTRIBUTE_NAME,SYS_CONNECT_BY_PATH(ATTRIBUTE_NAME, '/') as attrib, TREESTRUCT_ATTRIBUTE_NAME,parent_id,attribute_id from MY_TABLE where TREESTRUCT_ATTRIBUTE_NAME = 'xyz' start with attribute_level =1 connect by prior attribute_id = parent_id);").toString();

Statement stmt=con.createStatement();  
System.out.println("After connection");
ResultSet rs =  stmt.executeQuery(query);
System.out.println("After ececute");

未执行查询。转到异常块。在我的java类中执行此查询时,我应该做些什么?

您遇到了什么异常..详细说明异常是什么?无论何时提出问题,请思考有人试图帮助您了解哪些信息。在这种情况下,我们真的,真的需要看到异常。请阅读(另外,您为什么要使用
StringBuilder
?您只是在创建它,附加一个字符串,然后调用
toString
。这是一种模糊的书写方式
string query=“select…”;
)我收到ORA-00911:无效字符例外删除查询末尾的分号。
    query = new StringBuilder().append("select SUBSTR(attrib,2) as DEF,DECODE(parent_id,null,null,'C'||parent_id) as xyz,'C'||attribute_id as lmn,decode(parent_id,null,'C'||(to_char(attribute_id)),'C'||parent_id||'/'||'C'||attribute_id) as abc from (select ATTRIBUTE_NAME,SYS_CONNECT_BY_PATH(ATTRIBUTE_NAME, '/') as attrib, TREESTRUCT_ATTRIBUTE_NAME,parent_id,attribute_id from MY_TABLE where TREESTRUCT_ATTRIBUTE_NAME = 'xyz' start with attribute_level =1 connect by prior attribute_id = parent_id);").toString();

Statement stmt=con.createStatement();  
System.out.println("After connection");
ResultSet rs =  stmt.executeQuery(query);
System.out.println("After ececute");