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

qry:            
select txnCount,currency,amount,days from test where country='IN' AND ROWNUM<=5;

IT MAY FETCH MAX 5 RECORDS
SOME TIME 1 or 2 or 3....
if the rocords count is less than 5 i have set val as NA
EACH COLUMN I NEED TO FETCH VALUES AND SET INTO LIST THEN NEED TO CONVERT IT AS STRING

LET SEE if the above qry fect 3 records
i want to see txnCount column as "23,34,56,NA,NA"
OUTPUT
String txnCount-->"23,34,56,NA,NA"

similary for the rest of the columns as well

i have written below code is there any better approach?

ResultSet rs = st.executeQuery(Query());
		List<String> txnCount = new ArrayList<String>();
		List<String> currency = new ArrayList<String>();
		List<String> docAmt = new ArrayList<String>();
		List<String> avgDays = new ArrayList<String>();
		
		
		System.out.println("size " + rs.getFetchSize());
		while (rs.next()){
			txnCount.add(rs.getString(1));
			currency.add(rs.getString(2));
			docAmt.add(rs.getString(3));
			avgDays.add(rs.getString(4));
			year = rs.getString(5);
		}
		System.out.println("txn sisss "+txnCount.size());
		System.out.println(5-txnCount.size());
		int size1 = 5-(txnCount.size());
		for(int i=0;i<size1;i++){
			txnCount.add("NA");
		}
		int size2 = 5-(currency.size());
		for(int i=0;i<size2;i++){
			currency.add("NA");
		}
		int size3 = 5-(docAmt.size());
		for(int i=0;i<size3;i++){
			docAmt.add("NA");
		}
		int size4 = 5-(avgDays.size());
		for(int i=0;i<size4;i++){
			avgDays.add("NA");
		}
		String txnCnt= 

Open in new window

0
CompTIA Security+
LVL 12
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

miss kyle santos  main appko apni native bhasha main sawaal karta hoon jiska mujhe jaldi she jaldi samadhaan chahiye sawaal yeh hai ki main aapni email I'd ya mobile number pe java ya java script chalana chahta hoon MATLAB confirm karna chahta hoon waise mujhe java ya java scrip aati nahin hai yani mujhe maloom nahi ki java ya java script kya hota hai air mujhe java programing bhi nahi aati hai main bad itna chahta hoon ki main aapne system she kuch alag karke dekhu is me mujhe romanch hota hai isliye main chahta hoon ki main aapne cell phone number ya email I'd dwara jaisa bhi sambhav ho sake main videos aur anaye samagri download maroon Jo ki play bhi ho sake air main unhe play kar saku MATLAB ki java ya java script she videos download karon iske alawa doosri baat ki kye aaise files hain Jo mere mobile system me java ya java documents gain Jo download ho chuke gain Jo ki play nahin ho rahe play karne par in files ko mera system support nahin karts hai Jai's ki mera system main zop ,jpj,png,axp,docx,xisx,PDF aur bhi kayen tarah ki files gain Jo ki mera system ko support nahin karti aap mujhe is ka much tarika sujheye ki main in files ko kaise play karoon aur jaldi se mere is sawaal ko sahi kijiye mera yahi mat hai thank you
0
HI,
The problem is to design a solution for finding the number of users who are watching a particular video eg. on youtube etc.
Here is what i thought about solving it.
If the video is playing than every 5th minute from GMT it will send a play event
I will maintain a table containing  (userId, movieId, timeStamp)
So to count how many viewers playing a video i will simply have to count the number of entries in the table with the movieID and timeStamp not later than 5 minutes. Because if a play event is not recieved for 6 minutes than the video must not be playing...
And each time a play event is received the timeStamp will be updated to the current time.

Also i will run a cronJob that will be clearing entries that are not getting updated.
Will maintain a cache containing the count for each movie and will update it at a regular interval from the table.

Each video that is being played will send a https request for the number of current viewers every 6th minute and the number of viewers will be updated.
Please suggest if there is any flaw in this approach. or any better approach ?
Any pros and cons ?
Thanks
0
Dear Experts,

 I have created a Restful API which is being consumed from android application. The api is below.

@CrossOrigin
      @Cacheable("locations")
      @RequestMapping(value = "/locations/", method = RequestMethod.GET, produces = { "application/json" })
      public List<Map<String, Object>> locations() throws Exception {
            this.daoFactory.setClass(Location.class);
            return getLocationMap(daoFactory.getLargestUnits());
      } and  



private List<Map<String, Object>> getLocationMap(List<Location> locations) {
            logger.info("fetching microplan location from: {}", locations.size());
            List<Map<String, Object>> jsonLocations = new ArrayList<Map<String, Object>>();
            for (Location location : locations)
                  jsonLocations.add(location.toJsonizedMap());
            logger.debug("loaded microplan location {}.", jsonLocations.size());
            return jsonLocations;
      }


sometimes it tells service is down from the application.
But  if I  just run this  this api from the postman and I could able to login into the application again and it works fine.

Experts,
what would be the root cause problem of it??


Thanks
0
How to fix this error in java program

Exception in thread "main" org.eclipse.swt.SWTException: Failed to create Ole Client. result = -2147221164
      at org.eclipse.swt.ole.win32.OLE.error(Unknown Source)
      at org.eclipse.swt.ole.win32.OleClientSite.<init>(Unknown Source)
      at com.fis.OfacLoadCheck.main(OfacLoadCheck.java:31)
0
I am a newbie on mutation testing. I am using  PIT  to test my  code.Can anyone please  suggest  how  can I resolve this  code?

 
      import java.io.IOException; 
 
 5     import org.springframework.http.client.ClientHttpResponse;
 
 6     import org.springframework.web.client.ResponseErrorHandler;
 
 7     
 
 8     
 
 9     public class DataTagsNamesErrorHandler implements ResponseErrorHandler {
 
 10         @Override
 
 11         public boolean hasError(ClientHttpResponse response) throws IOException {
 
 12         	
 
 13  1  return false;
 
 14         }
 
 15     
 
 16         @Override
 
 17         public void handleError(ClientHttpResponse response) throws IOException {
 
 18         }
 
 19     }
 
  
Mutations 

13  1.replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
 

Active mutators
•INCREMENTS_MUTATOR
•VOID_METHOD_CALL_MUTATOR
•RETURN_VALS_MUTATOR
•MATH_MUTATOR
•NEGATE_CONDITIONALS_MUTATOR
•INVERT_NEGS_MUTATOR
•CONDITIONALS_BOUNDARY_MUTATOR

Tests examined

Open in new window

0
Hi

I am looking for Java training 1:1 in US .Core Java ,Advanced Java (nHibernate), Spring, Spring boot using Eclipse. Any good recommendation.

Thanks
0
Old software needing to be virtualized, hopefully on AWS. Wondering if it would be better suited to outsouce an upgrade for this or simply get this basic jBoss server operational.

I am using this as a template for the steps: https://mobiarch.wordpress.com/2012/07/30/running-jboss-as-7-on-amazon-ec2/ but it is obviously for a newer version so I have tweaked it a bit.

I have an application that was coded on jBoss3.2.3 almost 15 years ago and I'm having difficulty getting a basic server operational on AWS. I'm using a micro instance of Red Hat, and have installed JDK 1.5 using these steps: https://dzone.com/articles/installing-oracle-java6-ubuntu

"java -version"

[ec2-user@ip-172-31-24-211 bin]$ java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)

Open in new window


Also have set this in <JBOSS>/bin/run.conf.: JAVA_OPTS="-Xms64m -Xmx86m -XX:MaxPermSize=64m"

Trying to start just the basic install from <JBOSS>/bin/:
[ec2-user@ip-172-31-24-211 bin]$ sh run.sh
run.sh: Missing file: /lib/tools.jar
run.sh: Unexpected results may occur.  Make sure JAVA_HOME points to a JDK and not a JRE.
================================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /home/ec2-user/jboss-3.2.3

  JAVA: java

  JAVA_OPTS: -Xms64m -Xmx86m -XX:MaxPermSize=64m -Dprogram.name=run.sh

  CLASSPATH: 

Open in new window

0
Hi,

i am working on  a j2ee application and have java 8u11 installed on my machine. when i install higer version of java. on some places it is throwing the attached exception.
it's say "can not verify the self deployment rule set.jar". i have gone through the various options i.e to uncheck the some security settings in java control panel.

is there any solution of this issue except  deploying the new jar with ruleset.xml

Thanks,
pic1.jpg
0
Hi all,

I have problem to display my PDF file in an existing popup window using spring framework. The workflow is when I click a button from the main page, it popups a new window (child) and showing progress status. After the file finished generating, I set the view in controller and return to jsp. However, the PDF file displays (using DefaultResourceLoader and response.flushBuffer) in the main page instead of the popup window. I want to show in popup. Anything wrong? How can I specify which window the PDF should be displayed?

Please help. Thanks.
0
Learn SQL Server Core 2016
LVL 12
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Hi,
I was going through the url shortner example on this page -
https://www.interviewbit.com/problems/design-url-shortener/
Although my query is simply about the hashing function that can be used to compute the shortened url .
Here it gives a way to encode the url -
Screen-Shot-2018-08-10-at-6.30.54-PM.png
I have few queries on the same  -
1) suppose i use a base62 hash function to shorten a url or even some other function as anyone can easily discover this then that is not desirable.
what exactly are the reasons for this. Although it does feel bit insecure that someone knows the hash function but so what. what are the pros and cons ?

2) Database ID encoded to base_62 also won't be suitable for a production environment because it will leak information about the database. For example, patterns can be learnt to compute the growth rate(new URLs added per day) and in the worst case, copy the whole database.

How is this possible because at most a user can predict the shortenedUrl thats all .
And shortened url, original url is inserted into a database.

Please help me understand why above both are true..
Thanks
1
Hi,
I am planning to build a service like shortening url for learning purpose..I was working on it theoritically.
And realized that i would be needing to store approximately 32 GB of data in the long run...
It will be mostly key value pair data  
eg -
1) www.bity.com/abcdefg  |  www.klasjlkajsf.comalskdfjlaksdjflkasjdfl
2) www.bity.com/abcdefg  | www.laksdjflkasjdflkasd.aldskjflkasdjflkasdf//alsdkfjalsdfj

So i was wondering which database will be better.
Dont know how Mysql will behave when total data reaches 32 GB ?
How long will it take to query it..
Is there some theoritical way to find it out. I think putting an index on the first column should be really fast kind of binary search ?
What are the alternatives  or best way ?
I read about redis that seems to be an in memory database so should be really fast. But it probably cannot store more data than the amount of RAM.
is redis feasible when the amount of data is so big like 32 GB ?
Do we need 32 GB of RAM or there are alternatives ??


Thanks
0
Hi,
I have deployed my code on two machines M1 and M2.
They fetch a USer Object which contains details about name, designation, emailID etc corresponding to a userId.
Currently i am storing them in cache like this :

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
    private Cache<String, User> userCache;
 userCache = CacheBuilder.newBuilder()
                .maximumSize(1000)
                .expireAfterWrite(60, TimeUnit.MINUTES).build();

Open in new window


But i just realized that there will be two caches on M1 and M2 separately. That could be an issue because say M1 caches data for a user. But the load balancer than sends the request to M2 and it will have to again fetch data.
what are the possible solutions to this ?
I can think of keeping another machine with all the cache data in RAM.
And so create a cache on M1 and M2 that programmatically connects to this machine.
But then comes the problem of having one more replica of this machine because in case one is down then
we still have data access...
Please suggest what is used to solve this type of problem ?

Thanks
0
I am having a java application with source code and libraries.

I would like to convert the entire java source to DART. Basically wants to convert the java application to DART Application (Java flavour) - https://www.dartlang.org/

Can someone help me what would be the easiest way or best approach or ways to quickly convert a java project to DART project ???

All the functionalities are same and no change in the functionality of the appplication.
0
Hello

I would like to use Junit test for Code below
ANy One help do do " Testing JUnit  "

package com.nam.designer.GUIComponent.Editor.Ecran;

import org.dom4j.Element;

public class BWTabViewContainer extends BWContainer{
	private static final long serialVersionUID = 512395545947425467L;
	private int activeTab=0;
	public BWTabViewContainer(String name, Element node, BWComponent parent, int interfaceType) {
		super(name,node,parent,interfaceType);
	}

Open in new window

     @Override
      
public int getActiveTab(){
		int i=0;
		for(BWComponent child: this.getChilds()){
			if(child.getNode()!=null && "true".equals(child.getNode().attributeValue("isActiveTab"))){
				this.activeTab=i;
				return this.activeTab;
			}
			i++;
		}

Open in new window

           return this.activeTab;
      }
      
public void setActiveTab(int activeTab) {
		this.activeTab = activeTab;
	}

Open in new window

     @Override
      
public Object clone(){
		BWTabViewContainer o = (BWTabViewContainer) super.clone();
		o.setActiveTab(this.activeTab);
		return o;
	}

Open in new window

}
Nam.jpg
0
can any one provide an sample application for tomcat 7.x that can trigger OutOfMemory and hung threads?.
0
How to insert excel file bulky data into database using java
0
Hello There ,
 I am new to Spring framework , i started to learn Spring MVC framework , i am currently trying to use internationalization (i18n)and localization (i10n) and every thin is going as expected

but here is my question in my project i have just 3 JSP and i have apply the (i18n) concept on them but i am wondering what if have 100 JSP , do i have to write a code and labels for all 100 JSP or can i make my all of my JSP app internationalized  just by clicking on a link to change between languages i want ???
0
I am new to Spring MVC and I am trying to build a simple web App I am using Hibernate with Spring MVC. I am trying to implement CRUD operations in this web app, all CRUD operates properly except the update although DAO And Service Layers are working properly the problem here is about the JSP's and controllers. whenever I click update from the table it took me to the desired page to enter new book info but from the Update page when I click on update book submit button it stays on the same page and it does not call the desired controller method to take me where I want. I am talking about the last two methods.

Here is the Controller

package com.abed.controllers;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.abed.models.Book;
import com.abed.service.BookService;

@Controller

public class BookController {

    @Autowired
    BookService service;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String 

Open in new window

0
Bootstrap 4: Exploring New Features
LVL 12
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Hi Experts,
According to my work , iI have a java code which generate shell script for ftp files.
So in the code
ftp.append("cd /home/user/user output/files for June ");

Open in new window

But according to shell script , If folder name contains space, then either we need to keep complete path inside quotes or space we can replace with back slash
for eg
cd "/home/user/user output/files for June " 
or
cd /home/user/user\output/files\for\June

But in java , It is not allowing me to put both  back slash \ and " saying invalid escape sequence.
How can I resolve it?
Thanks in Advance Experts............
0
Our client are calling one web API developed by us thru URL. They are getting below http response error -

406 Not Acceptable:1

What could be the reason? Previously API was called without any http request header and it worked well for many months.

my $response = $ua->get($url);

Open in new window


Suddenly we started getting above error. Now they have changed API calling code to send empty http request header with just one attribute "User Agent". They are not passing any value for this attribute. But after this change, it started working again.

my $response = $ua->get($url,'User-Agent' => '',);

Open in new window


What could be possible reasons for it to stop working suddenly and throwing back 406 error? How can I investigate?
0
Recently got frustrated trying wsimport on several old SOAP sites. Found out its all been deprecated so no SOAP sites to run wsimport on.
Can anyone give me a few just to see that wsimport is working as I expect it should?
I would appreciate a chance to test these things also .
So other than web pages processing JAX-RS(Restful) links exactly what if anything is equivalent to WSDLs in the JAX-RS world
I mean put, post, get delete insert? httpd protocol.
Help ASAP
0
I created a web service with jax-rpc 1.1 for a QCM. The main class is defined as:

public class QCM_WebService  implements Serializable{

    public void fillQcm (QCMUserResponse [] userResponse) {

    }
 }
Class QCMUserResponse:

class QCMUserResponse implements Serializable{
     private int questionID;
     private QcmResponse [] qcmResponseList;    
 }
Class QcmResponse:

class QcmResponse implements Serializable{

    private int responseID;
    private String response;
}
This is an example of SoapUI request generated by the WSDL of this service:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:ws="http://org.example" xmlns:qcm="http://com.Test">
  <soapenv:Header/>
 <soapenv:Body>
  <ws:fillQcm>
     <!--Zero or more repetitions:-->
     <ws:userResponse>
        <qcm:questionID>14</qcm:questionID>
        <!--1 or more repetitions:-->
        <qcm:qcmResponseList>
           <qcm:responseID>1</qcm:responseID>
           <qcm:response>true</qcm:response>
        </qcm:qcmResponseList>
        <qcm:qcmResponseList>
           <qcm:responseID>2</qcm:responseID>
           <qcm:response>false</qcm:response>
        </qcm:qcmResponseList>
            <qcm:qcmResponseList>
           <qcm:responseID>3</qcm:responseID>
           <qcm:response>false</qcm:response>
        </qcm:qcmResponseList>
     </ws:userResponse>
    </ws:fillQcm>
 </soapenv:Body>
</soapenv:Envelope>
When I try to test…
0
Websphere 8.5.5 :- Launch Client (Bypass the Authentication)
I want to bypass the authentication.
My soap.client.props details :-

com.ibm.SOAP.authenticationTarget=BasicAuth
com.ibm.SOAP.loginUserid=XXXXXXX
com.ibm.SOAP.loginPassword={xor}HggrAC8KZCgXa2QmZS5o




opt/was/85/AppServer/profiles/node1/bin/launchClient.sh /tciservices/gts/fehComm/FehFcsPutCli.ear -CCverbose=false -CCBootstrapHost=fc9pfwasd01.usgfoundries.com -CCBootstrapPort=9813 -CCexitVM=true
IBM WebSphere Application Server, Release 8.5
Java EE Application Client Tool
Copyright IBM Corp., 1997-2011
WSCL0012I: Processing command line arguments.
WSCL0013I: Initializing the Java EE Application Client Environment.
[5/22/18 10:19:15:205 EDT] 00000001  W UOW=null source=com.ibm.ws.ssl.config.SSLConfig org=IBM prod=WebSphere component=Application Server thread=[P=755014:O=0:CT]
          CWPKI0041W: One or more key stores are using the default password.
WSCL0035I: Initialization of the Java EE Application Client Environment has completed.
WSCL0014I: Invoking the Application Client class com.ibm.invmgr.fehfcsputcli.FehFcsPutCli
Starting FehFcsPutCli --> main is being executed
Connecting to EJB server...
Realm/Cell Name: defaultWIMFileBasedRealm
User Identity: XXXXXXX
User Password:                                                                                                                                                    Processing...
Execution complete ET(ms):16
0
I have created a module topo-webapp
and I have created an action using the example of struts. When I enter the url http://localhost:8080/topo-webapp/index.action I got the following error
Where does the problem come?

Problem accessing /topo-webapp/index.action. Reason:

    Server Error


Caused by:

java.lang.NoSuchMethodError: org.apache.commons.lang3.reflect.MethodUtils.getAnnotation(Ljava/lang/reflect/Method;Ljava/lang/Class;ZZ)Ljava/lang/annotation/Annotation;
      at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:44)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:99)

merci

CEdric
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.