Hi,
I have the following settings:
platform : Win98
Tomcat version 3.3
Mysql version mysql-3.23.38
JDBC Driver: mm.mysql-2.0.4-bin
JDK 1.3
Now i got tomcat running, and also the
jsp examples running, mysql is also running fine on its own and i created a simple database with one table. Now i have put the JDBC driver in the C:\jakarta-tomcat-3.3\lib directory. As far as i know i dont need to specify any classpath as Tomcat manages finding and loading classes itself.
Now i created a simple jsp file(Temp.jsp) where i want to display the fields from the mysql database table:
here is my code:
<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://localhost:3306/Temp?user=Suzana;password=pass";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM Table_one");
while (rs.next()) {
out.println(rs.getString("FName")+"<br>");
out.println(rs.getString("LName")+"<br>");
out.println(rs.getString("Age")+"<br>");
}
rs.close();
%>
</body></html>
I m saving this Temp.jsp file in the root directory of tomcat:
C:\jakarta-tomcat-3.3\webapps\ROOT
But now, once i created the jsp file and the database, how to actually run all this?
I m pretty new to this and i m confused.....do i need to compile anything....I m pretty lost..??
Can anyone help....how do i get this to run?
Thanks,
Suzana