通过 JAVA 加载时 SQLLoader 704 内部错误

SQLLoader 704 Internal error while loading through JAVA

执行 sqlldr 命令时出现以下错误。

SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
ORA-12154: TNS:could not resolve the connect identifier specified

以下是 sqlldr 命令:

sqlldr BILLING/'"Bill!ng@123#"'@10.113.242.162:1521/bssstc control=/log/bssuser/CDR/Postpaid_CDR_Log/CTRL_File.ctrl log=/log/bssuser/CDR/Postpaid_CDR_Log/LOG_File.log direct=false silent=header skip_unusable_indexes=true rows=200000 bindsize=20000000 readsize=20000000 ERRORS=25000

注意:- 当通过命令提示符执行相同操作时,它会成功。

以下是我试过的代码片段。

            Runtime rt   = Runtime.getRuntime();
            Process proc = null;
            try {
                proc = rt.exec(sqlLoaderCommand);

                InputStream       stderr = proc.getErrorStream();
                InputStreamReader isr    = new InputStreamReader(stderr);
                BufferedReader    br     = new BufferedReader(isr);

                String line = null;
                while ((line = br.readLine()) != null){
                    logger.info(line);
                }
                int exitVal = proc.waitFor();
                logger.info("Process exitValue: " + exitVal);
                int returnValue = proc.exitValue();
                String str = null;

                if (returnValue != 0) {
                    InputStream in = proc.getInputStream();
                    InputStreamReader preader = new InputStreamReader(in);
                    BufferedReader breader = new BufferedReader(preader);
                    String msg = null;
                    while ((msg = breader.readLine()) != null) {
                        logger.info(msg);
                        str = str + msg;
                    }
                    System.out.flush();
                    preader.close();
                    breader.close();
                    in.close();
                    InputStream inError = proc.getErrorStream();
                    InputStreamReader preaderError = new InputStreamReader(inError);
                    BufferedReader breaderError = new BufferedReader(preaderError);


                    String errorMsg = null;
                    while ((errorMsg = breaderError.readLine()) != null) {
                        logger.info("Copy Error: " + errorMsg);
                        str = str + errorMsg;
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (NullPointerException e) {
                e.printStackTrace();
            }

1) 从命令行尝试执行 tnsping 10.113.242.162 如果该工具将 return 完整描述,您必须在 java.

中设置 "oracle.net.tns_admin"

System.setProperty("oracle.net.tns_admin", "ORACLE_DIRECTORY/network/admin"); -- 在此处输入正确的路径并在您的代码之前执行

2) 为了测试你可以尝试使用完整的连接描述。

而不是 10.113.242.162:1521/bssstc ->

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.113.242.162)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=bssstc))

我认为您的用户名可能有误 - "Bill!ng@123#"。查看 Java 中的引号转义规则。喜欢:

String str = "BILLING/'\"Bill!ng@123#\"'@10.113.242.162:1521";