How can I stop Java or Hibernate Caching

I have an app to retrieve data from Database, and I monitor the time my app takes to retrieve data. But I have an issue when I use the same data input set to retrieve data with my app, the second time retrieving will take much less time. I assume Jav

Sort int in JTable

I want to sort a column with int in it in a JTable. I use TableRowSorter with the sort order SortOrder.ASCENDING. But somehow it sorts not how I actually want it. What I want: What I get: What is the Problem? And how can I fix it? Here is the SSCCE:

where to put% sign correctly in a query of type sql?

ResultSet data = Db.db.search("select (flavour) from doenets where flavour like = '"+name+"%' "); i think there is something wrong with this like query i tried replacing the position of % sign but didn't work can someone tell me where

Spring Test - JavaConfig per project

I have various unit test classes in my system, and they all extend a centralized test class called AbstractContextTest. Said abstract superclass generally looks like this: @RunWith(SpringJUnit4ClassRunner.class) @TestExecutionListeners({DependencyInj

Generic table creation and null pointer errors

I have an array of linked list which runs parrallel to an ordered object array. If an extra element is entered into the object array i need to insert an extra element into the same space in the linked list. I have this method as follows public static

Collection throws UnsupportedOperationException

I am getting an UnsupportedOperationException when calling add() in the following code: Collection<MyClass> myClass = method(); MyClass newObject = new MyClass(); myClass.add(newObject); method() returns Collection<MyClass>. Also, what should

java.lang.NullPointerException when I try to persist

I'm coding an application in mave,jsf ,spring ,jpa/hibernate , when I try to access a "user" jsp page mapped to the " UserManagedBean" I get an exception: GRAVE: java.lang.NullPointerException javax.faces.el.EvaluationException: java.l

Unable to transfer after response has been validated - Servlet

I am trying to logout from the HTTPSession and redirect the user to the login page. Below is my complete Http servlet code as is. import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.s

How can I merge one bean into the other to do a partial update

I want to implement the http-patch method to do a partial update on a resource. I have a bean that is deserialized with Jackson and contains some valid properties. additionaly i have the a bean that is currently stored in my application. Is there an

Apache Http Client in Android

I'm trying to get the whole html from a web page in Android. In java console aplication I used to do like this: DefaultHttpClient httpclient = new DefaultHttpClient(); String busca = "kindle"; HttpGet httpGet = new HttpGet("http://www.amazo

IP address in Java valid or not

I want to validate IP address with or without a port number using regex. My input string would be IP:PORT or just IP. I want only one regex which will be validating IP:PORT or IP both. My IP address regex is: ^(?:(?:1\d?\d|[1-9]?\d|2[0-4]\d|25[0-5])\

AddAll Android Collections

I'm just starting out in java & android. Below is my code, to add all the buttons in an activity then hide them. Question: is their anyway to automatically add all the buttons in the activity without having to list each of them, I have looked at list

Java XPath umlaut / vowel parsing

I want to parse the following xml structure: <?xml version="1.0" encoding="utf-8"?> <documents> <document> <element name="title"> <value><![CDATA[Personnel changes: Müller]]></value>

How to add data in JTextArea in Java?

I am using this code to show text in a JTextArea: jTextArea1.setText(jTextArea1.getText() + text + "\r\n"); jTextArea1.repaint(); But it shows an exception: java.lang.NullPointerException You never instantiated your JTextArea. Also, you might wa

How to deploy a web application

I have created a dynamic web projects in eclipse which includes jsp pages and servlet.The back end of this application is Mysql and i include mysql-connector-java-5.1.15-bin.jar in the lib folder. I want to deploy this web application using Tomcat se

Combination of 2 RGB colors with Alpha

I'm trying (In Java) to get the resulting color when I combine 2 colors, the one on top having an alpha transparency. Basically, I'm trying to assign a background color to an image, but I've broken it down to each pixel being changed individually. I'

How can I parse an xpath expression in Java?

I need to parse an xpath expression to retrieve node name/attribute/predicate/etc. from the expression for further processing. I am not addressing into a specific xml file. For the xpath /root/nodeA[@attributeA=123] I would like the parsed node name:

Threads and event management in Java

I am a Java newbie and an Android newbie too. I am working on a game and trying to understand the exact nature of events in Java and Android. I have a few questions to help understand the correct way to do event handling in my app. Its a network game

match a large string to a few hundred small sentences

I have thousands of large strings that I need to compare / match against another set of hundreds of smaller phrases and words, to see if the phrases are contained in the large String. What is the quickest way of doing this? Do I just use a String.ind

Manipulation of strings in Java

I wish to return a String as follows: Josephine Blow (Associate Professor, Math) Teaching Assignments: **(for each course write on a seperate line)** Course No.: xxx \t Section No.: xxxx \t Course Name: xxxx \t Day and Time: dayOfWeek - timeOfweek If

Super CSV (Java) - Read files with spaces in column names

I'm working with Super CSV and it looks like an amazing package. My only worry is how to work with columns with spaces in their names. No, I cannot go back and remove the spaces myself. These files will be given to me by the hundreds and I don't have

problem using the base64 encoder and InputStreamReader

I have some CLOB columns in a database that I need to put Base64 encoded binary files in. These files can be large, so I need to stream them, I can't read the whole thing in at once. I'm using org.apache.commons.codec.binary.Base64InputStream to do t

How can I get a .wav sound to play?

Im making an app, and i want it to make a sound when a activity is opened , the sound file is in R.raw.sound_file , if someone could do some example code to make my app play a sound that would be great.doesn't the android.media.MediaPlayer class do t

Java parses many instances of the substring of the string

I am trying to write a small java program that will accept a file (using Scanner class), return the file as a String, and then search that string for any instance of a substring starting with "Email:" and ending with ".edu". There will

PNG transparency without alpha channel

I am trying to create a transparent PNG image from a BufferedImage in Java. The PNG will be loaded into another piece of the software, that does not support the alpha channel. That should be fine, because, according to Chapter 8, section 5, part 4 of

How to get the height and width of the image using java?

Is there any other way besides using ImageIO.read to get image height and width? Because I encounter an issue that locks up the thread. at com.sun.medialib.codec.jpeg.Decoder.njpeg_decode(Native Method) at com.sun.medialib.codec.jpeg.Decoder.decode(D