Counting Records in MySQL by JSP
| Published on 2/4/2006 by Dotnetindex More articles in JSP
|
This code source displays count of records in MySQL. We are using a SQL statement. You can easily modify the code to use in different languages. But this code can be used for JSP with MySQL. We will use Connector/J driver to connect database. Now our first lines are conncting to MySQL server :
Do not forget to import 'java.sql' to top of your page. If you do not want to add this line, you ust change some parts of the like this : java.sql.Connection ocon = null; I think, this type of coding is not funny and you can easily forgot to add. Now weil create our statement to use with our SQL sentence. This statement prepars connection to server.
Statement stmtt = ocon.createStatement(); Now we can add our SQL statement to our script and display count of our records :
Let's look at the code closely. First we have load the SQL driver to our server. Personally I am using 'resin' but this code is suitable to use in Tomcat, JBoss, JRun .. etc. Second we have wrote our SQL statement and create a ResultSet to display our result. All Source code :,
|
no comments submitted



