import org.apache.http.client.methods.*; import org.apache.http.client.*; import org.apache.http.impl.client.*; import org.apache.http.*; import org.apache.http.entity.mime.*; import org.apache.http.entity.*; import java.io.*; public class API_H01 { public static void main (String args[]) { try { HttpClient client = HttpClientBuilder.create().build(); File f = new File(“/opt/tomcat8/hierarchy.csv”); MultipartEntityBuilder builder = MultipartEntityBuilder.create();…
Category: Java
java dynamic SQL formatter
import java.sql.*; public class dynColumns { public static void main(String[] args) { try { Connection con = DriverManager.getConnection(“jdbc:oracle:thin:” + args[0]); Statement stm = con.createStatement(); ResultSet rst = stm.executeQuery(args[1]); ResultSetMetaData rstMeta = rst.getMetaData(); int columns = rstMeta.getColumnCount(); while (rst.next()) { for…
Why can’t I truncate my active JBOSS server.log file?
If you find yourself in a position where it is 3AM and the filesystem on which your server.log file lives is full, you may issue some kind off redirect or “cat /dev/null > server.log”, or even “truncate –size=0 server.log”. After…
Does BlockingQueue.take() use CPU?
No… [root@cmhlcarchapp01 ~]# cat t.java import java.util.concurrent.*; public class t implements Runnable { static ArrayBlockingQueue Q = new ArrayBlockingQueue(5); String type; public static void main (String args[]) { t n = new t(“producer”); t n2 = new t(“consumer”); } public…
Flexibly instrumenting java with CPU utilization recordings
Each of these has their own set of strengths, and is appropriate for differing and sometimes similar requirements. What each of them lack is the ability to flexibly, easily, and succinctly report on CPU utilization at not only an individual…
DNS server address cached in java?
We found that an old DNS address was used until we restarted the JVM. I need to review the class used to perform this activity.. Test this with a simple class. import java.net.*; public class test { static { java.security.Security.setProperty…
Pushing a file to Oracle database to write to database filesystem
import java.sql.*; import java.io.*; public class sendFile { public static void main (String args[]) throws Exception { File file = new File(“a.txt”); FileInputStream fis = new FileInputStream(file); byte[] data = new byte[(int)file.length()]; fis.read(data); fis.close(); String s = new String(data, “UTF-8”);…
Using Spring AMQP to post messages to RabbitMQ
The ActiveMQ jar’s come with the AMQP 1.0 protocol, which doesn’t work against a RabbitMQ AMQP version 0.9.1 broker. As such, we use a spring jar to get this to work, thanks to this link. Very simple example of this.…
Simulating SocketTimeoutException
A SocketTimeoutException occurs when a socket object instance has been configured to throw the exception if it receives no data in the prescribed number of milliseconds. The default is 0, which disables the timeout. Reasons you may want to use…
Connection Reset – What does it mean?
Generally, it indicates your client successfully connected to the server. A subsequent attempt to use the client connection failed after the server closed the socket, or had been disconnected for any reason. You can prove this with what is below,…