How to manage annotation based Hibernate versioning for time stamp column in which value generated by DB

We can generate version column’s value by using below tag in our hbm file <timestamp column="MODIFICATION_DATE" name="modificationDate" access="property" unsaved-value="undefined" source="db" generated="always"/>

What is the corresponding hibernate notation to generate value for time stamp column which date type

private java.util.Date modificationDate;

Java – Oracle Weblogic 12c – Eclipse . I can’t seem to get the proper path to connect my db file located in the resource folder

My program structure. myApp -> src -> database -> myApp.db

String DB_LOCATION = "myApp/src/database/myApp.db";
conn = DriverManager.getConnection("jdbc:sqlite:"+ DB_LOCATION);

This is the Console output

java.sql.SQLException: path to ‘myApp/src/database/myApp.db’: ‘C:OracleMiddlewareOracle_Homeuser_projectsdomainsbase_domainmyApp’ does not exist

I want to not point to the server path as i am going to deploy to another server.

What can i do?

How to convert a 2D Int array to a string

Trying to create a basic battleships game

   import java.util.*;
   import java.util.Scanner;
   public class BattleShip
      Scanner input = new Scanner(;
      //public static final boolean DEBUG = false;
      public static void breakln()


      public static void main(String[] arg)
          int size = 0;   
          int[][] board = new int[5][5];
         createShip(board, 4);
         BattleShip.createShip(board, size );


      public static void createBoard(int[][] board){
          for(int row=0 ; row < 5 ; row++ )
              for(int column=0 ; column < 5 ; column++ )

      public static void Display_Baord(int[][] board){
          System.out.println("t1 t2 t3 t4 t5");


          for(int row=0 ; row < 5 ; row++ ){
              for(int column=0 ; column < 5 ; column++ ){
                  }else if(board[row][column]==0){
                  }else if(board[row][column]==1){



      This is the method where the error is 

      public static void createShip(int[][] board,int size)
         if(Math.random() < 0.5)
            int col = (int)(Math.random()*5);
            int row = (int)(Math.random()*7);
            for(int i = 0; i<size; i++)
               board[row][col+i] = "S"; Hear is my error, i cannot have 's' as my 2d array ' board is an int
            int col = (int)(Math.random()*7);
            int row = (int)(Math.random()*5);
            for(int i = 0; i<size; i++)
               board[row+i][col] = "S";    Hear is my error, it cannot be a string as 'board' is an int 

I’m just looking to find out how I can store ‘s’ in my int 2D array Board.

Thanks in advance


Anyone have/know of any java SMTP client/server example code?

I’m trying to learn about smtp server and clients so that i can build both the client and server parts however i can’t really find any examples of a working set, only finding the client code. I understand the individual parts but not how to proplerly put it together and seeing a working example would be awesome and so helpful.

Thanks to anyone who can help me out!

Scanner issue! Code is skipping the first user input and printing twice instead of once ONLY on the first iteration.

Hello, I have a question about scanners because I don’t understand why the code
is skipping the user input on the first iteration but works fine on the rest.
I’m writing a code to create a madlib program and the link will provide the explanation to the program but pretty much you have these placeholders in a text file and when you see one, you prompt for user input to replace it with your own words. However, my program always go through TWO placeholders first and only ask the user input for one, completely skipping the first placeholder. What is wrong with my code??? Also, how do you fix this? Everything else is running perfectly fine, only that the first line is consuming two placeholders so I’m always off by one.

Welcome to the game of Mad Libs.
I will ask you to provide various words

and phrases to fill in a story.

The result will be written to an output file.

(C)reate mad-lib, (V)iew mad-lib, (Q)uit? c

Input file name: tarzan.txt

Output file name: test.txt

Please type an adjective: Please type a plural noun: DD DDDD <— why is it like this

Please type a noun: DDDD

Please type an adjective: DD

Please type a place:


package MadLibs;
import java.util.*;

public class MadLibs2 {
   public static void main(String[] args) throws FileNotFoundException {
      Scanner console = new Scanner(;
      boolean isTrue = true;
      while(isTrue) {
          System.out.print("(C)reate mad-lib, (V)iew mad-lib, (Q)uit? ");
          String choice =;
         if (choice.equalsIgnoreCase("c")) {
         else if (choice.equalsIgnoreCase("v")) {
         else if (choice.equalsIgnoreCase("q")) {

   public static void view(Scanner console) throws FileNotFoundException {
       System.out.print("Input file name: ");
       String viewFile =;
       File existingMadLib = new File(viewFile);
       Scanner printText = new Scanner(existingMadLib);
       while(printText.hasNextLine()) {

   public static void create(Scanner console) throws FileNotFoundException {
      System.out.print("Input file name: ");
      String inputFile =;
      File newMadLib = new File(inputFile);
      while(!newMadLib.exists()) {
         System.out.print("File not found. Try again: ");
         inputFile =;
         newMadLib = new File(inputFile);
      System.out.print("Output file name: ");
      String outputFile =;
      PrintStream output = new PrintStream(new File(outputFile));
      Scanner input = new Scanner(newMadLib); 
      while(input.hasNextLine()) {
         String line = input.nextLine();
         outputLines(line, output, console);

   public static void outputLines(String line, PrintStream output, Scanner console) throws FileNotFoundException{
      String s = "";
      Scanner lineScan = new Scanner(line);
         s =;
         if(s.startsWith("<") || s.endsWith(">")) {
            s = rePlaceholder(console, lineScan, s);
         output.print(s + " ");

   public static String rePlaceholder(Scanner console, Scanner input, String token) {           
      String placeholder = token;
      placeholder = placeholder.replace("<", "").replace(">", "").replace("-",  " ");
      if (placeholder.startsWith("a") || placeholder.startsWith("e") || placeholder.startsWith("i") 
       || placeholder.startsWith("o") || placeholder.startsWith("u")) {
         System.out.print("Please type an " + placeholder + ": ");
      }  else {
          System.out.print("Please type a " + placeholder + ": ");
      String change = console.nextLine();
      return change;

   public static void intro() {
      System.out.println("Welcome to the game of Mad Libs.");
      System.out.println("I will ask you to provide various words");
      System.out.println("and phrases to fill in a story.");
      System.out.println("The result will be written to an output file.");

Android – Select website and its language in AlertDialog and save it

I need to load and save a website and its language in sharedpreferences. When I exit and then open the app, saved website and language load. I have used various ways, but cant achieve it. There is String and int not compatible with each other. My simple code like this:

      private SharedPreferences prefs;
      private static final String SELECTED_ITEM = "SelectedItem";
      private SharedPreferences.Editor sharedPrefEditor;

public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    else if (id == 
    final CharSequence[] items={"English","Arabic","Russian"};

        AlertDialog.Builder builder = new AlertDialog.Builder(

        builder.setTitle("Choose Website");
        builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {}

        builder.setSingleChoiceItems(items, getSelectedItem(), new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                webView = (WebView) findViewById(;
                int website=current_page;

                else if("Arabic".equals(items[which]))
                else if("Russian".equals(items[which]))


 private int getSelectedItem() {
      if (prefs == null) {
        prefs = PreferenceManager
    return prefs.getInt(SELECTED_ITEM, -1);

  private void saveSelectedItem(int which) {
    if (prefs == null) {
        prefs = PreferenceManager
    sharedPrefEditor = prefs.edit();
    sharedPrefEditor.putInt(SELECTED_ITEM, which);

sending image dataUri using jQuery ajax post request and getting null when reading image data in servlet using request parameter

I have the image data url/blob and is trying jQuery ajax post request.
Getting null when reading image data as request parameter.


var dataURL = DataURL('image/jpeg',0.5);
var blob = dataURItoBlob(dataURL);
var fd = new FormData();
fd.append("myFile",blob, "image.jpg");


MyServlet: using SlingHttpServletRequest request

request.getParameter("myFile"): // gives me null

Do we know if there is something wrong with ajax call or i am trying to request a different parameter or there is other way of doing it in Adobe AEM.

Bean Validation on XML Element Choice

How do I add bean validation specifically for a String.class type element within a choice:

    @NotNull(message = "ContactUser or CompanyName is required.")
    @XmlElements(value = {
        @XmlElement(name = "ContactUser", type = ContactUser.class, required = true),
        @XmlElement(name = "CompanyName", type = String.class, required = true) })
private Object contactInfo;

(This is from reading article:
@Valid works to turn on validation for ContactUser.class and @NotNull works because contactInfo is of type Object. When I try to add

@Size(min = 10, max = 16)

Above the code, it gives me the following error:

javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.lang.Object.

I am guessing this is because of the type of contactInfo?