public boolean insertImage(File f)
{
String StrSql = "insert into imageTable values (?,?,?,?,?,?,?)";
String sFile = f.getName(); try
{
// File f = new File("e:\\T14.gif");
fin = new FileInputStream(f);
/*//////////////////////////////////////通过字节数组来存入数据库
byte[] ib = new byte[(int)f.length()];
fin.read(ib);
ByteArrayInputStream fou1 = new ByteArrayInputStream(ib);
*/
ps = conn.prepareStatement(StrSql); ps.setInt(1,miCurrentCount+1);
ps.setString(2,sFile);
ps.setString(3,sFile.substring(sFile.length()-3));
ps.setString(4,f.getPath());
ps.setInt(5,(int)f.length());
///时间
Calendar cc = new GregorianCalendar();
ps.setTimestamp(6,new Timestamp(cc.getTime().getTime()),cc);
/////////////////////////////////////////////////
int len = (int)f.length();
ps.setBinaryStream(7,fin,len);
ps.executeUpdate();
ps.clearParameters();
}
catch ( Exception ex )
{
ex.printStackTrace();
return false;
} miCurrentCount++;
mTestImageDb.jCBRowNumber.addItem(String.valueOf(miCurrentCount)); return true;
}
{
String StrSql = "insert into imageTable values (?,?,?,?,?,?,?)";
String sFile = f.getName(); try
{
// File f = new File("e:\\T14.gif");
fin = new FileInputStream(f);
/*//////////////////////////////////////通过字节数组来存入数据库
byte[] ib = new byte[(int)f.length()];
fin.read(ib);
ByteArrayInputStream fou1 = new ByteArrayInputStream(ib);
*/
ps = conn.prepareStatement(StrSql); ps.setInt(1,miCurrentCount+1);
ps.setString(2,sFile);
ps.setString(3,sFile.substring(sFile.length()-3));
ps.setString(4,f.getPath());
ps.setInt(5,(int)f.length());
///时间
Calendar cc = new GregorianCalendar();
ps.setTimestamp(6,new Timestamp(cc.getTime().getTime()),cc);
/////////////////////////////////////////////////
int len = (int)f.length();
ps.setBinaryStream(7,fin,len);
ps.executeUpdate();
ps.clearParameters();
}
catch ( Exception ex )
{
ex.printStackTrace();
return false;
} miCurrentCount++;
mTestImageDb.jCBRowNumber.addItem(String.valueOf(miCurrentCount)); return true;
}
解决方案 »
- 求求马士兵_JAVA视频教程第01章_JAVA简介_源代码.rar
- 关于SWT多线程的问题。
- 怎么用Collections.sort()按doubel型的大小排序啊?
- 关于java打印问题
- java是什么
- Java实现模拟web登录
- 急!!!!!JTable中为JComboBox的怪问题
- 有一个JTextField控件,限制输入格式为"2003/06",前四位是年份,中间是"/",后两位是月份!急,谢谢!!!
- sdk与jdk两个软件的联系与区别
- InputStream流写到数据库里抛出以下的异常??
- 我要在applet中实现本地打印,在安全限制方面应该如何处理才能实现。
- 在Jbuilder6.0中,如何用CORBA开发数据库APP!
是用来执行查询语句的
必须用
st.executeUpdate("insert into tx values(1,'bb',99,88)");
就行
tx是一个表