java´æ´¢Í¼Æ¬µ½Êý¾Ý¿â
1 mysql´æ´¢´óÈÝÁ¿µÄ¶þ½øÖÆÎļþµÄ¸ñʽÊÇblob£¬Æäʵ³ýÁËͼƬ»¹¿ÉÒÔ´æ±ðµÄ
2 ÒªÏòÊý¾Ý¿â´æ´¢¶þ½øÖƵÄÎļþÒ»¶¨Òª°ÑÒª´æ´¢µÄÊý¾Ýת»»³É¶þ½øÖÆÁ÷
·Ï»°¾Í²»¶à˵ÁË£¬´ó¼Ò¿´¿´´úÂëºÜÈÝÒ×Ã÷°×£¬ÏÈÀ´¿´Ò»¸öapp³ÌÐò£¬µ±È»Ê×ÏÈÄúÒªÔÚÊý¾Ý¿âÖÐÏȽ¨Á¢Ò»¸öÓÃÓÚ±£´æͼƬµÄ±íºÍÏàÓ¦µÄÁУ¬Êý¾Ý¸ñʽΪblob
package com.lizhe;
import java.io.*;
import java.sql.*;
public class PutImg {
public void putimg() {
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url = "jdbc:mysql://localhost/img?user=root&password=root&useUnicode=true&characterEncoding=gbk";
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
//stmt.execute("insert into imgt (id) values (5)");
stmt.close();
PreparedStatement pstmt = null;
String sql = "";
File file = new File("c:\\blog.jpg");
InputStream photoStream = new FileInputStream(file);
//sql = " UPDATE imgt SET img = ? ";
sql = "INSERT INTO imgtable (img) VALUES (?)";
pstmt = conn.prepareStatement(sql);
pstmt.setBinaryStream(1, photoStream, (int) file.length());
pstmt.executeUpdate();
pstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]){
PutImg pi=new PutImg();
pi.putimg();
}
}
InputStream photoStream = new FileInputStream(file);
¿ÉÒÔºÜÇå³þµÄ¿´µ½ÎÒÃÇÊ×ÏÈ°ÑÒ»¸öͼƬÎļþ(µ±È»Ò²¿ÉÒÔÊDZðµÄʲôÎļþ)ת»»³ÉÁËÒ»¸ö¶þ½øÖÆÊäÈëÁ÷
pstmt.setBinaryStream(1, photoStream, (int) file.length());
Õâ¸ö·½·¨½¨Òé´ó¼ÒÈ¥²éÒ»ÏÂAPIÎĵµ,µÚÒ»¸ö²ÎÊýÊÇͨÅä·ûλÖÃûµÄ˵,µÚ¶þ¸ö²ÎÊýÊÇÁ÷,ÕâºÍÒÔÍùµÄstringÀàÐ͵IJÎÊý²»Ì«Ò»Ñù,ÎÒ¸Õ¿´µ½µÄÊ
Ïà¹ØÎĵµ£º
1.½Ó¿ÚµÄ¶¨Ò壺
interface ½Ó¿ÚÃû
{ ½Ó¿ÚÌ壻 }
×¢Ò⣺½Ó¿ÚÌåÖÐÖ»ÄÜ°üº¬³£Á¿¶¨ÒåºÍ·½·¨¶¨ÒåÁ ......
¶ÔÏó³Ö¾Ã»¯£¬Ò²¾ÍÊÇ¿ÉÒÔ°ÑÕâ¸ö¶ÔÏóÓÀÔ¶µÄ±£´æÆðÀ´£¬ÕâÀïµÄ±£´æ²»½öÊǶÔÏó±¾Éí£¬»¹°üÀ¨ËûµÄÊôÐÔºÍËùÒÀÀµµÄÆäËûÀࡣͨ³££¬¶ÔÏó¿ÉÒԳ־û¯µ½Îļþ»òÕßÊÇÊý¾Ý¿âÖС£ÎÒÕâÀïÖ»½éÉÜÈçºÎ½«¶ÔÏó´æ´¢µ½Êý¾Ý¿âÖС£Ç¡ÇÉOracleÊý¾Ý¿âΪÎÒÃÇÌṩÁËÕâÑùµÄ·½±ã¡£
ÔÚOracleÖУ¬ÓÐÒ»ÖÖblogµÄ×Ö¶ÎÀàÐÍ£¬ËüÊÇÓÃÀ´´æ´¢´óÁ¿µÄ¶ ......
ÒÔÇ°Óùý¼¸´ÎÕâ¸ö¶«¶«£¬µ«Ã¿´Î¶¼ÖØвéѯһ´Î¡£±¾ÎÄÔʼ³ö´¦ÊÇÕâÀï ¡£
£££££££££££££££££££££££££££££££££££££££££££££££££££££££££££
Keytool ÊÇÒ»¸öJava Êý¾ÝÖ¤ÊéµÄ¹ÜÀí¹¤¾ß ,Keytool ½«ÃÜÔ¿£¨key£©ºÍÖ¤Ê飨certificates£©´æÔÚÒ»¸ö³ÆΪkeystoreµÄÎļþÖÐÔÚk ......
×î½ü³ÉÁ¢ÁËÒ»¸öJAVA Ⱥ Ïë¸ú´ó¼ÒÒ»¿é½»Á÷ 41912406 £» ¸Ð¾õºÃ¾Ãû¿´¹ýJAVAÁË £¬¶¼ÓÐЩÉúÊèÁË¡£ÏÖÔÚÔÚÒ»¼Ò»Æ½ðͶ×ʹ«Ë¾¹¤×÷£¬Ëä˵¹¤×÷»·¾³»¹ÐУ¬µ«ÄÚÐÄÀïºÃÏñ²¢²»Ï²»¶Õâ¸ö£¬ÒÔºó»¹ÊÇÕÒ¸öÈí¼þ¹«Ë¾¸ÉΪºÃ¡£ÔÚÕâ¸öÐÐÒµÄܶÔÊÀ½ç¾¼ÃÁËÁ˽âºÜ¶à£¬ÎÒÏëÕâ¶ÔÎÒÒÔºó»áÓаïÖúµÄ£¬ÏÈÔÚÕâ¸É×Å£¬³¤µã֪ʶÓë¾ÑéÒ²²»´í¡£ ......
ÒòΪ³ÌÐòÒª´ÓÊý¾Ý¶ÁÈ¡½ü10WÐмǼ´¦Àí£¬µ±¶Áµ½9WµÄʱºò¾Í³öÏÖ java.lang.OutOfMemoryError: Java heap space ÕâÑùµÄ´íÎó¡£
ÔÚÍøÉÏÒ»²é¿ÉÄÜÊÇJAVAµÄ¶ÑÕ»ÉèÖÃ̫СµÄÔÒò¡£
¸ú¾ÝÍøÉϵĴ𰸴óÖÂÓÐÕâÁ½ÖÖ½â¾ö·½·¨£º
1¡¢ÉèÖû·¾³±äÁ¿
set JAVA_OPTS= -Xms32m -Xmx512m
¿ÉÒÔ¸ù¾Ý×Ô¼º»úÆ÷µÄÄÚ´æ½øÐиü¸Ä,µ«±¾È˲âÊÔÕâÖÖ· ......