connection

Java app handling for connections getting dropped

十年热恋 提交于 2019-12-08 03:17:16
问题 My app seems to be hanging overnight because of the connection getting dropped(I think that's the problem.) How can I structure my app so that it can try to roll up a new connection? Since the incident I have updated the getConnection() method that my app uses as so: private Connection getConnection() { boolean failed = false; try{ failed = !connection.isValid(1000); }catch(SQLException ex){ System.out.println("WARNING: Connection not valid!"); } try{ failed = connection.isClosed(); }catch

Each request from user call a new getConnection()?

拈花ヽ惹草 提交于 2019-12-08 02:13:16
问题 The database connection is get like below public Connection getDBConection(){ Context context = new InitialContext(); DataSource dataSource = (javax.sql.DataSource) context.lookup("java:myDataSource"); Connection conn = dataSource.getConnection(); } For a userA, is each database request should call getDBConnection() once; but no need to control all request use the same connection? That is, if userA has three database request, then userA should call getDBConnection() three times, and call

Using Javascript to connect SQL Server database

我们两清 提交于 2019-12-07 21:07:40
问题 I need to use Javascript to read some data from SQl Server 2008 Database. So I wrote this:(html page code) <!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Database Connect</title> <script type="text/javascript"> function loadDB(){ var connection = new ActiveXObject("ADODB.Connection"); var connectionstring="Data

MySQL: Single or Multiple Connections?

空扰寡人 提交于 2019-12-07 18:56:31
I am developing a server application, which uses mysql for some data storing. Should I create a connection to the mysql on the server's start and use it for all queries, or create connection on each query? Which is better/faster? If you ask me, It's better to use only one connection, that way you can use session variables without any issues. Besides, with static variables, it's easy to permanently save the connection somewhere in the script. 来源: https://stackoverflow.com/questions/19345485/mysql-single-or-multiple-connections

GlassFish not loading connector

前提是你 提交于 2019-12-07 18:28:02
问题 I'm using GlassFish 3 and I can't seem to get it to recognize the MySql connector. The admin console always says: Ping Connection Pool for --- is Failed. Ping failed Exception - Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource Please check the server.log for more details. However, JPA can connect even with the error. The only downside is that I get resize pool exceptions (null). I've even placed the connector in the following folders: %GLASSFISH%

MySQL connection character set problems

安稳与你 提交于 2019-12-07 17:58:31
问题 I'm using velosurf with MySQL on a Mac, without any encoding problems, but when I switch to a Linux machine, the values I get from velosurf are not encoded correctly. I found out it might be a problem with the default connection character set. On the Mac I got: mysql> show variables like "collation_%"; +----------------------+-------------------+ | Variable_name | Value | +----------------------+-------------------+ | collation_connection | utf8_general_ci | | collation_database | utf8

Maximum number of TCP connections in Python?

烂漫一生 提交于 2019-12-07 17:58:29
问题 I am working in Python on localhost. I wrote a raw server just read TCP socket, say in port 50001. Then I tried max client connections: def rawMultiConn(threadnum = 10000): g_event = threading.Event() def threadfn(): sockets = [socket.socket(socket.AF_INET, socket.SOCK_STREAM) for i in range(threadnum)] for s in sockets: s.connect(('localhost', SERVER_PORT)) g_event.wait() for s in sockets: s.close() t = threading.Thread(target = threadfn) t.start() g_event.set() t.join() but after about 3000

thrift: changing from tSimpleServer to TNonblockingServer

天涯浪子 提交于 2019-12-07 17:18:49
问题 I have a simple thrift server: shared_ptr<TProcessor> processor(new MyProcessor(handlerTrace)); shared_ptr<TServerTransport> serverTransport(new TServerSocket(port)); shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); and able to connect with the following lines: boost::shared_ptr<TSocket> socket(new

How many concurrent connection does IE9 have while in IE7 mode

十年热恋 提交于 2019-12-07 17:03:55
问题 Does anyone know how many concurrent connections IE 9 allows while in other browser modes? Since I'm asking, how concurrent connections do all IE browsers and other the top browsers have? Actually having issues in Chrome, i think its a concurrency problem, someone suggested that it should happen in IE& as well, but i do not have IE7 installed. I did try it in IE9 set to IE7 browser mode, and it worked. SO was wondering if IE7 mode was using IE9's concurrent connection? 回答1: IE8 and IE9 have 6

Proper way to test if server is up in Java?

心不动则不痛 提交于 2019-12-07 16:48:04
问题 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! 回答1: 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