简体   繁体   English

Oracle 11g 11.2.0.1:不再需要从套接字读取数据

[英]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: 我试图通过查询(SQL>从double;中选择numberingmachine(“ param1”,“ param2”)来调用我的函数“ NUMBERINGMACHINE”,该查询包含:

 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) 然后该函数将调用java类(NumberingMachine类)

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: 我的oracle sql开发人员版本:

SELECT * FROM V$VERSION 选择*从V $ VERSION

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production Oracle Database 11g企业版11.2.0.1.0版-生产

PL/SQL Release 11.2.0.1.0 - Production "CORE 11.2.0.1.0 Production" PL / SQL版本11.2.0.1.0-生产“ CORE 11.2.0.1.0生产”

TNS for 32-bit Windows: Version 11.2.0.1.0 - Production 适用于32位Windows的TNS:版本11.2.0.1.0-生产

NLSRTL Version 11.2.0.1.0 - Production NLSRTL版本11.2.0.1.0-生产

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. 您试图在SQL调用中将其作为Java存储过程执行。 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而不是Java来完成。 PL/SQL is the best language for orchestrating SQL statements in the database. PL / SQL是在数据库中编排SQL语句的最佳语言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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