#1
  1. Is a Psycho
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    In your computer
    Posts
    231
    Rep Power
    15

    JSP and mm.MySQL


    Hi,

    Does anyone know why I would be getting this error:

    Code:
    Internal Servlet Error:
    
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    C:\Dev\tomcat\work\localhost_8080\_0002findex_0002ejspindex_jsp_4.java:71: Ambiguous class: java.beans.Statement and java.sql.Statement
                    	Statement stmt = myConn.createStatement();
                    	^
    1 error, 1 warning
    When trying the following code:

    Code:
    <html>
    <head></head>
    <%@ page language="java" import="java.sql.*" %>
    <body>
    
    <%
    	Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    	
    	Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost/mysite?user=root&password=");
    	//myConn = DriverManager.getConnection("jdbc:mysql://localhost/mysite", "root", "");
    	
    	Statement stmt = myConn.createStatement();
    	
    	String strQuery = "select * from page_content where page_id=1";
    	
    	ResultSet rsResults = stmt.executeQuery(strQuery);
    	
    	if (rsResults != null) {
    		while (rsResults.next()) {
    			String strHeader = rsResults.getString("header");
    			String strContent = rsResults.getString("content");
    %>
    
    	<h2><%= strHeader %></h2>
    	<p><%= strContent %></p>
    
    <%
    		}
    	}
    %>
    </body>
    </html>
    deepspring

    - "Netscape 4 users are like lemmings... You can't help but laugh when one falls off a cliff"
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    It looks as if you are importing 2 packages that both have a Statement class and it does not know which one to use. Try using the fully qualified name of the class like:
    Code:
    java.sql.Statement stmt = myConn.createStatement();
  4. #3
  5. Is a Psycho
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    In your computer
    Posts
    231
    Rep Power
    15
    Cool thanx.. will try.
    deepspring

    - "Netscape 4 users are like lemmings... You can't help but laugh when one falls off a cliff"

IMN logo majestic logo threadwatch logo seochat tools logo