1
votes

I'm trying to call my function "NUMBERINGMACHINE" by query (SQL> select numberingmachine("param1","param2")from dual;) that contain:

create or replace
function NumberingMachine(numType in varchar2, now in varchar2) return varchar2
is language java name
'NumberingMachine.getSequence(java.lang.String, java.lang.String) return java.lang.String';

and then the function will calling the java class (NumberingMachine class)

public class NumberingMachine {


public static String getSequence(String type, String now)  throws SQLException {

    /* Connect to database */

    Connection conn = new OracleDriver().defaultConnection();
    conn.setAutoCommit(false);

    /* construct dynamic sql */

    String selectSql = "SELECT NUMVALUE,NUMLEN,UPDTYPE,UPDDATE FROM M_SEQUENCE WHERE NUMTPCD = ? FOR UPDATE";
    String updateSql = "UPDATE M_SEQUENCE SET NUMVALUE=?, UPDDATE=? WHERE NUMTPCD = ?";

but i get error: no more data to read from socket .

does anyone have the solution?

my oracle sql developer version:

SELECT * FROM V$VERSION

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

PL/SQL Release 11.2.0.1.0 - Production "CORE 11.2.0.1.0 Production"

TNS for 32-bit Windows: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 - Production

1
Not directly related to your question, but is there any specific reason why you're still using 11.2.0.1? You might want to patch that to 11.2.0.4Frank Schmitt
Could you please add the source code for the Java function you're calling from Oracle to your question?Frank Schmitt
This type of error can occur from any number of things, starting with JDBC driver bugs up to some problem with the Java code you're trying to run. So it's going to be tough for us to give a solution. You need to start by providing more details, starting with the Java source. Plus:does this error occur all the time. Why are you calling in with no values for the parameters? Does the Java code work when you run it not in the database (say in a JUnit test)?APC
@APC I call with 2 parameters select numberingmachine("param1","param2") from dual; , this error just occurs when i call the function, ..anri junuka
Okay, you should edit your question to make it clearer. Your posted call contains empty strings. What happens if you assign the function to a PL/SQL variable instead of calling it from dual?APC

1 Answers

0
votes

Your posted code is incomplete but I think it's fairly easy to spot the problem:

public static String getSequence(String type, String now)  throws SQLException {

    /* Connect to database */

    Connection conn = new OracleDriver().defaultConnection();
    conn.setAutoCommit(false);

You're trying to execute this as a Java Stored Procedure in a SQL call. To do that you must already be connected to the database. You don't need to connect again.

All your code should do is execute the actual business logic. Although looking at what you've got as a starter I think it should be done as PL/SQL rather than with Java. PL/SQL is the best language for orchestrating SQL statements in the database.