Problem with Tomcat, MySQL and Netbeans

View: New views
4 Messages — Rating Filter:   Alert me  

Problem with Tomcat, MySQL and Netbeans

by sauronnikko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi. I'm using Netbeans 6.7.1, Apache Tomcat 6.0.20 and MySQL 5.1. Tomcat with Netbeans works great. The Connection /J driver to make work MySQL with Tomcat seems to be working fine too, because this line:


Code:


Class.forName("com.mysql.jdbc.Driver").newInstance();





doesn't give an error. The one that does, however, is:


Code:


Connection c;





Netbeans says that it cannot find symbol class Connection from class Simplifed JSPServlet. When I try to run this app, it shows this error:


Code:


C:\Documents and Settings\Sauronnikko\Mis documentos\NetBeansProjects\WebApplication2\build\generated\src\org\apache\jsp\prueba_jsp.java:68: cannot find symbol

symbol  : class Connection

location: class org.apache.jsp.prueba_jsp

            Connection c;

            ^

1 error

C:\Documents and Settings\Sauronnikko\Mis documentos\NetBeansProjects\WebApplication2\nbproject\build-impl.xml:472: The following error occurred while executing this line:

C:\Documents and Settings\Sauronnikko\Mis documentos\NetBeansProjects\WebApplication2\nbproject\build-impl.xml:224: Compile failed; see the compiler error output for details.





It does not recognize "Connection", but this word should be. Here it's the complete code:




Code:


<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!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=UTF-8">

        <title>JSP Page</title>

    </head>

    <body>

        <%

            Class.forName("com.mysql.jdbc.Driver").newInstance();

            Connection c;

        %>

    </body>

</html>



Any thougts? Thanks







Problem with Tomcat, MySQL and Netbeans

by Humage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Code:
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.sql.Connection"%>

<!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=UTF-8">

        <title>JSP Page</title>

    </head>

    <body>

        <%

            Class.forName("com.mysql.jdbc.Driver").newInstance();

            Connection c;

        %>

    </body>

</html>





Possibly forgot to import the class:

java.sql.Connection;

Hope this helps.





Problem with Tomcat, MySQL and Netbeans

by sauronnikko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes... it was that. Sorry for this mistake. I've been installing and configuring this for two days and I did not think of that simple thing. Thanks!





Problem with Tomcat, MySQL and Netbeans

by Humage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Happy to help.  8)