如何使用 SQLJ 在 Oracle SQL Developer 控制台上打印

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2183103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 19:55:32  来源:igfitidea点击:

How to print on Oracle SQL Developer console using SQLJ

javaoraclesqljoracle-sqldeveloper

提问by Micha? Ziober

I created and launch the SQLJ Java procedure (using SQL Developer). I have some bugs and I would like to debug Java source code. What is the best way to do this? Is it possible to print to the SQL Developer console some information using System.out?

我创建并启动了 SQLJ Java 过程(使用 SQL Developer)。我有一些错误,我想调试 Java 源代码。做这个的最好方式是什么?是否可以使用 System.out 将一些信息打印到 SQL Developer 控制台?

回答by geekzspot

The default standard output device in the Oracle Java virtual machine (JVM) is the current trace file.

Oracle Java 虚拟机 (JVM) 中的默认标准输出设备是当前跟踪文件。

If you want to reroute all standard output from a program executing in the server--output from any System.out.println()calls, for example--to a user screen, you can execute the SET_OUTPUT()procedure of the DBMS_JAVApackage as in the following example.

如果要将服务器中执行的程序的所有标准输出System.out.println()(例如任何调用的输出)重新路由到用户屏幕,则可以执行DBMS_JAVA包的SET_OUTPUT()过程,如下例所示。

Input the buffer size in bytes (10,000 bytes in this case).

以字节为单位输入缓冲区大小(在本例中为 10,000 字节)。

sqlplus> execute dbms_java.set_output(10000);

Output exceeding the buffer size will be lost.

超出缓冲区大小的输出将丢失。

If you want your code executing in the server to expressly output to the user screen, you can also use the PL-SQL DBMS_OUTPUT.PUT_LINE()3procedure instead of the Java System.out.println()method.

如果您希望在服务器中执行的代码明确输出到用户屏幕,您还可以使用 PL-SQL DBMS_OUTPUT.PUT_LINE() 3过程而不是 JavaSystem.out.println()方法。

回答by APC

SQL Developer has a built-in PL/SQL debugger. There is a useful guide on how to use it here. Pay special attention to the need for DEBUG CONNECT SESSION and DEBUG ANY PROCEDURE privileges.

SQL Developer 有一个内置的 PL/SQL 调试器。有关于如何使用它了有益的指导这里。特别注意需要 DEBUG CONNECT SESSION 和 DEBUG ANY PROCEDURE 权限。

I admit I don't know whether this works for SQLJ but it seems like the best place to start.

我承认我不知道这是否适用于 SQLJ,但它似乎是最好的起点。