| | |
Increment value of MySQL columnJSP button
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
the following is the code:
With the above I m not able to increment the value of hitCount in the MySQL each time when the button is clicked..
tell me wats wrong with my code
JSP Syntax (Toggle Plain Text)
<%@ page import="java.util.*" import="java.sql.*" import="java.io.*" language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <% Integer hit = 0; Connection con = null; Statement stmt=null; ResultSet rs = null; %> <% try { out.println(); Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost/lab2","root","root"); stmt=con.createStatement(); rs=stmt.executeQuery("SELECT hitCount from table1"); hit = rs.getInt("hitCount"); hit = hit + 1; rs=stmt.executeQuery("UPDATE table1 set hitCount=10"); rs.close(); stmt.close(); con.close(); } catch(Exception ex) { out.println(ex); } %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Welcome!!</title> <script language="javascript"> var hitCount=0; var jsvar="Hello World"; function counter() { hitCount = hitCount + 1; alert(hitCount); } </script> </head> <body> <FORM name="welcome" method="post"> <marquee> Welcome to the Tic-Tac-Toe game!!!!</marquee> <table width="100%" border=0 cellspacing=0 cellpadding=0 align=center> <tr> <td><br></br></td> </tr> <tr> <td> <div align="center"> <img src="images/tictacimg.jpg" name="1.jpg"></img> <br></br> <font color="#19A1CB" size="2" face="Verdana, Arial, Helvetica, sans-serif"> <span><b>Tic Tac Toe Game</b></span><br></br> <span>Click below to start the game</span><br></br> <br></br> </font> </div> </td> </tr> <tr> <td> <div align="center"> <input type="button" name="start" value="START GAME" onClick="counter()"></input> </div> </td> </tr> <tr><td><div id='counter' style="display:"><%= hit %></div></td></tr> </table> </FORM> </body> </html>
With the above I m not able to increment the value of hitCount in the MySQL each time when the button is clicked..
tell me wats wrong with my code
![]() |
Similar Threads
- auto increment the record value in database when the button clicks (MS SQL)
- Problem with button (VB.NET)
- Resetting Auto Increment in MYSQL (PHP)
- How to put Delete button PHP (PHP)
- problem with for loop (Java)
- a for loop problem (Java)
- auto incrememnt mysql (PHP)
Other Threads in the JSP Forum
- Previous Thread: Table locked and session was invalidated
- Next Thread: Query on Dropdown list
Views: 463 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write





