Java Reference
In-Depth Information
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData md = rs.getMetaData();
while (rs.next()) {
clob = rs.getClob(1);
}
text = clob.getSubString(1,((int)clob.length()));
con.close();
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
byte[] bytes = null;
if(text!=null)bytes = text.getBytes();
return bytes;
}
}
The large object servlet can be used to drive a Web page by combining images saved as Blobs and text
or HTML saved as Clobs. Listing 14-9 offers a simple illustration.
Listing 14-9: Creating a Blob-based and Clob-based Web page using frames
<html>
<head>
<title>Byron</title>
</head>
<frameset cols="50%,*">
<frame src="http://localhost/servlet/LobServlet?type=blob&id=1">
<frame src="http://localhost/servlet/LobServlet?type=clob&id=1">
</frameset>
<body>
</body>
</html>
In Figure 14-1 , the image is a jpeg, previously stored using ID = 1, and the text is stored in HTML form
as a Clob using the same ID. The HTML frame set simply serves to format the page, and the content is
entirely database driven. This is a simple way to drive catalog pages and similar formats.
Search WWH ::




Custom Search