Tuesday, May 24, 2011
Sunday, May 22, 2011
Thursday, May 19, 2011
Tuesday, May 17, 2011
Thursday, May 5, 2011
Close ResultSet, PreparedStatement, Connection Properly in Java
It is good to close the following in order properly
1. ResultSet
2. PreparedStatement
3. Connection
http://stackoverflow.com/questions/2363785/which-should-i-close-first-the-preparedstatement-or-the-connection
Or use the Common DBUtils class by Apache
http://commons.apache.org/dbutils/examples.html
1. ResultSet
2. PreparedStatement
3. Connection
http://stackoverflow.com/questions/2363785/which-should-i-close-first-the-preparedstatement-or-the-connection
Or use the Common DBUtils class by Apache
http://commons.apache.org/dbutils/examples.html
Wednesday, May 4, 2011
Save RequestStream to file
DataInputStream dataStream = new DataInputStream(req.getInputStream());
byte datas[] = new byte[formDataLength];
int totalBytes = 0;
while (totalBytes < formDataLength) {
int bytes = dataStream.read(datas, totalBytes, formDataLength);
totalBytes += bytes;
}
saveMp3(datas);
public static void saveFile(byte[] datas) throws Exception{
FileOutputStream fileOutputStream = new FileOutputStream("xxxxx");
fileOutputStream.write(datas);
fileOutputStream.flush();
fileOutputStream.close();
}
byte datas[] = new byte[formDataLength];
int totalBytes = 0;
while (totalBytes < formDataLength) {
int bytes = dataStream.read(datas, totalBytes, formDataLength);
totalBytes += bytes;
}
saveMp3(datas);
public static void saveFile(byte[] datas) throws Exception{
FileOutputStream fileOutputStream = new FileOutputStream("xxxxx");
fileOutputStream.write(datas);
fileOutputStream.flush();
fileOutputStream.close();
}
Tuesday, May 3, 2011
Sunday, May 1, 2011
JSP Installation
Tomcat 7 with Eclipse
Follow the instruction to setup the whole development environment:
==========================================
a. Download Java SE 6 with JDK (If you don't use EJB, you don't need the Java EE version)
b. Installation of Tomcat server
Subscribe to:
Posts (Atom)