java-ee

Queries returning multiple result sets

允我心安 提交于 2019-12-17 06:47:12
问题 I have a MSSQL database and am running the following query: select * from projects; select * from user The above query returns two result sets at once, and I cannot fire both queries separately. How can I handle both the result set at once in a Java class? 回答1: Correct code to process multiple ResultSet s returned by a JDBC statement: PreparedStatement stmt = ...; boolean isResultSet = stmt.execute(); int count = 0; while(true) { if(isResultSet) { rs = stmt.getResultSet(); while(rs.next()) {

javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 25;

血红的双手。 提交于 2019-12-17 06:43:32
问题 The Code I'm Using to send a simple mail import javax.mail.*; import javax.mail.internet.*; import java.util.*; import java.io.*; import javax.activation.DataHandler; import javax.activation.FileDataSource; public class SendMailUsingAuthentication { private static final String SMTP_HOST_NAME = "smtp.gmail.com"; private static final String SMTP_AUTH_USER = "myemail@gmail.com"; private static final String SMTP_AUTH_PWD = "mypassword"; public static void main(String args[]) throws Exception { }

javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 25;

筅森魡賤 提交于 2019-12-17 06:42:45
问题 The Code I'm Using to send a simple mail import javax.mail.*; import javax.mail.internet.*; import java.util.*; import java.io.*; import javax.activation.DataHandler; import javax.activation.FileDataSource; public class SendMailUsingAuthentication { private static final String SMTP_HOST_NAME = "smtp.gmail.com"; private static final String SMTP_AUTH_USER = "myemail@gmail.com"; private static final String SMTP_AUTH_PWD = "mypassword"; public static void main(String args[]) throws Exception { }

Which compression (is GZIP the most popular) servlet filter would you suggest?

旧街凉风 提交于 2019-12-17 06:36:14
问题 I am looking for a GZIP servlet filter to be used in a high volume web-app. I doesn't want to use the container specific options. Requirement Ability to compress response payload (XML) Faster Proven in production for high volume applications Should properly set appropriate Content-Encoding portable across containers Optionally able to decompress request Thank you. 回答1: From what i've seen, most people generally use the gzip compression filter. Typically from ehcache. The GZIP filter

Stateless and Stateful Enterprise Java Beans

旧城冷巷雨未停 提交于 2019-12-17 06:20:11
问题 I am going through the Java EE 6 tutorial and I am trying to understand the difference between stateless and stateful session beans. If stateless session beans do not retain their state in between method calls, why is my program acting the way it is? package mybeans; import javax.ejb.LocalBean; import javax.ejb.Stateless; @LocalBean @Stateless public class MyBean { private int number = 0; public int getNumber() { return number; } public void increment() { this.number++; } } The client import

How to save state when extending UIComponentBase

 ̄綄美尐妖づ 提交于 2019-12-17 06:14:31
问题 I'm creating a composite component that will wrap a datatable to implement very simple paging. I need to save state (the current page number) between ajax requests. I tried creating fields in my FacesComponent, but I discovered they are wiped out during the JSF lifecycle: @FacesComponent(value = "bfTableComponent") public class BFTableComponent extends UIComponentBase implements NamingContainer { private int currentPageNumber; ... I can't seems to find a concise guide to doing this anywhere!

How can I check what version of EL is server using

我的未来我决定 提交于 2019-12-17 06:10:13
问题 How can I check what version of EL is server using . I am running Websphere 7 . EL classes are in j2ee.jar and manifest is below. Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.5 Created-By: 2.4 (IBM Corporation) Specification-Title: Java Platform, Enterprise Edition Specification Specification-Version: 5.0 Specification-Vendor: Sun Microsystems, Inc. Implementation-Title: Java Platform, Enterprise Edition Specification Implementation-Version: 5.0 Implementation-Vendor: Sun Microsystems,

EJB Transactions in local method-calls

元气小坏坏 提交于 2019-12-17 06:05:17
问题 In the following setup, does method B run in a (new) transaction? An EJB, having two methods, method A and method B public class MyEJB implements SessionBean public void methodA() { doImportantStuff(); methodB(); doMoreImportantStuff(); } public void methodB() { doDatabaseThing(); } } The EJB is container managed, with methodB in requires_new transaction, and method A in required transaction. thus: <container-transaction id="MethodTransaction_1178709616940"> <method id="MethodElement

Get the server port number from tomcat without a request

偶尔善良 提交于 2019-12-17 05:50:27
问题 Is there any Tomcat API or configuration available which can tell an application (probably on startup), what port its running on without a request? Imagine a scenario where there are two web applications running in the same Tomcat and one of which need to invoke a web service from the other one. We don't want the request to leave the Tomcat (if you use the Apache server name or absolute URL, the request will go out and come back again and it can go to any instance) and come back in. For that

Another Repeated column in mapping for entity error

非 Y 不嫁゛ 提交于 2019-12-17 04:46:47
问题 Despite all of the others post, I can't find a solution for this error with GlassFish, on MacOSX, NetBeans 7.2. Here the error : SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method SEVERE: Exception while preparing the app SEVERE: [PersistenceUnit: supmarket] Unable to build EntityManagerFactory ... Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.supmarket.entity.Sale column: customerId (should be mapped with