How to set connect URL to connect to more than 1 databases in HSQLDB - hsqldb

I've started the HSQLDB server with two databases open. i'm using the server protocol for connection i.e.
jdbc:hsqldb:hsql://localhost/portdb
portdb is just one database, how can i tweak this URL such that it connects to this and the other db?
I've been referring to hsql user guide but seems nowhere defines this

You cannot open or connect to two databases with the same java.sql.Connection. Use two different connections, each with its URL.
You can have multiple schemas inside a database and access them with a single connection. See http://hsqldb.org/doc/2.0/guide/databaseobjects-chapt.html

Related

Same database - different output from different clients

I have a docker container with Oracle DB which I try to access from different clients with same credentials and its behaviour is quite strange.
I have set up connection in IDEA with following JDBC URL: jdbc:oracle:thin:#//localhost:1526/XEPDB1
Also I work with it via Spring Data framework in another container, url is jdbc:oracle:thin:#oracle:1521/XEPDB1 (port is forwarded to outer world as 1526, container name is oracle)
And finally, I tried to access the db using sqlplus from within db host: sqlplus LOGIN/PASSWORD#localhost:1521/XEPDB1
All connections are successful, but simple inserts and selects for same table show that each client sees only it's own modifications. What is wrong? How do I share same table between clients?
According to the connection strings, all the users are connected to the same database, so that isn't the issue.
The issue is probably that each user that modifies the data (e.g., inserts new rows), does so without committing, and thus this data is only available in their current session. Once they commit the data, it will be available to all the other sessions too.

Connect to Multiple Database

How to Connect Multiple Database in Single App.
How can i Connect multiple databases using SQL adapter in IBM Worklight.. Scenario is Drop down which database selected that database has to connect in app.
In current releases of Worklight (5.x - 6.3), you cannot achieve this when using 1 adapter.
In order to connect to different databases your only option is to create several adapters.
Then, for each selected option from the dropdown, a different WL.Client.invokeProcedure code will be used to send a request (different adapter name).
This means you'll probably need to duplicate the adapter code as well... depending on your needs.

SQL synchronize database between local and remote server

I've got 2 companies in different locations and the main server is at my office. The main server is working with a full version of SQL Server where the companies use SQL Server express version.
What is the best way to synchronize these SQL Server databases together that the main server have always the latest updates?
There are several technologies specifically for this type of scenario:
SQL Replication
Supports unidirectional or bidirectional synchronization
SSIS
Lets you define the mappings of the data, as well as transformations, and attach other code to the process easily
Linked-servers
Allows you to query databases and tables on remote servers as though they are part of the local database. Very easy to setup (just call exec sp_addlinkedserver) and once defined uses nothing but plain old SQL
If you want to do in an event (like button click), I would suggest Linked Server. Click here for a simple tutorial about how to create a linked server. After creating linked server, we can query it as follows:
select * from LinkedServerName.DatabaseName.SchemaName.TableName

how can communicate two SQL database in LAN to save data in both database

We have a server with SQL database (8 database) working in LAN, Now we are planning to make a backup server connected through LAN.
What we need is, when user enter data it should save in both database, so that we have all the data in both database.
I am a newbie so pls give me some detail information. I have seen some replication option, is it better option for us.
We have SQL Server 2005.
Which database engine are you using?
There're several ways to build a distributed/replicated database, I'm sure you'll find out how to do it by reading your engine documentation, but we cannot help here without more info.
Yes, you can backup your database from one server to other by multiple way.. Following are those
1) Make script of complete database with schema and data..Technique is here
2) Export your database to excel file and import it to other server (Use only in required conditions).
3) communicate two server by addlink.. Technique here
Now if you want dump data in two different server then its depend on code logic written for dumping database and connection string provided for it. By adding Trigger to one server database you can dump data on different server or database.. Trigger

How to limit the number of connections to a SQL Server server from my tomcat deployed java application?

I have an application that is deployed on tomcat on server A and sends queries to a huge variety of SQL Server databases on an server B.
I am concerned that my application could overload this SQL Server database server and would like some way to preventing it making requests to connect to any database on that server if some arbitrary number of connections were already in existence and unclosed.
I am looking at using connection pooling but am under the impression that this will only pool connections to a specific database on the SQL Server server, I want to control the total of these combined connections that will occur to many different databases (incidentally I can only find out the names of individual db's dynamically as they change day to day). Will connection pooling take care of this for me, are am I looking at this from the wrong perspective?
I have no access to the configuration of the SQL Server server.
Links to tutorials or working examples of your suggested solution are most welcome!
Have you considered using DBCP? See here for more info
You're correct. A database pool will limit connections to either the database, or to all databases, depending on how the pool is configured.
Here are several open source packages that implement database connection pools. One of them probably does what you want.
connection pooling ... this will only pool connections to a specific database on the mssql server
AFAIK, this is correct. Your connection pool will only limit the number of connections to the specific database it is defined for.
want to control the total of these combined connections that will occur to many different databases
I dont think you can control the number of connections to all databases from the pool. You've written you don't have access to change things on the MSSQL server. so creating SYNONYMs to the various databases on MSSQL itself is not an option.
You can write your own class within the application, say a ConnPoolManager, which has an internal counter prior to getting and releasing Connections from any of the pools.
This class should cache all the JNDI lookups to each pool.
For the app to get a connection to ANY pool, it goes through the ConnPoolManager and if the counter shows the maxlimit is not yet crossed, only then does it fetch the connection.
Else it throws some exception for you to try later.
There might be a design pattern for this on the lines of Business Delegate.
Having said that, I think a bigger problem for you will be
incidentally I can only find out the names of individual db's dynamically as they change day to day
since you will be expected to create new or edit the connection pool settings in Tomcat each day? This is a maintenance nightmare in the future.