dbconnection

ASP .NET Application_Start Event + Connection to a DB

跟風遠走 提交于 2019-12-12 04:46:02
问题 I have started developing a full-web application by using the ASP .NET MVC 3 framework. I am a MVC 3 beginner developer. On the server-side I am going to execute some queries to a DB. Consequently I will have to make a connection to the DB. I would like to know if it is better to make a connection in the beginning of each action method or in an event handler. I have thought about making the connection in the Application_Start event handler and then storing an object representing my connection

Modify Logger's adoAppender.ConnectionString

自古美人都是妖i 提交于 2019-12-11 06:26:05
问题 I am using log4net. The problem is I create the connection string only after the application is started based on the connection string in the config file. This means the config file does not have a proper connection string yet. I am able to modify the connection string of the appender using this code.. IAppender[] appenders = log.Logger.Repository.GetAppenders(); foreach(IAppender appender in appenders) { AdoNetAppender adoAppender = appender as AdoNetAppender; if (adoAppender != null) {

SSMA for Oracle “Connect to Oracle” error

北城以北 提交于 2019-12-11 06:24:37
问题 i tried to connect to Oracle using Sql server migration assistant for oracle(SSMA for oracle). and specified parameters like this provider: Oracle Client Provider mode: standard mode and connection info(servername, port ...) but i got a error message "Unable to find specified provider. Compatible Oracle Data Access Connectivity libraries were not found on the machine. You can install them from Oracle product media or download it from Oracle web site." so i installed Oracle Data Access

Properly disposing of a DbConnection

南笙酒味 提交于 2019-12-11 04:06:25
问题 I have a class called DatabaseHelper that wraps a DbConnection. What's the proper way to setup this class for a using statement? I have implemented IDisposible, but I'm not sure when and where I should be calling Connection.Close() or Connection.Dispose(). When I simply call Connection.Dispose() in my own Dispose() method, I'll sometimes get a SocketException from my DbConnection object. I assume this is because old connections are being left open, but there's no details attached the to

Multiple database connection Yii2 not working

旧时模样 提交于 2019-12-11 03:01:35
问题 Yii::setAlias('@tests', dirname(__DIR__) . '/tests'); $params = require(__DIR__ . '/params.php'); $db = require(__DIR__ . '/db.php'); $dbPusat = require(__DIR__ . '/dbPusat.php'); $dbPaperless = require(__DIR__ . '/dbPaperless.php'); return [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'gii'], 'controllerNamespace' => 'app\commands', 'modules' => [ 'gii' => 'yii\gii\Module', ], 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], 'log' => [

Executing a stored procedure using a DbConnection

China☆狼群 提交于 2019-12-10 19:06:54
问题 I need to execute a stored procedure on a database. This is what I got so far that works: protected DbProviderFactory dbProviderFactory; this.dbProviderFactory = DalFactory.GetFactory(this.adapterConfiguration); DbConnection dbConnection = dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = this.adapterConfiguration.DatabaseInformation.ExternalDatabaseInformation.connectionString; try { dbConnection.Open(); } catch (Exception e) { throw; } I suspect that DbCommand would do

Connecting to DB2 via .NET DbConnection

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 03:23:37
Our current DB Connection provider model relies on database connectivity to use DbConnection (System.Data) based objects. We can connect to DB2 (*Nix * Windows) via OdbcConnection, but we would like to allow the use of native DB2 Drivers. Is there any way to do so (either .Net framework, OpenSource or (last choice) vendor) without breaking away from our current DAL model? There is another method not mentioned in the article above, and that is to use DbNetData which simplifies database access and has the ability to connect to DB2 from .NET. The source is hosted on CodePlex below: DbNetData 来源:

ASP.NET: How to create a connection from a web.config ConnectionString?

倾然丶 夕夏残阳落幕 提交于 2019-12-04 18:44:16
问题 How do you construct a DbConnection based on a provider name ? Sample provider name s System.Data.SqlClient System.Data.OleDb System.Data.Odbc FirebirdSql.Data.FirebirdClient i have connection strings stored in my IIS server's web.config file: <connectionStrings> <add name="development" connectionString="Provider = IBMDA400; Data Source = MY_SYSTEM_NAME; User Id = myUsername; Password = myPassword;" providerName="System.Data.OleDb" /> <add name="live" connectionString="usd=sa;pwd=password

Couchbase Connection - External ip instead of internal

跟風遠走 提交于 2019-12-04 04:46:02
问题 In the same data center I have an application server (the client) connecting to a couchbase cluster containing 3 nodes. I would like the client to connect via the internal IP and not the external for optimized performance. Let's assume these are my IPs: node1InternalIP / node1ExternalIP node2InternalIP / node2ExternalIP node3InternalIP / node3ExternalIP When creating my couchbase client (java code) im providing my internal IPs but when the connection has been established I get these logs:

HikariCP auto reconnect

大城市里の小女人 提交于 2019-12-01 01:29:26
I use jpa+hibernate+hikariCP. Today I got connection closed error. I setted connectionTimeout and ideleTimeout properties(hikari). If in meantime use does not do any operition hikari close the pool connections auto. So that I got closed connection problem. My question how can I set properly hiker(jpa,hibernate) properties so if user comes back after 3-4 hours and try to do some operation hikari auto reconnect to db? is it possible? I use hikari v2.6.1 and hibernate v5.2.8.Final This should already be working. Are you holding the connection open during this time? By default HikariCP closes and