String Pool And Function Call
Aug 23, 2014
String pool puzzles me again. I think a==b and a==c are both true...
public class StringPoolTest {
public static void main(String[] args) {
String a = "abc";
String b = f() + "c";
String c = g();
[Code] .....
View Replies
ADVERTISEMENT
Mar 17, 2015
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class vowels{
public static void main(String arg [])
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a String : ");
[Code] .....
View Replies
View Related
Jun 23, 2014
I would use the return value of a function how parameter of other function..In java is:
// the call produce "YES"
SecondClassController.funcSecondClass(FirstClassController.funcFirstClass());
In my web page I need to do something like this:
[...]
<h:outputText value="#{secondClassController.funcSecondClass(#{firstClassController.funcFirstClass()})}" />
[...]
obtain:
javax.servlet.ServletException JBWEB006007: Failed to parse the expression
@Named
@SessionScoped
public class FirstClassController implements Serializable{
[...]
[code]....
View Replies
View Related
Jan 23, 2014
my first assignment is to convert a md5 string to password of the user, the MD5 function is available, i just need to call it and print the result. Here is my code. I can't call the md5 because of the String[] and String is different in main and md5 function,modify the code so it can run properly, also the input has to be entered from command line.
import java.security.*;
public class PasswordCracker {
public static void main (String[] args){
String password;
md5(args)
System.out.printf(""+password+"");
[code]....
View Replies
View Related
Jan 6, 2014
I have a program like below:
final String s1 = "AAA";
final String s2 = "AAA";
String s6 = s1+s2;
String s7 = "AAAAAA";
if ( s6 == s7 ){
System.out.println("s6 and s7 are same" );
}
On running, it prints "s6 and s7 are same". But if i remove the final modifier of s1 and s2 then it's not. What could be the reason?
View Replies
View Related
Dec 21, 2014
I an using a pop out java script and in the notes it says
if later on you want to open / close a specific item you could do it like so:
ExpandingMenu.openItem(3); // toggles item 3 (zero-based indexing)
*/
How to call the function from a button click. I have some button already on my page like so
<li><a href="#">Menu3</a></li>
And from what I have read I should be able to do this:
<li><a href="#" onclick="ExpandingMenu.openItem(3)">Menu3</a></li>
But I don't get any response ..... no error message NOTHING
View Replies
View Related
Mar 18, 2015
i don't need ordinary javascript alert box. so i was use the jquery modal alert box for different action like success, error etc.but i have problem to call the alert box within servlet.
out.println("<link href="css/jquery.modal.css" type="text/css" rel="stylesheet" />");
out.println("<script type="text/javascript" src="js/jquery-latest.min.js">");
out.println("<script type="text/javascript" src="js/jquery.modal.min.js">");
out.println("<script type="text/javascript" src="js/jscript.js">");
out.println("<script type="text/javascript" src="js/success.js">");
out.println("<script type="text/javascript">");
response.getOutputStream().println("success();");
out.println("</script>");
how to call the modal function in the js file?
otherwise how to show the modal alert box?
View Replies
View Related
Dec 3, 2014
I have understood my programming class up to this point and now I have been given a lab that I can't figure out for the life of me. Here what I have to do: Write a program that will call a method (called f) to calculate the following function" f(x)=(x^2)-16...this is what the output should be:
x f(x)
1 -15
2 -12
3 -7
4 0
5 9
6 20
7 33
8 48
9 65
10 84
I guess it also has to print this output in a table even though my professor never mentioned it. Usually
public class Lab12 {
public static int f(int x)
{
return x*x-16;
[code]....
View Replies
View Related
Sep 18, 2014
Write a function that will add the contents of a String array.
1. This time the input array to your function will be an array of Strings.
2. Your function body will be similar except you'll have to convert each String to a double number.
public class SumVals2 {
String aryVals[];
double result;
[Code]....
View Replies
View Related
Apr 20, 2014
Working on my java skills. The is Delimiter function is suppose to return true if there is a delimiter in the string and false otherwise. The main is suppose to call this function and count the number of words in the string:
Here is what I came up with:
import java.util.*;
public class NumberOfWordsInString {
public static void main (String[] args){
Scanner in= new Scanner (System.in);
String s;
[Code] ....
Somehow my method isn't being successfully called by my main and the following error msg was received:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
length cannot be resolved or is not a field
The method isDelimiter(char) in the type NumberOfWordsInString is not applicable for the arguments (char[])
at javaimprovements.NumberOfWordsInString.main(Number OfWordsInString.java:10)
line 10:
char ch [] = new char [s.length];
and the main doesn't call the isDelimiter function
View Replies
View Related
Jun 23, 2014
I am encountering a problem while running this small piece of code.
public class TestSplit{
public static void main(String[] args){
String myWords[]="My.Home.Is.Being.Painted".split(".");
for(int i=0;i<myWords.length;i++)
System.out.println(myWords[i]+" ");
}
}
The problem is: it does not run at all. No error message is displayed. It just returns to the command prompt when i run it. Where am i wrong?
View Replies
View Related
Dec 9, 2014
The following code is located in my main class called InjectionFix. I have another class where I need to call or initiate the string in the code below. How can I achieve this. I tried to create an Object of the class but I cant do this because my other class doesnt contain a main method.How can I get the other class to initiate the code below which is loacted in my main class.
public static String escapeDN(String name) {
StringBuilder sb = new StringBuilder();
// space or # character at the beginning of a string
if ((name.length() > 0) &&
((name.charAt(0) == ' ') ||
(name.charAt(0) == '#'))) {
[Code] .....
View Replies
View Related
Oct 14, 2014
What it is supposed to do is decide whether a ceiling fan is on or off, and describe it (color, area, speed). This is all user input (even pi) so it should decide whether to turn it on or off but for some reason skips over my if/else if statements all together.
I've tried changing it around a bit, looking up what my problem may be but this problem remains the same. my code:
import java.util.Scanner;
public class CeilingFan
{
final int slow = 1;
final int medium = 2;
final int fast = 3;
private int speed;
boolean on = false;
private double radius = 5;
private double pi = 3.1415;
String color = "blue";
[code]....
View Replies
View Related
Apr 19, 2014
I have to implement an object pool that uses phantom references to collect objects abandoned by client threads. This is what I have. I'm really not sure about this implementation.
class ObjectPool<T extends CloneableObject<T>> {
private Queue<T> pool;
private List references = new ArrayList();
private ReferenceQueue rq = new ReferenceQueue();
private CloneableObject<T> prototype
[Code] .....
View Replies
View Related
May 24, 2010
I have installed and configured Oracle Business Intelligence Applications on top of one demo eBS instance as a source. Now I would like to change the OLTP to a different eBS instance but am not sure which steps to take. I don't know if I can add new EBS connection pool and a new DataWarehouse Connection Pool in the administration and have old ones preserved or I need to overwrite the old ones? Or (ideally) can I just change the OLTP and overwrite the old DWH?
Any document supporting the process of changing the eBS OLTP database without new installation of the OBIAPPS?
View Replies
View Related
Jan 23, 2013
I am working on netbeans IDE , but I understand how the application know the parametres for the connections. I understand what is a Context , specifically i understand this code about the init method
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
servicioConexiones = (DataSource) envCtx.lookup("jdbc/bd_tutorias");
I want to know how the application knows to use these connection parameters, on the Context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/tutorias_pag480">
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
maxActive="8" maxIdle="4" name="jdbc/bd_tutorias" password="mysqladmin"
type="javax.sql.DataSource" removeAbandoned="true"
url="jdbc:mysql://localhost:3306/bd_tutorias" username="root"/>
</Context>
View Replies
View Related
Jun 19, 2015
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production0PL/SQL Release 12.1.0.2.0 - Production0CORE12.1.0.2.0Production0TNS for Linux: Version 12.1.0.2.0 - Production0NLSRTL Version 12.1.0.2.0 - Production0
Using JavaSE-1.7
Using ucp.jar,ons.jar and OJDBC7.jar
I set up the datasource as follows :
pds = PoolDataSourceFactory.getPoolDataSource();
pds.setConnectionFactoryClassName(factoryClassName);
pds.setMaxPoolSize(maxPoolSize); maxPoolSize 10
pds.setMinPoolSize(minPoolLimit); minPoolLimit 1
[Code] ....
In the class that actually uses it I create a method variable for the connection object.
Closing the connection as well as pds.getConnection().close();e
I am thinking that at the most I should have only one inactive connection showing up when I monitor the session. How do I configure the pool as to only show on inactive connection? I am running the test queries once every five minutes. But I am opening three connections each time.
View Replies
View Related
Jun 19, 2014
We have a J2EE business web application that runs in WebLogic. We noticed in application log files errors messages that seems like "No resource available in db pool", it means all the connection objects (to Oracle database) are used. Then the application is unstable and unseable.
I think the maximum number of connections configured in Weblogic pool has been reached due to an increase of users and activity. But when the workload decreases the application is still out of service. It seems connections objects are not relased to the pool. What can be the explanation for this issue ? Normally it is managed by the container (EJB3 for the business tier).
Once the limit of the pool is reached it is necessary to restart the server to solve this kind of error ?
View Replies
View Related
Sep 17, 2014
This program is for a swimming pool filling service company. They charge 2 cents per gallon and $50 per hour to fill a pool. The truck can fill at a rate of 730 gallons per hour.
Create the Pool class that calculates the cost to fill a pool based on it's Shape, length, width and depth. (Input order is S L W D)
The pool class will need data fields for String shape, double length, double width, double depth, static double GallonsPerSqFoot = 7.4805, static double price per gallon = .02, static double FillingFeePerHour = 50.0, and static double FillingRate = 730gal/hr.
Create a No-Arg constructor and a constructor that accepts the non-static values, and has the methods: getShape, getLength, getWidth, getDepth, getGallons, getHours, getFillingFeePerHour, getHourlyCost and getTotalCost.
At the end of the class, create a main() method that asks for the input and returns the output based on the Pool class gets.. methods.
The shape options are oblong or rectangle. (A round pool would be oblong with the same width and height, a square pool would have the same width and height)
Formulas:
Rectangle cubic ft = length * width * depth.
Oblong cubic ft= ((Math.PI * Math.pow(width/2,2)* depth) +((length-width) * width * depth))
Gallons = cubic ft * 7.4805.
hours = total gallons/730.
Total cost = (total Gallons * .02)+(hours * $50)
Example Output
An oblong pool 18.00 feet long by 12.00 feet wide and 5.00 feet deep will use 6923.10 gallons of water and take 9.48 hours to fill. The total cost will be 612.65.
Here is my code:
import java.util.Scanner;
import java.util.*;
public class Pool
{
private String poolshape1 = "oblong";
private String poolshape1 = "rectangle";
private double length;
private double width;
private double depth;
private static double GallonsPerSqFoot = 7.4805;
[Code] .....
View Replies
View Related
Sep 1, 2014
I have created a JSP page, on click of a particular button, the control moves to the servlet "TestServlet".
This is the code under TestServlet:
import java.io.IOException;
import java.io.PrintWriter;
import java.security.Principal;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
[Code]...
Now, I have got a comment saying I should get the database connection from connection pool. And one more issue is that I have used the function System.getProperty("user.name") to get the username which i have logged in. But this code will be run on Unix which will not support this function. Any function where I can get the windows username. There is a function getUserPrincipal(), but this function returns a NULL. How to resolve this.
View Replies
View Related
Jan 11, 2015
I configured a connection pool in tomcat 7. For every database activity I get a connection from the pool. Do I have to close the connection like other regular connection after the database operation is done? If I close the connection will it have any effect on the connection pool?
View Replies
View Related
Jul 11, 2014
I'm trying to create a booklist in java using swings but I'm facing a problem. I don't know how to add a search function to my list. I need a search box with the book names.
View Replies
View Related
Jan 29, 2014
where I have to write a Java program that asks for user input regarding a book and provides information based on that input like the number of pages required, number of words on the final page and if the final page is more than half full, etc. We are told that each page should have 250 words maximum to use for our calculations. The problem I am having here is that when the total number of words is a multiple of 250 the output tells me that there are 0 words on the last page when in fact there are 250. I've tried messing around with mod functions in this format ((x+a)%250)+y which is what the professor told us to use instead of creating an if-statement for this case but I haven't been able to crack it. I don't think I fully understand how the mod function cycle could work for this case.
import javax.swing.JOptionPane;
public class CorreiaFranciscaA1Q1 {
public static void main(String[] args) {
String ManuscriptTitle =
JOptionPane.showInputDialog ("Please enter a book title.");
String AuthorName =
JOptionPane.showInputDialog ("Please enter the author name.");
String TotalWords =
JOptionPane.showInputDialog ("Please enter the number of words.");
[code]....
Above if totalWords is a multiple of 250 like 17500 then wordsFinalPage will give us 0 and I need it to give 250. How can I do that without using an if statement but instead using a mod function?
View Replies
View Related
Jul 16, 2014
Using JPA 2.1, I have been trying without luck to call a function that returns a REF CURSOR containing RECORD TYPES. Is there a way of doing this?
One Example of trying:
Query query = em.createNativeQuery("select my_package.my_function from dual");
Object a = query.getSingleResult();
I have also tried to use the StoredProcedureQuery though this does not look like it can return the functions value.
Produced
org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC type: -10;
nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -10
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:244)
[Code] ....
View Replies
View Related
Feb 12, 2015
I just wanted to ask that when we invoke a function by passing certain arguments in it ,so for instance I have certain variables like a,b and c with some values assigned to them,so when I invoke a function like func(a*b , 8, c+a) where the function func accepts parameters like func(int x,int y,int z) ,so is there any order of evaluation of expressions defined like the value of c+d would be evaluated first and then assigned to variable z ,because in C we have sequence points and since comma when acting like a separator is not a sequence point so any of the expression can be executed first ,so basically is there any sequence in which the function arguments are assigned to the parameters of the function or any relation with the stack implementation.
Even in C ,the printf starts executing its expressions from right to left so basically in why does it happen there when comma is a separator in a function argument.
View Replies
View Related
Apr 10, 2007
E.g:
onblurr="check(this, '<%=company.getId()%>' );return false;"
doing this, function check(field, inputVal) {
alert("companyId:" + inputVal);
}
Gave me the alerted value as :
companyId:<%=company.getId()%>
instead, if the company.getId() --> 30
When I do like this, how to get the value 30 inside the function? i want companyId:30
View Replies
View Related