connection

php db class with mysqli, which support multiple connections

99封情书 提交于 2019-12-06 05:47:12
The thing is that I need to write a db class with mysqli and it should support multiple connections to different databases. I know that multiple connections is bad, but I don't have any other choice. If there is any good example of class which supports multiple connections? Do you know any tips that I should take into consideration when I will start writing the class? What is the best practice in my case? Thanks in advance, First thing that comes to mind, is a container class, that stores MySQLi object in it. Something like this: class MySQLiContainer extends SplObjectStorage{ public function

Data connection enable/disable code crashes inside a android service

梦想的初衷 提交于 2019-12-06 05:27:10
void turnData(boolean ON) { final ConnectivityManager conman = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); final Class conmanClass = Class.forName(conman.getClass().getName()); final Field iConnectivityManagerField = conmanClass.getDeclaredField("mService"); iConnectivityManagerField.setAccessible(true); final Object iConnectivityManager = iConnectivityManagerField.get(conman); final Class iConnectivityManagerClass = Class.forName(iConnectivityManager.getClass().getName()); final Method setMobileDataEnabledMethod = iConnectivityManagerClass

Refresh a connection in Excel to SQL Server (with password) using VBA

南笙酒味 提交于 2019-12-06 05:23:45
I have 10 Excel files that are connected to a SQL Server by OLEDB and I need to refresh them everyday one by one manually. When I refresh them I need to insert a password. I tried to make a macro to automate this process, but I didn't succeed. I did this function to automate one of my workbooks: Sub updateABC() Workbooks("Teste").Connections("SQL Server_Azure1").OLEDBConnection.Refresh End Sub And the Excel ask for the password to SQL Server logon. Is there any way to put this password automatically using vba? Thanks. King_nothing6 There is a way in Excel without VBA: You can go to Data then

iOS to Mac OS X [core] bluetooth data transfer

萝らか妹 提交于 2019-12-06 05:11:07
问题 My objective here is to create a connection between a device running iOS to a device running Mac OS X , via bluetooth. I know that I might be able to use CoreBluetooth for this but I don't understand how since I don't see a method to setup a service on the iOS device and broadcast it as an available service for a device running Mac OS X . In other words, I simply want to setup a connection to get the iOS device to send data to the Mac OS X device . Also, how would I go about to specify how to

Java outgoing TCP connection failover based on multiple DNS results

为君一笑 提交于 2019-12-06 04:34:55
问题 If I make a connection using new Socket("unit.domain.com", 100) and the unit.domain.com DNS record has multiple IP addresses in the A record.. In the event of a failed connection, Does Java automatically connect to one of the other addresses in the list like the browser does? or does that have to be implemented manually? 回答1: No! Creating a socket via new Socket(String, int) results in a resolving like that addr = InetAddress.getByName(hostname); which is a shortcut for return InetAddress

Arduino Ethernet Shield Not Connecting to WebServer

大兔子大兔子 提交于 2019-12-06 04:24:25
问题 I have a problem making my Arduino Ethernet shield to communicate with the server, the result on the serial monitor is always: my arduino code is #include <Ethernet.h> //library for ethernet functions #include <SPI.h> #include <Dns.h> #include <Client.h> //library for client functions #include <DallasTemperature.h> //library for temperature sensors // Ethernet settings byte mac[] = {0x09,0xA2,0xDA,0x00,0x01,0x26}; //Replace with your Ethernet shield MAC byte ip[] = { 192,168,0,54}; //The

Proper way to test if server is up in Java?

丶灬走出姿态 提交于 2019-12-06 03:18:06
What would be the proper way to simply see if a connection to a website/server can be made? I want this for an application I am coding that will just alert me if my website goes offline. Thanks! You can use an HttpURLConnection to send a request and check the response body for text that is unique to that page (rather than just checking to see if there's a response at all, just in case an error or maintenance page or something is being served). Apache Commons has a library that removes a lot of the boiler plate of making Http requests in Java. I've never done anything like this specifically on

How to keep the connection pool from closing with a java driver on a mongodb?

自古美人都是妖i 提交于 2019-12-06 03:17:33
问题 I'm in the middle of upgrading from java driver 2.12.3 to 3.3.0. Curiously it seems that the collection pool is suddenly "acting up". My set up is as follows: The Connection is established in the main thread: mongoClient = new MongoClient(new MongoClientURI("mongodb://localhost:27017")); mongoClient.setWriteConcern(new WriteConcern(0, 10)); // deprecated, replace soon database = mongoClient.getDatabase("Example"); // java.util.logging.Logger.getLogger("org.mongodb.driver").setLevel(Level

Mysql2: close client connection

倖福魔咒の 提交于 2019-12-06 02:40:47
问题 I am using Mysql2 to query a database on ruby . I initialize the connection by: client = Mysql2::Client.new(:host => "localhost", :database => 'mydb', :username => "root") Once the query is done successfully, how can I close the client connection? If I do not close it, I soon reach the maximum number of possible open connections. Solution Thanks to @joonty: client.close 回答1: Use client.close . From the docs: Mysql2::Client#close Immediately disconnect from the server, normally the garbage

How to make the HTTP connection timeout/disconnected after a time interval?

∥☆過路亽.° 提交于 2019-12-06 01:33:27
I am new in Apache HttpClient , I used the following code to get the HTTP connection timeout (disconnected) after certain time interval: PostMethod method = new PostMethod(authURL); HttpClient client = new HttpClient(); HttpClientParams params= new HttpClientParams(); params.setParameter(params.CONNECTION_MANAGER_TIMEOUT, 10); //10 Nano second client.executeMethod(method); but it wait for more than one minute without any hope to timeout/disconnect? Where can the problem be? ZZ Coder There are 2 timeouts involved in HTTPClient, try to set both, client.getHttpConnectionManager(). getParams()