Skip to Main Content

Japanese

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java ストアドプログラムから別マシンの共有フォルダへのアクセスについて

MasafumiKokuiFeb 13 2012 — edited Feb 15 2012
Java ストアドプログラムで、別マシンの共有フォルダにあるファイルを BLOB に格納しようとしています。
DB サーバは、
・Windows Server 2003 R2
・Oracle Database 10g
です。


以下の JAVA クラスで Function を作成し、PL/SQL から呼び出そうとしています。

public static long loadBlob( BLOB blob, String dirName, String fileName )
{
File dir = null;
File file = null;
FileInputStream fis = null;
OutputStream os = null;

try {
dir = new File( dirName );
if( !dir.exists() ) {
return -1L;
}
file = new File( dir, fileName );
fis = new FileInputStream( file );
os = blob.getBinaryOutputStream();
byte[] buffer = new byte[ blob.getBufferSize() ];

int length = -1;
while ( ( length = fis.read( buffer ) ) != -1 ) {
os.write( buffer , 0 , length );
}
return blob.length();

} catch (Exception e) {
e.printStackTrace();
return -1L;
} finally {
try { fis.close(); } catch( Exception ignore ) {}
try { os.close(); } catch( Exception ignore ) {}
}


ここで、第二引数にネットワークパスを指定すると
if( !dir.exists() ) でパスが見つからない判定に引っかかり、
うまくいかない問題に直面しています。

第二引数に指定するパスをいくつか検証した所、下記のようになりました。
・これらはOK
 d:\temp\
 \\localhost\d$\temp\
 z:\temp\ (「\\localhost\d$」を z ドライブへマッピング )

・これらはNG
 \\127.0.0.1\d$\temp\
 z:\temp\ (「\\127.0.0.1\d$」を z ドライブへマッピング )
 \\[他サーバのIP]\Share\ ( 共有フォルダへは、Everyone にアクセス権限を設定 )


JAVA に MAIN 関数を作成して直接実行すると、問題なく上記の全てのパスにアクセスできました。
( Explorer からパスを指定しても問題なくフォルダにアクセスできます。)

Oracle サービスと Listener は、「Local System」から「Administrator」で起動するように変更しました。
Function を作成した Oracle ユーザには、SYSDBA に付与されていた全ての JAVA ロールを付与しています。

良きアドバイスをお願いします。
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2012
Added on Feb 13 2012
2 comments
5,134 views