I'm developing an application for multi tenant purpose, for this, I've used Orchestral/Tenanti but I'm experiencing the following problem.
I already performed some of the required steps for Multi Database Connection Setup.
Configuration Tenant Driver for Multiple Database: on my tenanti.php
Setting Default Database Connection: on my Tenant.php Middleware
Definition of my Tenants Connection: on my config/database.php
The problem becomes on the Database Connection Resolver step. In my Middleware I'm defining the connection to be used (I don't post the code because is not relevant for Tenanti use) which is correctly setted.
My resolver code is:
public function boot()
{
Tenanti::connection('tenants', function (User $entity, array $template) {
$template['database'] = "db_{$entity->getKey()}";
return $template;
});
}
This code is located on my AppServiceProvider. But my database to be used, is not correctly setted from my Resolver, throwing the following error:
ErrorException in MySqlConnector.php line 110:
Undefined variable: database
Clearly the error means that database is no setted.
Someone can help? Thanks in advance.
After many tests, I didn't find the solution using Tenanti, instead of that, I used Config class to set the database to use, and maintained my tenants configuration on database.php.
Config::set('database.connections.tenants.database', 'legal_'.$request->route()->parameter('account'));
Config::set('database.default', 'tenants');
Related
I have written a java code of connecting to server mode
p.setProperty("server.database.3",
"file:G:/SERVERMODE/soamware;user=soamware;password=123#123");
p.setProperty("server.dbname.3", "soamware");
server.setProperties(p);
server.setLogWriter(null); // can use custom writer
server.setErrWriter(null); // can use custom writer
server.start();
try {
//Registering the HSQLDB JDBC driver
Class.forName("org.hsqldb.jdbc.JDBCDriver");
con = DriverManager.getConnection("jdbc:hsqldb:hsql://ip/soamware;
file:G:/SERVERMODE/soamware;user=soamware;password=123#123");
this code is working fine in netbeans with jdk8 and hsqldb2.5.1, however the console shows the build is not terminated and its still running. While when i connect to SwingDatabaseManager
with same url, username and password as mentioned in java code. It throws above mentioned exception. Kindly clarify also, why my program doesnt exit. I am not adding "server.shutdownCatalogs(1);" statement at end because then I cannot perform multiple operations in one session.
Because you are starting the server with only one database, you should set database.0 properties. You shouldn't use the # character at all on a connection string because it has a special meaning. You shouldn't use the file path when connecting to a server database. Use the dbname.0 value only. Edited code below:
p.setProperty("server.database.0", "file:G:/SERVERMODE/soamware;user=soamware;password=123x123");
p.setProperty("server.dbname.0", "soamware");
server.setProperties(p);
server.setLogWriter(null); // can use custom writer
server.setErrWriter(null); // can use custom writer
server.start();
try {
Class.forName("org.hsqldb.jdbc.JDBCDriver");
con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/soamware", "soamware", "123x123");
I am new to SSIS, here is the issue I am facing.
1) Created an OLEDB connection to connect to database. Storing the Connection String in SSIS variable and have added expression to Connection Manager to pick the connection string according to environment.
2) Have used Windows Authentication to connect to database, so that no need to provide user ID and Password. In development environment it worked perfectly fine. But when moved to testing environment, its failing with Error "SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "REGEDB" failed with error code 0xC0202009"
3) Using SQL Server Configuration to deploy the package. But getting error Failed to load at least one of the configuration entries for the package. Check configuration entries for "CBPSSIS" and previous warnings to see descriptions of which configuration failed.
Below is the Connection String
Data Source=abcd\ISQLQ02;Initial Catalog=DRIP;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;
COuld you please let me know how to set Password property? I tired in Script file but its not working. Thank you
ConnectionManager OldedbConn;
OldedbConn = Dts.Connections["QAREGE"]; Dts.Connections["QAREGE"].Properties["ServerName"].SetValue(OldedbConn, Dts.Variables["User::dbServerName"].Value); Dts.Connections["QAREGE"].Properties["InitialCatalog"].SetValue(OldedbConn, Dts.Variables["User::dbCatalog"].Value); Dts.Connections["QAREGE"].Properties["UserName"].SetValue(OldedbConn, Dts.Variables["User::dbUserID"].Value); Dts.Connections["QAREGE"].Properties["Password"].SetValue(OldedbConn, Dts.Variables["User::dbPwd"].Value);
Since you are using ssis-2008 you can create a ssis configFile with .dtsConfig format with xml configuration file type. Include all your Database connection string in the config file. So when you moved your ssis package to another server you just need to edit the config file and set your connection based on your target server.
So I basically do this.
OObjectDatabaseTx result = OObjectDatabasePool.global().acquire( "local:orientdb", "admin", "admin");
//dostuff
result.close;
The problem is that when I redeploy my webapp (without restarting the Java EE container) I get the folling error:
com.orientechnologies.orient.core.exception.OStorageException: Cannot open local storage 'orientdb' with mode=rw
which I interpret to mean "Tomcat still has a filelock from the last app".
So my question is how do I cleanly exit in this scenario? I've tried:
OObjectDatabasePool.global().close()
and
new OObjectDatabaseTx("local:orientdb").close()
but neither seem to work. Any ideas? The documentation isn't exactly clear on this issue.
Set the property "storage.keepOpen" to false:
java ... -Dstorage.keepOpen=false ...
or via Java code:
OGlobalConfiguration.STORAGE_KEEP_OPEN.setValue( false );
I am reading Grails in Action and it says to use
dataSource {
dbCreate = "update"
url = "jdbc:hsqldb:file:devDB;shutdown=true"
}
This causes an error when I run grails console: Unsupported connection setting "SHUTDOWN"
grails console works fine when I remove ;shutdown=true
What is shutdown=true meant to do?
This is described here: http://www.hsqldb.org/doc/guide/ch04.html
It's probably not useful for an in-memory database since it is lost when the web server stops anyway.
I don't know how to fix this...
URI dbURI = URI.create("file:///SDCard/Databases/MyDatabase.db");
Database database = DatabaseFactory.open(dbURI);
It created DB without any problem, throws exception while trying to open DB.
I figured it out. If I try to open a DB connection before closing the previous connection it throws this exception. So, after all DB operations I call database.close()
make new folder with application name in SDCard/Databases/ and put your database in it.
After that you have to just pass database name in URI.create().
I hope it will be helpful to your .:)