建立表:
CREATE TABLE example (name VARCHAR(100),city VARCHAR(100),image BLOB,Phone VARCHAR(100));
使用一张图片qqq.jpg
存图片的代码:
package test;
import java.sql.*;
import java.io.*;
public class SaveImageToDatabase {
public static void main(String[] args) throws SQLException {
// declare a connection by using Connection interface
Connection connection = null;
/*
* Create string of connection url within specified format with machine
* name, port number and database name. Here machine name id localhost
* and database name is mahendra.
*/
String connectionURL = "jdbc:mysql://localhost:3306/test";
/*
* declare a resultSet that works as a table resulted by execute a
* specified sql query.
*/
ResultSet rs = null;
// Declare pre