DOC

2943.docjava

By Valerie Warren,2014-10-12 14:16
17 views 0
2943.docjava

    由于程序的原因?本文件未被完整保存。

    首页 ? 研究文集 ? JSP/Servlet/JSF

    JSP处女作:commons-fileupload-1.0.jar + Oracle数据库文件上传

    Sunny.Xiao 原创 (参与分?3746?专家分?181) 发表?2005-03-21 20:52 版本?1.0 阅读?674

    目前想用Spring+Hibernate+Struts修改可是还没有完成,先共享代码出来:

    使用的librariescommons-fileupload-1.0.jar,Oraclejdbc驱动. 1. <!--$Header: ProcessFileUpload.jsp 1.0.0 2004/10/22 15:10:19 pkm ship $--> 2.

    3. <%@ page contentType="text/html;charset=GB2312"%>

    4. <%@ page import="org.apache.commons.fileupload.DiskFileUpload"%> 5. <%@ page import="org.apache.commons.fileupload.FileItem"%> 6. <%@ page import="java.util.*"%>

    7. <%@ page import="java.io.File"%>

    8. <%@ page import="java.sql.*" %>

    9. <html>

    10.<head>

    11.<style>

    12..NButton

    13.{

    14. cursor:hand; 15. width: 87px;

    16. height: 20px;

    17. font-family: 宋体;

    18. font-size: 12px;

    19. text-align:center ;

    20. background-image: url(btn_bkg.gif);

    21. border:0px;

    22.}

    23.</style>

    24.

    25.<%!

    26.// Connect to Oracle database and Insert into cux_upload_files 27.public void dbInsert(String p_c_file_name,String p_c_path,String p_s_file_name,String p_s_path) {

    28. Connection conn = null;

    29. String connStr;

    30. try {

    31. connStr="jdbc:oracle:thin:@local:1521:orcl";

    32. DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); 33. conn = DriverManager.getConnection(connStr,"apps", "apps"); 34. // Insert into table

    35. conn.setAutoCommit(false);

36. PreparedStatement insertCUF = conn.prepareStatement("INSERT INTO cux.cux_upload_files(file_id,client_file_name,client_path,server_file_name,server_path,created_by,creation_date) "

    37. + " VALUES (cux.cux_upload_files_s.nextval,?,?,?,?,?,SYSDATE) ");

    38.

    39. //insertCUF.setInt(1,2);

    40. insertCUF.setString(1,p_c_file_name); 41. insertCUF.setString(2,p_c_path);

    42. insertCUF.setString(3,p_s_file_name); 43. insertCUF.setString(4,p_s_path);

    44. insertCUF.setString(5,"XXX");

    45. insertCUF.executeUpdate();

    46.

    47. conn.commit();

    48.

    49. conn.setAutoCommit(true);

    50.

    51. conn.close();

    52. }catch(SQLException ex) { // Handle SQL errors 53. System.out.println("Error in Connecting to the