A simple thing!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug

    #1

    A simple thing!

    Hello
    It has been some years since I used Mysql. How
    could I forget so much?!

    I can connect to my (4.x-Connector/J 3.0.17-ga) (using password
    123456) test db with:

    mysql -u dkr -h localhost -p ARPWS

    I cannot create a connection with:

    Connection conn =
    DriverManager.g etConnection("j dbc:mysql://localhost/ARPWS?user=dkr& password=123456 ");

    The runtime returns an exception:
    java.sql.SQLExc eption: Unable to connect to any hosts due to exception: java.net.Socket Exception: java.net.Connec tException: Connection refused

    ** BEGIN NESTED EXCEPTION **

    java.net.Socket Exception
    MESSAGE: java.net.Connec tException: Connection refused

    STACKTRACE:

    java.net.Socket Exception: java.net.Connec tException: Connection refused
    at com.mysql.jdbc. StandardSocketF actory.connect( StandardSocketF actory.java:143 )
    at com.mysql.jdbc. MysqlIO.<init>( MysqlIO.java:22 5)
    at com.mysql.jdbc. Connection.crea teNewIO(Connect ion.java:1805)
    at com.mysql.jdbc. Connection.<ini t>(Connection.j ava:452)
    at com.mysql.jdbc. NonRegisteringD river.connect(N onRegisteringDr iver.java:411)
    at java.sql.Driver Manager.getConn ection(DriverMa nager.java:525)
    at java.sql.Driver Manager.getConn ection(DriverMa nager.java:193)
    at MySqlDB.<init>( Unknown Source)
    at UserActions.<in it>(Unknown Source)
    at UserButtonHandl er.<init>(Unkno wn Source)
    at UserDataPanel.< init>(Unknown Source)
    at PainFull.<init> (Unknown Source)
    at Main.init(Unkno wn Source)
    at Main.main(Unkno wn Source)


    class 'com.mysql.jdbc .Driver' not found java.sql.SQLExc eption: Unable to connect to any hosts due to exception: java.net.Socket Exception: java.net.Connec tException: Connection refused

    ** BEGIN NESTED EXCEPTION **

    java.net.Socket Exception
    MESSAGE: java.net.Connec tException: Connection refused


    OK - I'm getting old. What have I forgotten this time?

    Thank you for your time!
    dkr

  • Bill Karwin

    #2
    Re: A simple thing!

    "Doug" <dkrqXXX@XXXtel us.planet.net> wrote in message
    news:pan.2006.0 1.30.23.24.59.7 84424@XXXtelus. planet.net...[color=blue]
    > Connection conn =
    > DriverManager.g etConnection("j dbc:mysql://localhost/ARPWS?user=dkr& password=123456 ");
    >
    > The runtime returns an exception:
    > java.sql.SQLExc eption: Unable to connect to any hosts due to exception:
    > java.net.Socket Exception: java.net.Connec tException: Connection refused[/color]

    Frequently I see the JDBC getConnection using the three-String method
    signature, for example:

    DriverManager.g etConnection("j dbc:mysql://localhost/ARPWS", "dkr",
    "123456");

    Even though javax.sql.Drive rManager includes a single-String method
    signature for getConnection, and the MySQL Connector/J docs imply your usage
    should work, it seems folks don't use that form much. Searching Koders.com,
    I see only usage of the three-String method signature, for MySQL connections
    (and also for other RDBMS brands)

    Regards,
    Bill K.


    Comment

    • Doug

      #3
      Re: A simple thing!

      On Mon, 30 Jan 2006 17:27:36 -0800, Bill Karwin wrote:
      [color=blue]
      > "Doug" <dkrqXXX@XXXtel us.planet.net> wrote in message
      > news:pan.2006.0 1.30.23.24.59.7 84424@XXXtelus. planet.net...[color=green]
      >> Connection conn =
      >> DriverManager.g etConnection("j dbc:mysql://localhost/ARPWS?user=dkr& password=123456 ");
      >>
      >> The runtime returns an exception:
      >> java.sql.SQLExc eption: Unable to connect to any hosts due to exception:
      >> java.net.Socket Exception: java.net.Connec tException: Connection refused[/color]
      >
      > Frequently I see the JDBC getConnection using the three-String method
      > signature, for example:
      >
      > DriverManager.g etConnection("j dbc:mysql://localhost/ARPWS", "dkr",
      > "123456");
      >
      > Even though javax.sql.Drive rManager includes a single-String method
      > signature for getConnection, and the MySQL Connector/J docs imply your usage
      > should work, it seems folks don't use that form much. Searching Koders.com,
      > I see only usage of the three-String method signature, for MySQL connections
      > (and also for other RDBMS brands)
      >
      > Regards,
      > Bill K.[/color]

      Thanks for the advice - I will give it a try as soon as I can!

      dkr

      Comment

      Working...