Doubt related to using JAVA calling it via PL/SQL and recording data in the local machine

  • From: Eriovaldo Andrietta <ecandrietta@xxxxxxxxx>
  • To: ORACLE-L <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 5 Nov 2013 11:01:29 -0200

Hello ,

I have the code below and would like to know if it is possible record file
in my machine and not in the oracle server.

We are using:
                       BufferedWriter out = new BufferedWriter(new
FileWriter("file_backupparam.conf"));
to specify the file name

We tried putting the path of the file , but without sucess.

                       BufferedWriter out = new BufferedWriter(new
FileWriter("d:\file_backupparam.conf"));

Best Regards
Eriovaldo


Start of the code:

create or replace and compile java source named selecttables as
import java.sql.*;
import java.io.*;
import oracle.jdbc.*;

public class SelectTables{

       public static void exportTables(){
               try{
                       Connection connection =
DriverManager.getConnection("jdbc:default:connection:");

                       Statement statement = connection.createStatement();

                       BufferedWriter out = new BufferedWriter(new
FileWriter("file_backupparam.conf"));

                       String query = "select table_name " +
                                                       " from user_tables "
+
                                                       " where (table_name
not like '%_VE' " +
                                                       " AND table_name NOT
LIKE 'MDRT%') " +
                                                       " AND NOT EXISTS
(SELECT 1 " +
                                                       " FROM CACHE_VWS_CFG
" +
                                                       " WHERE VWS_NAME =
table_name)";

                       ResultSet resultset = statement.executeQuery(query);

                       out.write("TABLES=( \n");

                       while(resultset.next()){
                               out.write(resultset.getString("TABLE_NAME")
+ ",\n");
                       }

                       out.write("DB_INFO_BKP, USER_SDO_GEOM_METADATA_BKP,
BKP_INDEX_DDL)");

                       out.close();
                       statement.close();
                       connection.close();
               }
               catch(Exception e){
               }
       }
}
/



create or replace
FUNCTION FSelectTables RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'SelectTables.exportTables () return java.lang.String';

create or replace
PROCEDURE PSelectTables
AS
my_string varchar2(400 char);
begin
my_string:=FSelectTables();
dbms_output.put_line('The value of the string is ' || my_string);
end;


begin
  PSelectTables;
end;
/

Other related posts: