How to solve the JSP problem ?!

Source: Internet
Author: User

The teacher asked me to build a small personal financial management system and use the jsp I learned this semester. Because the project is relatively small, I use JSP + JavaBean.

The previous analysis was successful, and there was a problem at the end, and such an error was reported. Forcibly disable my tomcat.

 
 
  1. #  
  2. # An unexpected error has been detected by Java Runtime Environment:  
  3. #  
  4. #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c92100b, pid=2360, tid=1300 
  5. #  
  6. # Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)  
  7. # Problematic frame:  
  8. # C  [ntdll.dll+0x100b]  
  9. #  
  10. # An error report file with more information is saved as:  
  11. # D:/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_8.5.0.me201003121946/tomcat/bin/hs_err_pid2360.log  
  12. #  
  13. # If you would like to submit a bug report, please visit:  
  14. #   http://java.sun.com/webapps/bugreport/crash.jsp  
  15. # The crash happened outside the Java Virtual Machine in native code.  
  16. # See problematic frame for where to report the bug.  
  17. #  

The related code is as follows:

1. Database Operations

 
 
  1. /**
  2. * The entity bean of the output table is operated.
  3. */
  4. Package com. HB. Dao;
  5.  
  6. Import java. SQL. connection;
  7. Import java. SQL. preparedstatement;
  8. Import java. SQL. resultset;
  9.  
  10. /**
  11. * @ Author icecold
  12. *
  13. */
  14. Public class outdao {
  15. Java. SQL. Connection conn = NULL;
  16. Java. SQL. preparedstatement PS = NULL;
  17. Java. SQL. resultset rs = NULL;
  18. Java. SQL. Statement stmt = NULL;
  19. String SQL = "";
  20. /*
  21. * Determine whether duplicate IDs exist.
  22. */
  23. Public Boolean isoutexist (string ID ){
  24. Conn = databaseutil. getconnection ();
  25. String SQL = "select * From out where id =? ";
  26. Try {
  27. Preparedstatement PS = conn. preparestatement (SQL );
  28. PS. setstring (1, ID );
  29. Resultset rsw.ps.exe cutequery ();
  30. If (Rs. Next ()){
  31. // This ID already exists
  32. Return true;
  33. }
  34. Rs. Close ();
  35. PS. Close ();
  36. } Catch (exception e ){
  37. E. printstacktrace ();
  38. } Finally {
  39. Databaseutil. closeconnection (conn );
  40. }
  41. Return false;
  42. }
  43. /*
  44. * Add record
  45. */
  46. Public Boolean insertout (string ID, string name, string type,
  47. Java. SQL. Date, double money, string beizhu ){
  48. Boolean flag = false;
  49. Int n = 0;
  50. SQL = "insert into out values (?,?,?,?,?,?) ";
  51. Try {
  52. PS = conn. preparestatement (SQL );
  53. PS. setstring (1, ID );
  54. PS. setstring (2, name );
  55. PS. setstring (3, type );
  56. PS. setdate (4, date );
  57. PS. setdouble (5, money );
  58. PS. setstring (6, beizhu );
  59. N = ps.exe cuteupdate ();
  60. If (n> 0 ){
  61. Flag = true;
  62. } Else {
  63. Flag = false;
  64. }
  65. PS. Close ();
  66.  
  67. } Catch (exception e ){
  68. E. printstacktrace ();
  69. } Finally {
  70. Try {
  71. Conn. Close ();
  72. } Catch (exception e ){
  73. E. printstacktrace ();
  74. }
  75. }
  76. Return flag;
  77. }
  78. }

2. jsp file code for calling Javabean to operate the database:

 

 
 
  1. If (outdao. isoutexist (ID )){
  2. Out. println ("<script language = 'javascript '> alert ('This number already exists. Please add it after replacement! '); </SCRIPT> ");
  3. } Else {
  4. // If (outdao. insertout (myout. GETID (), myout. getname (), myout. getType (), myout. getdate (), myout. getmoney (), myout. getbeizhu ())){
  5. Response. sendredirect ("outman. jsp ");
  6. //}
  7. }

In the above Code, I have to comment out the two lines as above to avoid forcible shutdown of my tomcat. I searched the internet and someone said it was a problem with database operations, I think this problem should be between isoutexist and insertout.

Thank you !!!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.