4 Replies - 561 Views - Last Post: 04 May 2013 - 01:57 AM Rate Topic: -----

#1 ibnmvungi  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 50
  • Joined: 20-April 12

cannot connect to mysql database in linux .JDBC not working

Posted 03 May 2013 - 10:03 AM

I am new in linux.I have install netbeans and import project from the window .The project works fine on window.but in linux I cannot connet to the mysql database.

I am using mysql. Is there any configuation i should make on linux so that I can connect to mysql the database on linux?

here is the code which works fine on window but not in linux

    con=DriverManager.getConnection("jdbc:mysql://locahost/test","root","xxx");
                    stm= con.createStatement();
                    stm2= con.createStatement();
          JOptionPane.showMessageDialog(null,"connected");



Please help me fix this issue.I am stack.

This post has been edited by ibnmvungi: 03 May 2013 - 10:04 AM


Is This A Good Question/Topic? 0
  • +

Replies To: cannot connect to mysql database in linux .JDBC not working

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10809
  • View blog
  • Posts: 40,288
  • Joined: 27-December 08

Re: cannot connect to mysql database in linux .JDBC not working

Posted 03 May 2013 - 10:04 AM

Moved to Java. Please do not post help questions in the Advanced Discussion forum.
Was This Post Helpful? 0
  • +
  • -

#3 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,994
  • Joined: 20-September 08

Re: cannot connect to mysql database in linux .JDBC not working

Posted 03 May 2013 - 12:03 PM

Quote

fine on window.but in linux I cannot connet to the mysql database.
It should work fine and much the same in each case, if, of course, 'localhost' is the same in each case, iow if the command

hostname

prints the same value at the command line
Was This Post Helpful? 0
  • +
  • -

#4 ibnmvungi  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 50
  • Joined: 20-April 12

Re: cannot connect to mysql database in linux .JDBC not working

Posted 03 May 2013 - 01:09 PM

I get this error

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Was This Post Helpful? 0
  • +
  • -

#5 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,994
  • Joined: 20-September 08

Re: cannot connect to mysql database in linux .JDBC not working

Posted 04 May 2013 - 01:57 AM

What happens if you try (from the terminal)?

mysql -u username -p

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1