This worked great!
July 28, 2005 - 12pm Central time zone
Reviewer: Mark
Thank you, Tom for your quick and comprehensive response. This really helps me!
Dubugging how java program printing console out from package.
April 24, 2006 - 9am Central time zone
Reviewer: Anupam v Rahangdale from India (pune)
Hi,
At very first i would like to say thank you very much for
this valueable topic. I am working developer in Manas Solutions pvt. ltd. Pune India . i am
searching how the java class printing dbms output in java console . and i got
the answer form this topic this help me to solve my problem.
Thanks & Regards
Anupam v Rahangdale
DBMS_OUTPUT from JDBC
August 18, 2006 - 5am Central time zone
Reviewer: Ganti Raghunath from India
This was an excellent help and we might have to something similar to this in our application which
is still in the design phase.
I would again say a BIG Thank You for the question and the explanation.
Great Solution, but what about when an exception is raised?
September 5, 2006 - 11am Central time zone
Reviewer: From an Oracle guy who doesn't know Java from Minneapolis, MN
This example is what I was looking for, but it doesn't seem to work if an exception is raised from
Oracle. How do you get it to print the dbms_output if an exception is raised?
Followup September 5, 2006 - 5pm Central time zone:
not sure what you mean ??
sure it does, anything you wrote to the dbms_output buffer will be there, you're application just
needs to retrieve and display it.
saved me a lot of work
September 27, 2006 - 10am Central time zone
Reviewer: A reader
Thanks for this solution that saved me a lot of effort:)
sheers

July 5, 2008 - 3pm Central time zone
Reviewer: AlcoNaft from Norway
Thanks a lot! Your post saves a lot of time for me :)
Usage of this information
October 10, 2008 - 1pm Central time zone
Reviewer: A reader from Chicago, IL, USA
Very Useful. We used the code within our architecture so now the developers automatically see all
the PUT_LINE statements when executing the batch scripts in the DOS window.
Simple to understand ?
February 20, 2009 - 10am Central time zone
Reviewer: A reader
System.out.println("Executing stored proc.");
clStmt = con.prepareCall("begin dbms_output.enable(?); " +
"dbms_output.put_line('----hello there---'); " +
"dbms_output.put_line('----hello there2---'); " +
"end;");
clStmt.setInt(1, 100000);
clStmt.execute();
CallableStatement showOutput = con.prepareCall("" +
" begin " +
" dbms_output.get_line(:1,:status); " +
"end;" );
showOutput.registerOutParameter(1, java.sql.Types.VARCHAR); // line
showOutput.registerOutParameter(2, java.sql.Types.INTEGER); // done (no more) ?
for (int i=0;;i++){
showOutput.executeUpdate();
if(showOutput.getInt(2)== 1){
break;
}
System.out.println(showOutput.getString(1));
}
showOutput.close();
Followup February 21, 2009 - 9pm Central time zone:
I don't know what you mean????
I did however, provide a package (a class, a module, a set of subroutines, whatever you want to call it) to make using dbms_output from a java program "simple" yes.
It makes it this simple, code in bold is what you would have to 'code' and it is not hard:
public static void main (String args [])
throws SQLException
{
DriverManager.registerDriver
(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@dbserver:1521:ora8i",
"scott", "tiger");
conn.setAutoCommit (false);
Statement stmt = conn.createStatement();
DbmsOutput dbmsOutput = new DbmsOutput( conn );
dbmsOutput.enable( 1000000 );
stmt.execute
( "begin emp_report; end;" );
stmt.close();
dbmsOutput.show();
dbmsOutput.close();
conn.close();
}
Very Good
April 28, 2009 - 5am Central time zone
Reviewer: User
It was very useful one. Thanks a ton
|