Based on my understanding on String objects, that every string literal is being added/created on the String Constant Pool. two objects are being created, one is the “hello world” being added on the constant pool and the other object is the new instance of String. Does the same principle is being a…
Tag: java
How to enable query logging in Spring-data-elasticsearch
I use spring-data-elasticsearch framework to get query result from elasticsearch server, the java code like this: While how can I know the raw http query sent to elasticssearch server? How can I enable the logging, I tried add log4j, but it seems the spring-data-elasticsearch doesn’t log the query. Answ…
Why method overloading is the best example of static binding in Java?
In java, I know that we have some differences between static binding and dynamic binding and method overloading is the best example of static binding but I don’t know why it is the method overloading instead of the the method overriding? Answer Method overloading is determined at compile time. The compi…
Java simpledateformat Unparseable date, even though the format appears to be right
I’ve got a silly problem, here’s my code: the result is following: Fri Jun 05 2015 15:34:29 GMT+0000 null Unparseable date: “Fri Jun 05 2015 17:30:00 GMT+0000” What’s wrong with my format? It outputs the current date in the same format as the date I want to parse, but keeps telli…
java format particular date with T character
What is the correct form for parse this date?: 2015-05-29T00:00:00+02:00 Answer Try with Notice that MM represents months, while mm represents minutes. if you want to have 24h format use HH, hh is for 12h format XXX represents time zone in format like -08:00 to add literal like T in format you need to surroun…
Use JDBC/Mysql Connector in intellij idea
I’m new in Java, and I need to establish a connection to a MySQL server (local), I have add the libraries in Intellij idea but it seems not work, the IDE can’t find the class i think… I become crazy I’m searching since two hours… I come from visual studio/c# dev environment and i…
JXLS – how to create hyperlink to Excel worksheets in workbook
I am trying to create an Excel workbook with with JXLS. I want a text hyperlink for navigating through worksheets in a workbook. I couldn’t find any helpful information online. Please give any idea or hyperlink for that can help to to solve the problem. Thanks Answer jXLS is a small and easy-to-use Java…
How to specify the JDK version in Android Studio?
Android Studio is giving me a Gradle build error that looks like this: Now it gives me these clickable prompts: And I have already downloaded and installed JDK 7. The problem is when I go to select it in the “File System” i can only find a directory named 1.6.0 JDK. Furthermore, the installation o…
Hibernate with Sql Server fail for nvarchar field with “No Dialect mapping…”
I’m using Hibernate’s JPA-Implementation to access our SQL Server 2012 database. When trying to select a nvarchar field in a native query, I get an exception “No Dialect mapping for JDBC type: -9”. It looks much like No Dialect mapping for JDBC type: -9 with Hibernate 4 and SQL Server …
Cannot load font in JRE 8
I cannot load a font from an S3 Inputstream in JRE 8. I do not have issue if a system is installed with JRE 7, JDK 7, or even JDK 8. The error that I got is I tried to load the inputstream to a temp file, but it does not help. I also tried to load a font directly