Re: Connection problem after long idle periods

2006-02-09 Thread Michael Lai

David Logan wrote:


Michael Lai wrote:

I am currently using MySQL 5.0.15 with mysql-connector-java-3.1.11.  
I can access the database from my JSPs with no problem except for one 
small issue.  After a long delay (usually overnight), when someone 
first tries to access the database, I would get the following error:


Communications link failure due to underlying exception: ** BEGIN 
NESTED EXCEPTION ** java.net.SocketException MESSAGE: Broken pipe 
STACKTRACE: java.net.SocketException: Broken pipe at 
java.net.SocketOutputStream.socketWrite0(Native Method) at 
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) 
at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at 
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) 
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) 
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2690) at 
com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2619) at 
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1552) at 
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666) at 
com.mysql.jdbc.Connection.execSQL(Connection.java:2978) at 
com.mysql.jdbc.Connection.execSQL(Connection.java:2902) at 
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:933) 
at 
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027) 
at 
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92) 
at 
org.apache.jsp.processLogin_jsp._jspService(org.apache.jsp.processLogin_jsp:81) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) 
at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) 
at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 
at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) 
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) 
at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 
at 
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) 
at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) 
at java.lang.Thread.run(Thread.java:595) ** END NESTED EXCEPTION ** 
Last packet sent to the server was 0 ms ago.


But afterwards, on the second and subsequent attempts, the database 
runs fine.  It is only the first try after a long idle period that I 
get this error message.  I am not sure how to fix this.  I am 
guessing that the database connection is down after a long idle 
period and have to recreate a connection first after the first try.



Hi Michael,

Try looking at
http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html more
specifically the connect-timeout variable. You should use SHOW VARIABLES
LIKE %connect%; and check the value.

It maybe this and you can stretch it out further if you need to.

Regards



I tried lengthening the connection timeout but it doesn't seem to be 
working.  Here is my ROOT.xml configuration:


Context path= docBase=/home/tomcat/applications/ debug=0 
reloadable=true 

   Resource name=jdbc/ type=javax.sql.DataSource
 auth=Container driverClassName=com.mysql.jdbc.Driver
 url=jdbc:mysql://localhost/hostname?autoReconnect=true
 username= password=
 maxActive=8 maxIdle=-1 maxWait=1 /
/Context

Is there any way to keep a connection alive indefinitely?  I thought the 
autoReconnect would do the trick.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Connection problem after long idle periods

2006-01-31 Thread Michael Lai
I am currently using MySQL 5.0.15 with mysql-connector-java-3.1.11.  I 
can access the database from my JSPs with no problem except for one 
small issue.  After a long delay (usually overnight), when someone first 
tries to access the database, I would get the following error:


Communications link failure due to underlying exception: ** BEGIN NESTED 
EXCEPTION ** java.net.SocketException MESSAGE: Broken pipe STACKTRACE: 
java.net.SocketException: Broken pipe at 
java.net.SocketOutputStream.socketWrite0(Native Method) at 
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at 
java.net.SocketOutputStream.write(SocketOutputStream.java:136) at 
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) 
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) at 
com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2690) at 
com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2619) at 
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1552) at 
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666) at 
com.mysql.jdbc.Connection.execSQL(Connection.java:2978) at 
com.mysql.jdbc.Connection.execSQL(Connection.java:2902) at 
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:933) 
at 
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027) 
at 
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92) 
at 
org.apache.jsp.processLogin_jsp._jspService(org.apache.jsp.processLogin_jsp:81) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) 
at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) 
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) 
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) 
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) 
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) 
at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) 
at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) 
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) 
at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 
at 
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) 
at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) 
at java.lang.Thread.run(Thread.java:595) ** END NESTED EXCEPTION ** Last 
packet sent to the server was 0 ms ago.


But afterwards, on the second and subsequent attempts, the database runs 
fine.  It is only the first try after a long idle period that I get this 
error message.  I am not sure how to fix this.  I am guessing that the 
database connection is down after a long idle period and have to 
recreate a connection first after the first try.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: images with mysql

2003-03-20 Thread Lai Liu-yuan
I am now having a database storing images of chinese characters for research purpose. 
I wrote a program to store and retrieve them. My images are of type ppm. This is how I 
designed my table:

mysql describe poor;
+++--+-+-+---+
| Field  | Type   | Null | Key | Default | Extra |
+++--+-+-+---+
| cc | char(2) binary |  | | |   |
| width  | int(1) | YES  | | NULL|   |
| height | int(1) | YES  | | NULL|   |
| data   | blob   | YES  | | NULL|   |
+++--+-+-+---+

Just have to be really careful in storing binary data. Hope this help.

On Thu, 20 Mar 2003 10:34:19 +0100
[EMAIL PROTECTED] wrote:

 Hi!
 
 I have a problem with my MySQL
 
 I need to have some a images related with an item
 
 for example
 
 --
 ! author ! date of birth an death ! image!
 --
 
 How can I define the field for the images? I have read that LONGBLOB
 could be useful for large objct like images, but I can't understand how
 to set it in my database...
 
 Thank you in advance
 
 stefano
 -- 
 S t e f a n o  C a r d o
 Debian GNU-Linux user
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 
 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: images with mysql

2003-03-20 Thread Lai Liu-yuan
Well, this may be off topic.

In my case, I store tens of thousands of images, gradually growing. All of them are 
quite small, most around 30*30 gray scale. Would it still be faster to store them on 
disk?

On Thu, 20 Mar 2003 13:57:06 +0100
B. van Ouwerkerk [EMAIL PROTECTED] wrote:

 IMHO it's better to store a link.
 I have seen databases (not MySQL) getting corrupted because the file 
 inserted was to big.
 
 For the visitor it doesn't really matter whether you put it into the 
 database or not. A link is less difficult and you don't have to retrieve 
 pictures from the database so it might be quicker..
 
 
 
 B.
 
 
 At 18:34 20-03-2003 +, Lai Liu-yuan wrote:
 I am now having a database storing images of chinese characters for 
 research purpose. I wrote a program to store and retrieve them. My images 
 are of type ppm. This is how I designed my table:
 
 mysql describe poor;
 +++--+-+-+---+
 | Field  | Type   | Null | Key | Default | Extra |
 +++--+-+-+---+
 | cc | char(2) binary |  | | |   |
 | width  | int(1) | YES  | | NULL|   |
 | height | int(1) | YES  | | NULL|   |
 | data   | blob   | YES  | | NULL|   |
 +++--+-+-+---+
 
 Just have to be really careful in storing binary data. Hope this help.
 
 On Thu, 20 Mar 2003 10:34:19 +0100
 [EMAIL PROTECTED] wrote:
 
   Hi!
  
   I have a problem with my MySQL
  
   I need to have some a images related with an item
  
   for example
  
   --
   ! author ! date of birth an death ! image!
   --
  
   How can I define the field for the images? I have read that LONGBLOB
   could be useful for large objct like images, but I can't understand how
   to set it in my database...
  
   Thank you in advance
  
   stefano
   --
   S t e f a n o  C a r d o
   Debian GNU-Linux user
  
 
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 
 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: This query shouldn't be wrong, but mysql says it is???

2003-03-19 Thread Lai Liu-yuan
I reread the mysql manual again, and found the little piece I've missed : version 4!! 
That's the problem.

Thanks for your reply.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



This query shouldn't be wrong, but mysql says it is???

2003-03-18 Thread Lai
Hi.

Here is my table design, my query and the error:

mysql describe poor;
+++--+-+-++
| Field  | Type   | Null | Key | Default | Extra  |
+++--+-+-++
| cc | char(2) binary |  | | ||
| width  | int(1) | YES  | | NULL||
| height | int(1) | YES  | | NULL||
| data   | blob   | YES  | | NULL||
| id | int(11)|  | PRI | NULL| auto_increment |
| target | int(11)| YES  | | NULL||
+++--+-+-++

mysql describe pindex;
+--++--+-+-++
| Field| Type   | Null | Key | Default | Extra  |
+--++--+-+-++
| cc   | char(2) binary | YES  | | NULL||
| count| int(11)| YES  | | NULL||
| contourc | blob   | YES  | | NULL||
| contourv | blob   | YES  | | NULL||
| densityc | blob   | YES  | | NULL||
| densityv | blob   | YES  | | NULL||
| id   | int(11)|  | PRI | NULL| auto_increment |
+--++--+-+-+
mysql update poor, pindex set poor.target=pindex.id where poor.cc=pindex.cc;
ERROR 1064: You have an error in your SQL syntax near ' pindex set 
poor.target=pindex.id where poor.cc=pindex.cc' at line 1

My query is almost exact as the example in mysql document. What is wrong with it?

Thanks.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



store an array of double to mysql, How?

2003-03-17 Thread Lai
Hi.

I am writing a program to do pattern recognition. I decide to use mysql to store the 
features calculated. The features are stored as an array of double in my c program.

But now I do think about it, I don't know how. I've searched the internet, none really 
fit my problem.

Is there a way to do this?

Thank you


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Is mysql_real_escape_string for blob storage?

2003-03-11 Thread Lai Liu-yuan
Hi, everyone.

I use blob to store image data in mysql. I use mysql_real_query to store it, but did 
not use mysql_real_escape_string to process it before hand.

Then I saw in the document that this is needed. But I am testing the data stored by 
reading them out to do some processing, there seems no segmentation fault happened.

By the way, when I stored the image, I stored the width and height also into the 
database. I read the image out for processing alsa based on these two variables. So if 
the image data is truncated due to special characters, there should be segmentation 
fault, shouldn't it?

So, back to the question, is mysql_real_escape_string needed when storing blob data?

Thanks.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: Is mysql_real_escape_string for blob storage?

2003-03-11 Thread Lai Liu-yuan
Thanks for your reply.

But, what then is the role of mysql_real_query? In document, it says You must use 
mqsql_real_query for queries that contain binary data?

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



what's wrong with this query?

2003-03-10 Thread Lai Liu-yuan
Please help me with the following c code:

sprintf(update, update chrc set center=');
len = 24;
memcpy(update+len, center, 128);
len += 128;
sprintf(update+len, ', var=');
len += 8;
memcpy(update+len, var, 128);
len += 128;
sprintf(update+len, ' where cc='%s', row[0]);
len += 15;

if (ret = mysql_real_query(conn, update, len))
printf(fail update %d\n, ret);

int center[4][8], var[4][8]
row[0] is a chinese character (2 bytes)
update is a buffer of char [500]

mysql describe chrc;
++--+--+-+-+---+
| Field  | Type | Null | Key | Default | Extra |
++--+--+-+-+---+
| cc | char(2) binary   | YES  | | NULL|   |
| count  | int(11)  | YES  | | NULL|   |
| center | char(128) binary | YES  | | NULL|   |
| var| char(128) binary | YES  | | NULL|   |
++--+--+-+-+---+

The query I want to do is
update chrc set center='--', var'++' where cc='xx' (1)
where -- is center[4][8] (all of them), ++ is var[4][8], and xx is the chinese 
character.

The result I get is that all rows in the table chrc are updated. And it can be seen 
from /var/log/mysql/mysql.log, the query executed is
update chrc set center=' (2)
But I dumped the variable update to a file, and it is exactly as what I want in (1).

Please point me out what is the problem.
Thank you very much.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php