简体   繁体   中英

Oracle 11g 11.2.0.1 : No more data to read from socket

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM