20 messages in com.mysql.lists.javaRe: MM JDBC Driver with MySQL| From | Sent On | Attachments |
|---|---|---|
| Lawrence, Gareth | 25 Mar 2002 18:56 | |
| Lawrence, Gareth | 25 Mar 2002 20:09 | |
| Fabian Sommer | 26 Mar 2002 01:40 | |
| Rakesh | 26 Mar 2002 02:10 | |
| Fabian Sommer | 26 Mar 2002 03:38 | |
| Fabian Sommer | 26 Mar 2002 04:15 | |
| Adnan Al-bar | 26 Mar 2002 04:43 | |
| Leo Przybylski | 26 Mar 2002 07:19 | |
| Mark Matthews | 26 Mar 2002 10:03 | |
| Mark Matthews | 26 Mar 2002 10:08 | |
| Tom Myers | 26 Mar 2002 12:53 | |
| Bruce Scharlau | 26 Mar 2002 13:00 | |
| Lawrence, Gareth | 26 Mar 2002 13:36 | |
| Bruce Scharlau | 26 Mar 2002 13:59 | |
| Mark Matthews | 26 Mar 2002 14:33 | |
| Bruce Scharlau | 26 Mar 2002 16:01 | |
| Bruce Scharlau | 26 Mar 2002 16:27 | |
| Tom Myers | 26 Mar 2002 18:08 | |
| Tye, Timothy | 27 Mar 2002 11:38 | |
| Fabian Sommer | 10 Apr 2002 23:56 |
| Subject: | Re: MM JDBC Driver with MySQL![]() |
|---|---|
| From: | Leo Przybylski (le...@engr.arizona.edu) |
| Date: | 03/26/2002 07:19:49 AM |
| List: | com.mysql.lists.java |
Well, some of the mysql tools are native code which can connect to the database server without going through localhost 3306. So, if your server is up and you are able to connect with it using your tools that doesn't necessarily mean it is running on 3306. I would try to telnet to 3306. Immediately, you should see something like: ( 3.23.45(b5~=Uq\X Of couse, this depends on the version you are running. If you don't get this and you are able to connect to 3306, there is something running on that port that isn't mysql. If you aren't able to connect at all, mysql is probably running on another port. If mysql is indeed running on 3306, then I would look into the socket permissions of your profile. If you are running the default jre profile, you should be able to connect to 3306 on localhost.
-Leo
On Monday 25 March 2002 19:57, Lawrence, Gareth wrote:
Greetings All,
Would love some help on the following problem please :-))))
The error message I'm getting is:
SQLException: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.ConnectException)
And yet I've tested MySQL and Java independently :-( I think that this problem could be something do to with the MySQL configuration - but I really don't know :-( See below for details, and let me know if I need to provide anymore information
Any help is greatly, muchly, heaps and heaps appreciated !!!!!!
Thanx, Gareth
Problem Details
Setup I'm using: JDK1.4, the lastest version of MySQL (apt-get install mysql-common, mysql-server on debian linux), with mm.mysql.jdbc-1.2c.
My set up looks good:
setenv JAVA_HOME /usr/java/j2sdk1.4.0 setenv JAKARTA_HOME /usr/java/jakarta setenv ANT_HOME $JAKARTA_HOME/jakarta-ant-1.4.1 setenv TOMCAT_HOME $JAKARTA_HOME/jakarta-tomcat.4.0.3 setenv MM_HOME /usr/java/mysql.jdbc-1.2c
setenv CLASSPATH .:./usr/java/mm.mysql.jdbc-1.2c:/usr/java/j2sdk1.4.0/bin:$CLASSPATH
setenv PATH .:./bin:/usr/local/bin:/usr/X11R6/bin:/usr/java/jakarta/jakarta-tomcat.4.0. 3 /bin:/usr/java/jakarta/jakarta-ant-1.4.1:/usr/java/j2sdk1.4.0/bin:$PATH
Test File
import java.sql.*;
// Do not import org.gjt.mm.mysql.* or you will have problems! public class test { public static void main(String[] Args) { System.out.println("Loading Driver."); try { // The newInstance() call is a work around for some // broken Java implementations
Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch (Exception E) { System.err.println("Unable to load driver."); E.printStackTrace(); }
try {
String url="jdbc:mysql://localhost/weblearn?user=root"; //String url="jdbc:mysql://it017731.massey.ac.nz/weblearn"; System.out.println("Connecting to MySQL.");
Connection Conn = DriverManager.getConnection(url, "root", ""); System.out.println("connected!");
Statement Stmt = Conn.createStatement(); ResultSet RS = Stmt.executeQuery("SELECT Title from Quiz");
while (RS.next()) { System.out.println(RS.getString(1)); }
// Clean up after ourselves RS.close(); Stmt.close(); Conn.close(); } catch (SQLException E) { System.out.println("SQLException: " + E.getMessage()); System.out.println("SQLState: " + E.getSQLState()); System.out.println("VendorError: " + E.getErrorCode()); } }
}
Full Error Message Loading Driver. Connecting to MySQL. java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148) at java.net.Socket.connect(Socket.java:425) at java.net.Socket.connect(Socket.java:375) at java.net.Socket.<init>(Socket.java:290) at java.net.Socket.<init>(Socket.java:118) at org.gjt.mm.mysql.MysqlIO.<init>(MysqlIO.java:114) at org.gjt.mm.mysql.Connection.<init>(Connection.java:229) at org.gjt.mm.mysql.Driver.connect(Driver.java:126) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at test.main(test.java:26) SQLException: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.ConnectException) SQLState: 08S01 VendorError: 0
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail java...@lists.mysql.com
To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java...@lists.mysql.com instead.




