الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Java Source

Featured Replies

بتاريخ:

Dear all
I made a java class that copies the data from a table and write it to a file named "c:\tarek.txt"
the class works fine and the file is created successfuly.

I descided to make a java source that include this class.
but i execute function that call the java source , the file is not created.
the following is my code
----------------
-- java source
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "CreateFile" AS
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class CreateFile{

public static String getData(){
String file_name = "c:\\tarek.txt";
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.85.10:1521:orahr","sal","sal1");
Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery("select region_code,region_name from nmp_region");

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
File file = new File(file_name);
FileWriter fstream = new FileWriter(file_name);
BufferedWriter out = new BufferedWriter(fstream);
while(rs.next())
{
int col = rs.getInt(1);
String val = rs.getString(2);
out.write(val);
}

rs.close();
con.close();
out.close();

}

catch(Exception e){
System.out.println(e);
}
return("File created successfully.");
}
public static void main(String args[])
{
CreateFile c = new CreateFile();
c.getData();
}
};
/
----------------------------------
--- function
CREATE OR REPLACE FUNCTION copytofile
RETURN varchar2
AS LANGUAGE JAVA
NAME 'CreateFile.getData () return java.lang.String';
/

------- test
SQL> select copytofile from dual;

COPYTOFILE
--------------------------------------------------------------------------------
File created successfully.

the problem is that the file is not created
I do not know why
please help

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.