DButils 는 clob 와 blob 저장 소 를 실현 합 니 다.
928 단어 DbUtils
// dbutils .
@Test
public void testClob() throws Exception{
String sql="insert into article (content)values(?)";
File file=new File("bin/stylesheet.css");
char[] c=new char[(int)file.length()];
FileReader reader=new FileReader(file);
reader.read(c);
SerialClob clob=new SerialClob(c);
QueryRunner runner=new QueryRunner(JDBCUtils.getDataSource());
runner.update(sql, clob);
}
// dbutils .
@Test
public void testBlob() throws Exception{
String sql="insert into image (content)values(?)";
File file=new File("bin/bg.jpg");
byte[] b=new byte[(int)file.length()];
InputStream in=new FileInputStream(file);
in.read(b);
SerialBlob blob=new SerialBlob(b);
QueryRunner runner=new QueryRunner(JDBCUtils.getDataSource());
runner.update(sql,blob);
}
원작 자 실명