發表文章

目前顯示的是 2013的文章

Set the max no. of port and tcp timeout on window

Run regedit Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters Create the following setting: value name: MaxUserPort value type: DWORD value: 65534 effective range: 5000-65534 default: 5000 value name: TCPTimedWaitDelay value type: DWORD value: 30

Solution for MongodbException: can't find a chunk! when using GridFS

public void insertFileByGridFS(byte[] data, ObjectId id, String filename) throws Exception{ GridFS gfs = new GridFS(database, "pdf"); GridFSInputFile gfsFile = gfs.createFile(data.clone()); gfsFile.setContentType("application/pdf"); //GridFS will set the parent file id for the chunk id by default. //if set the id by setId(new ObjectId()), the file_id of the chunk will be null gfsFile.setId(id); gfsFile.setFilename(filename); gfsFile.save(); } Please don't explicitly call GridFSInputFile.setId(), otherwise the file_id field of chunk will be null, you can't retrieve the file by GridFSDBFile.findOne(filename) (file name is store in the files collection and link to chunk collection by the file_id)

Invoking web services via proxy using JAX-RPC and JAX-WS

Invoking Web Services through a proxy using JAX-WS MyService service = null; service = new MyService(); MyServiceSoap port = service.getMyServiceSoap(); BindingProvider bp = (BindingProvider) port; Binding binding = bp.getBinding(); Map ctx = bp.getRequestContext(); ctx.put(BindingProvider.USERNAME_PROPERTY, "proxyuser"); ctx.put(BindingProvider.PASSWORD_PROPERTY, "proxypassword"); Note that we don't specify the Proxy Server here. JAX-WS sends authentication information for the proxy in request headers. Invoking Web Services through a proxy using JAX-WS private HttpTransportInfo getHttpInfo() { Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyServer", 9090)); HttpTransportInfo httpInfo = new HttpTransportInfo(); httpInfo.setProxy(proxy); httpInfo.setProxyUsername("proxyuser".getBytes()); httpInfo.setProxyPassword("proxypassword".getBytes()); ret

Chrome default search engine keeps changing to Yahoo

Please go to this location and delete the file in C:\Program Files (x86)\Common Files\Spigot\Search Settings

Enable JPA 2.0 on Weblogic Server

Enable JPA 2.0 on Weblogic Server Support for JPA 2.0 in WebLogic Server is provided as a patch, because JPA 2.0 is part of Java Platform, Enterprise Edition (Java EE) 6. Therefore, enabling JPA 2.0 support in the current release results in WebLogic Server not meeting all Java EE 5 compatibility requirements. To maintain Java EE 5 compatibility in the current release, the files required for the support are not enabled by default, although they are included in a standard WebLogic Server installation. Install the Patch - Using Smart Update To install the patch using Smart Update, do the following: Ensure that you are logged in to My Oracle Support. For information, see  http:\\support.oracle.com . Start Smart Update, as described in " Starting Smart Update ." In the  Target Installation  panel of the main Smart Update window, select the target installation. Select the  Get Patches  tab. In the available patches panel, select the check box for patch  QWG8 - Enab

Debugging PreparedStatement

1) Using a Debug package that developed by java underground: Connection con = DriverManager.getConnection(url); DebugLevel debug = DebugLevel.ON; String sql = "SELECT name,rate FROM EmployeeTable WHERE rate > ?"; //Use a factory instead of Connection to get a PreparedStatement. //PreparedStatement ps = con.prepareStatement(sql); PreparedStatement ps = StatementFactory.getStatement(con,sql,debug); ps.setInt(1,25); //If ps is a DebuggableStatement, you see the statement, //otherwise, an object identifier is displayed System.out.println(" debuggable statement= " + ps.toString()); Reference: http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-overpower.html?page=3 Download the source code:  http://www.javaworld.com/javaworld/jw-01-2002/overpower/jw-0125-debug.zip 2) Using LOG4J: log4j.rootLogger=DEBUG, stdout  log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.std

Writing nested CDATA in XML and reuse of DocumentBuilder

XmlHelper Class: package com.jaspersoft.jasperserver.ws.xml; import java.io.StringWriter; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class XmlHelper { private static final ThreadLocal docBuilder = new ThreadLocal () { @Override protected DocumentBuilder initialValue() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { thro