LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Java JDBC-Exception: Communications link failure (http://www.linuxquestions.org/questions/programming-9/java-jdbc-exception-communications-link-failure-604817/)

Swift&Smart 12-05-2007 10:02 PM

Java JDBC-Exception: Communications link failure
 
Hello,everyone.:)

Recently,I have been playing around with Java and JDBC using MySQL database,which is my favourite.However,after I put the mysql-connector...jar to my JDK installation location /usr/local/jdk1.6/jre/lib/ext/.jar and I used the sample script on the Internet and try to connect to,it returned a failure message.

Exception: Communications link failure in the command prompt

Please drop me a line if you have any ideas with this error.Thanks a million.

The sample script goes like:
Code:

import java.sql.*;
public class MySqlConnectionUrl {
  public static void main(String [] args) {
    Connection con = null;
    try {
      Class.forName("com.mysql.jdbc.Driver") ;
      System.out.println("MySQL JDBC driver loaded ok.");
      con = DriverManager.getConnection(
        "jdbc:mysql://localhost:3306/mysql?"
        + "user=user&password=mypasswd");
      System.out.println("Connected with host:port/database.");
      con.close();
    }
    catch (Exception e) {
      System.err.println("Exception: "+e.getMessage());
    }
  }
}


ehawk 12-06-2007 12:12 AM

Does starting to read from here help?

http://docs.sun.com/source/817-6087/dgjdbc.html

http://forum.java.sun.com/thread.jsp...=136&tstart=15

Perhaps you can post to the java forum above

Also see (perhaps another good forum to consider):

http://www.daniweb.com/forums/thread68988.html

http://viconflex.blogspot.com/2006_11_01_archive.html

http://mext.at/?p=14


All times are GMT -5. The time now is 12:42 PM.