以下は、Web.javaというファイルの内容です。ユーザーはこの内容をコンパイルして、Web.classファイルを生成することができます。Web.classファイルは、Web.jarというJARファイルに入れることができます。
import com.teradata.fnc.*;
import java.net.*;
import java.io.*;
import java.sql.*;
public class Web {
public static void getWebData(int ID, String url) throws SQLException
{
final int ClobSize = 1024*1000;
final char[] buffer = new char[ ClobSize ];
try {
/* Establish default connection. */
Connection con =
DriverManager.getConnection( "jdbc:default:connection" );
/* Prepare the command */
String sql = "INSERT INTO webtab ( ? , ? )";
PreparedStatement stmt = con.prepareStatement( sql );
stmt.setInt( 1, ID );
/* Get the data */
URL urlcon = new URL( url );
InputStreamReader data =
new InputStreamReader(urlcon.openStream());
int length = data.read( buffer );
stmt.setCharacterStream(2, data, length );
/* Insert the data. */
stmt.execute();
stmt.close();
}
catch (Exception e) {
throw new SQLException(e.getMessage(), "38U01");
}
}
}