Tomcat connecting to MySQL - Ubuntu 8.10 Server
Ambrose Krapacs
akrapacs at gmail.com
Wed Nov 19 16:06:38 UTC 2008
On Nov 17, 2008, at 23:39 , Ambrose Krapacs wrote:
> On Nov 17, 2008, at 1:03 , Mark Kirkwood wrote:
>
>> Ambrose Krapacs wrote:
>>>
>>> I found a couple log files that seem to be associated with mysql
>>> but they were all empty. I also checked tomcat log files with no
>>> luck.
>>>
>>
>> Hmm - I guess the next step is to try a standalone jdbc prog using
>> the mysql connector (see example attached) and debug from there.
>>
>> Cheers
>>
>> Mark
>> <mysql-connector-example.tar.gz>--
>> ubuntu-users mailing list
>> ubuntu-users at lists.ubuntu.com
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
> I was able to execute the standalone java application and
> successfully use the MySQL connector to open a JDBC connection to
> the MySQL database. It looks like everything is good with MySQL now,
> I think I need to focus on Tomcat now I guess.
I've got to be missing something or doing something wrong here. I set
up ANOTHER system, this time with Ubuntu Desktop 8.10 and I'm getting
the exact same results. I'm attaching the test JSP file that I am
using, perhaps somebody will be identify something wrong with what I
am doing in the JSP. I have configured two accounts on the MySQL
server (root:admin and inventory:password) and verified that they both
work. Also, I have created the database "testdb". All of the tests in
the code of this JSP execute fine on my Mac OS X machine, but all fail
with the same CommunicationException on all of the Ubuntu machines
that I have tried. These are all new installs of Ubuntu so there's got
to be something wrong or something that I am missing every time.
<%--
Document : index
Created on : Nov 16, 2008, 1:19:22 PM
Author : ambrose
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page 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>
More information about the ubuntu-users
mailing list