Category "java"

Converting String date to SQL Date

I have a string date in the format DD/MM/YY (16/07/13) How do I convert this string date to SQL Date format (maintaining the same DD/MM/YY format) for storing i

Restart Tomcat Service on AWS EC2 instance, on a schedule

I have an instance on Tomcat running on EC2. Based on some resourcing reasons that I don't want to get into, I'd like it to restart each evening at 11:00pm. I

Cannot Add Http Headers to Message with Spring's WebServiceTemplate

I have a fairly simple case where I am trying to add HTTP headers (not SOAP headers) to a request I am making using Spring's WebServiceTemplate. I have defined

how to get next item in ArrayList in java

i followed a YouTube tutorial about programming a quiz app using java android studio in the tutorial you put the question in array list then you get randomly qu

File has been compiled by a more recent version of the Java Runtime error SceneBuilder

I've used JLink + JPackage to build a JavaFX app into a self-contained application. I'm using JDK 14. However, when I try to open one of my FXML files in Intell

JPA created too many fields in table

enter image description here I am trying to map some entities to tables in MySQL database using Spring Boot JPA. I have a problem with one of the tables because

JDBC driver connection problems (sun.jdbc.odbc.JdbcOdbcDriver)

I'm having some issues with the connection with Java and SQL 2008 Express. I'm using sun.jdbc.odbc.JdbcOdbcDriver driver for the connections and have created my

Test a method that use a spring service

I have a problem testing a method in Java (I use jUnit 4) and this method to test make a call to a repository and should throw an exception if something is wron

React Native Android run causes "Illegal number of arguments for updateHotspot command"

I am creating a simple app using React Native for both iOS and Android. I've tested both platforms for a while and all works very well. But recently, I was focu

Why my RecyclerView updated while I don't notify the adapter?

I have some trouble to understand why my recyclerView get update while I add the data only after setAdapter() and never call notifyDataSetChanged() ! In the sa

Do variables/flags can be affected by another thread on a non-synchronized method?

For example I have a non-synchronized method like this: public void nonSynchronized(){ boolean flag = false; if(/*some condition*/){ flag

java.lang.ClassCastException class xxxxx cannot be cast to class io.micronaut.data.model.Page Micronaut data

Trying to implement the pagination with Micronaut data with MongoDB as below @MongoRepository public interface IDiscountRepository extends ReactorCrudRepository

How to enable assertions in the Gradle run task

By default, Java disables assertions. (The test I'm using here is assert false; as the first line in main().) I'd like to have them enabled while running my p

Error java.lang.AssertionError: expected: null<null> but was: java.lang.String<null> what does it mean?

I have this strange issue in my Junit 4.12 test code. The application uses Spring Framework 4.1.6 and Hibernate 4. When comparing two beans coming from differen

Mockito when() method not working and getting null pointer exception

I am writing unit test cases using Mockito and JUnit . But getting NullPointerException when running a test. On debugging I get to know that Mockito on method:

how to make overlay window view clickable and touchable in android

I am trying to learn how to create an overlay window similar to Facebook chat head messenger icon in Android. I managed to create the following class which ena

React Native: 'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compat

Hello everyone I am trying to create and run a react native app. I run npx react-native init rn4 but when I run npm run android I have this error: > Task :re

How to check whether a known uri file exists in Android storage?

The file uri is known, such as `file:///mnt/sdcard/Download/AppSearch_2213333_60.apk` I want to check if this file can open or not in background, how to do?

Reading from a .txt file into a JFrame

I'm stuck trying to figure out how to read from a Java file into a JFrame. I need to make a frame and read in the names of cars and how much they cost. From the

Dynamic Programming (Codility Q: NumberSolitaire)

This is the question: codility.com/programmers/task/number_solitaire and below link is my result (50% from Codility): https://codility.com/demo/results/trainin