开发者

how to setup dynamic datasources in Spring.NET

开发者 https://www.devze.com 2023-01-08 17:32 出处:网络
I\'m working on a project wherein each time a new client comes in, a new database is created for that speci开发者_如何学运维fic client. In setting up the datasource, it is normally done this way:

I'm working on a project wherein each time a new client comes in, a new database is created for that speci开发者_如何学运维fic client. In setting up the datasource, it is normally done this way:

<?xml version="1.0" encoding="utf-8"?>

<objects xmlns="http://www.springframework.net"
xmlns:db="http://www.springframework.net/database">

<db:provider id="globalDBProvider"
provider="SqlServer-1.1"
connectionString="Server=myServer;Database=myGloba lDB;Uid=user1;Pwd=user1"/>

<object id="globalAdoTemplate" type="Spring.Data.Generic.AdoTemplate, Spring.Data">
<property name="DbProvider" ref="globalDBProvider"/>
</object>

That works fine for my "master" database since I know the database name. However, for my "new" databases. I was wondering if anyone has ideas on how to plugin the connectionString dynamically? E.g. suppose a user logs in and clicks on Client1 information. The Client1 information is stored in its own database.

I assume that I'd need to have another dbprovider for the client. But how to set it up such that it'll plugin the database and credentials at runtime?


Have you taken a look at implementing one of the other IDbProvider implementations that come with Spring.NET?

Have a look at the documentation here.

0

精彩评论

暂无评论...
验证码 换一张
取 消