环境是在小机(aix)的数据库上,Oracle 11g。其他环境中Linux、Windows均没这个错误。
在运行Java写的存储过程的时候,提示一下错误
在删除 ArrayList<String> list=null; 这段代码后,是可以运行的。
所以问题出在 "<" 尖括号上,我不知道是什么原因,为什么会导致 尖括号会报这个错。不知道有没有朋友遇到过,有解决方案没?
在运行Java写的存储过程的时候,提示一下错误
在删除 ArrayList<String> list=null; 这段代码后,是可以运行的。
所以问题出在 "<" 尖括号上,我不知道是什么原因,为什么会导致 尖括号会报这个错。不知道有没有朋友遇到过,有解决方案没?
package com.wonders.sjzl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
public class Indicator{
public final static String FAILURE="E";
public final static String CONNERR="C";
public final static SimpleDateFormat SDF=new SimpleDateFormat("yyyyMMdd");
public final static String[] list(Connection connection,String indicator_type,String indicator_code)throws Exception{
String[] returnValue=null;
StringBuffer sql=null;
ResultSet resultSet=null;
PreparedStatement preparedStatement=null;
ArrayList<String> list=null;
try{
sql=new StringBuffer(32);
sql.append("SELECT * FROM TB_INDICATOR WHERE INDICATOR_TYPE=?");
if(indicator_code!=null&!"".equals(indicator_code)){
sql.append(" AND INDICATOR_CODE=?");
}
list=new ArrayList<String>(8);
preparedStatement=connection.prepareStatement(sql.toString());
preparedStatement.setString(1,indicator_type);
if(indicator_code!=null&!"".equals(indicator_code)){
preparedStatement.setString(2,indicator_code);
}
resultSet=preparedStatement.executeQuery();
while(resultSet.next()){
list.add(resultSet.getString("INDICATOR_CODE"));
}
if(!list.isEmpty()){
returnValue=list.toArray(new String[list.size()]);
}
}finally{
if(resultSet!=null){
try{
resultSet.close();
}catch(Exception ne){
}
resultSet=null;
}
if(preparedStatement!=null){
try{
preparedStatement.close();
}catch(Exception ne){
}
preparedStatement=null;
}
}
return returnValue;
}
}
package com.wonders.sjzl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
public class Indicator{
public final static String FAILURE="E";
public final static String CONNERR="C";
public final static SimpleDateFormat SDF=new SimpleDateFormat("yyyyMMdd");
public final static String[] list(Connection connection,String indicator_type,String indicator_code)throws Exception{
String[] returnValue=null;
StringBuffer sql=null;
ResultSet resultSet=null;
PreparedStatement preparedStatement=null;
ArrayList<String> list=null;
try{
sql=new StringBuffer(32);
sql.append("SELECT * FROM TB_INDICATOR WHERE INDICATOR_TYPE=?");
if(indicator_code!=null&!"".equals(indicator_code)){
sql.append(" AND INDICATOR_CODE=?");
}
list=new ArrayList<String>(8);
preparedStatement=connection.prepareStatement(sql.toString());
preparedStatement.setString(1,indicator_type);
if(indicator_code!=null&!"".equals(indicator_code)){
preparedStatement.setString(2,indicator_code);
}
resultSet=preparedStatement.executeQuery();
while(resultSet.next()){
list.add(resultSet.getString("INDICATOR_CODE"));
}
if(!list.isEmpty()){
returnValue=list.toArray(new String[list.size()]);
}
}finally{
if(resultSet!=null){
try{
resultSet.close();
}catch(Exception ne){
}
resultSet=null;
}
if(preparedStatement!=null){
try{
preparedStatement.close();
}catch(Exception ne){
}
preparedStatement=null;
}
}
return returnValue;
}
}
你可以试下,我觉得是我环境的问题,不知道 Oracle10G 支不支持 Java类型的存储过程
支持的,我前些年就是在 10g 下取的网卡号。 你这个 java source ,在我这里,是没有问题的,我现在是 11g 的环境,一会儿我找个 10 试试;
支持的,我前些年就是在 10g 下取的网卡号。 你这个 java source ,在我这里,是没有问题的,我现在是 11g 的环境,一会儿我找个 10 试试;
因为我记得也是从8i 开始支持的吧。 不知道是不是我系统环境的原因。我的11G测试环境也是没问题的。
我这里的10g,也是报这个错。
SQL> select * from v$version ;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionSQL>
我这里的10g,也是报这个错。
SQL> select * from v$version ;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionSQL>
这么说,那是版本的问题了。