Step 1: Establish a database Create Table test_img (ID Number (4), Name Varchar (20), IMG Long Raw);
Step 2:
Step 3: Insert the database (InsertImg.jsp)
<% @ page language = "java"%> <% @ page contentType = "text / html; charSet = GB2312"%> <% @ page import = "java.util. *"%> <% @ page import = " Java.sql. * "%> <% @ Page Import =" java.text. * "%> <% @ page import =" java.io. * "%>
<% Class.forname ("Oracle.jdbc.driver.OracleDriver"); string url = "JDBC: Oracle: Thin: @lubin: 1521: b2bdb"; connection con = DRIVERMANAGER.GETCONNECTION (URL, "Demo", "Demo ");
// Insert the database string SQL = "INSERT INTO TEST_IMG VALUES (?,?,?)"; // Get the Value ID String ID = Request.getParameter ("ID"); // Get image of Image String KK = Request. GetParameter ("Image"); // Convert to File File FileName = New File (KK);
// read the length of the file and convert to a long-type long L1 = filename.length (); int L2 = (int) L1;
// Assign fileinputstream fis = new fileinputstream (filename) with stream format; fileInputStream (filename);