импортировать java.sql.*;
импортировать java.io.*;
общественный класс WriteDB {
public static void main(String[] args) {
Соединение conn=null;
String driver="com.mysql.jdbc.Driver";//驱动
String url="jdbc:mysql://127.0.0.1/test?useUnicode=true;characterEncoding=8859_1";// 数据库联接
try{
Class.forName(driver).newInstance();
conn=DriverManager.getConnection(url,"root","");
Файл file=новый файл(args[0]);
FileInputStream fis = новый FileInputStream (файл);
ReadedStatement pstmt=conn.prepareStatement(
"вставить в изображение(изображение) значения(?)");
int bytes=(int)file.length();
System.out.println(байты);
pstmt.setBinaryStream(1,fis,bytes);//1为插入的参数1,2。。。fileInStream为插入的数据,bytes为字节长度
pstmt.executeUpdate();
конн.закрыть();
фис.закрыть();
}catch(Исключение е){
System.out.println(e.getMessage());
}
}
}