the following is the code:
<%@ 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