On Nov 18, 2008, at 7:58 , David Smith wrote:

Can you post your database config and code snippet for accessing the
db?  Obfuscate the username/password info.

One immediate observation is the JDBC url should have the name of the
database you are trying to access like this:

jdbc:mysql://localhost/myDatabase?user= ....

--David

<TRIMMED>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Here is the test JSP page that I have been using to test multiple urls. On my OS X machine they all pass and on the Ubuntu machine they all fail with the CommunicationException. As for the url without the database, my application attempts to connect to the specific database and if that fails it will then try to connect without the database specified in the url so it can create the database. Therefore, the connection to the url database is only attempted after the connection to the url with the database has failed. This method seems to work flawlessly on my OS X machine so I dont think that it should cause a problem. You will see in my test JSP though, that I'm trying multiple different url variations and they all fail with the exact same exception.

<%--
    Document   : index
    Created on : Nov 16, 2008, 1:19:22 PM
    Author     : ambrose
--%>

<[EMAIL PROTECTED] contentType="text/html" pageEncoding="UTF-8"%>

<[EMAIL PROTECTED] import="java.sql.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd";>

<html>
    <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

        <%

            Class.forName("com.mysql.jdbc.Driver").newInstance();

String[] url = new String[] { "jdbc:mysql://localhost/ testdb?user=inventory&password=password", "jdbc:mysql://localhost/ testdb?user=root&password=admin", "jdbc:mysql://127.0.0.1/ testdb?user=inventory&password=password", "jdbc:mysql://127.0.0.1/ testdb?user=root&password=admin", "jdbc:mysql://localhost: 3306/testdb?user=inventory&password=password", "jdbc:mysql://localhost: 3306/testdb?user=root&password=admin", "jdbc:mysql:// 127.0.0.1:3306/testdb?user=inventory&password=password", "jdbc:mysql:// 127.0.0.1:3306/testdb?user=root&password=admin",

"jdbc:mysql://localhost? user=inventory&password=password", "jdbc:mysql://localhost? user=root&password=admin", "jdbc:mysql://127.0.0.1? user=inventory&password=password", "jdbc:mysql://127.0.0.1? user=root&password=admin", "jdbc:mysql://localhost: 3306?user=inventory&password=password", "jdbc:mysql://localhost: 3306?user=root&password=admin", "jdbc:mysql:// 127.0.0.1:3306?user=inventory&password=password", "jdbc:mysql:// 127.0.0.1:3306?user=root&password=admin",

"jdbc:mysql://localhost/? user=inventory&password=password", "jdbc:mysql://localhost/? user=root&password=admin", "jdbc:mysql://127.0.0.1/? user=inventory&password=password", "jdbc:mysql://127.0.0.1/? user=root&password=admin", "jdbc:mysql://localhost: 3306/?user=inventory&password=password", "jdbc:mysql://localhost: 3306/?user=root&password=admin", "jdbc:mysql:// 127.0.0.1:3306/?user=inventory&password=password", "jdbc:mysql:// 127.0.0.1:3306/?user=root&password=admin",

"jdbc:mysql:///? user=inventory&password=password", "jdbc:mysql:///testdb? user=inventory&password=password"
                                        };

            for( int i = 0; i < url.length; i++ )
            {
                String retVal = openConnection(url[i]);

                if( retVal == null )
                {
                    out.write("Successful: " + url[i] + "<br/>");
                }
                else
                {
out.write("Failed: " + url[i] + "(" + retVal + ")<br/>");
                }
            }

        %>

        <%!
        public String openConnection(String url)
        {
            String retVal = null;
            Connection c = null;
            try
            {
                c = DriverManager.getConnection(url);
            }
            catch( Exception e )
            {
                retVal = e.toString();
            }
            finally
            {
                if( c != null )
                {
                    try
                    {
                        c.close();
                    }
                    catch( Exception e ) {}
                }
            }

            return retVal;
        }
        %>
    </body>
</html>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to