新手,还请各位多多指教
解决方案 »
- 部署程序,时候启动tomcat出现的错误求解决
- 日期选择
- HttpServletRequest如何获取客户端请求的参数
- jsp 中利用xml文件生成动态菜单
- 求解--------------------------
- 请帮我解答一下数据库连接时候的问题。。。感谢
- 在Java 2 SDK version 1.5.0_01下用什么命令来编译JAVA文件?
- 利用poi如何处理2007版的excel文件?急!!!!!!!!!!!!!!
- itext2.1.7操作word怎么在一张A4纸并列2个表格
- 求Jrun3.02注册码,急
- 大虾救命!JSP动态首页如何发布为html静态首页? 模式是resin+IIS , 在办公室的服务器向internet发布
- 小弟还没吃中午饭呢、请高手帮帮忙看看是怎么回事
int result = 0;
Connection con = null;
PreparedStatement pStatement = null; try {
Date currentTime = new Date();
SimpleDateFormat HMFromat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String strCurrentTime = HMFromat.format(currentTime); con = ConnectionManager.getConnction();
String strSql =
"insert into SecondLevelTitle(Id,TitleName,FilePath,Creater,"
+ "CreatTime,ParentTitle,FileBytes) values(?,?,?,?,?,?,?)";
pStatement = con.prepareStatement(strSql);
pStatement.setInt(1, getNewId());
pStatement.setString(2, sTitle.getTitleName());
pStatement.setString(3, sTitle.getFilePath());
pStatement.setString(4, sTitle.getCreater());
pStatement.setString(5, strCurrentTime);
pStatement.setInt(6, sTitle.getParentTitleId());
pStatement.setBytes(7, sTitle.getFileByte());
System.out.println(strSql);
result = pStatement.executeUpdate();
}
catch (SQLException sqlE) {
sqlE.printStackTrace();
}
finally {
ConnectionManager.closeStatement(pStatement);
ConnectionManager.closeConnection(con);
}
return result;
}
不同的数据库要用不同的方法,如果需要支持多种数据库,代码里面的分支是必不可少的
把文件名存到数据库里,另外提供一个专门的IMG文件夹来存放图片。