LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-05-2007, 09:02 PM   #1
Swift&Smart
Member
 
Registered: Jan 2003
Location: Hong Kong,China
Distribution: Slackware,OpenSUSE
Posts: 472

Rep: Reputation: 30
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());
    }
  }
}
 
Old 12-05-2007, 11:12 PM   #2
ehawk
Senior Member
 
Registered: Jul 2003
Posts: 1,257

Rep: Reputation: 48
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
jdbc mysql java - please help me j0hnd0e Linux - Software 2 07-22-2006 05:23 AM
Java JDBC driver mickeyboa Fedora 2 07-23-2005 07:53 AM
jdbc connection in java balanagireddy Programming 2 07-01-2004 06:42 AM
JDBC connection in java balanagireddy Programming 1 06-30-2004 07:34 AM
I was working with jdbc in java in which we need navalarora Linux - Software 0 12-05-2003 06:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration