>> This sounds like a bad bad idea. I'm no expert on this, but connections
>> in general have lots of local resources that are completely
[quoted text clipped - 3 lines]
>
> The whole idea is the connect string is hidden for security reasons.
> christop...@dailycrossword.com wrote:
> >> This sounds like a bad bad idea. I'm no expert on this, but connections
[quoted text clipped - 8 lines]
> any way to do this myself. Like Andrea the next thing that comes to
> mind is to encrypt the connect string.
First, the connect url, username, and password are in a file with
access restrictions -- they are never in the source, which means there
is only one place from which the passwords can be obtained (except
from memory and my workstation). This file is read at the time the
singleton is instantiated, which occurs when the Tomcat context is
started using ContextListener. Then the connections are created and
references to them are kept in the singleton. It is these references
that are used to obtain the connections like "dbwrite" in the above
example, *not* connect strings. There are connectors for different
databases and connectors that are read-only for eventual database load
balancing if it becomes necessary.
(Not that it matters to this question, but I think what some of you
are missing is the fact that these connections are created by a
factory earlier using the url, name and password, and that
DriverManager.getConnection() is returning a reference to a pooled
connection, not creating a new one, so it doesn't need the password.
An interesting side note is connections obtained in this manner are
shared by all the webapps in Tomcat 6, so the references to them have
to be individualized per webapp. I found this out when one webapp was
updating data in the wrong database during a test phase!)
The fact that the connection cannot be serialized is what prompted my
question -- sorry I was not clear! I intended to say that a pool of
connections would be maintained on each of the 'web' servers, which
obtain serialized 'collector' singletons form the 'app' server. These
'collector' singletons currently refer directly to a singleton
'connection pooler' which without modification of the code is
definitely not going to work. I was not certain how to use
'transient' to prevent the 'connection pooler' from being serialized,
and I was unclear what would happen if I just made it not
serializable. It looks like "readResolve" will accomplish what I
need, forcing the local copy of the 'collector' singleton to use the
local instance of the 'connection pooler'.
I hope I said this right. Its a big job, so I will make a trial run
using this technique before I update all my code. Thanx for all your
help!
Mark Space - 26 Mar 2008 23:18 GMT
> I hope I said this right. Its a big job, so I will make a trial run
> using this technique before I update all my code. Thanx for all your
> help!
Well I don't think I understood all of that, but good luck. There were
to many things in your post that referred to some internal concept in
your own code. I would have loved to see a description how the actual
jdbc objects move about.
It does seem to me that you have some proxy objects ("collectors") that
make requests not to the DB, but to the app server, and it's the app
server that has the full connection string. However, I'm not sure
that's what is going on.
Anyway, have fun. ;-)
Andrea Francia - 26 Mar 2008 23:53 GMT
> First, the connect url, username, and ...
Now I realized that I did not understood the problem.
You don't need to serialize the connection but your collector object.
> I hope I said this right. Its a big job, so I will make a trial run
> using this technique before I update all my code. Thanx for all your
> help!
I wish you to resolve successfully your problem.

Signature
Andrea Francia
http://www.andreafrancia.it/