Try jdbc:mysql://localhost:<port>/<database> (usually the port number
is 3306) in the url param value


On Fri, 1 Oct 2004 01:09:43 -0700, Eric Wulff <[EMAIL PROTECTED]> wrote:
> Hi, I am not able to access a mysql server from a simple jsp example.
> I have googled the errors, checked mysql and tomcat docs and mailing
> list archives without success.  Finding a tremendous amount of info
> but nothing so far worked to solve my problem.  I created a data
> resource in my server.xml.  I have defined a resource reference in my
> web.xml.  I have tried shutting down my firewall.  I'm sure others
> have had similar problems and I'm hoping one of you can share your
> wisdom or point me in the right direction?
> 
> many thx
> Eric
> 
> More, hopefully enlightening, details below.
> 
> fedoa core 2
> tomcat 5
> j2sdk 1.4.2
> mysql 3.23.58 for linux redhat
> 
> -when mysql server is started I access it by simply typing 'mysql' at
> the command line
> 
> following is web.xml, JNDI db res entry from the server.xml, and 3
> error listings
> 
> -web.xml...
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!DOCTYPE web-app
>    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>    "http://java.sun.com/dtd/web-app_2_3.dtd";>
> 
> <web-app>
>    <servlet>
>        <servlet-name>Database Rates</servlet-name>
>        <servlet-class>DatabaseRates</servlet-class>
>    </servlet>
>    <servlet>
>        <servlet-name>DataSource Rates</servlet-name>
>        <servlet-class>DataSourceRates</servlet-class>
>    </servlet>
>    <servlet>
>        <servlet-name>Rates</servlet-name>
>        <jsp-file>/rates.jsp</jsp-file>
>    </servlet>
> 
>    <servlet-mapping>
>        <servlet-name>Database Rates</servlet-name>
>        <url-pattern>/database</url-pattern>
>    </servlet-mapping>
>    <servlet-mapping>
>        <servlet-name>DataSource Rates</servlet-name>
>        <url-pattern>/datasource</url-pattern>
>    </servlet-mapping>
>    <servlet-mapping>
>        <servlet-name>Rates</servlet-name>
>        <url-pattern>/rates</url-pattern>
>    </servlet-mapping>
> 
>        <resource-ref>
>          <res-ref-name>jdbc/conversion</res-ref-name>
>          <res-type>javax.sql.DataSource</res-type>
>          <res-auth>Container</res-auth>
>        </resource-ref>
> </web-app>
> 
> -server.xml JNDI db resource entry...
> I have set a password for root to match the example but that didn't work.
> 
>  <Context path="/database" docBase="database" debug="0" reloadable="true">
>    <ResourceParams name="jdbc/conversion">
>      <parameter>
>        <name>username</name>
>        <value>root</value>
>      </parameter>
>      <parameter>
>        <name>password</name>
>        <value>secret</value>
>      </parameter>
>      <parameter>
>        <name>driverClassName</name>
>        <!-- <value>org.gjt.mm.mysql.Driver</value> tried both -->
>        <value>com.mysql.jdbc.Driver</value>
>      </parameter>
>      <parameter>
>        <name>url</name>
>        <value>jdbc:mysql://localhost/test</value>
>      </parameter>
>    </ResourceParams>
>  </Context>
> 
> java.sql.SQLException: Data source rejected establishment of
> connection, message from server: "Host 'localhost.localdomain' is not
> allowed to connect to this MySQL server" SQL state: 08004
> Error code: 1130
> 
> 3 similar errors based on different db access strategies...
> org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver
> of class '' for connect URL 'null' SQL state: null
> Error code: 0
> 
> -error when using a datasource object...
> org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver
> of class '' for connect URL 'null'
> 
> -stack trace when using a DAO via a .jsp...
> org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
>        converters.ConversionDAO.<init>(ConversionDAO.java:23)
>        org.apache.jsp.rates_jsp._jspService(rates_jsp.java:46)
>        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
>        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>        
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
>        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
>        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
>        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 
> -I can create the test db table manually but can't via the java
> program provided in the tutorial.  This is the error I get when
> attempting to run that...
> java -classpath
> .:/usr/local/jakarta-tomcat-5.0.28/common/lib/mysql-connector-java-3.0.15-ga-bin.jar
> CreateDB
> Loaded driver: com.mysql.jdbc.Driver
> SQL Exception thrown: java.sql.SQLException: Data source rejected
> establishment of connection,  message from server: "Host
> 'localhost.localdomain' is not allowed to connect to this MySQL
> server"
> java.sql.SQLException: Data source rejected establishment of
> connection,  message from server: "Host 'localhost.localdomain' is not
> allowed to connect to this MySQL server"
>        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:649)
>        at com.mysql.jdbc.Connection.createNewIO(Connection.java:1782)
>        at com.mysql.jdbc.Connection.<init>(Connection.java:450)
>        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411)
>        at java.sql.DriverManager.getConnection(DriverManager.java:512)
>        at java.sql.DriverManager.getConnection(DriverManager.java:193)
>        at CreateDB.main(CreateDB.java:17)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



-- 
------------------------------------------------------------------
 Carlos J, Bracho M.                                  
 "The significant problems we face cannot    
  be solved at the same level of thinking      
  we were at when we created them."          
  Albert Einstein                           
------------------------------------------------------------------
 e-mail:  [EMAIL PROTECTED]
 MSN:    [EMAIL PROTECTED]                      
------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to