Link to home
Start Free TrialLog in
Avatar of xoxomos
xoxomos

asked on

Unknown Tag In Eclipse

I'm going through one of those online tutorials from lynda.com where i'm using Eclipse, Apache and mySQL.  The problem is simply to connect to a mySQL database  using JSP i believe.   When I click run, i see a warning , 'unknown tag(tours).  How to i get rid of that problem?
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import = "com.mysql.*" %>
<?xml version="1.0"?>
<tours>
 <%      
     Connection connection = null;
     Statement statement = null;
     ResultSet result = null;
     try {
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/tours", "root", "root");
         out.println("connected to database");
      }
      catch(SQLException e) {
           out.println("error connecting to database");
      }
%>
</tours>
ASKER CERTIFIED SOLUTION
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xoxomos
xoxomos

ASKER

Thanks.  I believe you although i'm not seeing it in the tutorial.  Would you point to some doc on what needs to be put in tours.tag?
It depends on what you're trying to do in the application. It's hard to know without knowing which tutorial you are following. Were there some files you downloaded? Or are you creating them yourself? Are you creating a custom tag?
Avatar of xoxomos

ASKER

Thanks.  It's a lynda.com java tutorial.  The exercise files are all downloaded. Additionally they have us download wampserver , Apache and the driver mysql-connector-java-5.1.35-bin.jar , Eclipse IDE
If i change the imports to be all on the same line:
<%@ page import="java.sql.*" %><%@ page import="java.io.*" %><%@ page import = "com.mysql.*" %><?xmlversion="1.0"?>
<tours>
 i still have the warning about the tours tag but the stuff inside executes and i get SQLException.
<%@ page import="java.sql.*" %><%@ page import="java.io.*" %><%@ page import = "com.mysql.*" %><?xml version="1.0"?>
<tours>
<%      
     Connection connection = null;
     Statement statement = null;
     ResultSet result = null;
     try {
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/tours", "root", "root");
         out.println("connected to database");
      }
      catch(SQLException e) {
           out.println("error connecting to database");
      }
%>
</tours >
I downloaded jdk 1.8 so now i'm wondering if the version of java is compatible with the driver release or if i may need to try and find some older java :-(
If you're working with JSPs you probably need the Java EE SDK, not the Java SE SDK.
Avatar of xoxomos

ASKER

Yes, i have the EE, but:
Connector/J version        Java RTE required      JDK required (to build source code)
5.1                                         1.4.x, 1.5.x, 1.6.x      1.6.x and 1.5.x (or older)

http://www.cs.utah.edu/~thanhhoa/projects/PubmedAnalysis/libraries/mysql-connector-java-5.1.8/docs/connector-j.html#connector-j-versions-java

The connector is mysql-connector-java-5.1.35-bin.jar and my java is JAVA_VERSION="1.8.0_31"
OS_NAME="Windows"    :-(   :-(
I'm guessing i'll have to suck it up a install a 1.6 java if i cannot find a newer mysql connector.  I'll put out another question on that.
You can use JDBC to connect to a MySQL database. Then you don't have to worry about the Java version.
Avatar of xoxomos

ASKER

Is that not some sort of jdbc connection code?
I recommend using JDBC instead of mysql connector so you can use your java 1.8