Here is the code I am using.
Please try not to laugh too much, keep in mind I am new to JSP and Java. ;-)
Thanks
John Brosan
<%@page contentType="text/html" import="java.sql.*" %>
<html>
<body>
<%= new String("Hello there John") %>
<%
Class.forName("org.gjt.mm.mysql.Driver");
Connection con =
DriverManager.getConnection("jdbc:mysql:///howlerdb","howler",
"winston2644");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM tblMenu");
while (rs.next())
{
out.println(rs.getString("MnuItemName"));
out.println("<BR>");
}
try {
if ( rs!=null ) rs.close();
if ( stmt!=null) stmt.close();
if ( con!=null ) con.close();
}
catch (SQLException ignored) {}
%>
</body>
</html>
Matt Read wrote:
> You'll need to show the code you use to establish the connection, in the
> meantime here's an example of some lines of code I use to establish a
> connection that works, hopefully this will help...
>
> import java.sql.*;
>
> public class MyClass {
>
> public MyClass() throws SQLException {
> Class.forName("org.gjt.mm.mysql.Driver").newInstance();
> Connection c =
> DriverManager.getConnection("jdbc:mysql://mymachine.mydomain.com/mySqlDataba
> seName?user=myUserName&password=myPassword");
> }
>
> }
>
>
> Matt.
>
> ----- Original Message -----
> From: "Howler D. Wolfe" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: 18 July 2001 14:19
> Subject: Problems with a simple JSP and mySQL connect
>
>
>> Hello Everyone,
>>
>> I apologize if this has been answered in a previous post. I've been
>
> digging through old posts and
>
>> and searching on the net for an answer to this problem.
>>
>> I am runnin Tomcat 3.2.2 and Apache 1.3.19 and MySQL (I think the latest
>
> version). I am able to
>
>> run the examples without a hitch. I am new to Java, JSP and MySQL, I have
>
> created a database with
>
>> two tables, when I try to use the MySQL driver to connect to the database
>
> I get the following error.
>
>> I think I get this error because I don't have a user other than root setup
>
> on MySQL. In my searching
>
>> for an answer, I read about using the URL of the MySQL db as part of
>
> getConnection(). I tried this
>
>> and it failed due to the MySQL port not being open on my firewall. After I
>
> opened the appropriate
>
>> port, I got the same error.
>>
>> What have I failed to do when setting up MySQL? I've installed it, ran the
>
> grants, I think I've done
>
>> what was supposed to be done.
>>
>> I've used the user id of "root" with the password I set for it.
>>
>> Partial Error Text follows:
>> *
>> java.sql.SQLException: Server configuration denies access to data source*
>>
>> Thanks in advance
>> John Brosan
>>