jruit718
asked on
Cannot find tables using JDBC to MySQL database
I have set up:
- a JSP connection to a MySQL database using Tomcat
- on my Windows 2000 machine
- I have also downloaded the "MySQL driver mm.mysql-2.0.4-src.jar" and placed it in tomcat/lib.
I have set up a table called "article" and added several columns. I have also set up test.jsp which connects to the database and reads the columns.
My problem is that when I run "test.jsp" I get the following error...
Internal Servlet Error:
javax.servlet.ServletExcep tion: General error: Table 'icore.article' doesn't exist
Root cause:
java.sql.SQLException: General error: Table 'icore.article' doesn't exist
My table does exsist and I have checked it using the same SQL statement as in my JSP code.
Any ideas if this is a code error, or config error or something else?
- a JSP connection to a MySQL database using Tomcat
- on my Windows 2000 machine
- I have also downloaded the "MySQL driver mm.mysql-2.0.4-src.jar" and placed it in tomcat/lib.
I have set up a table called "article" and added several columns. I have also set up test.jsp which connects to the database and reads the columns.
My problem is that when I run "test.jsp" I get the following error...
Internal Servlet Error:
javax.servlet.ServletExcep
Root cause:
java.sql.SQLException: General error: Table 'icore.article' doesn't exist
My table does exsist and I have checked it using the same SQL statement as in my JSP code.
Any ideas if this is a code error, or config error or something else?
can you provide the code (test.jsp) ?
ASKER
This is the code I'm using.....
<%@ page import="java.sql.*" %>
<%
String connectionURL="jdbc:mysql: //localhos t/icore?us er=icore&p assword=th epass";
Connection connection = null;
java.sql.Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("org.gjt.mm. mysql.Driv er").newIn stance();
connection = DriverManager.getConnectio n(connecti onURL, "", "");
statement = connection.createStatement ();
rs = statement.executeQuery("SE LECT * FROM ARTICLE;");
while (rs.next()) {
out.println(rs.getString(" title")+"< br>");
}
rs.close();
%>
</body></html>
<%@ page import="java.sql.*" %>
<%
String connectionURL="jdbc:mysql:
Connection connection = null;
java.sql.Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("org.gjt.mm.
connection = DriverManager.getConnectio
statement = connection.createStatement
rs = statement.executeQuery("SE
while (rs.next()) {
out.println(rs.getString("
}
rs.close();
%>
</body></html>
are you sure table article exists and your user has permission to view/access it?
Maybe you have to qualify the database.. like test.Article or whatever.
Just ideas.
CJ
Maybe you have to qualify the database.. like test.Article or whatever.
Just ideas.
CJ
The table and field name in mysql are case sensitive. Please double check.
ASKER
Never Mind... I found the problem... Seems that there was 2 databases of similar names "icore" and "icore;" one was empty and one was not. I must have created it by mistake.
Thanks for your help.
Thanks for your help.
ok.
Please as Community Support to delete this question.
CJ
Please as Community Support to delete this question.
CJ
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.