Olá!!
Gente,
Criei um método que chama um método java para chamar uma FUNCTION do Oracle. No momento da execução o erro ORA-01745: nome de variável de host/ligação inválido é gerado. Alguém já passou por isso :?:
Para facilitar, segue o código.
public static String abrirOS( String codfil, String codcen, String codapl, String obs, String maqpar)throws Exception {
ResultSet rs = null;
Connection conn = SqlConnection.getInstance().getConnection();
CallableStatement stmt = null;
String result = "";
/**/
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
java.sql.Date data_formatada = new java.sql.Date(format.parse(maqpar).getTime());
/**/
try {
String call = "CALL ? := ABRIR_OS(?, ?, ?, ?, ?)";
stmt = conn.prepareCall(call);
stmt.registerOutParameter(1, OracleTypes.VARCHAR);
stmt.setString(2,codfil);
stmt.setString(3,codcen);
stmt.setString(4,codapl);
stmt.setString(5,obs);
stmt.setDate(6, data_formatada);
stmt.execute();
rs = (ResultSet) stmt.getObject(1);
if(rs != null){
while (rs.next()) {
result = rs.getString(1);
System.out.println(result);
}
} else {
result = "Erro: ABRIR_OS";
System.out.println(result);
}
rs.close();
} catch (Exception e) {
throw e;
} finally {
if (stmt != null) {
stmt.close();
}
SqlConnection.getInstance().closeConnection(conn);
}
return result;
}
