• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connecting via a specific Socket?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

 
reply
    Bookmark Topic Watch Topic
  • New Topic