<% @ Page contentType = "text/html; charset = gb2312" %>
<% @ Page import = "java. SQL. *, java. io. *, java. awt. Image, java. awt. image. *, com.sun.image.codec.jpeg. *" %>
<Html>
<Body>
<%
/*
Drop table imagetable;
Create table imagetable
(
Nid int not null,
Image blob,
Primary key (nid)
)
Type = InnoDB;
*/
/*
// ========================= 1. Write the file to the large field of the database and begin in ============ ==============
Class. forName ("org. gjt. mm. mysql. Driver"). newInstance ();
String url = "jdbc: mysql: // localhost: 3306/test? User = root & password = eastsoftweb ";
Connection conn = DriverManager. getConnection (url );
Java. io. File file = new File ("d:/temp/1.jpg ");
FileInputStream is = new FileInputStream (file );
PreparedStatement stmt = conn. prepareStatement (
"Insert into imagetable (nid, image)" +
"VALUES (?, ?) "); // Pre-compiled SQL statements
Stmt. setInt (1, 1 );
Stmt. setBinaryStream (2, is, (int) file. length ());
Stmt.exe cuteUpdate ();
Stmt. close ();
Is. close ();
Out. println ("update end ");
// ======================== Write the file into the large field of the Database end ==================== ================
*/
/*
// ======================================= 2. jsp display server hard disk image example begin ========== ========