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.j dbc.Driver ").newInst ance();
connection = DriverManager.getConnectio n("jdbc:my sql://loca lhost:3306 /tours", "root", "root");
out.println("connected to database");
}
catch(SQLException e) {
out.println("error connecting to database");
}
%>
</tours>
<%@ 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.j
connection = DriverManager.getConnectio
out.println("connected to database");
}
catch(SQLException e) {
out.println("error connecting to database");
}
%>
</tours>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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.3 5-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.j dbc.Driver ").newInst ance();
connection = DriverManager.getConnectio n("jdbc:my sql://loca lhost: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 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.j
connection = DriverManager.getConnectio
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.
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.3 5-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.
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.3
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.
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
ASKER