List:MySQL and Java« Previous MessageNext Message »
From:Anthony G. Starovojtov Date:September 8 1999 7:34am
Subject:Trouble with connection
View as plain text  
Please, help.

I'm trying to connect to the mSQL server, locating at 10.0.254.9 with
the
linux user 'test' and password 'tester'.
I use MM.mySQL driver.

The following message appears:
' SQLException caught: Server configuration denies access to data source
'

It fails while trying to get connection to database.
Why does this exception throws?

Here is the text of my servlet:


import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class mSQL extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    try {
      Class.forName("org.gjt.mm.mysql.Driver");

      // Get a Connection to the database
      con = DriverManager.getConnection(
        "jdbc:mysql://10.0.254.9/test?user=tester=test");
      out.println("Ready for Create Statement\n");
      // Create a Statement object
      stmt = con.createStatement();

      // Execute an SQL query, get a ResultSet
      rs = stmt.executeQuery("SELECT * from simple;");

      // Display the result set as a list
     
out.println("<HTML><HEAD><TITLE>results</TITLE></HEAD>");
      out.println("<BODY>");
      out.println("<UL>");
      while(rs.next()) {
        out.println("<LI>" + rs.getString("name"));// + " " +
Integer.toString(rs.getInteger("age")));
      }
      out.println("</UL>");
      out.println("</BODY></HTML>");
    }
    catch(ClassNotFoundException e) {
      out.println("Couldn't load database driver: " + e.getMessage());
    }
    catch(SQLException e) {
      out.println("SQLException caught: " + e.getMessage());
    }
    finally {
      // Always close the database connection.
      try {
        if (con != null) con.close();
      }
      catch (SQLException ignored) { }
    }
  }
}


--
Regards,
Anthony G. Starovojtov,
System Administrator of IMS Department,
Kharkov State Technical University of Radioelectronics,
pr. Lenina,14, room 260, Kharkov, 310726, Ukraine
Phone +380-572-409451 (Work), +380-572-648863 (Home)
E-mail: anthony@stripped,  sysadmin@stripped


Thread
Trouble with connectionAnthony G. Starovojtov8 Sep
  • Re: Trouble with connectionMark Matthews8 Sep
  • Re: Trouble with connectiondarcy8 Sep