JDBC and abstraction layer

357 Views Asked by At

I want to open access to a database using JDBC protocol, so that many people in the company can access it.

The JDBC connection string would look like jdbc:sqlserver://[serverName[\instanceName][:portNumber].

I'm wondering if there is a way to have a layer of abstraction between the client and the server. Let me explain...

For example, using REST services, we can tell people to use a URL that looks like https://servername/path/to/resource/123, which we can url-rewrite to https://my-server/my-path/resource?id=123. Implementation, location, complexity is hidden from the user, and anything can be changed transparently.

Is there something similar we can do with JDBC ? For example, can I redirect jdbc://[serverName[\instanceName][:portNumber] to jdbc:sqlserver://[my--server[\my-instance][:my-port] ?

Thanks for your help !

1

There are 1 best solutions below

0
bayuforest On

We can't rewrite JDBC url. But you can use JNDI (Javax Naming Directory Interface). You must configure JNDI data source first, ex: in tomcat 6.0
Then you can use this JNDI in your application