Java Reading from a socket

Reading Time: 1 minute Socket socket = new Socket(); try { socket.connect(new InetSocketAddress(“”, 7777)); System.out.println(“connected!”); BufferedReader in = new BufferedReader(new InputStreamReader( socket.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }

Java Eclipse Remote Debugging

Reading Time: 1 minute This could be needed to remote debug a java program first on the remote or to simulate it on your machine issue the below code to run it in debug mode java.exe -Xdebug -Xrunjdwp:transport=dt_socket,address=9991,server=y,suspend=n -jar C:\Users\tugrul.aslan\xxx.jar   then in eclipse Run ==> Debug configurations

LAMP Stack on Windows

Reading Time: 2 minutes Apache 2.4 Installation Download Apache 2.4.16 win32 from Apache lounge – Unzip entire content to C: and keep the folder name as given Visual C++ Redistributable for Visual Studio 2015 package for Win32 and install it – Go to unzipped Apache folder –> conf edit httpd.conf and edit those lines; Listen *:80 remove #

Callable Interface

Reading Time: 1 minute Normally when we work with threads and runnable does not return a processed product, for that reason we either need to have our own implementations using observer pattern or Callable interface provided default by Java Even Callable interface has been designed by using observer patter. Observer pattern is simply to notify other concrete classes when one

Spring ZKoss Customized Login, Logout, Authorization and Authentication

Reading Time: 2 minutes public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFilter { @Autowired private xxService xService; static final Logger logger = Logger.getLogger(CustomAuthenticationFilter.class); @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { String username = request.getParameter(getUsernameParameter()); String password = request.getParameter(getPasswordParameter()); String server = request.getParameter(“server”); if(username.trim().length() == 0 || password.trim().length() == 0){ logger.error(“Error empty credentials entered ” + username + password

JDBC Batch Bulk Data Insertion

Reading Time: 2 minutes At work I did dwell on finding a faster way to insert bulk data into an Oracle datasource. My project contained huge amount of data retrieval, processing and bulk insertion into a target database. I’ve implemented a standardized way of data insertion, e.g. establishing a connection, proceeding data insertion as well as terminating the concurrent