jsp²åͼƬµ½MySQL - Web ¿ª·¢ / ÆäËû
¸ãÁËÒ»¸öÏÂÎçÁË£¬ËÑË÷ÁËÍøÂ绹Êǽâ¾ö²»ÁË...Ï£Íû¸ßÊÖ°ïæ½â¾öÏÂ
Ô´´úÂ룺
private void SendPhoto(HttpServletRequest request,
HttpServletResponse response) {
String name=request.getParameter("image"); //»ñȡͼƬ·¾¶£¬²âÊÔºóûÓÐÎÊÌâ
String filename=name.replace("\\", "\\\\");
File file=new File(filename);
InputStream str = null;
try {
str = new BufferedInputStream(new FileInputStream(file));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
String sql= "insert into photos(image) values(null,now(),?)";//null¶ÔÓ¦µÄΪ×Ô¶¯Ôö¼ÓµÄid,imageµÄÀàÐÍΪblob
Connection conn=DB.getConn();//DBÊÇ·â×°µÄÁ´½ÓÊý¾Ý¿âµÄÀà
PreparedStatement pstmt=DB.prepareStmt(conn, sql);
try {
pstmt.setBinaryStream(1,str,str.available());
result=pstmt.executeUpdate();
pstmt.close();
str.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
´íÎóÈçÏ£ºcom.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?:?v·é-??±???ü??zq?5*?we,V·Zd?I?ùQ??ü] ???
z???#?o>?l6? (??Rz?*?o??§???Wu??¡
Ïà¹ØÎÊ´ð£º
ÎÊÌâÃèÊö£º
ÀýÈçÎÒÒªÏÔʾµÄÄÚÈÝÈçÏÂËùʾ
Ò»¼¶Ä¿Â¼1
Ò»¼¶Ä¿Â¼1×ÓÀà1
×ÓÀà1
Ò»¼¶Ä¿Â¼1×ÓÀà2
......
ÎÒÒѾ°´Õս̳ÌÉÏÅäÖÃtomcatµÄserver.xml
<Context path = "/POS" docBase = "POS" debug = "5" reloadable = "true" crossContext = "true" workDir = &quo ......
ÎÒJSPµÄÒ³ÃæÊÇ£º
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
jspÒ³ÃæÖеÄJava±äÁ¿³ö´í£¬ÇëÎÊÒ»ÏÂJavaµÄ¸ßÊÖÃÇ£¬ÈçºÎ½â¾ö£¿ÐèÒªÌí¼ÓÄĸöjar°ü
<logic:notEqual name="parts" property="checkStatus2" value="1">
<label for=&q ......