Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow other connection pools to be used, not just the internal one #4

Closed
timmolter opened this issue Sep 7, 2012 · 4 comments
Closed

Comments

@timmolter
Copy link
Member

No description provided.

@solinad21
Copy link

Hello i am using this lib thanks. do you have some basic example about how to use dbconnectionpool ?

i am building an app with diferent conns for each user.

@timmolter
Copy link
Member Author

Multiple connections is really easy. In your DB.properties file you just need multiple entries. For example:

driverclassname=org.hsqldb.jdbcDriver

# User1
user1.url=jdbc:hsqldb:mem:aname;shutdown=true
user1.user=user1
user1.password=
user1.maxconn=10

# User2
user2.url=jdbc:hsqldb:mem:aname;shutdown=true
user2.user=user2
user2.password=
user2.maxconn=10

Then, whenever you use the DBProxy class to run SQL queries, you need to reference the specific pool name like this:

DBProxy.executeSQL("user1", SQL, params);
DBProxy.executeSQL("user2", SQL, params);

Each user get's its own connection pool.

@solinad21
Copy link

thanks for your quick response.

I quite understand the idea.

I use mysql, I guess this works for different urls.

@timmolter
Copy link
Member Author

For MySQL the driverclassname and url would look somthing like this:

driverclassname=com.mysql.jdbc.Driver
user2.url=jdbc:mysql://localhost:3306/DB_NAME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants