w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Confused about default string comparison option in SQL Server
As you have discovered, upper and lower are only of use in comparisons when you have a case-sensitive collation applied, but that doesn't make them useless. For example, Upper and Lower can be used for formatting results. select upper(LicencePlate) from cars You can apply collations without reinstalling, by applying to a column in the table design, or to specific comparisons ie: if 'a' = 'A' collate latin1_general_cs_as select '1' else select '2' if 'a' = 'A' collate latin1_general_ci_as select '3' else select '4' See http://technet.microsoft.com/en-us/library/aa258272(v=sql.80).aspx

Categories : Sql Server

When should SQL server connection be closed in a script?
You don't have to do them at all. After header('Location... you should use exit immediately. Open connections are closed when the script exits automatically. You could manually close them and use exit after that, though. You only need to worry about manually closing the connections if you're running out of connections during long-running scripts, but you may have other problems at that point.

Categories : PHP

.NET SQL Server connection being prematurely closed
The simplest thing to do would be to check the connection state and open it if necessary: if(conn.State == ConnectionState.Closed)//Can't quite remember the exact syntax { conn.Open(); } //do DB stuff here.

Categories : Sql Server

TCP server socket is closed if i switched to another app
In android, the decision whether to keep your app running or not depends a lot on the existence of a Context whether it is an Activity, Service or BroadcastReceiver. According to android's documentation: An empty process is one hosting no activities or other application components (such as Service or BroadcastReceiver classes). These are killed very quickly by the system as memory becomes low. For this reason, any background operation you do outside of an activity must be executed in the context of an activity BroadcastReceiver or Service to ensure that the system knows it needs to keep your process around. So what do you want to do is starting a service once your activity is started and from that service spawn a thread that will manage the TCP server. that way you will be fine as l

Categories : Java

application crashes if the server is closed due to timeout. How can I catch it?
Please try the following public String getData(String url) { HttpClient httpclient = new DefaultHttpClient(SetHttpParams.setHttp( 50000, 50000)); HttpGet httpget = new HttpGet(url); HttpResponse response; try { response = httpclient.execute(httpget); if (response.getStatusLine().getStatusCode() == 200) { org.apache.http.HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); String res = Functions.convertStreamToString(instream); } } } catch (ConnectTimeoutException e) { } catch (SocketTimeoutException e) { } catch (IOException ex) { } } String res is your string where the response will be stored

Categories : Android

SQL Server session stays open when application is closed
Entity framework uses the underlying SQL Server ADO.NET provider which pools database connections as they are an expensive operation to create and flush each time. You can flush the connection pool using a SqlConnection.ClearPool method call on your Application_End event handler. Note: I would not recommend disabling or flushing the connection pool for production code. An alternate method for development can be to modify to disable pooling via you connection string using the Pooling=false option.

Categories : C#

determine if client has closed connection to server using socket
Here is some code I believe can be used to detect exiting socket... Originator of this code was stated as Andrew Gillard no other licence information was available... <?php $host = '127.0.0.1'; $port = 7010; gc_enable(); set_time_limit(0); function socketError($errorFunction, $die=false) { $errMsg = socket_strerror(socket_last_error()); echo $errorFunction.' '.$errMsg." "; if ($die) die("Program Ended "); } //Attempt to create our socket. The "@" hides PHP's standard error reporting, if (!($server = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) socketError('socket_create', true); //socket_set_option($server, SOL_SOCKET, SO_REUSEADDR, 1); if (!@socket_bind($server, $host, $port)) socketError('socket_bind', true); if (!@socket_listen($server)) socketError('socket_list

Categories : PHP

Fatal: Server unexpectedly closed network connection
The command is working fine for me. However, your question suggests that you're trying to connect to an FTP server. WinSCP can handle both SCP/SFTP and FTP connections, but to my knowledge psftp supports only SFTP (a file transfer protocol based on SSH, not to be confused with FTPS). If your server is not an SSH server, you need an FTP client for the data transfer (e.g. ftp.exe shipped with Windows). If your server is an SSH server, try running psftp with the option -v to get more information, and also check the logs on the server.

Categories : Powershell

Server dies on `send` if client was closed with Ctrl+c
When you call send() on an already closed connection, the operating system may issue SIGPIPE to your process. Usually the default handler for SIGPIPE is to kill your process. In order to prevent this from occurring, you can either ignore the signal (e.g., with signal(SIGPIPE, SIG_IGN) or sigignore(SIGPIPE)), or you can pass the MSG_NOSIGNAL option to send(): int send_result = send(newfd, ok, 3, MSG_NOSIGNAL); if (send_result >= 0) { /* okay, but check if all your data got sent! */ if (send_result < 3) /* ...do something */; } else { switch (errno) { /* ... */ case EPIPE: /* sending on a closed connection... */ } } Now, instead of issuing SIGPIPE, the send() call will fail, and errno will be set to EPIPE.

Categories : C

Run a python socket server and if closed remotely start it listening again
The way you usually program a threaded socket server is: call accept() in a loop spawn a new thread to handle the new connection A very minimal example would be somethig like this: import socket import threading import time server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind(('0.0.0.0', 9999)) server.listen(1) def handle(conn): conn.send(b'hello') time.sleep(1) # do some "heavy" work conn.close() while True: print('listening...') conn, addr = server.accept() print('handling connection from %s' % (addr,)) threading.Thread(target=handle, args=(conn,)).start() You're spawning new threads in which you create your listening socket, then accept and handle your connection. And while socketIsOpen is True your programm will be using a lot of

Categories : Python

Catch the exception thrown at client side when the server closed the pipe
the most common way to know that the other side is dead is the "echo": once in a while(let's say every 10 seconds) the client sends an "echo" - meaning a simple request to the server to get replay. if 3 echo in a row(could be more, depend on you) did not answered by the server, the client decide that the server is down and disconnect his side

Categories : C#

Client prints Half Data Before Connection is Closed By Server on Socket
try flush data after sent. it needs if you use socket with fdopen FILE *fdsock = fdopen(sock, "a+"); ... fwrite(fdsock, 1, 1 "A"); fflush(fdsock); ... fclose(fdsock); and to finish socket, close with shutdown(sock, SD_SEND); UPDATE Take memset out of loop

Categories : C

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

Confused about SQL Server trigger that does an UPDATE (strange UPDATE statement format)
I'm not sure if you are aware of the fact that Inserted or Deleted in the above mentioned queries are not alias but special tables used by the SQL server to track insertion, update or deletion of data within triggers. Here is more information: http://msdn.microsoft.com/en-us/library/ms191300.aspx

Categories : Sql Server

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

How to draw closed spline 3D (closed curve 3d) through unordered list of points3D. How to arrange points3D?
It sounds like you're looking for the Concave Hull of the data set. Unfortunately, I don't know of any pre-canned algorithms, but the link references a paper that another developer was starting from, as well as some sample code, so maybe that'll help you in the right direction.

Categories : C#

Heroku and NodeJs - MySql Connection lost: The server closed the connection
You already seem to know what is happening; the MySQL server is closing the connection. Many database services, including ClearDB, to do this (ie, close inactive connections). You're going to have to detect the disconnect event, and recreate the connection. There are instructions in the node-mysql documentation for doing this.

Categories : Mysql

Node.js + setInterval = Connection lost: The server closed the connection
Looks like you're keeping an open connection to a remote MySQL server. The remote server is closing the connection after 8 hours of idle connection. So you have two options. Either you send a keepalive request or you disconnect after your initial request and then open the connection again when timer initiates the next event. Keepalive If you want to send a keepalive request, simply setup a select 1 on an interval timer. select 1 is just a simple query that will cause MySQL to return a result of 1 and reset the MySQL server's connection timeout. It would look something like this. function keepalive() { connection.query('select 1', [], function(err, result) { if(err) return console.log(err); // Successul keepalive }); } setInterval(keepalive, 1000*60*5); Pooling Howeve

Categories : Javascript

The underlying connection was closed: The connection was closed unexpectedly wcf service
The first thing i will do is, instead of returning the full list of candidates i will return an empty list. If that works fine, then it is very clear that the size of the data is a problem. To modify the size play with your binding parameters.

Categories : Wcf

"The underlying connection was closed: The connection was closed unexpectedly"
The first request does not utilize a header that indicates the length of the result. It closes the connection when it finishes. The second request utilizes the length header, reads the designated number of bytes, then closes the connection gracefully. (under the client side control instead of server driven disconnection) -or- The url you sent caused an error on the server. Is there an error in the server log or event viewer?

Categories : C#

Confused about DBus
This sounds like you should write an isolated D-Bus service to act as a datastore, and communicate synchronously with it in your scripts to write and read values. You can use shelve to persist the values between service invocations. In the tutorial, the "Making method calls" section covers synchronous calls, and "Exporting objects" covers writing most of the D-Bus service.

Categories : Python

Confused about arrayList
check out this Question The component type of an array object may not be a type variable or a parameterized type, unless it is an (unbounded) wildcard type.You can declare array types whose element type is a type variable or a parameterized type, but not array objects.

Categories : Java

got confused with 'this' in one form in js
onFocus="getExpression(this.form);" , what does this represent here? this here is your input <INPUT TYPE=text NAME="entry"/> onFocus="this.blur();" this here is your input <INPUT TYPE=text NAME="results"/>

Categories : Javascript

Confused about NFC tag size
Look at this. Write Tag This is my NFC library. You can use this, if you need. :) NFC Wrapper

Categories : Android

iOS: DequeTableViewCell..a little bit confused
It says clearly in documentation dequeueReusableCellWithIdentifier:forIndexPath: For performance reasons, a table view's data source should generally reuse UITableViewCell objects when it assigns cells to rows in its tableView:cellForRowAtIndexPath: method. A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse. Call this method from your data source object when asked to provide a new cell for the table view. This method dequeues an existing cell if one is available or creates a new one based on the class or nib file you previously registered. . dequeueReusableCellWithIdentifier: Return Value : A UITableViewCell object with the associated identifier or nil if no such object exists in the reusable-cell

Categories : IOS

Confused about unistd_XX.h
So, the right way is using unistd.h for x64 and/or unistd_32.h for x86 and ia32. Those files are in the headers of your linux distro. but keep in mind that the path changes between distros (and even between kernels), so the best way to find out where exactly those files are is: uni_hack.h #if defined(CONFIG_X86) <---- replace with whatever you want, #ifdef CONFIG_IA32_EMULATION for example # include <asm/unistd_32.h> #endif - Kbuild file obj-m += kernel_module_example.o $(obj)/kernel_module_example.o: $(obj)/real_unistd.h $(obj)/real_unistd.h: $(src)/uni_hack.h FORCE cpp $(c_flags) -E -dM <$< >$@ <---- this will generate "real_unistd.h" in the directory of your kernel module, and it will contain the content of unistd_32.h Using the unistd.h for x64 is

Categories : C

Confused by calculation
8.3333333333e-4 is the same as 0.00083333. It equates to: 8.3333333333 * 10^-4 = 8.3333333333 times ( ten to the power of -4 ) = 8.3333333333 * 0.0001 = 0.00083333333 N.b. After rounding The e stands for exponent and the relevant Wikipedia article is http://en.wikipedia.org/wiki/Exponentiation

Categories : C#

I'm confused with C libraries
For the first question, glibc follows both standard C and POSIX, from About glibc The GNU C Library is primarily designed to be a portable and high performance C library. It follows all relevant standards including ISO C11 and POSIX.1-2008. It is also internationalized and has one of the most complete internationalization interfaces known. For the second question, yes, you can compile Linux using gcc. Even gcc itself can be compiled using gcc, it's called bootstrapping.

Categories : C

Confused over the JNDI
Think about that when you are trying to access a file under d:/users/name/text.txt you just type its name and you access its contents. JNDI works at same concept, you go there with a name JNDI handles what you want.

Categories : Java

Utterly confused by Ajax
In your code, it should be type:'POST' or type:"POST", not type:POST. The official explanation page is actually quite good: http://api.jquery.com/jQuery.ajax/ Just grab some of the sample code from there.

Categories : Ajax

Little confused with import python
Interesting question. As you know, in PHP, you can separate your code by using include, which literally takes all the code in the included file and puts it wherever you called include. This is convenient for writing web applications because you can easily divide a page into parts (such as header, navigation, footer, etc). Python, on the other hand, is used for way more than just web applications. To reuse code, you must rely on functions or good old object-oriented programming. PHP also has functions and object-oriented programming FYI. You write functions and classes in a file and import it in another file. This lets you access the functions or use the classes you defined in the other file. Lets say you have a function called foo in file file1.py. From file2.py, you can write import

Categories : Python

Spring bean getting confused
The behavior is expected, this is because you have two beans with the exact same name info and the one defined later(in A) is the one which gets created at runtime. The behavior is same as what would have happened with the beans defined using xml. How this happens is best explained by understanding the internals of Spring @Configuration which is explained with the Spring documentation here - http://static.springsource.org/spring-framework/docs/3.2.3.RELEASE/spring-framework-reference/html/beans.html#beans-java-further-information-java-config. In short, even if you call info() method directly in AConfig, it is not actually invoking the method on the real AConfig instance, instead it is invoked on a proxy, which has the logic to make sure that the correct bean instance is returned.

Categories : Java

Confused about data types in COM, VFP and C#
First of all, CLSCompliant attribute doesn't have anything to do with COM. It's for Common Language Runtime compliance. OLE Automation specification lists the types which are automation-compatible. Your C# class, if compiled as 32-bit assembly and registered with RegAsm, exposes the following COM interface: [ odl, uuid(AFA13243-F593-3B28-A4D3-4E4138AA1F22), hidden, dual, nonextensible, oleautomation, custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "SampleNSpace.AnyClass") ] interface _AnyClass : IDispatch { [id(00000000), propget, custom(54FC8F55-38DE-4703-9C4E-250351302B1C, 1)] HRESULT ToString([out, retval] BSTR* pRetVal); [id(0x60020001)] HRESULT Equals( [in] VARIANT obj, [out, retval] VARIANT_BOOL* pRetVal);

Categories : C#

Confused by "...extends Function1[Int, Int]"
It's return type. Function1[Int, Int] is the same as Int => Int. It takes one Int and returns one Int. We can write simplified scala.Function1 like this: trait Function1[T1, R]{ def apply(v1: T1): R }

Categories : Scala

Confused about the third normal form
If you want to strictly hold to the normalization and it's normal forms, you would have to start with 1NF. You might create separate tables for Make,Model,Owner and rename current one into Car. Then you can add foreign keys respectively. To uphold 2NF you can wonder to grab the year attribute from the VIN, which it contains as a model year number (does not necessarily have to be the same as the actual year of making). 3NF states that table columns should contain only columns that are fully dependent upon primary key, which would've been ok now.

Categories : Entity Framework

Undefined variable using PDO - confused
You only define $user_data if the user is logged in. You need to make sure that $user_data exists before you try to access it. if (!empty($user_data) && $user_data['moderator'] == 1)

Categories : PHP

Confused with the Output of the query
SELECT emp.emp_id,mast.name FROM empmtg emp left JOIN users mast ON emp.emp_id=mast.id WHERE emp.emp_mtg = 141; here a working demo

Categories : Mysql

A bit confused with blitting (Pygame)
Blit means 'BL'ock 'I'mage 'T'ranfser When you are displaying things on the screen you will, in some way, use screen because that's where you are putting it. When you do: pygame.draw.circle(screen, (0, 0, 0), (100, 100), 15, 1) you are still using screen but you are just not blitting because pygame is drawing it for you. And when you use text, pygame renders it into an image then you have to blit it. So basically you blit images, but you can also have pygame draw them for you. But remember when you blit an image, say over a background, you need to loop it back and fourth; so that it blits the background, then the image, then the background etc... You dont need to know much more than that, but you can read all about it here Pygame Blit I hope this helped. Good Luck!

Categories : Python

asp.net entity framework confused
You have one-to-many relationship between UserProfile and Roles. So each Role is associated with one user and therefore UserProfile_ID is stored in Roles table. To build many-to-many relationship you must do: Specify in class UserProfile that it have many Roles - done by you Specify in class Role that it have many UserProfiles: [Table("webpages_Roles")] public class Roles { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int RoleId { get; set; } public string RoleName { get; set; } public string Description { get; set; } public ICollection<UserProfile> Users { get; set; } } Yeah, that's all. Now EF will generate third table named UserProfileRoles and will make hidden one-to-many relationships between UserProfile and UserProfil

Categories : Asp Net

A little confused about access count
Will the loginTimeMap slow the server if the size of the map exceed 10000? A HashMap has a time complexity of O(1). That is, it hashes, then goes straight to the value. It does not search for the value. That means that it's performance is not proportional to the amount of elements in the array, although with 10,000 entries it might be somewhat memory heavy!

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.