FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SQLException





NewGuyinTown
I got an error: java.sql.Exception: Base table or view not found, message from server: "Table 'mysql.students' doesn't exist"

I just installed JBoss and configured mySQL accordingly to the tutorials/manuals.

I do not know what is wrong here... is it my server, database, or code?

Code:

<html>
<head>
<%@ page
   import = "java.io.*"
   import = "java.lang.*"
   import = "java.sql.*"
%>
<title>
JSP Example 2
</title>
</head>
<body>
<h1>JSP Example 3</h1>
<%
   String   place;
   Connection dbconn;
   ResultSet results;
   PreparedStatement sql;
   try
   {
      Class.forName("org.gjt.mm.mysql.Driver");
      try
      {
         int   latitude,longitude,easting,northing;
         boolean   doneheading = false;
         dbconn = DriverManager.getConnection("jdbc:mysql://localhost/mysql:3306/cmpsci320","root","[password]");
         place = request.getParameter("place");
         sql = dbconn.prepareStatement("SELECT * FROM students");
         results = sql.executeQuery();
         while(results.next())
         {
            if(! doneheading)
            {
               out.println("<table border=2>");
               doneheading = true;
            }
                                latitude = results.getInt("latitude");
                                longitude = results.getInt("longitude");
                                easting = results.getInt("easting");
                                northing = results.getInt("northing");
            out.println("<tr><td>" + latitude);
            out.println("<td>" + longitude);
            out.println("<td>" + easting);
            out.println("<td>" + northing);
         }
         if(doneheading)
         {
            out.println("</table>");
         }
         else
         {
            out.println("No matches for " + place);
         }
      }
      catch (SQLException s)
      {
         out.println("SQL Error<br>");
      }
   }
   catch (ClassNotFoundException err)
   {
      out.println("Class loading error");
        }
%>
</body>
</html>
kv
the driver is looking for your "students" table in system database "mysql". I think your connection string should be like this.

Code:

DriverManager.getConnection("jdbc:mysql://localhost/cmpsci320","root","[password]");


Then it will connect to database cmpsci320.
NewGuyinTown
Thank you, kv! It works... but now I have an ArrayOutofBound...

(Didn't wrote the code , but I used to verify if the database is configured correctly.)

The table students has three fields:

lastname - varchar(30)
firstname - varchar(30)
StudentID - int(1)


but now... I received the error: java.sql.SQLException: Unable to connect to any hosts due to exception: java.lang.ArrayIndexOutOfBoundsException: 43

I tested the code without everything from {place = request... to out.println(No matches for...}, and still received the same error.
NewGuyinTown
Nevermind... Got it working Controller-J was the old one. : )
Thanks.
Related topics
Servletsgis application development basic problems i faced and solngis application dev. for rain,river,floodInsertion error for date values
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.