Notes by Dr. Xi
Displaying notes 91 - 100
Created by Dr. Xi on March 07, 2011 16:23:40
Last update: March 07, 2011 16:25:05
Oracle operator || doesn't work for MySQL. Looks like I have to use the concat function:
mysql> select 'abc' || '123';
+----------------...
Created by Dr. Xi on March 05, 2011 15:17:58
Last update: March 05, 2011 15:19:51
To change the default character set of a database:
ALTER DATABASE database_name CHARSET charset_name
or
ALTER DATABASE database_name COLLATE collation_nam...
but this only changes the default character set or collation, it doesn't change the charset or collation of existing tables.
Use ALTER TABLE to change the charset of an existing table:
Change the default charset or collation for a table (existing columns are untouched!):
ALTER TABLE table_name CHARSET charset_name | COLL...
Convert a table to a new charset:
ALTER TABLE table_name CONVERT TO CHARSET charset_...
Warning: character set conversion may not be a simple process, c.f.: Converting Database Character Sets .
Created by Dr. Xi on March 05, 2011 14:39:42
Last update: March 05, 2011 14:40:35
Select from information_schema :
mysql> select cc.character_set_name
-> from...
Other columns available from the information_schema tables:
mysql> desc tables;
+-----------------+--------...
Note that show create table <table_name> also works.
Created by Dr. Xi on March 05, 2011 14:31:44
Last update: March 05, 2011 14:32:21
Select from information_schema.tables :
mysql> select table_collation from information_sch...
Or,
show create table mysql.host;
CREATE TABLE `host` (
`Host` char(60) collate...
Created by Dr. Xi on March 05, 2011 14:10:54
Last update: March 05, 2011 14:10:54
mysql> show collation like 'latin1%';
+--------...
Created by Dr. Xi on March 05, 2011 13:04:54
Last update: March 05, 2011 13:04:54
mysql> show character set;
+----------+--------...
Created by Dr. Xi on March 01, 2011 16:11:50
Last update: March 01, 2011 16:11:50
Java PrintWriter is buffered. You can turn on autoFlush, but it does'nt work for all methods.
Test code:
import java.io.*;
public class TestPrintWri...
Output:
[START] Test PrintWriter
Auto-flush only work...
Created by Dr. Xi on November 23, 2010 20:20:01
Last update: March 01, 2011 13:38:51
I tried to find a GZIP compression servlet filter to compress a large log file that we send down to the browser. Most of the implementations I found were overly complicated and many buggy. This is a simple implementation that worked for me. The filter:
package filter.demo; import java.io.*; i... Config web.xml : <filter> <filter-name>gzipFilter</filte... The ugly anonymous inner class could have been avoided if the servlet API did not insist on ServletResponse.getOutputStream returning the bogus ServletOutputStream class (instead of the plain OutputStream ). Additional Note: In an earlier version of this filter, the gzip headers were added in doFilter , like this: // This is NOT good! if (supportsGzip) { ... It turned out that the ServletResponse methods sendError bypasses the gzip...
Created by Dr. Xi on February 28, 2011 15:39:08
Last update: February 28, 2011 15:39:08
For simple projects, archetype:generate seemed too heavy for me, but creating the standard Maven file structure by hand is such a chore. So I created this simple script to ease the pain:
#!/bin/sh
if [ $# -lt 4 ]; then
echo "Us...
Example usage:
./initmvn.sh myProject theGroupId theArtifactId co...
Created by Dr. Xi on February 28, 2011 15:20:07
Last update: February 28, 2011 15:20:07
Follow these steps to start hsqldb from maven:
Add hsqldb dependency to pom.xml :
<!-- HSQLDB -->
<dependency>
<gro...
Start hsqldb with:
mvn exec:java -Dexec.mainClass="org.hsqldb.server....