Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting via a specific Socket?

 
Robert Fry
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure where to put this, sockets & networking or here? I figured here.

Is it possible to obtain a JDBC Connection object for SQL operations via a Socket object? I know there is a socket object(s) buried inside that Connection, hence all the socket exceptions you get if it fails to connect. But the DriverManager creates the socket internally. The problem is that I want to use an SSLSocket so the connection to the remote DB is encrypted, using a specific protocol no less. I did read some stuff on encrypted SQL connections - I noticed Oracle allows you to specify encryption as part of the vendor provided stuff you can access via DriverManager properties - but that doesn't appear to be an option with MySQL.

It doesn't seem to be an easy task to do this - far as I can tell it would involve extending some JDBC classes and getting right into the guts of hairy code. But maybe I'm wrong.

Am I?

The alternative is to just use the SSL connection to get to the server and then the server can be rigged up to connect to the database on localhost the usual way and pass serialised objects back and forth I suppose, but that seems immensely ugly to me.

Unfortunately the internet fails because all I get is talk about SocketExceptions when hunting for clues.
 
Robert Fry
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Typical, I post, and then I find something.

Apparently the MySQL drivers do support SSL themselves so I can fiddle with Properties objects to get it to work.

However there seem to be problems with it judging by unfortunates tearing their hair out on the net over this functionality, so maybe I'll be back...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its usually the responsibility of the driver to support SSL if the database supports it, so you shouldn't have to do any socket programming yourself. The driver will also hide the mechanics of the connection from you (well, it is an deliberate layer of abstraction after all ) so you can't get at it via normal JDBC code. I don't know if there are drivers that supprt SSL for MySQL, but the driver it does supply is open source so you could possible extend it to do the SSL stuff?
 
Robert Fry
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:Its usually the responsibility of the driver to support SSL if the database supports it, so you shouldn't have to do any socket programming yourself. The driver will also hide the mechanics of the connection from you (well, it is an deliberate layer of abstraction after all ) so you can't get at it via normal JDBC code. I don't know if there are drivers that supprt SSL for MySQL, but the driver it does supply is open source so you could possible extend it to do the SSL stuff?


Well, there is apparently SSL support in MySQL, but it looks a bit ropey judging by the people posting in forums trying vainly to get it to work.

For interests sake there are some instructions here :-

http://dev.mysql.com/doc/refman/5.0/en/secure-create-certs.html
http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-using-ssl.html

I'm going to try and get a prototype going next...

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic