aspose file tools*
The moose likes JDBC and the fly likes Sockets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Sockets" Watch "Sockets" New topic
Author

Sockets

Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Hi there.

I am trying to connect to a mysql server that does not have a port number, but does have a socket.

My understanding is that in the past JDBC did not support sockets. Does it now? How do I go about setting up a connection using the socket if I already have the code below?

Thanks.



Moosey knows best
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Have you tried the default port number? I'm sure there's a port number configured for the mysql server.


My Blog: Down Home Country Coding with Scott Selikoff
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Hi,

No - there is no port number when i type 'status' at the MySQL prompt. I have tried the default 3306 and this did not work...

I get the error:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Can you view the MySQL config file? my.ini in windows, my.cnf in mac/linux.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Sam Bluesman wrote:No - there is no port number when i type 'status' at the MySQL prompt. I have tried the default 3306 and this did not work...

I get the error:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.


Ok first, the fact that you can't connect may indicate a firewall or configuration error. Second, *how* are you connecting to the server to send the status command?
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
I don't have priviliges to see that.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Sam Bluesman wrote:I don't have priviliges to see that.


It would definitively answer which port to use. The file usually contains a [client] port value in it.

Either way, how are you connecting to MySQL to send commands? My guess would be you are using the port you are looking for.
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Hi,

OK so I have been using putty to connect to the server and then logged into mysql from there, using the defauly port:22 option.

That seems to have done something but given the code above I am not getting the following error:

com.mysql.jdbc.PacketTooBigException: Packet for query is too large

But this still does not put "Sucess" as it should in the code so not sure if it connecting. Any advice?

Thanks
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

1) Contact the DBA and find out the port. You shouldn't be guessing.

2) Use the standard driver and driverName. The mm driver hasn't been updated in 8 years
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sockets