mysql+jsp如何存储图片文件啊? mysql+jsp如何存储图片文件啊?又如何从页面存取啊,谢谢谢谢啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.sql.*;import java.io.*;public class insertImage{ public static void main(String[] args) { System.out.println("Insert Image Example!"); String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/"; String dbName = "hibernatetutorial"; String userName = "root"; String password = "root"; Connection con = null; try{ Class.forName(driverName); con = DriverManager.getConnection(url+dbName,userName,password); Statement st = con.createStatement(); File imgfile = new File("images.jpg"); FileInputStream fin = new FileInputStream(imgfile); PreparedStatement pre = con.prepareStatement("insert into Image values(?,?,?)"); pre.setInt(1,5); pre.setString(2,"Durga"); pre.setBinaryStream(3,fin,(int)imgfile.length()); pre.executeUpdate(); System.out.println("Inserting Successfully!"); pre.close(); con.close(); } catch (Exception e){ System.out.println(e.getMessage()); } }}http://www.roseindia.net/jdbc/jdbc-mysql/insert-image-in-mysql.shtml mysql_stmt_execute 执行成功,但是数据库中无数据 My Sql和 WORD VBA融合 MYSQL索引区分大小写问题 myodbc能连接,但是不能查询,而且出现段错误,奇怪 mysql一个比较怪异的问题 自动增长类型可以重置吗? MySQL 整除问题?? 在linux中java与mysql的问题,急!! 一个sql 请教关于动态sql在并发场景下的安全性 MySQL高性能查询问题 重发: MySQL建库的问题,选什么引擎好
import java.io.*;public class insertImage{
public static void main(String[] args) {
System.out.println("Insert Image Example!");
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/";
String dbName = "hibernatetutorial";
String userName = "root";
String password = "root";
Connection con = null;
try{
Class.forName(driverName);
con = DriverManager.getConnection(url+dbName,userName,password);
Statement st = con.createStatement();
File imgfile = new File("images.jpg");
FileInputStream fin = new FileInputStream(imgfile);
PreparedStatement pre = con.prepareStatement("insert into Image values(?,?,?)");
pre.setInt(1,5);
pre.setString(2,"Durga");
pre.setBinaryStream(3,fin,(int)imgfile.length());
pre.executeUpdate();
System.out.println("Inserting Successfully!");
pre.close();
con.close();
}
catch (Exception e){
System.out.println(e.getMessage());
}
}
}http://www.roseindia.net/jdbc/jdbc-mysql/insert-image-in-mysql.shtml