connection

What are the implications of opening MySQL connections over and over again in PHP

不羁的心 提交于 2020-01-02 06:14:08
问题 Specifically, I have a DB class that opens and closes multiple MySQL connections every time I call the Query function in the class. Should I open a connection once? or is it ok to open and close connections like this? 回答1: My simple-minded (ISAM, no transactions) C-language app runs for eight hours a day, updating multiple tables in one database over one single MySQL connection that stays open the whole time. It works just fine. Anytime there's any kind of MySQL error (not only server gone

Can I use datasource=.\\SQLEXPRESS or do I need to now use: machinename\\SQLEXPRESS

落花浮王杯 提交于 2020-01-02 06:07:17
问题 Can I still use datasource=.\SQLEXPRESS or do I need to change it to : machine_name\SQLEXPRESS for a local instance of SQL Server 2008 Express in C#? My connection string worked fine in SQL Express 2005, but with the same settings no longer works for 2008. 回答1: Assuming the instance name is indeed SQLEXPRESS , using .\SQLEXPRESS will work locally. Use the SQL Server Configuration Manager to find out the correct instance name. 回答2: What is the final purpose of the app as it more conventional

Xcode 8 beta simulator fails to run app after accidentally running Xcode8 simulator

一世执手 提交于 2020-01-02 01:08:12
问题 "Failed to initiate service connection to simulator" Tried to clean app, reinstall it, delete derived data, reset simulator settings, restart xCode. I've also heard other people solved problems with their simulators by recreating the simulator. I tried that as well. When I press create, I get the very same error message: "Error returned in reply: Connection invalid" 回答1: Even this occurs on Xcode 8.0 stable version. Got it solved by closing Xcode 7 and its simulator. It seems that when you

How do multiple clients connect simultaneously to one port, say 80, on a server? [duplicate]

旧街凉风 提交于 2020-01-01 18:21:30
问题 This question already has answers here : Does the port change when a server accepts a TCP connection? (3 answers) Closed last year . I understand the basics of how ports work. However, what I don't get is how multiple clients can simultaneously connect to say port 80. I know each client has a unique (for their machine) port. Does the server reply back from an available port to the client, and simply state the reply came from 80? How does this work? 回答1: First off, a "port" is just a number.

Sqlite + c#: Unable to open the database file

北战南征 提交于 2020-01-01 09:15:15
问题 private void SetConnection() { string a = string.Format(@"Data Source={0};Version=3;New=False;Compress=True;", "~/lodeDb.db"); sql_con = new SQLiteConnection(a); } private void ExecuteQuery(string txtQuery) { SetConnection(); sql_con.Open(); sql_cmd = sql_con.CreateCommand(); sql_cmd.CommandText = txtQuery; sql_cmd.ExecuteNonQuery(); sql_con.Close(); } When i run to sql_cmd.ExecuteNonQuery, Sqlexception is "Unable to open the database file". "lodeDb.db" file on my online hosting, i think data

Connect Websocket with Poco libraries

荒凉一梦 提交于 2020-01-01 06:11:09
问题 I am trying to connect to the Echo Test Websocket using the Poco C++ libraries. In order to do so here is my code which should set up the Websocket: HTTPClientSession cs("echo.websocket.org"); HTTPRequest request(HTTPRequest::HTTP_GET, "/ws"); HTTPResponse response; WebSocket* m_psock = new WebSocket(cs, request, response); m_psock->close(); //close immidiately However it does not work: I am getting an error message like this: Poco::Exception: WebSocket Exception: Cannot upgrade to WebSocket

Postgres not allowing localhost but works with 127.0.0.1

吃可爱长大的小学妹 提交于 2020-01-01 04:21:05
问题 Postgres not accepting connection if I say -h localhost but it works if I say -h 127.0.0.1 [root@5d9ca0effd7f opensips]# psql -U postgres -h localhost -W Password for user postgres: psql: FATAL: Ident authentication failed for user "postgres" [root@5d9ca0effd7f opensips]# psql -U postgres -h 127.0.0.1 -W Password for user postgres: psql (8.4.20) Type "help" for help. postgres=# My /var/lib/pgsql/data/pg_hba.conf # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket

How to send data from service to activity?

拥有回忆 提交于 2019-12-31 04:07:28
问题 I'm beginner in Android development. I try to create kind of MusicPlayer, which uses Service for playing music. When I click buttons in MainActivity, I call startService with Intent, which includes signal for action, such as play, pause, stop, etc... But I want to send data back from service to activity. For example, when current track has stopped and begin to play the next one, MainActivity got to receive track name and author name. Or when last track in the playlist is stopped, button

Are resources used by a Java application freed when it terminates?

送分小仙女□ 提交于 2019-12-31 02:40:27
问题 Java applications may use IO streams, sockets or database connections that should be closed when they are no longer needed. However, applications may be terminated (e.g. by killing the process). Will all used resources be freed in this case? Who will free them: OS or JRE? 回答1: If your software doesn't take care of resource management properly, the following will happen: at runtime: the JVM will attempt during the duration of your program to close open streams if they're are seemingly unused

SqlTransaction after catch transaction connection is null

怎甘沉沦 提交于 2019-12-31 00:58:30
问题 I have a loop where I call stored procedure with different parameter value. Next call cmd.ExecuteNonQuery(); I use transaction to save all or rollback, and checkBox2 - save always. I found one problem and I can't find solution. After first problem when catch block is fired transaction object loses its connection. t.connection is null! Everything is good but transaction object is without connection at start it has! try { while (!sr.EndOfStream) { strLine.Remove(0, strLine.Length); //c = sr