Java EE

17K

Solutions

9K

Contributors

Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

Share tech news, updates, or what's on your mind.

Sign up to Post

Below line gives error as below as        device.getInternetConnection() return enum not String.            
callableStatement.setString("InternetConnection", device.getInternetConnection());


Multiple markers at this line
      - The method getInternetConnection() is undefined for the type Device
      - The method setString(String, String) in the type CallableStatement is not applicable for the arguments (String,
       Device.getInternetConnection)


Here  device.getInternetConnection()); returns the enum  InternetConnection

      public enum InternetConnection{
            
            WIFI("08"),
            CELLULAR("06");
            
            InternetConnection(String ip){
                  this.ip = ip;
            }
            
            private final String ip;
            
            public static InternetConnection getFromIP(String ip) {
                  for(InternetConnection pc : InternetConnection.values()) {
                  if(pc.getIP().equals(ip))...
                       ......
                  }
                  throw new IllegalArgumentException("This iP: " + iP + " does not exist");
            }
            
            public String getIP() {
                  return ip;
            }
      }

How to change my callable statement setter to accommodate enum instead of string?
please advise
0
New benefit for Premium Members - Upgrade now!
LVL 9
New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Hi,

while creating client from wsdl using web servicesw getting below error




public class CustomerOrdersWS {

      public static void main(String[] args) {
            // TODO Auto-generated method stub
            CustomerOrdersService service=new CustomerOrdersService(new URL{"http://localhost:8080/wsdlfirstws/services/customerOrders?wsdl"});
            

      }

}




Multiple markers at this line
      - Type mismatch: cannot convert from String[] to
       CustomerOrdersService
      - Syntax error on token(s), misplaced construct(s)
      - Syntax error on token ")", delete this token

i wonder what it mean by above error and how to resolve it please advise
0
Hi,


what is difference between below 3 lines




 map.put("ab", map.get("a").concat(map.get("b")));



map.put("ab", map.get("a")+ map.get("b"));

map.put("ab", "null" + map.get("b"));


I passed all tests
http://codingbat.com/prob/p107259
Looking for ways to improve my code and also avoid Null pointer exceptions


Expected	Run		
mapAB({"a": "Hi", "b": "There"}) → {"a": "Hi", "ab": "HiThere", "b": "There"}	{"a": "Hi", "ab": "HiThere", "b": "There"}	OK	
mapAB({"a": "Hi"}) → {"a": "Hi"}	{"a": "Hi"}	OK	
mapAB({"b": "There"}) → {"b": "There"}	{"b": "There"}	OK	
mapAB({"c": "meh"}) → {"c": "meh"}	{"c": "meh"}	OK	
mapAB({"a": "aaa", "ab": "nope", "b": "bbb", "c": "ccc"}) → {"a": "aaa", "ab": "aaabbb", "b": "bbb", "c": "ccc"}	{"a": "aaa", "ab": "aaabbb", "b": "bbb", "c": "ccc"}	OK	
mapAB({"ab": "nope", "b": "bbb", "c": "ccc"}) → {"ab": "nope", "b": "bbb", "c": "ccc"}	{"ab": "nope", "b": "bbb", "c": "ccc"}	OK

Open in new window


please advise
0
Hi,

public Map<String, String> topping2(Map<String, String> map) {
  if(map.get("ice cream")!=null){
    map.put("yogurt", map.get("ice cream"));
  }
  if(map.get("spinach")!=null){
    map.put("nuts", map.get("spinach"));
  }
  else{
    map=map;
  }
  return map;
}

Open in new window

how above code different from below code

public Map<String, String> topping2(Map<String, String> map) {
//public Map < String, String > topping1(Map < String, String > map) {
   // map.put("spinach", "nuts");
    if (map.containsKey("spinach")) {
        map.put("spinach", "nuts");
   }
      if (map.containsKey("ice cream")) {
        map.put("yogurt", map.get("ice cream"));
       // map.put("ice cream", map.get("ice cream"));

   }
    return map;
}

Open in new window


my above first code fails below test
http://codingbat.com/prob/p196458

Expected      Run            
topping2({"ice cream": "cherry"}) → {"yogurt": "cherry", "ice cream": "cherry"}      {"yogurt": "cherry", "ice cream": "cherry"}      OK      
topping2({"spinach": "dirt", "ice cream": "cherry"}) → {"yogurt": "cherry", "spinach": "nuts", "ice cream": "cherry"}      {"yogurt": "cherry", "spinach": "dirt", "ice cream": "cherry", "nuts": "dirt"}      X      
topping2({"yogurt": "salt"}) → {"yogurt": "salt"}      {"yogurt": "salt"}      OK      
topping2({"yogurt": "salt", "bread": "butter"}) → {"yogurt": "salt", "bread": "butter"}      {"yogurt": "salt", "bread": "butter"}      OK      
topping2({}) → {}      {}      OK      
topping2({"ice cream": "air", "salad": "oil"}) → {"yogurt": "air", "ice cream": "air", "salad": "oil"}      {"yogurt": "air", "ice cream": "air", "salad": "oil"}      OK      
0
Hi,

How below solution is different from

public Map<String, String> topping3(Map<String, String> map) {
 // Map<String, String> map=null;
  if(map.get("potato")!=null){
    map.put("fries",map.get("potato"));
  }
    if(map.get("salad")!=null){
    map.put("spinatch",map.get("salad"));
  }
  else
  map=map;
  return map;
  
}

Open in new window


below solution

public Map < String, String > topping3(Map < String, String > map) {
   // map.put("bread", "butter");
    if (map.containsKey("potato")) {
        map.put("fries", map.get("potato"));

    }
     if (map.containsKey("salad")) {
        map.put("spinach", map.get("salad"));

    }
    return map;
}

Open in new window



please advise.

First one does not pass all tests from
http://codingbat.com/prob/p128461
Expected      Run            
topping3({"potato": "ketchup"}) → {"potato": "ketchup", "fries": "ketchup"}      {"potato": "ketchup", "fries": "ketchup"}      OK      
topping3({"potato": "butter"}) → {"potato": "butter", "fries": "butter"}      {"potato": "butter", "fries": "butter"}      OK      
topping3({"salad": "oil", "potato": "ketchup"}) → {"spinach": "oil", "salad": "oil", "potato": "ketchup", "fries": "ketchup"}      {"salad": "oil", "spinatch": "oil", "potato": "ketchup", "fries": "ketchup"} missing: "spinach": "oil"      X      
topping3({"toast": "butter", "salad": "oil", "potato": "ketchup"}) → {"toast": "butter", "spinach": "oil", "salad": "oil", "potato": "ketchup", "fries": "ketchup"}      {"toast": "butter", "salad": "oil", "spinatch": "oil", "potato": "ketchup", "fries": "ketchup"} missing: "spinach": "oil"      X      
topping3({}) → {}      {}      OK      
topping3({"salad": "pepper", "fries": "salt"}) → {"spinach": "pepper", "salad": "pepper", "fries": "salt"}      {"salad": "pepper", "spinatch": "pepper", "fries": "salt"} missing: "spinach": "pepper"      X      
other tests
OK
0
Hi Experts,

I have a list of files all the file names will be stored in one text document.
now i want to know all the filenames are available in souce directory.
how to identify it.
Please refer the attachment.
0
Hi,
i am making an ajax call with text in post data. how do i capture this text in a parameter of a method in my controller or inside the method.
Thanks
0
hi,

in eclipse java project i have below stored procedure in a DAO class say LMN.java


abc_TerminalXYZ_Select

wen i search on it eclipise not finding.
how to find all the stored proc similar to above in all DAO classes?
what are best search strategies to find what i want in eclipise?
please advise
0
I have create Database in my Localhost in mysql Server by phpmyadmin. where i have define no any privileges for the database. when i made live this db on the Hostech Server provider phpmyadmin al tables where successfully imported and  in the Case of views it is showing  me the following error.
"#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation".

This is the example of the views query that i have to upload on my live DB server from my local server .
"CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `crqry_bomoils`  AS  select
`qry_bom`.`FormulaID` AS `FormulaID`,`qry_bom`.`Code` AS `Code`,`qry_bom`.`MaxOfRevision` AS `MaxOfRevision`,`qry_bom`.`Revision` AS
`Revision`,`qry_bom`.`FormulaName` AS `FormulaName`,`qry_bom`.`Group` AS `Group`,`qry_bom`.`FragranceID` AS
`FragranceID`,`qry_bom`.`Qty` AS `Qty`,`qry_bom`.`FragranceName` AS `FragranceName`,`qry_bom`.`Flag` AS `Flag`,`qry_bom`.`CAS1` AS
`CAS1` from `qry_bom` where (`qry_bom`.`Group` = 'ESSENTIAL OIL') order by `qry_bom`.`FragranceName` ".

1:Main Question is that how can i make live my database with my views that i have created on my Localhost server.??
2:How can i import my  database with views  from my localhost server that should be import on any other mysql server without any privileges errors ??

Thanks In Advance!
0
At what point should I be concerned with learning data structure and algorithm in Java. I have discovered that it's a very important strategy  to be good in writing codes in any computer language.
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

How authentication and authorization different from data integrity and Confidentiality.

why we use key, tokens, certificates, rkm etc. please advise
0
I was reading about Resource Bundles

as below
internationalization feature of the JDK provides a mechanism for separating user interface (UI) elements and other locale-sensitive data from the application logic in a program.
I can relate with local sensitive data separation but not the UI elements like buttons etc why we need to separate?

pelase advise
0
import java.util.*;
import java.util.stream.*;
public class X {
	public static void main(String[] args) {
		List<String> list = Arrays.asList("xxax", "xbxbx", "xxcx", "zzz");
		System.out.println(noX(list));
	}
	public static List<String> noX(List<String> strings) {
		return strings.stream().map(s -> s.replaceAll("x","")).collect(Collectors.toList());
    }	
}

Open in new window

in above program what are Collectors , stream, collect methods. And why map is used in this lamda functional examples
0
http://codingbat.com/prob/p128270
public int[] front11(int[] a, int[] b) {
 
  if (a.length==0) return new int[]{b[0]};
  if (b.length==0) return new int[]{a[0]};
   if ((a.length==0) && (b.length==0)) return new int[]{};
  return new int[]{a[0],b[0]};
}





public int[] front11(int[] a, int[] b) {
    if ((a.length==0) && (b.length==0)) return new int[]{};
  if (a.length==0) return new int[]{b[0]};
  if (b.length==0) return new int[]{a[0]};

  return new int[]{a[0],b[0]};
}




why first one fails below test with ArrayIndexOutOfBoundsException
Expected	Run		
front11([1, 2, 3], [7, 9, 8]) → [1, 7]	[1, 7]	OK	
front11([1], [2]) → [1, 2]	[1, 2]	OK	
front11([1, 7], []) → [1]	[1]	OK	
front11([], [2, 8]) → [2]	[2]	OK	
front11([], []) → []	ArrayIndexOutOfBoundsException: 0 (line:3)	X	
front11([3], [1, 4, 1, 9]) → [3, 1]	[3, 1]	OK	
front11([1, 4, 1, 9], []) → [1]	[1]	OK	
other tests
OK	
Correct for more than half the tests

Your progress graph for this problem

Open in new window


please advise
0
Hi,

http://codingbat.com/prob/p105967

I wrote my code as below and failing some tests
public List<String> noX(List<String> strings) {
   strings.replaceAll(x -> "");
  return strings;
}

Open in new window



Expected	Run		
noX(["ax", "bb", "cx"]) → ["a", "bb", "c"]	["", "", ""]	X	
noX(["xxax", "xbxbx", "xxcx"]) → ["a", "bb", "c"]	["", "", ""]	X	
noX(["x"]) → [""]	[""]	OK	
noX([""]) → [""]	[""]	OK	
noX([]) → []	[]	OK	
noX(["the", "taxi"]) → ["the", "tai"]	["", ""]	X	
noX(["the", "xxtxaxixxx"]) → ["the", "tai"]	["", ""]	X	
noX(["this", "is", "the", "x"]) → ["this", "is", "the", ""]	["", "", "", ""]	X	
other tests
		X	

Open in new window


how to fix and improve my code, please advise
0
Hi,

I am trying to double list numbers using functionala lamda programming


http://codingbat.com/prob/p117665
Given a list of integers, return a list where each integer is multiplied by 2.

doubling([1, 2, 3]) → [2, 4, 6]
doubling([6, 8, 6, 8, -1]) → [12, 16, 12, 16, -2]
doubling([]) → []

Open in new window


Solution:

public List<Integer> doubling(List<Integer> nums) {
  nums.replaceAll(n -> n * 2);
  return nums;
  
  // OR the equivalent java streams solution:
  // return nums.stream()
  //  .map(n -> n * 2)
  //  .collect(Collectors.toList());
}

Open in new window

i am trying to write a java a program to execute it in exclipse to see result in eclipise consoel

import java.util.List;

public class FuncProgDouble {
	public static void main(String[] args) {
		List<Integer> li=[1, 2, 3];
		System.out.println(doubling(li));
	}

	
	public static List<Integer> doubling(List<Integer> nums) {
	  nums.replaceAll(n -> n * 2);
	  return nums;
}

	
}

Open in new window


i am getting below compilation error.

Multiple markers at this line
      - Syntax error on token "]", } expected
      - Type mismatch: cannot convert from int[] to
       List<Integer>
      - Syntax error on token "[", { expected

canont i add primitives as below to Integer list


import java.util.ArrayList;
import java.util.List;

public class FuncProgDouble {
      public static void main(String[] args) {
            
            
            ArrayList<Integer> al=new ArrayList<Integer>();  
            al.add("1");  
            al.addAll("3");  
            al.addAll("8");  
            //al.add(1,"Sachin");
            
            //List<Integer> li=[1, 2, 3];
            System.out.println(doubling(al));
      }

      
      public static List<Integer> doubling(List<Integer> nums) {
        nums.replaceAll(n -> n * 2);
        return nums;
}

      
}

please advise
0
padserver/padErr.txt

==> /usr/local/pad/padserver/padOut.txt <==

---- java.library.path   ../lib/dll;/usr/local/pad\lib\dll\sys32

---- java.ext.dirs   /usr/java/jdk1.7.0_79/jre/lib/ext:/usr/local/pad/lib/ext



 checkFileInPath jspWin.dll   exists false

 checkFileInPath x25lyra.dll   exists false




==> /usr/local/pad/padserver/padErr.txt <==

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space


Hi Experts

we get above Java heap space error on our servers due to this we face other issues on server. kindly help.
0
I am doing below challenge

http://codingbat.com/prob/p128270
public int[] front11(int[] a, int[] b) {
   //int[] z;
  if(a.length>0&&b.length>0){
 
 // z[0]=a[0];
 // z[1]=b[0];
 // return z;
   return new int[]{a[0],b[0]};
  }
   else if(a.length>=0&&b.length==0){
  // int[] z=new int[2];
  //z[0]=a[0];
  //z[1]=b[0];
  return new int[]{a[0]};
  }
  else if(a.length==0&&b.length>=0){
  // int[] z=new int[2];
 // z[0]=a[0];
 // z[0]=b[0];
 // return z;
   return new int[]{b[0]};
  }
  return new int[0];
  
}

Open in new window


i am failing one
how to improrve my code
Expected      Run            
front11([1, 2, 3], [7, 9, 8]) → [1, 7]      [1, 7]      OK      
front11([1], [2]) → [1, 2]      [1, 2]      OK      
front11([1, 7], []) → [1]      [1]      OK      
front11([], [2, 8]) → [2]      [2]      OK      
front11([], []) → []      ArrayIndexOutOfBoundsException: 0 (line:14)      X      
front11([3], [1, 4, 1, 9]) → [3, 1]      [3, 1]      OK      
front11([1, 4, 1, 9], []) → [1]      [1]      OK      
other tests
OK      
please advise
0
Hi,

I was working on below challenge again

http://codingbat.com/prob/p151359
public String withoutX2(String str) {
  
  if(str.length()==1&&str.charAt(0)=='x'){
    return "";
  }
  if(str.length()>=2){
  if ( str.charAt(0)=='x' && str.charAt(1)=='x' ){
  return str.substring(2);
  }else if(str.charAt(0)=='x'){
      return str.substring(1);
  }else if(str.charAt(1)=='x'){
      return str.substring(0,1)+str.substring(2);
  }
  }
  return str;
}

Open in new window

below code passes all tests
Expected      Run            
withoutX2("xHi") → "Hi"      "Hi"      OK      
withoutX2("Hxi") → "Hi"      "Hi"      OK      
withoutX2("Hi") → "Hi"      "Hi"      OK      
withoutX2("xxHi") → "Hi"      "Hi"      OK      
withoutX2("Hix") → "Hix"      "Hix"      OK      
withoutX2("xaxb") → "axb"      "axb"      OK      
withoutX2("xx") → ""      ""      OK      
withoutX2("x") → ""      ""      OK      
withoutX2("") → ""      ""      OK      
withoutX2("Hello") → "Hello"      "Hello"      OK      
withoutX2("Hexllo") → "Hexllo"      "Hexllo"      OK      
withoutX2("xHxllo") → "Hxllo"      "Hxllo"      OK      
other tests
OK      

But if i have input say z what would be output and my code fails in that scenario right

withoutX2("z") → z
public class WithoutX2 {

	public static void main(String[] args) {
		
		// TODO Auto-generated method stub
		System.out.println("Value is"+withoutX2("z"));//should get true but getting false
	}
	
	public static String withoutX2(String str) {
		  
		  if(str.length()==1&&str.charAt(0)=='x'){
		    return "";
		  }
		  if(str.length()>=2){
		  if ( str.charAt(0)=='x' && str.charAt(1)=='x' ){
		  return str.substring(2);
		  }else if(str.charAt(0)=='x'){
		      return str.substring(1);
		  }else if(str.charAt(1)=='x'){
		      return str.substring(0,1)+str.substring(2);
		  }
		  }
		  return str;
		}


}

Open in new window

0
What does it mean to be "Always On"?
LVL 4
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Hi,
I tried below challenge as
http://codingbat.com/prob/p167430
public class Has271 {

	public static void main(String[] args) {
		int[] arr={1, 2, 7, 1};
		// TODO Auto-generated method stub
		System.out.println("Value is"+has271(arr));//should get true but getting false
	}
	
	public static boolean has271(int[] nums) {
		 int val=nums[0];
		 
		 for(int i=0;i<nums.length-2;i++){
		   
		   if(  (nums[i+1]==val+5)
		   && (  (Math.abs(nums[i+2]-val)<=2) )  )
		   return true;
		   continue;
		 }
		 return false;
		}


}

Open in new window


what is wrong with my above code why i am getting false instead of true?
please advise
0
Difference Between Path Parameter and query parameter in web service
0
Hello Sirs,

I have CSRF protection enabled, and CSRF parameters added to my login JSP view.
My question is the following: Should add CSRF parameters to the rest of my JSP view that involve form submission?

I am looking forward to hearing from you.
0
Hi,

What is the use of below command from eclipse project by right clicking and run as "maven build.."

what is meaning of shade why we need to give in the goal?

please advise
0
How to visualize call hierarchy in java using a pencil and paper all the way from beginning till end from UI to say model to controllers to dao to db calls etc including which object go in method and where the values changing etc in the new project

Please advise
0
Hi,
I am looking for String Format Method example using various date formats
https://www.javatpoint.com/java-string-format.

I found above link but no example there using the date format though like MMDDYYYY or YYYYMMDD etc to represent date?
please advise
0

Java EE

17K

Solutions

9K

Contributors

Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.