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.
- #
- # An unexpected error has been detected by Java Runtime Environment:
- #
- # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c92100b, pid=2360, tid=1300
- #
- # Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)
- # Problematic frame:
- # C [ntdll.dll+0x100b]
- #
- # An error report file with more information is saved as:
- # D:/MyEclipse/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_8.5.0.me201003121946/tomcat/bin/hs_err_pid2360.log
- #
- # If you would like to submit a bug report, please visit:
- # http://java.sun.com/webapps/bugreport/crash.jsp
- # The crash happened outside the Java Virtual Machine in native code.
- # See problematic frame for where to report the bug.
- #
The related code is as follows:
1. Database Operations
- /**
- * The entity bean of the output table is operated.
- */
- Package com. HB. Dao;
-
- Import java. SQL. connection;
- Import java. SQL. preparedstatement;
- Import java. SQL. resultset;
-
- /**
- * @ Author icecold
- *
- */
- Public class outdao {
- Java. SQL. Connection conn = NULL;
- Java. SQL. preparedstatement PS = NULL;
- Java. SQL. resultset rs = NULL;
- Java. SQL. Statement stmt = NULL;
- String SQL = "";
- /*
- * Determine whether duplicate IDs exist.
- */
- Public Boolean isoutexist (string ID ){
- Conn = databaseutil. getconnection ();
- String SQL = "select * From out where id =? ";
- Try {
- Preparedstatement PS = conn. preparestatement (SQL );
- PS. setstring (1, ID );
- Resultset rsw.ps.exe cutequery ();
- If (Rs. Next ()){
- // This ID already exists
- Return true;
- }
- Rs. Close ();
- PS. Close ();
- } Catch (exception e ){
- E. printstacktrace ();
- } Finally {
- Databaseutil. closeconnection (conn );
- }
- Return false;
- }
- /*
- * Add record
- */
- Public Boolean insertout (string ID, string name, string type,
- Java. SQL. Date, double money, string beizhu ){
- Boolean flag = false;
- Int n = 0;
- SQL = "insert into out values (?,?,?,?,?,?) ";
- Try {
- PS = conn. preparestatement (SQL );
- PS. setstring (1, ID );
- PS. setstring (2, name );
- PS. setstring (3, type );
- PS. setdate (4, date );
- PS. setdouble (5, money );
- PS. setstring (6, beizhu );
- N = ps.exe cuteupdate ();
- If (n> 0 ){
- Flag = true;
- } Else {
- Flag = false;
- }
- PS. Close ();
-
- } Catch (exception e ){
- E. printstacktrace ();
- } Finally {
- Try {
- Conn. Close ();
- } Catch (exception e ){
- E. printstacktrace ();
- }
- }
- Return flag;
- }
- }
2. jsp file code for calling Javabean to operate the database:
- If (outdao. isoutexist (ID )){
- Out. println ("<script language = 'javascript '> alert ('This number already exists. Please add it after replacement! '); </SCRIPT> ");
- } Else {
- // If (outdao. insertout (myout. GETID (), myout. getname (), myout. getType (), myout. getdate (), myout. getmoney (), myout. getbeizhu ())){
- Response. sendredirect ("outman. jsp ");
- //}
- }
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 !!!