create alias if not exists jcifs_rename as $$
import java.io.*;
import java.sql.*;
import org.h2.tools.*;
import jcifs.smb.*;
@CODE
int jcifs_rename(String domain,
String user, String password, String server,
String path, String filename, String filename2)
throws Exception
{
if( domain == null ){
throw new Exception("domain is not specified.");
}
user = (user == null)?"":user;
password = (password == null)?"":password;
if( server == null ){
throw new Exception("server is not specified.");
}
if( path == null ){
throw new Exception("path is not specified.");
}
if( filename == null ){
throw new Exception("filename is not specified.");
}
if( filename2 == null ){
throw new Exception("filename2 is not specified.");
}
SmbFile file = new SmbFile(
"smb://" + domain + ";" + user + ":" + password +
"@" + server + "/" + path + "/" + filename
);
SmbFile file2 = new SmbFile(
"smb://" + domain + ";" + user + ":" + password +
"@" + server + "/" + path + "/" + filename2
);
file.renameTo(file2);
return 0;
}
$$
実行例
select jcifs_rename(
'LIFERAY1',
'test1', 'test1', 'liferay1',
'share', 'test.txt', 'renamed_test.txt');
※システム環境変数CLASSPATHにtools.jarとJCIFSのjar
(jcifs-1.3.15.jar)を追加しておくこと。
動作環境
JDK6 Update 21, H2 Database 1.2.143 (2010-09-18), JCIFS 1.3.15
○関連情報
・H2 Databaseに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿